public void SetUp() { var source = new int[arraySize]; var random = new Random(); for (var i = 0; i < arraySize; i++) { source[i] = random.Next(); } sourceArray = source; var accessor = ArrayAccessorBuilder.BuildForArrayOf(typeof(int)); getByAccessor = accessor.GetElement; setByAccessor = accessor.SetElement; var xSourceArray = Expression.Parameter(typeof(Array)); var xDestinationArray = Expression.Parameter(typeof(Array)); var xIndex = Expression.Parameter(typeof(int)); var xSetItem = Expression.Lambda <Action <Array, int, Array> >( Expression.Assign( Expression.ArrayAccess(Expression.Convert(xDestinationArray, typeof(int[])), xIndex), Expression.ArrayAccess(Expression.Convert(xSourceArray, typeof(int[])), xIndex) ), xDestinationArray, xIndex, xSourceArray); setViaExpression = xSetItem.Compile(); }
public CloneArrayReplicationStrategy(Type elementType) { this.elementType = elementType; IArrayAccessor arrayAccessor = ArrayAccessorBuilder.BuildForArrayOf(elementType); getElement = arrayAccessor.GetElement; setElement = arrayAccessor.SetElement; }
protected override void SetUp() { base.SetUp(); var random = new Random(); array = Enumerable.Range(0, 100) .Select(_ => random.NextDouble()) .ToArray(); number = random.NextDouble(); arrayAccessor = ArrayAccessorBuilder.BuildForArrayOf(typeof(double)); }