예제 #1
0
        protected override void SerializeValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
        {
            if ((model.TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.EmbedObjects) != 0)
            {
                using (s.EnterCursorBookmark("VT"))                 // have to nest or MegaloScriptModelObjectHandle will overwrite our Param ID with the VT's
                    MegaloScriptModelObjectHandle.SerializeForEmbed(s, model, ref mVirtualTriggerHandle);
            }
            else
            {
                if (s.IsReading)
                {
                    int id = TypeExtensions.kNone; s.ReadCursor(ref id);
                    if (id < 0)
                    {
                        throw new System.IO.InvalidDataException(string.Format(Util.InvariantCultureInfo,
                                                                               "VirtualTrigger value #{0} has an invalid value {1}", Id, id));
                    }

                    mVirtualTriggerHandle = model.VirtualTriggers[id].Handle;
                }
                else
                {
                    s.WriteCursor(VirtualTriggerHandle.Id);
                }
            }
        }
예제 #2
0
        static void SerializeTriggerReferenceValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s,
                                                                   MegaloScriptValueType valueType, ref int value)
            where TDoc : class
            where TCursor : class
        {
            var handle = s.IsWriting ? new MegaloScriptModelObjectHandle(MegaloScriptModelObjectType.Trigger, value) : MegaloScriptModelObjectHandle.Null;

            if (s.IsWriting)
            {
                Contract.Assert(model.Triggers[handle.Id].TriggerType == MegaloScriptTriggerType.InnerLoop);
            }
            using (s.EnterCursorBookmark("T"))             // have to nest or MegaloScriptModelObjectHandle will overwrite our Param ID with the Trigger's
                MegaloScriptModelObjectHandle.SerializeForEmbed(s, model, ref handle);

            if (s.IsReading)
            {
                value = handle.Id;
            }
        }