コード例 #1
0
        public bool CanCreateInstance()

        {
            IProtoTypeSerializer pts = Tail as IProtoTypeSerializer;

            return(pts != null && pts.CanCreateInstance());
        }
コード例 #2
0
 private CompiledSerializer(IProtoTypeSerializer head, RuntimeTypeModel model)
 {
     this._head = head;
     _isStableWireType = head.DemandWireTypeStabilityStatus();
     _serializer = Compiler.CompilerContext.BuildSerializer(head, model);
     _deserializer = Compiler.CompilerContext.BuildDeserializer(head, model);
 }
コード例 #3
0
        public bool HasCallbacks(TypeModel.CallbackType callbackType)

        {
            IProtoTypeSerializer pts = Tail as IProtoTypeSerializer;

            return(pts != null && pts.HasCallbacks(callbackType));
        }
コード例 #4
0
        public SurrogateSerializer(TypeModel model, Type forType, Type declaredType, IProtoTypeSerializer rootTail)

        {
            Helpers.DebugAssert(forType != null, "forType");

            Helpers.DebugAssert(declaredType != null, "declaredType");

            Helpers.DebugAssert(rootTail != null, "rootTail");

            Helpers.DebugAssert(rootTail.RequiresOldValue, "RequiresOldValue");

            Helpers.DebugAssert(!rootTail.ReturnsValue, "ReturnsValue");

            Helpers.DebugAssert(declaredType == rootTail.ExpectedType || Helpers.IsSubclassOf(declaredType, rootTail.ExpectedType));

            this.forType = forType;

            this.declaredType = declaredType;

            this.rootTail = rootTail;

            toTail = GetConversion(model, true);

            fromTail = GetConversion(model, false);
        }
コード例 #5
0
 public static ICompiledSerializer Wrap(IProtoTypeSerializer head, RuntimeTypeModel model)
 {
     if (!(head is ICompiledSerializer result))
     {
         ConstructorInfo ctor;
         try
         {
             if (head.IsSubType)
             {
                 ctor = Helpers.GetConstructor(typeof(InheritanceCompiledSerializer <,>).MakeGenericType(head.BaseType, head.ExpectedType),
                                               new Type[] { typeof(IProtoTypeSerializer), typeof(RuntimeTypeModel) }, true);
             }
             else
             {
                 ctor = Helpers.GetConstructor(typeof(SimpleCompiledSerializer <>).MakeGenericType(head.BaseType),
                                               new Type[] { typeof(IProtoTypeSerializer), typeof(RuntimeTypeModel) }, true);
             }
         } catch (Exception ex)
         {
             throw new InvalidOperationException($"Unable to wrap {head.BaseType.NormalizeName()}/{head.ExpectedType.NormalizeName()}", ex);
         }
         try
         {
             result = (CompiledSerializer)ctor.Invoke(new object[] { head, model });
         }
         catch (System.Reflection.TargetInvocationException tie)
         {
             throw new InvalidOperationException($"Unable to wrap {head.BaseType.NormalizeName()}/{head.ExpectedType.NormalizeName()}: {tie.InnerException.Message} ({head.GetType().NormalizeName()})", tie.InnerException);
         }
         Debug.Assert(result.ExpectedType == head.ExpectedType);
     }
     return(result);
 }
コード例 #6
0
        public void Write(object value, ProtoWriter writer)
        {
            IProtoTypeSerializer protoTypeSerializer = this.rootTail;
            MethodInfo           methodInfo          = this.toTail;

            object[] objArray = new object[] { value };
            protoTypeSerializer.Write(methodInfo.Invoke(null, objArray), writer);
        }
コード例 #7
0
 public SurrogateSerializer(TypeModel model, Type forType, Type declaredType, IProtoTypeSerializer rootTail)
 {
     this.forType      = forType;
     this.declaredType = declaredType;
     this.rootTail     = rootTail;
     toTail            = GetConversion(model, toTail: true);
     fromTail          = GetConversion(model, toTail: false);
 }
コード例 #8
0
 public SurrogateSerializer(Type forType, Type declaredType, IProtoTypeSerializer rootTail)
 {
     this.forType      = forType;
     this.declaredType = declaredType;
     this.rootTail     = rootTail;
     this.toTail       = this.GetConversion(true);
     this.fromTail     = this.GetConversion(false);
 }
コード例 #9
0
 public SurrogateSerializer(TypeModel model, Type forType, Type declaredType, IProtoTypeSerializer rootTail)
 {
     this.forType = forType;
     this.declaredType = declaredType;
     this.rootTail = rootTail;
     this.toTail = this.GetConversion(model, true);
     this.fromTail = this.GetConversion(model, false);
 }
コード例 #10
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);
            }
        }
コード例 #11
0
 IProtoTypeSerializer WrapRootSerializer(IProtoTypeSerializer s)
 {
     return(new RootDecorator(
                Type,
                GetRootNetObjectMode(),
                !GetRootLateReferenceMode(),
                s,
                _model));
 }
