Пример #1
0
            //---------------------------------------------------------------------
            public void Deserialize(Stream Stream_in)
            {
                BinaryFormatter   formatter = new BinaryFormatter();
                GenericVector <T> vector    = (GenericVector <T>)formatter.Deserialize(Stream_in);

                this.CopyFromArray(vector.ToArray());
                return;
            }
Пример #2
0
        public ListConverter(GenericVector sexp, IDataConverter converter)
        {
            var array = sexp.ToArray();

            _length = sexp.Length;

            _intersectedItemType = null;
            _converters          = new IConverter[_length];
            for (var i = 0; i < _length; i++)
            {
                _converters[i] = converter.GetConverter(array[i].DangerousGetHandle().ToInt64());
                if (_converters[i] == null)
                {
                    throw new InvalidDataException("Unable to get convert for data at index: " + i + " in List");
                }

                var itemTypes = _converters[i].GetClrTypes();
                _intersectedItemType = _intersectedItemType == null
                    ? itemTypes
                    : _intersectedItemType.Intersect(itemTypes);
            }

            if (_intersectedItemType == null)
            {
                _intersectedItemType = new[] { typeof(object) }
            }
            ;

            var fullTypes = new List <Type>();

            _names = sexp.Names;
            if (_names != null)
            {
                fullTypes.AddRange(keyTypes.GetDictionaryTypes(_intersectedItemType));
                if (_names.Length != _length)
                {
                    var swap = new string[_length];
                    for (var i = 0; i < _length; i++)
                    {
                        swap[i] = i < _names.Length
                            ? _names[i]
                            : "Column " + (i + 1);
                    }
                    _names = swap;
                }
            }

            fullTypes.AddRange(_intersectedItemType.GetListOrArrayTypes());

            var count = fullTypes.Count;

            _types = fullTypes[0].GetFullHierarchy();
            for (var i = 1; i < count; i++)
            {
                _types = _types.Union(fullTypes[i].GetFullHierarchy());
            }
        }
Пример #3
0
 //---------------------------------------------------------------------
 public void CopyFromByteArray(byte[] Bytes_in)
 {
     using (MemoryStream buffer = new MemoryStream(Bytes_in))
     {
         BinaryFormatter   formatter = new BinaryFormatter();
         GenericVector <T> vector    = (GenericVector <T>)formatter.Deserialize(buffer);
         this.CopyFromArray(vector.ToArray());
         buffer.Close();
     }
     return;
 }