コード例 #1
0
        internal MethodInfo this[TypeModel.CallbackType callbackType]
        {
            get
            {
                switch (callbackType)
                {
                case TypeModel.CallbackType.BeforeSerialize:
                {
                    return(this.beforeSerialize);
                }

                case TypeModel.CallbackType.AfterSerialize:
                {
                    return(this.afterSerialize);
                }

                case TypeModel.CallbackType.BeforeDeserialize:
                {
                    return(this.beforeDeserialize);
                }

                case TypeModel.CallbackType.AfterDeserialize:
                {
                    return(this.afterDeserialize);
                }
                }
                throw new ArgumentException(string.Concat("Callback type not supported: ", callbackType.ToString()), "callbackType");
            }
        }
コード例 #2
0
 private void EmitCallbackIfNeeded(CompilerContext ctx, Local valueFrom, TypeModel.CallbackType callbackType)
 {
     if (this.isRootType && this.HasCallbacks(callbackType))
     {
         ((IProtoTypeSerializer)this).EmitCallback(ctx, valueFrom, callbackType);
     }
 }
コード例 #3
0
        public bool HasCallbacks(TypeModel.CallbackType callbackType)

        {
            IProtoTypeSerializer pts = Tail as IProtoTypeSerializer;

            return(pts != null && pts.HasCallbacks(callbackType));
        }
コード例 #4
0
 public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
 {
     if (Tail is IProtoTypeSerializer pts)
     {
         pts.Callback(value, callbackType, context);
     }
 }
コード例 #5
0
 public bool HasCallbacks(TypeModel.CallbackType callbackType) {
     if(callbacks != null && callbacks[callbackType] != null) return true;
     for (int i = 0; i < serializers.Length; i++)
     {
         if (serializers[i].ExpectedType != forType && ((IProtoTypeSerializer)serializers[i]).HasCallbacks(callbackType)) return true;
     }
     return false;
 }
コード例 #6
0
 public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
 {
     if (callbacks != null)
     {
         InvokeCallback(callbacks[callbackType], value, context);
     }
     ((IProtoTypeSerializer)GetMoreSpecificSerializer(value))?.Callback(value, callbackType, context);
 }
コード例 #7
0
ファイル: TagDecorator.cs プロジェクト: radtek/work-1
        public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
        {
            IProtoTypeSerializer tail = base.Tail as IProtoTypeSerializer;

            if (tail != null)
            {
                tail.Callback(value, callbackType, context);
            }
        }
コード例 #8
0
        public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
        {
            IProtoTypeSerializer pts = Tail as IProtoTypeSerializer;

            if (pts != null)
            {
                pts.Callback(value, callbackType, context);
            }
        }
コード例 #9
0
        public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
        {
            if (_callbacks != null)
            {
                InvokeCallback(_callbacks[callbackType], value, _constructType, context);
            }
            IProtoTypeSerializer ser = (IProtoTypeSerializer)GetMoreSpecificSerializer(value);

            ser?.Callback(value, callbackType, context);
        }
コード例 #10
0
        public bool HasCallbacks(TypeModel.CallbackType callbackType)
        {
            IProtoTypeSerializer tail = this.Tail as IProtoTypeSerializer;

            if (tail == null)
            {
                return(false);
            }
            return(tail.HasCallbacks(callbackType));
        }