コード例 #12
0
 public static void AddCustomSerializer(Type type, IProtoTypeSerializer customSerializer)
 {
     if (allocaters.ContainsKey(type))
     {
         //exist
         return;
     }
     allocaters.Add(type, customSerializer);
 }
コード例 #13
0
        private CompiledSerializer(IProtoTypeSerializer head, TypeModel model)

        {
            this.head = head;

            serializer = Compiler.CompilerContext.BuildSerializer(head, model);

            deserializer = Compiler.CompilerContext.BuildDeserializer(head, model);
        }
コード例 #14
0
        public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
        {
            IProtoTypeSerializer pts = Tail as IProtoTypeSerializer;

            if (pts != null)
            {
                pts.Callback(value, callbackType, context);
            }
        }
コード例 #15
0
        public bool CanCreateInstance()
        {
            IProtoTypeSerializer tail = this.Tail as IProtoTypeSerializer;

            if (tail == null)
            {
                return(false);
            }
            return(tail.CanCreateInstance());
        }
コード例 #16
0
        public static CompiledSerializer Wrap(IProtoTypeSerializer head, TypeModel model)
        {
            CompiledSerializer serializer = head as CompiledSerializer;

            if (serializer == null)
            {
                serializer = new CompiledSerializer(head, model);
            }
            return(serializer);
        }
コード例 #17
0
 public static CompiledSerializer Wrap(IProtoTypeSerializer head, TypeModel model)
 {
     CompiledSerializer result = head as CompiledSerializer;
     if (result == null)
     {
         result = new CompiledSerializer(head, model);
         Helpers.DebugAssert(((IProtoTypeSerializer)result).ExpectedType == head.ExpectedType);
     }
     return result;
 }
コード例 #18
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);
        }
コード例 #19
0
 public static CompiledSerializer Wrap(IProtoTypeSerializer head, RuntimeTypeModel model)
 {
     CompiledSerializer result = head as CompiledSerializer;
     if (result == null)
     {
         result = new CompiledSerializer(head, model);
         Helpers.DebugAssert(((IProtoTypeSerializer)result).ExpectedType == head.ExpectedType);
     }
     return result;
 }
コード例 #20
0
        public bool HasCallbacks(TypeModel.CallbackType callbackType)
        {
            IProtoTypeSerializer tail = this.Tail as IProtoTypeSerializer;

            if (tail == null)
            {
                return(false);
            }
            return(tail.HasCallbacks(callbackType));
        }
コード例 #21
0
 public SurrogateSerializer(Type forType, IProtoTypeSerializer tail)
 {
     Helpers.DebugAssert(forType != null, "forType");
     Helpers.DebugAssert(tail != null, "tail");
     Helpers.DebugAssert(tail.RequiresOldValue, "RequiresOldValue");
     Helpers.DebugAssert(!tail.ReturnsValue, "ReturnsValue");
     this.forType = forType;
     this.tail    = tail;
     toTail       = GetConversion(true);
     fromTail     = GetConversion(false);
 }
コード例 #22
0
 public SurrogateSerializer(Type forType, IProtoTypeSerializer tail)
 {
     Helpers.DebugAssert(forType != null, "forType");
     Helpers.DebugAssert(tail != null, "tail");
     Helpers.DebugAssert(tail.RequiresOldValue, "RequiresOldValue");
     Helpers.DebugAssert(!tail.ReturnsValue, "ReturnsValue");
     this.forType = forType;
     this.tail = tail;
     toTail = GetConversion(true);
     fromTail = GetConversion(false);
 }
コード例 #23
0
        public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
        {
            if (this.callbacks != null)
            {
                this.InvokeCallback(this.callbacks[callbackType], value, context);
            }
            IProtoTypeSerializer moreSpecificSerializer = (IProtoTypeSerializer)this.GetMoreSpecificSerializer(value);

            if (moreSpecificSerializer != null)
            {
                moreSpecificSerializer.Callback(value, callbackType, context);
            }
        }
コード例 #24
0
        // Token: 0x0600361B RID: 13851 RVA: 0x00135C9C File Offset: 0x0013409C
        public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context)
        {
            if (callbacks != null)
            {
                InvokeCallback(callbacks[callbackType], value, context);
            }
            IProtoTypeSerializer protoTypeSerializer = (IProtoTypeSerializer)GetMoreSpecificSerializer(value);

            if (protoTypeSerializer != null)
            {
                protoTypeSerializer.Callback(value, callbackType, context);
            }
        }
コード例 #25
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);
            }
        }
