示例#1
0
 private RegularArrayAccessor(Array array, RegularArrayInfo arrayInfo, bool asRanges, bool zeroBased, int[] transpose, bool readOnly)
     : base(array != null ? indices => GetValue(array, arrayInfo, asRanges, zeroBased, transpose, indices) : (FuncParams <int, T>)null,
            array != null && !array.IsReadOnly ? (value, indices) => SetValue(array, arrayInfo, value, asRanges, zeroBased, transpose, indices) : (ActionParams <int, T>)null)
 {
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     if (!typeof(T).IsAssignableFrom(array.GetType().GetElementType()))
     {
         throw new ArgumentException("Invalid array element type");
     }
     //
     if (transpose != null)
     {
         bool[] occurs = new bool[transpose.Length];
         for (int i = 0; i < transpose.Length; i++)
         {
             if (transpose[i] < 0 && transpose[i] >= transpose.Length)
             {
                 throw new ArgumentRegularArrayElementException("transpose", "Transpose index is out of range", i);
             }
             else if (occurs[transpose[i]])
             {
                 throw new ArgumentRegularArrayElementException("transpose", "Duplicate transpose index", i);
             }
             else
             {
                 occurs[transpose[i]] = true;
             }
         }
     }
 }
示例#2
0
        public SqlRangeRegularArray(int[] lengths)
        {
            if (lengths != null && lengths.Any(l => l < 0))
            {
                throw new ArgumentException("One or many items have invalid values.", "lengths");
            }

            _array     = PwrArray.CreateAsRegular <Range?>(lengths);
            _arrayInfo = new RegularArrayInfo(lengths);
        }
示例#3
0
        public SqlStringRegularArray(int[] lengths, Encoding encoding)
        {
            if (lengths != null && lengths.Any(t => t < 0))
            {
                throw new ArgumentException("One or many items have invalid values.", "lengths");
            }

            _array     = PwrArray.CreateAsRegular <String>(lengths);
            _arrayInfo = new RegularArrayInfo(lengths);
            _encoding  = encoding;
        }
示例#4
0
        protected StoredFlaggedStreamedRegularArray(Stream stream, SizeEncoding countSizing, SizeEncoding itemSizing, Func <T, int> dataSizer, SizeEncoding flagSizing, int flagSize,
                                                    Func <T, F> itemFlag, Func <F, bool> hasData, Func <Stream, F> flagReader, Action <Stream, F> flagWriter, Func <Stream, F, int, T> dataReader, Action <Stream, F, int, T> dataWriter, Equality <T> itemEquality,
                                                    RegularArrayInfo arrayInfo, ICollection <T> coll, bool leaveOpen, bool boostAccess, bool initialize)
            : base(stream, countSizing, itemSizing, dataSizer, flagSize, itemFlag, hasData, flagReader, flagWriter, dataReader, dataWriter, itemEquality, arrayInfo, coll, leaveOpen, boostAccess, false)
        {
            if (flagSize < 0)
            {
                throw new ArgumentOutOfRangeException("flagSize");
            }

            _flagSizing = flagSizing;
            if (initialize)
            {
                BaseStream.Position = 0;
                Initialize(coll ?? default(T).Repeat(ArrayInfo.Length));
            }
        }
示例#5
0
        protected CustomStreamedRegularArray(Stream stream, SizeEncoding countSizing, SizeEncoding itemSizing, Func <T, int> dataSizer,
                                             Func <Stream, int, T> dataReader, Action <Stream, int, T> dataWriter, Equality <T> itemEquality,
                                             RegularArrayInfo arrayInfo, ICollection <T> coll, bool leaveOpen, bool boostAccess, bool initialize)
            : base(stream, leaveOpen, boostAccess)
        {
            if (arrayInfo == null)
            {
                throw new ArgumentNullException("arrayInfo");
            }
            if (dataSizer == null)
            {
                throw new ArgumentNullException("dataSizer");
            }
            if (dataReader == null)
            {
                throw new ArgumentNullException("dataReader");
            }
            if (dataWriter == null)
            {
                throw new ArgumentNullException("dataWriter");
            }

            _countSizing  = countSizing;
            _itemSizing   = itemSizing;
            _dataSize     = null;
            _dataSizer    = dataSizer;
            _dataReader   = dataReader;
            _dataWriter   = dataWriter;
            _dataEquality = itemEquality != null ? itemEquality : EqualityComparer <T> .Default.Equals;
            _arrayInfo    = arrayInfo;
            if (initialize)
            {
                BaseStream.Position = 0;
                Initialize(coll ?? default(T).Repeat(ArrayInfo.Length));
            }
        }
 public SqlSexagesimalAngleRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
示例#7
0
 private SqlStringRegularArray(Array array, Encoding encoding)
 {
     _array     = array;
     _arrayInfo = _array != null ? new RegularArrayInfo(array.GetRegularArrayDimensions()) : null;
     _encoding  = encoding;
 }
