public ObjectTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, Type type)
 {
     _typeSerializers = typeSerializers;
     _type = type;
     Sealed = _type.IsSealed;
     _name = typeSerializers.TypeNameMapper.ToName(type);
 }
Exemple #2
0
 public ListTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, Type type)
 {
     _convertorGenerator = typeSerializers.ConvertorGenerator;
     _typeSerializers = typeSerializers;
     _type = type;
     _itemType = GetItemType(type);
 }
Exemple #3
0
 ObjectTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, string name, bool @sealed, List<KeyValuePair<string, ITypeDescriptor>> nfs)
 {
     _typeSerializers = typeSerializers;
     Sealed = @sealed;
     _name = name;
     _fields = nfs;
 }
Exemple #4
0
 EnumTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, Type type, string name, bool signed, bool flags, List<KeyValuePair<string, ulong>> pairs)
 {
     _typeSerializers = typeSerializers;
     _type = type;
     _name = name;
     _signed = signed;
     _flags = flags;
     _pairs = pairs;
 }
 public DictionaryTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, Type type)
 {
     _convertorGenerator = typeSerializers.ConvertorGenerator;
     _typeSerializers = typeSerializers;
     _type = type;
     var genericArguments = type.GetGenericArguments();
     _keyType = genericArguments[0];
     _valueType = genericArguments[1];
 }
 public ObjectTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, AbstractBufferedReader reader, Func<AbstractBufferedReader, ITypeDescriptor> nestedDescriptorReader)
 {
     _typeSerializers = typeSerializers;
     Sealed = false;
     _name = reader.ReadString();
     var fieldCount = reader.ReadVUInt32();
     while (fieldCount-- > 0)
     {
         _fields.Add(new KeyValuePair<string, ITypeDescriptor>(reader.ReadString(), nestedDescriptorReader(reader)));
     }
 }
Exemple #7
0
 public EnumTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, AbstractBufferedReader reader)
 {
     _typeSerializers = typeSerializers;
     _name = reader.ReadString();
     var header = reader.ReadVUInt32();
     _signed = (header & 1) != 0;
     _flags = (header & 2) != 0;
     var count = header >> 2;
     _pairs = new List<KeyValuePair<string, ulong>>((int)count);
     for (int i = 0; i < count; i++)
     {
         _pairs.Add(_signed
                        ? new KeyValuePair<string, ulong>(reader.ReadString(), (ulong)reader.ReadVInt64())
                        : new KeyValuePair<string, ulong>(reader.ReadString(), reader.ReadVUInt64()));
     }
 }
        public EnumTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, AbstractBufferedReader reader)
        {
            _typeSerializers = typeSerializers;
            _name            = reader.ReadString() !;
            var header = reader.ReadVUInt32();

            _signed = (header & 1) != 0;
            _flags  = (header & 2) != 0;
            var count = header >> 2;

            _pairs = new List <KeyValuePair <string, ulong> >((int)count);
            for (var i = 0; i < count; i++)
            {
                _pairs.Add(_signed
                    ? new KeyValuePair <string, ulong>(reader.ReadString(), (ulong)reader.ReadVInt64())
                    : new KeyValuePair <string, ulong>(reader.ReadString(), reader.ReadVUInt64()));
            }
        }
Exemple #9
0
        public ITypeDescriptor CloneAndMapNestedTypes(ITypeDescriptorCallbacks typeSerializers, Func <ITypeDescriptor, ITypeDescriptor> map)
        {
            var tds = new ITypeDescriptor[_fields.Count];

            for (var i = 0; i < _fields.Count; i++)
            {
                tds[i] = map(_fields[i].Value);
            }
            if (typeSerializers == _typeSerializers && tds.SequenceEqual(_fields.Select(i => i.Value)))
            {
                return(this);
            }
            var nfs = new List <KeyValuePair <string, ITypeDescriptor> >(tds.Length);

            for (var i = 0; i < _fields.Count; i++)
            {
                nfs.Add(new KeyValuePair <string, ITypeDescriptor>(_fields[i].Key, tds[i]));
            }
            return(new ObjectTypeDescriptor(typeSerializers, _name, Sealed, nfs));
        }