コード例 #26
0
 public SurrogateSerializer(Type forType, Type declaredType, IProtoTypeSerializer rootTail)
 {
     Helpers.DebugAssert(forType != null, "forType");
     Helpers.DebugAssert(declaredType != null, "declaredType");
     Helpers.DebugAssert(rootTail != null, "rootTail");
     Helpers.DebugAssert(rootTail.RequiresOldValue, "RequiresOldValue");
     Helpers.DebugAssert(!rootTail.ReturnsValue, "ReturnsValue");
     Helpers.DebugAssert(declaredType == rootTail.ExpectedType || Helpers.IsSubclassOf(declaredType, rootTail.ExpectedType));
     this.forType = forType;
     this.declaredType = declaredType;
     this.rootTail = rootTail;
     toTail = GetConversion(true);
     fromTail = GetConversion(false);
 }
コード例 #27
0
        public SurrogateSerializer(TypeModel model, Type forType, Type declaredType, IProtoTypeSerializer rootTail)
        {
            Helpers.DebugAssert(forType != null, "forType");
            Helpers.DebugAssert(declaredType != null, "declaredType");
            Helpers.DebugAssert(rootTail != null, "rootTail");
            Helpers.DebugAssert(rootTail.RequiresOldValue, "RequiresOldValue");  // old check, may work without!
#if FEAT_COMPILER
            Helpers.DebugAssert(!rootTail.EmitReadReturnsValue, "ReturnsValue"); // old check, may work without!
#endif
            Helpers.DebugAssert(declaredType == rootTail.ExpectedType || Helpers.IsSubclassOf(declaredType, rootTail.ExpectedType));
            this.ExpectedType  = forType;
            this._declaredType = declaredType;
            this._rootTail     = rootTail;
            _toTail            = GetConversion(model, true);
            _fromTail          = GetConversion(model, false);
        }
コード例 #28
0
 public InheritanceCompiledSerializer(IProtoTypeSerializer head, RuntimeTypeModel model)
     : base(head)
 {
     try
     {
         subTypeSerializer = Compiler.CompilerContext.BuildSerializer <T>(model.Scope, head, model);
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException($"Unable to bind serializer: " + ex.Message, ex);
     }
     try
     {
         subTypeDeserializer = Compiler.CompilerContext.BuildSubTypeDeserializer <T>(model.Scope, head, model);
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException($"Unable to bind deserializer: " + ex.Message, ex);
     }
     factory = Compiler.CompilerContext.BuildFactory <T>(model.Scope, head, model);
 }
コード例 #29
0
        public bool CanCreateInstance()
        {
            IProtoTypeSerializer pts = DelegationHandler as IProtoTypeSerializer;

            return(pts != null && pts.CanCreateInstance());
        }
コード例 #30
0
ファイル: MetaType.cs プロジェクト: yonglehou/Symbiote
        //IEnumerable GetFields() { return fields; }

#if FEAT_COMPILER && !FX11
        internal void CompileInPlace()
        {
            serializer = CompiledSerializer.Wrap(Serializer);
        }
コード例 #31
0
ファイル: MetaType.cs プロジェクト: helios57/anrl
 //IEnumerable GetFields() { return fields; }
 /// <summary>
 /// Compiles the serializer for this type; this is *not* a full
 /// standalone compile, but can significantly boost performance
 /// while allowing additional types to be added.
 /// </summary>
 /// <remarks>An in-place compile can access non-public types / members</remarks>
 public void CompileInPlace()
 {
     serializer = CompiledSerializer.Wrap(Serializer);
 }
コード例 #32
0
 public RootDecorator(Type type, bool wrap, bool protoCompatibility, IProtoTypeSerializer serializer, RuntimeTypeModel model)
 {
     _protoCompatibility = protoCompatibility;
     _serializer         = wrap ? new NetObjectValueDecorator(serializer, Helpers.GetNullableUnderlyingType(type) != null, !Helpers.IsValueType(type), false, false, model) : serializer;
 }
コード例 #33
0
 private CompiledSerializer(IProtoTypeSerializer head, TypeModel model)
 {
     this.head = head;
     serializer = Compiler.CompilerContext.BuildSerializer(head, model);
     deserializer = Compiler.CompilerContext.BuildDeserializer(head, model);
 }
コード例 #34
0
        //IEnumerable GetFields() { return fields; }

#if FEAT_COMPILER && !FX11
        internal void CompileInPlace()
        {
            serializer = CompiledSerializer.Wrap(Serializer);
        }
コード例 #35
0
 public static CompiledSerializer Wrap(IProtoTypeSerializer head, TypeModel model)
 {
     return(head as CompiledSerializer ?? new CompiledSerializer(head, model));
 }
コード例 #36
0
        public bool HasCallbacks(TypeModel.CallbackType callbackType)
        {
            IProtoTypeSerializer pts = DelegationHandler as IProtoTypeSerializer;

            return(pts != null && pts.HasCallbacks(callbackType));
        }
コード例 #37
0
 protected CompiledSerializer(IProtoTypeSerializer head)
 {
     this.head = head;
 }