示例#1
0
        protected override bool TryStore(object input, ISerializerContext context, CompositeType type, CompositeVersion typeVersion, ICompositeStorage storage)
        {
            if (!base.TryStore(input, context, type, typeVersion, storage))
            {
                return(false);
            }

            ICompositeStorage payloadStorage;
            GuidedObject      guided = input as GuidedObject;

            if (guided != null && storage.TryGet(Name.Payload, out payloadStorage))
            {
                payloadStorage.Add("Guid", guided.Guid);
            }

            return(true);
        }
示例#2
0
        protected override bool TryLoad(Stream input, IDeserializerContext context, CompositeType type, ICompositeStorage storage)
        {
            if (!base.TryLoad(input, context, type, storage))
            {
                return(false);
            }

            ICompositeStorage payloadStorage;
            GuidedObject      guided = context.Output as GuidedObject;

            if (guided != null && storage.TryGet(Name.Payload, out payloadStorage))
            {
                string guid;
                if (payloadStorage.TryGet("Guid", out guid))
                {
                    guided.Guid = guid;
                }
            }

            return(true);
        }