Exemple #10
0
 public EnumTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, Type type)
 {
     _typeSerializers = typeSerializers;
     _type = type;
     _name = typeSerializers.TypeNameMapper.ToName(type);
     _signed = IsSignedEnum(type);
     _flags = IsFlagsEnum(type);
     var undertype = type.GetEnumUnderlyingType();
     var enumValues = type.GetEnumValues();
     IEnumerable<ulong> enumValuesUlongs;
     if (undertype == typeof(int)) enumValuesUlongs = enumValues.Cast<int>().Select(i => (ulong)i);
     else if (undertype == typeof(uint)) enumValuesUlongs = enumValues.Cast<uint>().Select(i => (ulong)i);
     else if (undertype == typeof(sbyte)) enumValuesUlongs = enumValues.Cast<sbyte>().Select(i => (ulong)i);
     else if (undertype == typeof(byte)) enumValuesUlongs = enumValues.Cast<byte>().Select(i => (ulong)i);
     else if (undertype == typeof(short)) enumValuesUlongs = enumValues.Cast<short>().Select(i => (ulong)i);
     else if (undertype == typeof(ushort)) enumValuesUlongs = enumValues.Cast<ushort>().Select(i => (ulong)i);
     else if (undertype == typeof(long)) enumValuesUlongs = enumValues.Cast<long>().Select(i => (ulong)i);
     else enumValuesUlongs = enumValues.Cast<ulong>();
     _pairs = type.GetEnumNames().Zip(enumValuesUlongs.ToArray(), (s, v) => new KeyValuePair<string, ulong>(s, v)).ToList();
 }
 public DictionaryTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, AbstractBufferedReader reader, Func <AbstractBufferedReader, ITypeDescriptor> nestedDescriptorReader)
     : this(typeSerializers, nestedDescriptorReader(reader), nestedDescriptorReader(reader))
 {
 }
 public DictionaryTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, AbstractBufferedReader reader, Func<AbstractBufferedReader, ITypeDescriptor> nestedDescriptorReader)
 {
     _convertorGenerator = typeSerializers.ConvertorGenerator;
     _typeSerializers = typeSerializers;
     InitFromKeyValueDescriptors(nestedDescriptorReader(reader), nestedDescriptorReader(reader));
 }
 public ITypeDescriptor CloneAndMapNestedTypes(ITypeDescriptorCallbacks typeSerializers, Func <ITypeDescriptor, ITypeDescriptor> map)
 {
     throw new InvalidOperationException();
 }
Exemple #14
0
 public ListTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, AbstractBufferedReader reader, Func<AbstractBufferedReader, ITypeDescriptor> nestedDescriptorReader)
 {
     _convertorGenerator = typeSerializers.ConvertorGenerator;
     _typeSerializers = typeSerializers;
     InitFromItemDescriptor(nestedDescriptorReader(reader));
 }
Exemple #15
0
 public ITypeDescriptor CloneAndMapNestedTypes(ITypeDescriptorCallbacks typeSerializers, Func<ITypeDescriptor, ITypeDescriptor> map)
 {
     if (_typeSerializers == typeSerializers)
     {
         return this;
     }
     return new EnumTypeDescriptor(typeSerializers, _type, _name, _signed, _flags, _pairs.ToList());
 }
 public ITypeDescriptor CloneAndMapNestedTypes(ITypeDescriptorCallbacks typeSerializers, Func<ITypeDescriptor, ITypeDescriptor> map)
 {
     return this;
 }
Exemple #17
0
 public ITypeDescriptor CloneAndMapNestedTypes(ITypeDescriptorCallbacks typeSerializers, Func<ITypeDescriptor, ITypeDescriptor> map)
 {
     var itemDesc = map(_itemDescriptor);
     if (_typeSerializers == typeSerializers && itemDesc == _itemDescriptor)
         return this;
     return new ListTypeDescriptor(typeSerializers, itemDesc);
 }
Exemple #18
0
 public ITypeDescriptor CloneAndMapNestedTypes(ITypeDescriptorCallbacks typeSerializers, Func <ITypeDescriptor, ITypeDescriptor> map)
 {
     return(this);
 }
