Exemplo n.º 1
0
        protected virtual int SerializeImpl <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            int type = s.IsReading ? TypeExtensions.kNone : ProtoData.DBID;

            model.SerializeOperationId(s, ref type, ObjectType);

            if (type != 0)
            {
                if (s.IsWriting && (model.TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.TryToPort) != 0)
                {
                    ProtoData.WriteForTryToPort(s, model.Database);
                }

                if (s.IsWriting && (model.TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.WriteConditionTypeNames) != 0)
                {
                    s.WriteAttribute("name", ProtoData.Name);
                }

                #region UnionGroup
                if (model.TagElementStreamSerializeFlags.EmbedObjectsWriteSansIds())
                {
                    if (s.IsWriting)
                    {
                        WriteUnionGroupForSansIds(model, s);
                    }
                    else if (!s.ReadAttributeOpt(kAttributeNameUnionGroup, ref mUnionGroup))
                    {
                        mUnionGroup = kUseNewUnionGroupId;
                    }
                }
                else
                {
                    s.StreamAttribute(kAttributeNameUnionGroup, ref mUnionGroup);
                }
                #endregion

                s.StreamAttributeOpt("invert", ref mInverted, Predicates.IsTrue);

                // #REVIEW_BLAM: ThrowReadException?
                if (!UnionGroupIdIsValid(model, s.IsReading))
                {
                    throw new System.IO.InvalidDataException(string.Format(Util.InvariantCultureInfo,
                                                                           "Condition #{0} has an invalid union group id #{1}",
                                                                           Id, UnionGroup));
                }
            }
            return(type);
        }
Exemplo n.º 2
0
        // #NOTE_BLAM: Can be embedded via MegaloScriptModelObjectHandle. Attributes must not conflict with that type's
        #region ITagElementStringNameStreamable Members
        protected virtual int SerializeImpl <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            int type = s.IsReading ? TypeExtensions.kNone : ProtoData.DBID;

            model.SerializeOperationId(s, ref type, ObjectType);

            if (type != 0 && s.IsWriting)
            {
                if ((model.TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.TryToPort) != 0)
                {
                    ProtoData.WriteForTryToPort(s, model.Database);
                }

                if ((model.TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.WriteActionTypeNames) != 0)
                {
                    s.WriteAttribute("name", ProtoData.Name);
                }
            }
            return(type);
        }