Exemplo n.º 1
0
        internal static bool SerializeId <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s,
                                                         string attributeName, ref int engineId, bool isOptional = false)
            where TDoc : class
            where TCursor : class
        {
            bool streamed = true;

            if (isOptional)
            {
                streamed = s.StreamAttributeOptIdAsString(attributeName, ref engineId, null,
                                                          EngineIdResolver, EngineNameResolver, Predicates.IsNotNullOrEmpty);

                if (!streamed && s.IsReading)
                {
                    engineId = TypeExtensions.kNone;
                }
            }
            else
            {
                s.StreamAttributeIdAsString(attributeName, ref engineId, null,
                                            EngineIdResolver, EngineNameResolver);
            }

            return(streamed);
        }
        internal bool SerializeActionTemplateReference <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s,
                                                                       string attributeName, ref MegaloScriptProtoActionTemplate template)
            where TDoc : class
            where TCursor : class
        {
            bool streamed = s.StreamAttributeOptIdAsString(attributeName, ref template, this,
                                                           kActionTemplateResolver, kActionTemplateNameResolver, Predicates.IsNotNullOrEmpty);

            if (!streamed && s.IsReading)
            {
                template = null;
            }

            return(streamed);
        }
Exemplo n.º 3
0
        internal void SerializeStringTableIndexOpt <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s,
                                                                   string attributeName, ref int stringIndex)
            where TDoc : class
            where TCursor : class
        {
            bool streamed = false;

            if ((TagElementStreamSerializeFlags & GameEngineMegaloVariantTagElementStreamFlags.UseStringTableNames) != 0)
            {
                streamed = s.StreamAttributeOptIdAsString(attributeName, ref stringIndex,
                                                          this, StringTableEntryIdResolver, StringTableEntryNameResolver, Predicates.IsNotNull);
            }
            else
            {
                streamed = s.StreamAttributeOpt(attributeName, ref stringIndex, Predicates.IsNotNone);
            }

            if (!streamed)
            {
                stringIndex = TypeExtensions.kNone;
            }
        }
        internal bool SerializeEnumTypeReference <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s,
                                                                 string attributeName, ref int enumIndex, bool isOptional = false)
            where TDoc : class
            where TCursor : class
        {
            bool streamed = true;

            if (isOptional)
            {
                streamed = s.StreamAttributeOptIdAsString(attributeName, ref enumIndex, this,
                                                          kEnumIdResolver, kEnumNameResolver, Predicates.IsNotNullOrEmpty);

                if (!streamed && s.IsReading)
                {
                    enumIndex = TypeExtensions.kNone;
                }
            }
            else
            {
                s.StreamAttributeIdAsString(attributeName, ref enumIndex, this, kEnumIdResolver, kEnumNameResolver);
            }

            return(streamed);
        }