public bool CanCreateInstance() { IProtoTypeSerializer pts = Tail as IProtoTypeSerializer; return(pts != null && pts.CanCreateInstance()); }
private CompiledSerializer(IProtoTypeSerializer head, RuntimeTypeModel model) { this._head = head; _isStableWireType = head.DemandWireTypeStabilityStatus(); _serializer = Compiler.CompilerContext.BuildSerializer(head, model); _deserializer = Compiler.CompilerContext.BuildDeserializer(head, model); }
public bool HasCallbacks(TypeModel.CallbackType callbackType) { IProtoTypeSerializer pts = Tail as IProtoTypeSerializer; return(pts != null && pts.HasCallbacks(callbackType)); }
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); }
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); }
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); }
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); }
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); }
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); }
public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context) { IProtoTypeSerializer tail = base.Tail as IProtoTypeSerializer; if (tail != null) { tail.Callback(value, callbackType, context); } }
IProtoTypeSerializer WrapRootSerializer(IProtoTypeSerializer s) { return(new RootDecorator( Type, GetRootNetObjectMode(), !GetRootLateReferenceMode(), s, _model)); }
public static void AddCustomSerializer(Type type, IProtoTypeSerializer customSerializer) { if (allocaters.ContainsKey(type)) { //exist return; } allocaters.Add(type, customSerializer); }
private CompiledSerializer(IProtoTypeSerializer head, TypeModel model) { this.head = head; serializer = Compiler.CompilerContext.BuildSerializer(head, model); deserializer = Compiler.CompilerContext.BuildDeserializer(head, model); }
public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context) { IProtoTypeSerializer pts = Tail as IProtoTypeSerializer; if (pts != null) { pts.Callback(value, callbackType, context); } }
public bool CanCreateInstance() { IProtoTypeSerializer tail = this.Tail as IProtoTypeSerializer; if (tail == null) { return(false); } return(tail.CanCreateInstance()); }
public static CompiledSerializer Wrap(IProtoTypeSerializer head, TypeModel model) { CompiledSerializer serializer = head as CompiledSerializer; if (serializer == null) { serializer = new CompiledSerializer(head, model); } return(serializer); }
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; }
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); }
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; }
public bool HasCallbacks(TypeModel.CallbackType callbackType) { IProtoTypeSerializer tail = this.Tail as IProtoTypeSerializer; if (tail == null) { return(false); } return(tail.HasCallbacks(callbackType)); }
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); }
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); } }
// 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); } }
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); } }
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); }
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); }
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); }
public bool CanCreateInstance() { IProtoTypeSerializer pts = DelegationHandler as IProtoTypeSerializer; return(pts != null && pts.CanCreateInstance()); }
//IEnumerable GetFields() { return fields; } #if FEAT_COMPILER && !FX11 internal void CompileInPlace() { serializer = CompiledSerializer.Wrap(Serializer); }
//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); }
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; }
public static CompiledSerializer Wrap(IProtoTypeSerializer head, TypeModel model) { return(head as CompiledSerializer ?? new CompiledSerializer(head, model)); }
public bool HasCallbacks(TypeModel.CallbackType callbackType) { IProtoTypeSerializer pts = DelegationHandler as IProtoTypeSerializer; return(pts != null && pts.HasCallbacks(callbackType)); }
protected CompiledSerializer(IProtoTypeSerializer head) { this.head = head; }