4 using System.Runtime.InteropServices;
5 using SiliconStudio.Core.Serialization;
6 using SiliconStudio.Core.Serialization.Serializers;
8 namespace SiliconStudio.
Paradox.DataModel
11 [StructLayout(LayoutKind.Sequential)]
14 private readonly
int ticks;
24 return TimeSpan.MinValue;
26 return TimeSpan.MaxValue;
27 return new TimeSpan(t.
Ticks * TicksCompressedRatio);
32 if (t == TimeSpan.MinValue)
33 return CompressedTimeSpan.MinValue;
34 if (t == TimeSpan.MaxValue)
35 return CompressedTimeSpan.MaxValue;
39 public const int TicksPerMillisecond = 100;
40 public const int TicksPerSecond = TicksPerMillisecond * 1000;
42 private const long TicksCompressedRatio = TimeSpan.TicksPerMillisecond / (long)TicksPerMillisecond;
60 return other.ticks == ticks;
63 public override bool Equals(
object obj)
65 if (ReferenceEquals(null, obj))
return false;
77 return left.Equals(right);
82 return !left.Equals(right);
87 return t1.Ticks < t2.Ticks;
92 return t1.Ticks > t2.Ticks;
97 return t1.Ticks <= t2.Ticks;
102 return t1.Ticks >= t2.Ticks;
143 if (ticks > other.ticks)
return 1;
144 if (ticks < other.ticks)
return -1;
154 throw new ArgumentException();
156 return CompareTo((CompressedTimeSpan)obj);
161 return Ticks.ToString();
168 internal class CompressedTimeSpanSerializer :
DataSerializer<CompressedTimeSpan>
174 stream.Write(timeSpan.Ticks);
178 timeSpan =
new CompressedTimeSpan(stream.ReadInt32());
FbxDouble3 operator*(double factor, FbxDouble3 vector)
CompressedTimeSpan(int ticks)
static readonly CompressedTimeSpan MaxValue
static readonly CompressedTimeSpan MinValue
override bool Equals(object obj)
override int GetHashCode()
int CompareTo(CompressedTimeSpan other)
Base class for implementation of SerializationStream.
int CompareTo(object obj)
static CompressedTimeSpan FromSeconds(double seconds)
Describes how to serialize and deserialize an object without knowing its type. Used as a common base ...
ArchiveMode
Enumerates the different mode of serialization (either serialization or deserialization).
bool Equals(CompressedTimeSpan other)
override string ToString()
static bool operator<(CompressedTimeSpan t1, CompressedTimeSpan t2)