コード例 #11
0
 internal MethodInfo this[TypeModel.CallbackType callbackType]
 {
     get
     {
         return(callbackType switch
         {
             TypeModel.CallbackType.BeforeSerialize => beforeSerialize,
             TypeModel.CallbackType.AfterSerialize => afterSerialize,
             TypeModel.CallbackType.BeforeDeserialize => beforeDeserialize,
             TypeModel.CallbackType.AfterDeserialize => afterDeserialize,
             _ => throw new ArgumentException("Callback type not supported: " + callbackType.ToString(), nameof(callbackType)),
         });
コード例 #12
0
        public void Callback(object value, TypeModel.CallbackType callbackType)
        {
            if (callbacks != null)
            {
                InvokeCallback(callbacks[callbackType], value);
            }
            IProtoTypeSerializer ser = (IProtoTypeSerializer)GetMoreSpecificSerializer(value);

            if (ser != null)
            {
                ser.Callback(value, callbackType);
            }
        }
コード例 #13
0
        // Token: 0x06000299 RID: 665 RVA: 0x0000F934 File Offset: 0x0000DB34
        public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
        {
            if (this.callbacks != null)
            {
                this.InvokeCallback(this.callbacks[callbackType], value, context);
            }
            IProtoTypeSerializer protoTypeSerializer = (IProtoTypeSerializer)this.GetMoreSpecificSerializer(value);

            if (protoTypeSerializer != null)
            {
                protoTypeSerializer.Callback(value, callbackType, context);
            }
        }
コード例 #14
0
ファイル: CallbackSet.cs プロジェクト: warpten2001/ET-1
 internal MethodInfo this[TypeModel.CallbackType callbackType]
 {
     get
     {
         switch (callbackType)
         {
             case TypeModel.CallbackType.BeforeSerialize: return beforeSerialize;
             case TypeModel.CallbackType.AfterSerialize: return afterSerialize;
             case TypeModel.CallbackType.BeforeDeserialize: return beforeDeserialize;
             case TypeModel.CallbackType.AfterDeserialize: return afterDeserialize;
             default: throw new ArgumentException("Callback type not supported: " + callbackType.ToString(), "callbackType");
         }
     }
 }
コード例 #15
0
        void IProtoTypeSerializer.EmitCallback(CompilerContext ctx, Local valueFrom, TypeModel.CallbackType callbackType)
        {
            bool copyValue = false;

            if (this.CanHaveInheritance)
            {
                for (int i = 0; i < this.serializers.Length; i++)
                {
                    IProtoSerializer serializer = this.serializers[i];
                    if ((serializer.ExpectedType != this.forType) && ((IProtoTypeSerializer)serializer).HasCallbacks(callbackType))
                    {
                        copyValue = true;
                    }
                }
            }
            MethodInfo method = (this.callbacks == null) ? null : this.callbacks[callbackType];

            if ((method != null) || copyValue)
            {
                ctx.LoadAddress(valueFrom, this.ExpectedType);
                EmitInvokeCallback(ctx, method, copyValue, null, this.forType);
                if (copyValue)
                {
                    CodeLabel label = ctx.DefineLabel();
                    for (int j = 0; j < this.serializers.Length; j++)
                    {
                        IProtoTypeSerializer serializer3;
                        IProtoSerializer     serializer2 = this.serializers[j];
                        Type expectedType = serializer2.ExpectedType;
                        if ((expectedType != this.forType) && (serializer3 = (IProtoTypeSerializer)serializer2).HasCallbacks(callbackType))
                        {
                            CodeLabel label2 = ctx.DefineLabel();
                            CodeLabel label3 = ctx.DefineLabel();
                            ctx.CopyValue();
                            ctx.TryCast(expectedType);
                            ctx.CopyValue();
                            ctx.BranchIfTrue(label2, true);
                            ctx.DiscardValue();
                            ctx.Branch(label3, false);
                            ctx.MarkLabel(label2);
                            serializer3.EmitCallback(ctx, null, callbackType);
                            ctx.Branch(label, false);
                            ctx.MarkLabel(label3);
                        }
                    }
                    ctx.MarkLabel(label);
                    ctx.DiscardValue();
                }
            }
        }
コード例 #16
0
 public bool HasCallbacks(TypeModel.CallbackType callbackType)
 {
     if (_callbacks?[callbackType] != null)
     {
         return(true);
     }
     for (int i = 0; i < _serializers.Length; i++)
     {
         if (_serializers[i].ExpectedType != ExpectedType && ((_serializers[i] as IProtoTypeSerializer)?.HasCallbacks(callbackType) ?? false))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #17
0
ファイル: TypeSerializer.cs プロジェクト: pinzeweifen/DCET
 public bool HasCallbacks(TypeModel.CallbackType callbackType)
 {
     if (callbacks != null && callbacks[callbackType] != (MethodInfo)null)
     {
         return(true);
     }
     for (int i = 0; i < serializers.Length; i++)
     {
         if (serializers[i].ExpectedType != forType && ((IProtoTypeSerializer)serializers[i]).HasCallbacks(callbackType))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #18
0
 // Token: 0x06000293 RID: 659 RVA: 0x0000F734 File Offset: 0x0000D934
 public bool HasCallbacks(TypeModel.CallbackType callbackType)
 {
     if (this.callbacks != null && this.callbacks[callbackType] != null)
     {
         return(true);
     }
     for (int i = 0; i < this.serializers.Length; i++)
     {
         if (this.serializers[i].ExpectedType != this.forType && ((IProtoTypeSerializer)this.serializers[i]).HasCallbacks(callbackType))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #19
0
ファイル: CallbackSet.cs プロジェクト: Starbucksbot/SteamBot
        internal MethodInfo this[TypeModel.CallbackType callbackType]
        {
            get
            {
                switch (callbackType)
                {
                case TypeModel.CallbackType.BeforeSerialize: return(beforeSerialize);

                case TypeModel.CallbackType.AfterSerialize: return(afterSerialize);

                case TypeModel.CallbackType.BeforeDeserialize: return(beforeDeserialize);

                case TypeModel.CallbackType.AfterDeserialize: return(afterDeserialize);

                default: throw new ArgumentException();
                }
            }
        }
コード例 #20
0
        void IProtoTypeSerializer.EmitCallback(Compiler.CompilerContext ctx, Compiler.Local valueFrom, TypeModel.CallbackType callbackType)
        {
            bool actuallyHasInheritance = false;

            if (CanHaveInheritance)
            {
                for (int i = 0; i < serializers.Length; i++)
                {
                    IProtoSerializer ser = serializers[i];
                    if (ser.ExpectedType != forType && ((IProtoTypeSerializer)ser).HasCallbacks(callbackType))
                    {
                        actuallyHasInheritance = true;
                    }
                }
            }

            Helpers.DebugAssert(((IProtoTypeSerializer)this).HasCallbacks(callbackType), "Shouldn't be calling this if there is nothing to do");
            MethodInfo method = callbacks == null ? null : callbacks[callbackType];

            if (method == null && !actuallyHasInheritance)
            {
                return;
            }
            ctx.LoadAddress(valueFrom, ExpectedType);
            EmitInvokeCallback(ctx, method, actuallyHasInheritance, null, forType);

            if (actuallyHasInheritance)
            {
                Compiler.CodeLabel @break = ctx.DefineLabel();
                for (int i = 0; i < serializers.Length; i++)
                {
                    IProtoSerializer     ser = serializers[i];
                    IProtoTypeSerializer typeser;
                    Type serType = ser.ExpectedType;
                    if (serType != forType &&
                        (typeser = (IProtoTypeSerializer)ser).HasCallbacks(callbackType))
                    {
                        Compiler.CodeLabel ifMatch = ctx.DefineLabel(), nextTest = ctx.DefineLabel();
                        ctx.CopyValue();
                        ctx.TryCast(serType);
                        ctx.CopyValue();
                        ctx.BranchIfTrue(ifMatch, true);
                        ctx.DiscardValue();
                        ctx.Branch(nextTest, false);
                        ctx.MarkLabel(ifMatch);
                        typeser.EmitCallback(ctx, null, callbackType);
                        ctx.Branch(@break, false);
                        ctx.MarkLabel(nextTest);
                    }
                }
                ctx.MarkLabel(@break);
                ctx.DiscardValue();
            }
        }
コード例 #21
0
 private void EmitCallbackIfNeeded(Compiler.CompilerContext ctx, Compiler.Local valueFrom, TypeModel.CallbackType callbackType)
 {
     Helpers.DebugAssert(valueFrom != null);
     if (isRootType && ((IProtoTypeSerializer)this).HasCallbacks(callbackType))
     {
         ((IProtoTypeSerializer)this).EmitCallback(ctx, valueFrom, callbackType);
     }
 }
コード例 #22
0
 public bool HasCallbacks(TypeModel.CallbackType callbackType)
 {
     return(false);
 }
コード例 #23
0
 public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
 {
 }
コード例 #24
0
ファイル: CompiledSerializer.cs プロジェクト: Leigh-Ma/gGame
 void IProtoTypeSerializer.EmitCallback(Compiler.CompilerContext ctx, Compiler.Local valueFrom, TypeModel.CallbackType callbackType)
 {
     head.EmitCallback(ctx, valueFrom, callbackType);
 }
コード例 #25
0
ファイル: CompiledSerializer.cs プロジェクト: Leigh-Ma/gGame
 public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
 {
     head.Callback(value, callbackType, context); // these routes only used when bits of the model not compiled
 }
コード例 #26
0
ファイル: CompiledSerializer.cs プロジェクト: Leigh-Ma/gGame
 bool IProtoTypeSerializer.HasCallbacks(TypeModel.CallbackType callbackType)
 {
     return(head.HasCallbacks(callbackType)); // these routes only used when bits of the model not compiled
 }
コード例 #27
0
 public void EmitCallback(Compiler.CompilerContext ctx, Compiler.Local valueFrom, TypeModel.CallbackType callbackType)
 {
     // we only expect this to be invoked if HasCallbacks returned true, so implicitly Tail
     // **must** be of the correct type
     ((IProtoTypeSerializer)Tail).EmitCallback(ctx, valueFrom, callbackType);
 }
コード例 #28
0
 public void Callback(object value, TypeModel.CallbackType callbackType)
 {
     head.Callback(value, callbackType); // these routes only used when bits of the model not compiled
 }
コード例 #29
0
 public void EmitCallback(CompilerContext ctx, Local valueFrom, TypeModel.CallbackType callbackType)
 {
     _serializer.EmitCallback(ctx, valueFrom, callbackType);
 }
コード例 #30
0
 public bool HasCallbacks(TypeModel.CallbackType callbackType)
 {
     return(_serializer.HasCallbacks(callbackType));
 }