internal bool StreamID <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, string xmlName, ref int dbid, TacticDataObjectKind kind, bool isOptional = true, IO.TagElementNodeType xmlSource = XML.XmlUtil.kSourceElement) where TDoc : class where TCursor : class { Contract.Requires(xmlSource.RequiresName() == (xmlName != XML.XmlUtil.kNoXmlName)); Contract.Requires(kind != TacticDataObjectKind.None); string id_name = null; bool was_streamed = true; bool to_lower = false; if (s.IsReading) { if (isOptional) { was_streamed = s.StreamStringOpt(xmlName, ref id_name, to_lower, xmlSource, intern: true); } else { s.StreamString(xmlName, ref id_name, to_lower, xmlSource, intern: true); } if (was_streamed) { IProtoDataObjectDatabaseProvider provider = this; dbid = provider.GetId((int)kind, id_name); Contract.Assert(dbid.IsNotNone()); } else { dbid = TypeExtensions.kNone; } } else if (s.IsWriting && dbid.IsNotNone()) { IProtoDataObjectDatabaseProvider provider = this; id_name = provider.GetName((int)kind, dbid); Contract.Assert(!string.IsNullOrEmpty(id_name)); if (isOptional) { s.StreamStringOpt(xmlName, ref id_name, to_lower, xmlSource, intern: true); } else { s.StreamString(xmlName, ref id_name, to_lower, xmlSource, intern: true); } } return(was_streamed); }
internal Collections.IHasUndefinedProtoMemberInterface GetMembersInterface(TacticDataObjectKind kind) { Contract.Requires <ArgumentOutOfRangeException>(kind != TacticDataObjectKind.None); switch (kind) { case TacticDataObjectKind.Weapon: return(Weapons); //case TacticDataObjectKind.TacticState: return TacticStates; case TacticDataObjectKind.Action: return(Actions); default: throw new KSoft.Debug.UnreachableException(kind.ToString()); } }