示例#8
0
 public SqlSingleRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
        protected CustomFlaggedStreamedRegularArray(Stream stream, SizeEncoding countSizing, SizeEncoding itemSizing, int dataSize, bool compact, int flagSize,
                                                    Func <T, F> itemFlag, Func <F, bool> hasData, Func <Stream, F> flagReader, Action <Stream, F> flagWriter, Func <Stream, F, int, T> dataReader, Action <Stream, F, int, T> dataWriter, Equality <T> itemEquality,
                                                    RegularArrayInfo arrayInfo, ICollection <T> coll, bool leaveOpen, bool boostAccess, bool initialize)
            : base(stream, leaveOpen, boostAccess && !compact)
        {
            if (arrayInfo == null)
            {
                throw new ArgumentNullException("arrayInfo");
            }
            if (dataSize < 0)
            {
                throw new ArgumentOutOfRangeException("dataSize");
            }
            if (flagSize < 0)
            {
                throw new ArgumentOutOfRangeException("flagSize");
            }
            if (itemFlag == null)
            {
                throw new ArgumentNullException("itemFlag");
            }
            if (hasData == null)
            {
                throw new ArgumentNullException("hasData");
            }
            if (flagReader == null)
            {
                throw new ArgumentNullException("flagReader");
            }
            if (flagWriter == null)
            {
                throw new ArgumentNullException("flagWriter");
            }
            if (dataReader == null)
            {
                throw new ArgumentNullException("dataReader");
            }
            if (dataWriter == null)
            {
                throw new ArgumentNullException("dataWriter");
            }

            _countSizing  = countSizing;
            _itemSizing   = itemSizing;
            _flagSize     = flagSize;
            _dataSize     = dataSize;
            _dataSizer    = t => dataSize;
            _compact      = compact;
            _itemFlag     = itemFlag;
            _hasData      = hasData;
            _flagReader   = flagReader;
            _flagWriter   = flagWriter;
            _dataReader   = dataReader;
            _dataWriter   = dataWriter;
            _dataEquality = itemEquality != null ? itemEquality : EqualityComparer <T> .Default.Equals;
            _arrayInfo    = arrayInfo;
            if (initialize)
            {
                BaseStream.Position = 0;
                Initialize(coll ?? default(T).Repeat(ArrayInfo.Length));
            }
        }
示例#10
0
 public SqlDoubleRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
示例#11
0
 public SqlDateTimeRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
示例#12
0
 public SqlGuidRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
示例#13
0
 public SqlGradAngleRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
示例#14
0
 private static T GetValue(Array array, RegularArrayInfo arrayInfo, bool asRanges, bool zeroBased, int[] transpose, int[] indices)
 {
     return(arrayInfo.GetValue <T>(array, asRanges, zeroBased, transpose != null ? Transpose(indices, transpose) : indices));
 }
示例#15
0
 public SqlByteRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
示例#16
0
 public SqlHourAngleRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
示例#17
0
 private static void SetValue(Array array, RegularArrayInfo arrayInfo, T value, bool asRanges, bool zeroBased, int[] transpose, int[] indices)
 {
     arrayInfo.SetValue <T>(array, value, asRanges, zeroBased, transpose != null ? Transpose(indices, transpose) : indices);
 }
示例#18
0
 public SqlBinaryRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
 private SqlSexagesimalAngleRegularArray(Array array)
 {
     _array     = array;
     _arrayInfo = _array != null ? new RegularArrayInfo(array.GetRegularArrayDimensions()) : null;
 }
示例#20
0
 public SqlBooleanRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
示例#21
0
 protected StoredStreamedRegularArray(Stream stream, SizeEncoding countSizing, SizeEncoding itemSizing, Func <T, int> dataSizer,
                                      Func <Stream, int, T> dataReader, Action <Stream, int, T> dataWriter, Equality <T> itemEquality,
                                      RegularArrayInfo arrayInfo, ICollection <T> coll, bool leaveOpen, bool boostAccess, bool initialize)
     : base(stream, countSizing, itemSizing, dataSizer, dataReader, dataWriter, itemEquality, arrayInfo, coll, leaveOpen, boostAccess, initialize)
 {
 }
示例#22
0
 public SqlInt16RegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
 public SqlBigIntegerRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
示例#24
0
 public SqlRangeRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }
示例#25
0
 public SqlStringRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
     _encoding  = null;
 }
示例#26
0
 private SqlRangeRegularArray(Array array)
 {
     _array     = array;
     _arrayInfo = _array != null ? new RegularArrayInfo(array.GetRegularArrayDimensions()) : null;
 }
示例#27
0
 public SqlComplexRegularArray()
 {
     _array     = null;
     _arrayInfo = null;
 }