public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { using (s.EnterUserDataBookmark(this)) { s.StreamAttributeOpt("name", this, obj => EcfName, Predicates.IsNotNullOrEmpty); s.StreamAttributeOpt("ext", this, obj => EcfFileExtension, Predicates.IsNotNullOrEmpty); using (s.EnterCursorBookmark("Header")) { s.StreamAttribute("id", this, obj => HeaderId, NumeralBase.Hex); s.StreamAttributeOpt("ChunkExtraDataSize", this, obj => ChunkExtraDataSize, Predicates.IsNotZero, NumeralBase.Hex); } using (var bm = s.EnterCursorBookmarkOpt("Chunks", Chunks, Predicates.HasItems)) s.StreamableElements("C", Chunks, obj => obj.HasPossibleFileData); } // #NOTE leaving this as an exercise for the caller instead, so they can yell when something is culled #if false if (s.IsReading) { CullChunksPossiblyWithoutFileData(); } #endif }
/* static void StreamDeclaredSystemsValue<TDoc, TCursor>(IO.TagElementStream<TDoc, TCursor, string> s, * BlamEngine engine, * ref string externsFile) * where TDoc : class * where TCursor : class * { * s.StreamAttributeOpt("externs", ref externsFile, Predicates.IsNotNullOrEmpty); * }*/ public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { Contract.Assert(s.Owner == null); s.Owner = this; using (s.EnterUserDataBookmark(this)) { BuildRepository.Serialize(s); using (var bm = s.EnterCursorBookmarkOpt("Systems", mSystemPrototypes, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("System", mSystemPrototypes, this, StreamSystemPrototypeKey); } } /* using (var bm = s.EnterCursorBookmarkOpt("Systems", mDeclaredSystems, Predicates.HasItems)) if (bm.IsNotNull) * s.StreamElements("System", mDeclaredSystems, this, * StreamSystemPrototypeKey, StreamDeclaredSystemsValue, * _ctxt => null);*/ if (s.IsReading) { if (mSystemPrototypes.Count > 0) { mActiveSystems = new Dictionary <Values.KGuid, EngineSystemBase>(mSystemPrototypes.Count); } } }
void SerializeExtern <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { /* var prototype = KSoft.Debug.TypeCheck.CastReference<BlamEngineSystem>(s.Owner); * if (s.IsReading) * Prototype = prototype; * else * Contract.Assert(prototype == Prototype);*/ EngineBuildHandle.Serialize(s, ref mRootBuildHandleBaseline); using (s.EnterUserDataBookmark(this)) { SerializeExternBody(s); } if (s.IsReading) { int expected_engine_index = Engine.RootBuildHandle.EngineIndex; int actual_engine_index = RootBuildHandle.EngineIndex; KSoft.Debug.ValueCheck.AreEqual( string.Format("{0} definition for {1} uses wrong engine id", GetType().Name, Engine.Name), expected_engine_index, actual_engine_index); } }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { using (s.EnterUserDataBookmark(this)) { XML.XmlUtil.Serialize(s, Weapons, BWeapon.kBListXmlParams); //XML.XmlUtil.Serialize(s, TacticStates, BTacticState.kBListXmlParams); XML.XmlUtil.Serialize(s, Actions, BProtoAction.kBListXmlParams); Tactic.Serialize(s); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { using (s.EnterUserDataBookmark(this)) { s.StreamAttributeOpt("name", this, obj => PkgName, Predicates.IsNotNullOrEmpty); s.StreamAttributeOpt("alignment", this, obj => Alignment, Predicates.IsNotZero); using (var bm = s.EnterCursorBookmarkOpt("Files", FileNames, Predicates.HasItems)) s.StreamElements("File", FileNames); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var xs = s.GetSerializerInterface(); s.StreamAttribute(DatabaseNamedObject.kXmlAttrNameN, ref mName); s.StreamAttributeEnum(kXmlAttrType, ref mType); s.StreamAttribute(kXmlAttrNextTriggerVar, ref mNextTriggerVarID); s.StreamAttribute(kXmlAttrNextTrigger, ref mNextTriggerID); s.StreamAttribute(kXmlAttrNextCondition, ref mNextConditionID); s.StreamAttribute(kXmlAttrNextEffect, ref mNextEffectID); s.StreamAttribute(kXmlAttrExternal, ref mExternal); using (s.EnterUserDataBookmark(this)) { XML.XmlUtil.Serialize(s, Groups, BTriggerGroup.kBListXmlParams); if (s.IsReading) { BuildDictionary(out mDbiGroups, Groups); } XML.XmlUtil.Serialize(s, Vars, BTriggerVar.kBListXmlParams); if (s.IsReading) { BuildDictionary(out mDbiVars, Vars); } XML.XmlUtil.Serialize(s, Triggers, BTrigger.kBListXmlParams); if (s.IsReading) { BuildDictionary(out mDbiTriggers, Triggers); } } if (s.IsReading) { (xs as XML.BTriggerScriptSerializer).TriggerDb.UpdateFromGameData(this); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var repo = KSoft.Debug.TypeCheck.CastReference <EngineBuildRepository>(s.UserData); if (s.IsReading) { Repository = repo; } else { Contract.Assert(repo == Repository); } using (s.EnterUserDataBookmark(this)) { s.StreamAttribute("name", this, obj => obj.Name); s.StreamAttribute("project", this, obj => obj.ProjectName); EngineTargetPlatform.SerializeBitSet(s, ref mValidTargetPlatforms, "ValidTargetPlatforms"); using (var bm = s.EnterCursorBookmarkOpt("Revisions", Revisions, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("Rev", Revisions); } } if (s.IsReading) { KSoft.Debug.ValueCheck.IsLessThanEqualTo("Too many registered branch revisions in " + Name, EngineBuildRevision.kMaxCount, Revisions.Count); Revisions.TrimExcess(); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var engine = KSoft.Debug.TypeCheck.CastReference <BlamEngine>(s.Owner); if (s.IsReading) { Engine = engine; } else { Contract.Assert(engine == Engine); } using (s.EnterCursorBookmark("Repository")) using (s.EnterUserDataBookmark(this)) { s.StreamElement("Guid", this, obj => obj.Guid); EngineTargetPlatform.SerializeBitSet(s, ref mValidTargetPlatforms, "ValidTargetPlatforms"); using (var bm = s.EnterCursorBookmarkOpt("Branches", Branches, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("Branch", Branches); } } if (s.IsReading) { KSoft.Debug.ValueCheck.IsLessThanEqualTo("Too many registered engine branches in " + Engine.Name, EngineBuildBranch.kMaxCount, Branches.Count); Branches.TrimExcess(); } }