public virtual object NewInstance(IReflectClass componentType, ArrayInfo info) { componentType = componentType.GetDelegate(); if (componentType is GenericClass) { int length = info.ElementCount(); return new GenericArray(((GenericClass)componentType).ArrayClass(), length); } return _delegate.NewInstance(componentType, info); }
private void ReadDimensions(ArrayInfo info, IReadBuffer buffer, int dimensionCount ) { var dim = new int[dimensionCount]; for (var i = 0; i < dim.Length; i++) { dim[i] = buffer.ReadInt(); } ((MultidimensionalArrayInfo) info).Dimensions(dim); info.ElementCount(ElementCount(dim)); }
protected override void ReadElements(IReadContext context, ArrayInfo info, object array) { if (array == null) { return; } object[] objects = new object[info.ElementCount()]; ReadInto(context, info, objects); ArrayReflector(Container(context)).Shape(objects, 0, array, ((MultidimensionalArrayInfo )info).Dimensions(), 0); }
public virtual object NewInstance(IReflectClass componentType, ArrayInfo info) { // TODO: implement multidimensional arrays. int length = info.ElementCount(); return NewInstance(componentType, length); }
protected virtual void AnalyzeDimensions(ObjectContainerBase container, object obj , ArrayInfo info) { info.ElementCount(ArrayReflector(container).GetLength(obj)); }
protected virtual void WriteDimensions(IWriteContext context, ArrayInfo info) { context.WriteInt(info.ElementCount()); }
protected virtual void WriteElements(IWriteContext context, object obj, ArrayInfo info) { if (HandleAsByteArray(obj)) { context.WriteBytes((byte[])obj); } else { // byte[] performance optimisation if (HasNullBitmap(info)) { BitMap4 nullItems = NullItemsMap(ArrayReflector(Container(context)), obj); WriteNullBitmap(context, nullItems); for (int i = 0; i < info.ElementCount(); i++) { if (!nullItems.IsTrue(i)) { context.WriteObject(_handler, ArrayReflector(Container(context)).Get(obj, i)); } } } else { for (int i = 0; i < info.ElementCount(); i++) { context.WriteObject(_handler, ArrayReflector(Container(context)).Get(obj, i)); } } } }
protected void ReadInto(IReadContext context, ArrayInfo info, object array) { if (array == null) { return; } if (HandleAsByteArray(array)) { context.ReadBytes((byte[])array); // byte[] performance optimisation return; } if (HasNullBitmap(info)) { BitMap4 nullBitMap = ReadNullBitmap(context, info.ElementCount()); for (int i = 0; i < info.ElementCount(); i++) { object obj = nullBitMap.IsTrue(i) ? null : context.ReadObject(_handler); ArrayReflector(Container(context)).Set(array, i, obj); } } else { for (int i = 0; i < info.ElementCount(); i++) { ArrayReflector(Container(context)).Set(array, i, context.ReadObject(_handler)); } } }
protected virtual void ReadDimensions(ArrayInfo info, IReadBuffer buffer) { info.ElementCount(buffer.ReadInt()); }
protected virtual void ReadInfo(Transaction trans, IReadBuffer buffer, ArrayInfo info) { int classID = buffer.ReadInt(); if (IsPreVersion0Format(classID)) { throw new UnsupportedOldFormatException(); } else { _versionHelper.ReadTypeInfo(trans, buffer, info, classID); ReflectClassFromElementsEntry(Container(trans), info, classID); ReadDimensions(info, buffer); } if (Debug4.ExceedsMaximumArrayEntries(info.ElementCount(), _usePrimitiveClassReflector )) { info.ElementCount(0); } }
private int ReducedCountForNullBitMap(ArrayInfo info, IReadBuffer context) { if (!HasNullBitmap(info)) { return 0; } return ReducedCountForNullBitMap(info.ElementCount(), ReadNullBitmap(context, info .ElementCount())); }
protected override void AnalyzeDimensions(ObjectContainerBase container, object obj , ArrayInfo info) { var dim = ArrayReflector(container).Dimensions(obj); ((MultidimensionalArrayInfo) info).Dimensions(dim); info.ElementCount(ElementCount(dim)); }
protected override void WriteElements(IWriteContext context, object obj, ArrayInfo info) { var objects = AllElements(Container(context), obj); if (HasNullBitmap(info)) { var nullBitMap = new BitMap4(info.ElementCount()); var nullBitMapBuffer = context.Reserve(nullBitMap.MarshalledLength()); var currentElement = 0; while (objects.MoveNext()) { var current = objects.Current; if (current == null) { nullBitMap.SetTrue(currentElement); } else { context.WriteObject(DelegateTypeHandler(), current); } currentElement++; } nullBitMapBuffer.WriteBytes(nullBitMap.Bytes()); } else { while (objects.MoveNext()) { context.WriteObject(DelegateTypeHandler(), objects.Current); } } }