public int Compare(GroupTagData x, GroupTagData y) { Contract.Assume(x != null); Contract.Assume(y != null); return(string.CompareOrdinal(x.Name, y.Name)); }
public int Compare(object x, object y) { Contract.Assume(x != null); Contract.Assume(y != null); return(Compare((GroupTagData)x, (GroupTagData)y)); }
void InitializeForNewProgram(Type systemType) { Contract.Assume(systemType != null); AttachToSystemType(systemType); FindEngineSystemFactoryMethod(); RegisterSystem(); }
/// <summary>Initialize a 32-bit group tag with a <see cref="Guid"/></summary> /// <param name="groupTag">Four character code string</param> /// <param name="name">Name of this group tag</param> /// <param name="uuid">Guid for this group tag</param> public GroupTagData32(string groupTag, string name, KGuid uuid) : base(groupTag, name, uuid, kExpectedTagLength) { Contract.Requires(!string.IsNullOrEmpty(groupTag)); Contract.Requires(!string.IsNullOrEmpty(name)); Contract.Requires(groupTag.Length == kExpectedTagLength); Contract.Assume(Tag.Length == kExpectedTagLength); mID = ToUInt(Tag); }
/// <summary>Initialize a 64-bit group tag</summary> /// <param name="groupTag">Eight character code string</param> /// <param name="name">Name of this group tag</param> public GroupTagData64(string groupTag, string name) : base(groupTag, name, kExpectedTagLength) { Contract.Requires(!string.IsNullOrEmpty(groupTag)); Contract.Requires(!string.IsNullOrEmpty(name)); Contract.Requires(groupTag.Length == kExpectedTagLength); Contract.Assume(Tag.Length == kExpectedTagLength); mID = ToULong(Tag); }
/// <summary>Specialized ctor for initialing from two <see cref="GroupTagData32"/> instances along with a <see cref="Guid"/></summary> /// <param name="maj">First four-character code</param> /// <param name="min">Second four-character code</param> /// <param name="name">Name of this <see cref="GroupTagData32"/> pair</param> /// <param name="uuid">Guid for this group tag</param> /// <remarks>Constructs a group tag in the form of '<paramref name="maj"/>' + '<paramref name="min"/>'</remarks> public GroupTagData64(GroupTagData32 maj, GroupTagData32 min, string name, KGuid uuid) : base(maj, min, name, uuid) { Contract.Requires(maj != null && maj != GroupTagData32.Null); Contract.Requires(min != null && min != GroupTagData32.Null); Contract.Requires(!string.IsNullOrEmpty(name)); Contract.Assume(Tag.Length == kExpectedTagLength); mID = ToULong(Tag); }
/// <summary>Only call me if you are <see cref="EngineSystemBase.RemoveReferenceAsync"/></summary> /// <param name="activeSystem">The system which no longer has any active references</param> internal void CloseSystem(EngineSystemBase activeSystem) { Contract.Assume(activeSystem != null); var system_guid = activeSystem.Prototype.SystemMetadata.SystemGuid; lock (mActiveSystems) { Contract.Assume(mActiveSystems.ContainsKey(system_guid)); mActiveSystems.Remove(system_guid); } }
internal EngineSystemReference(EngineSystemBase system, EngineBuildHandle buildHandle) { Contract.Assume(system != null); Contract.Assume(!buildHandle.IsNone); mSystem = system; mBuildHandle = buildHandle; #pragma warning disable 4014 system.AddReferenceAsync(buildHandle); #pragma warning restore 4014 }
internal static PropertyChangedEventArgs GetLanguageChangedEventArgs(int langIndex) { Contract.Requires(langIndex >= 0 && langIndex < NumberOfLanguages); if (gLanguageChangedEventArgs == null) { InitializeLanguageChangedEventArgs(); } Contract.Assume(gLanguageChangedEventArgs != null); return(gLanguageChangedEventArgs[langIndex]); }
internal static void SerializeValueForEmbed <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s, ref int valueId) where TDoc : class where TCursor : class { bool is_global = false; MegaloScriptValueBase value = null; if (s.IsReading) { if (s.ReadAttributeOpt(kIsGlobalAttributeName, ref is_global) && is_global) { s.ReadCursor(ref valueId); } else { bool streamed_sans_ids = model.TagElementStreamSerializeFlags.EmbedObjectsWriteSansIds(); var value_type = ReadType(s, model.Database); if (streamed_sans_ids) { valueId = TypeExtensions.kNone; // set to NONE to automatically add } else { SerializeId(s, ref valueId); } value = model.Recreate(value_type, valueId); if (streamed_sans_ids) // since the stream didn't have the id, we need to explicit set it via value { valueId = value.Id; } } } else { value = model.Values[valueId]; if (is_global = value.IsGlobal) { s.WriteAttribute(kIsGlobalAttributeName, true); s.WriteCursor(valueId); } } if (!is_global) // stream non-global values essentially like locals { Contract.Assume(value != null); value.Serialize(model, s); } }
EngineSystemBase TryGetSystem(Values.KGuid systemGuid) { if (!SupportsSystem(systemGuid)) { return(null); } var system_metadata = EngineRegistry.TryGetRegisteredSystem(systemGuid); Contract.Assume(system_metadata != null); return(GetNewOrExistingSystem(system_metadata)); }
public void WriteEntryBytes(IO.EndianStream s, ref CaPackageEntry entry, Stream entryStream) { Contract.Requires <ArgumentNullException>(s != null); Contract.Requires <ArgumentNullException>(entryStream != null); Contract.Assume(entry.Name.IsNotNullOrEmpty()); Contract.Assume(entry.Offset == 0); Contract.Assume(entry.Size == 0); entry.Offset = s.BaseStream.Position; entry.Size = entryStream.Length; entryStream.CopyTo(s.BaseStream); }
protected void SetStreamName(System.IO.Stream stream) { Contract.Assume(stream != null); StreamName = null; if (stream is System.IO.FileStream fs) { StreamName = fs.Name; } if (StreamName == null) { stream.ToString(); } }
protected override string ReadAttribute(string name) { ValidateReadPermission(); XmlNode n = Cursor.Attributes[name]; if (n == null) { ThrowReadException(new System.Collections.Generic.KeyNotFoundException( "Attribute doesn't exist: " + name)); } Contract.Assume(n != null); // update the error state with the node we're about to read from ReadErrorNode = n; return(n.Value); }
EngineSystemBase GetSystem(Values.KGuid systemGuid, EngineBuildHandle forBuild) { if (!SupportsSystem(systemGuid)) { string system_display_name = EngineRegistry.GetSystemDebugDisplayString(systemGuid); string msg = string.Format("{0} doesn't support the system {1}", forBuild.ToDisplayString(), system_display_name); throw new InvalidOperationException(msg); } var system_metadata = EngineRegistry.TryGetRegisteredSystem(systemGuid); Contract.Assume(system_metadata != null); return(GetNewOrExistingSystem(system_metadata)); }
public static byte IndexOfHighestBitSet(ulong value) { Contract.Ensures(Contract.Result <byte>() < kInt64BitCount); int index = 0; uint high = GetHighBits(value); if (high != 0) { index = IndexOfHighestBitSet(high) + kInt32BitCount; } else { index = IndexOfHighestBitSet(GetLowBits(value)); } Contract.Assume(index >= 0); return((byte)index); }
internal MemoryStream GetChunkFileDataStream(EcfFileChunkDefinition chunk) { Contract.Assume(chunk != null && chunk.Parent == this); MemoryStream ms; if (chunk.FileBytes != null) { ms = new MemoryStream(chunk.FileBytes, writable: false); } else { var source_file = GetChunkAbsolutePath(chunk); using (var fs = File.OpenRead(source_file)) { ms = new MemoryStream((int)fs.Length); fs.CopyTo(ms); } } ms.Position = 0; return(ms); }
internal int PredictedCount(string values) { Contract.Assume(values != null); int count = 1; // using StringSegment and its Enumerator won't allocate any reference types var sseg = new Collections.StringSegment(values); foreach (char c in sseg) { if (c == Separator) { count++; } else if (c == Terminator) { break; } } return(count); }
public void InitializeBitLengths() { Contract.Assume(MaxCount > 0); CountBitLength = Bits.GetMaxEnumBits(MaxCount + 1); IndexBitLength = Bits.GetMaxEnumBits(MaxCount); }