public DescriptorOf ( |
||
objType | ||
return | ITypeDescriptor |
public IDescriptorSerializerContext StoreNewDescriptors(AbstractBufferedWriter writer, object obj) { if (obj == null) { return(this); } InfoForType infoForType; var iKnowDescriptor = obj as IKnowDescriptor; if (iKnowDescriptor != null) { var descriptor = iKnowDescriptor.GetDescriptor(); if (!_typeOrDescriptor2InfoMap.TryGetValue(descriptor, out infoForType) && !_typeSerializersMapping._typeOrDescriptor2Info.TryGetValue(descriptor, out infoForType)) { infoForType = new InfoForType { Id = 0, Descriptor = descriptor }; } } else { var objType = obj.GetType(); if (!_typeOrDescriptor2InfoMap.TryGetValue(objType, out infoForType) && !_typeSerializersMapping._typeOrDescriptor2Info.TryGetValue(objType, out infoForType)) { var descriptor = _typeSerializers.DescriptorOf(objType); if (_typeOrDescriptor2InfoMap.TryGetValue(descriptor, out infoForType)) { _typeOrDescriptor2InfoMap[objType] = infoForType; } else if (_typeSerializersMapping._typeOrDescriptor2Info.TryGetValue(descriptor, out infoForType)) { _typeSerializersMapping._typeOrDescriptor2Info[objType] = infoForType; } else { infoForType = new InfoForType { Id = 0, Descriptor = descriptor }; } } } if (infoForType.Id == 0) { AddDescriptor(infoForType); } if (!infoForType.KnownNewTypeDiscoverer) { infoForType.NewTypeDiscoverer = _typeSerializers.GetNewDescriptorSaver(infoForType.Descriptor); infoForType.KnownNewTypeDiscoverer = true; } var action = infoForType.NewTypeDiscoverer; if (action != null) { action(obj, this); } return(this); }
public IDescriptorSerializerContext StoreNewDescriptors(object?obj) { if (obj == null) { return(this); } InfoForType infoForType; var objType = obj.GetType(); if (obj is IKnowDescriptor iKnowDescriptor) { var descriptor = iKnowDescriptor.GetDescriptor(); if (!_typeOrDescriptor2Info.TryGetValue(descriptor, out infoForType)) { infoForType = new InfoForType { Id = 0, Descriptor = descriptor }; } } else { if (!_typeOrDescriptor2Info.TryGetValue(objType, out infoForType)) { var descriptor = _typeSerializers.DescriptorOf(objType); if (!_typeOrDescriptor2Info.TryGetValue(descriptor !, out infoForType)) { infoForType = new InfoForType { Id = 0, Descriptor = descriptor }; } else { _typeOrDescriptor2Info[objType] = infoForType; } } }
public IDescriptorSerializerContext StoreNewDescriptors(AbstractBufferedWriter writer, object obj) { if (obj == null) { return(this); } InfoForType infoForType; var iKnowDescriptor = obj as IKnowDescriptor; if (iKnowDescriptor != null) { var descriptor = iKnowDescriptor.GetDescriptor(); if (!_typeOrDescriptor2Info.TryGetValue(descriptor, out infoForType)) { infoForType = new InfoForType { Id = 0, Descriptor = descriptor }; } } else { var objType = obj.GetType(); if (!_typeOrDescriptor2Info.TryGetValue(objType, out infoForType)) { var descriptor = _typeSerializers.DescriptorOf(objType); if (!_typeOrDescriptor2Info.TryGetValue(descriptor, out infoForType)) { infoForType = new InfoForType { Id = 0, Descriptor = descriptor }; } else { _typeOrDescriptor2Info[objType] = infoForType; } } } DescriptorSerializerContext ctx = null; if (infoForType.Id == 0) { ctx = new DescriptorSerializerContext(this, writer); ctx.AddDescriptor(infoForType); } if (!infoForType.KnownNewTypeDiscoverer) { infoForType.NewTypeDiscoverer = _typeSerializers.GetNewDescriptorSaver(infoForType.Descriptor, obj.GetType()); infoForType.KnownNewTypeDiscoverer = true; } var action = infoForType.NewTypeDiscoverer; if (action != null) { if (ctx == null) { ctx = new DescriptorSerializerContext(this, writer); } action(obj, ctx); } if (ctx != null && ctx.SomeTypeStored) { return(ctx); } return(this); }