Exemple #19
0
 public DictionaryTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, AbstractBufferedReader reader, Func <AbstractBufferedReader, ITypeDescriptor> nestedDescriptorReader)
 {
     _convertorGenerator = typeSerializers.ConvertorGenerator;
     _typeSerializers    = typeSerializers;
     InitFromKeyValueDescriptors(nestedDescriptorReader(reader), nestedDescriptorReader(reader));
 }
 public DictionaryTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, AbstractBufferedReader reader, Func<AbstractBufferedReader, ITypeDescriptor> nestedDescriptorReader)
     : this(typeSerializers, nestedDescriptorReader(reader), nestedDescriptorReader(reader))
 {
 }
 public ITypeDescriptor CloneAndMapNestedTypes(ITypeDescriptorCallbacks typeSerializers, Func<ITypeDescriptor, ITypeDescriptor> map)
 {
     var keyDesc = map(_keyDescriptor);
     var valueDesc = map(_valueDescriptor);
     if (_typeSerializers == typeSerializers && keyDesc == _keyDescriptor && valueDesc == _valueDescriptor)
         return this;
     return new DictionaryTypeDescriptor(typeSerializers, keyDesc, valueDesc);
 }
Exemple #22
0
 public ListTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, AbstractBufferedReader reader, Func <AbstractBufferedReader, ITypeDescriptor> nestedDescriptorReader)
 {
     _convertorGenerator = typeSerializers.ConvertorGenerator;
     _typeSerializers    = typeSerializers;
     InitFromItemDescriptor(nestedDescriptorReader(reader));
 }
Exemple #23
0
 public ITypeDescriptor CloneAndMapNestedTypes(ITypeDescriptorCallbacks typeSerializers, Func<ITypeDescriptor, ITypeDescriptor> map)
 {
     var tds = new ITypeDescriptor[_fields.Count];
     for (var i = 0; i < _fields.Count; i++)
     {
         tds[i] = map(_fields[i].Value);
     }
     if (typeSerializers == _typeSerializers && tds.SequenceEqual(_fields.Select(i => i.Value)))
         return this;
     var nfs = new List<KeyValuePair<string, ITypeDescriptor>>(tds.Length);
     for (var i = 0; i < _fields.Count; i++)
     {
         nfs.Add(new KeyValuePair<string, ITypeDescriptor>(_fields[i].Key,tds[i]));
     }
     return new ObjectTypeDescriptor(typeSerializers, _name, Sealed, nfs);
 }
 DictionaryTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, ITypeDescriptor keyDesc, ITypeDescriptor valueDesc)
 {
     _convertorGenerator = typeSerializers.ConvertorGenerator;
     _typeSerializers    = typeSerializers;
     InitFromKeyValueDescriptors(keyDesc, valueDesc);
 }
Exemple #25
0
 public NullableTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, ref SpanReader reader, DescriptorReader nestedDescriptorReader)
     : this(typeSerializers, nestedDescriptorReader(ref reader))
 {
 }
Exemple #26
0
 ListTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, ITypeDescriptor itemDesc)
 {
     _convertorGenerator = typeSerializers.ConvertorGenerator;
     _typeSerializers = typeSerializers;
     InitFromItemDescriptor(itemDesc);
 }
Exemple #27
0
 ListTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, ITypeDescriptor itemDesc)
 {
     _convertorGenerator = typeSerializers.ConvertorGenerator;
     _typeSerializers    = typeSerializers;
     InitFromItemDescriptor(itemDesc);
 }
Exemple #28
0
 ObjectTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, string name, bool @sealed)
 {
     _typeSerializers = typeSerializers;
     Sealed           = @sealed;
     Name             = name;
 }
 DictionaryTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, ITypeDescriptor keyDesc, ITypeDescriptor valueDesc)
 {
     _convertorGenerator = typeSerializers.ConvertorGenerator;
     _typeSerializers = typeSerializers;
     InitFromKeyValueDescriptors(keyDesc, valueDesc);
 }
 public DictionaryTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, ref SpanReader reader, DescriptorReader nestedDescriptorReader)
     : this(typeSerializers, nestedDescriptorReader(ref reader), nestedDescriptorReader(ref reader))
 {
 }