////TEST private ColumnDefinition createColDefinition(IVector vector) { var vType = vector.GetType(); if (vType.GenericTypeArguments.Any()) { return(new ColumnDefinition(vType.GenericTypeArguments.First(), vector)); } else { return(null); } }
/// <summary> Creates an array of new, empty vectors based upon the given template</summary> public static IVector[] createVectors(IVector template, int num) { // Special handling of block-vectors if (template is IBlockAccessVector) { IBlockAccessVector templateB = (IBlockAccessVector)template; int numBlocks = templateB.BlockCount; ConstructorInfo[] cons = template.GetType().GetConstructors(); object[] args = new object[2]; args[0] = template.Length; args[1] = numBlocks; for (int i = 0; i < cons.Length; ++i) { ParameterInfo[] pinfos = cons[i].GetParameters(); Type[] c = new Type[pinfos.Length]; for (int j = 0; j < pinfos.Length; j++) { c[j] = pinfos[j].ParameterType; } // UPGRADE_TODO: invalid java reflection if (c.Length == 2 && c[0].FullName.Equals("int") && c[1].FullName.Equals("int")) { IBlockAccessVector[] ret = new IBlockAccessVector[num]; for (int j = 0; j < num; ++j) { ret[j] = (IBlockAccessVector)cons[i].Invoke(args); // Copy indices and create empty internal vector for (int k = 0; k < numBlocks; ++k) { int[] index = templateB.GetBlockIndices(k), newIndex = new int[index.Length]; Array.Copy(index, 0, newIndex, 0, index.Length); IVector newVector = createVector(templateB.GetBlock(k)); ret[j].SetBlock(k, newIndex, newVector); } } return(ret); } } } // Not a block-vector return(createVectors(template, template.Length, num)); }
private void AddSegment(IVector X, IVector Y, ICollection <IElement> X2, ICollection <IElement> Y2, ScriptNode Node, DrawCallback PlotCallback, params object[] Parameters) { IVector X2V = (IVector)X.Encapsulate(X2, Node); IVector Y2V = (IVector)Y.Encapsulate(Y2, Node); if (this.axisTypeX == null) { this.axisTypeX = X2V.GetType(); this.axisTypeY = Y2V.GetType(); } else { if (X2V.GetType() != this.axisTypeX || Y2V.GetType() != this.axisTypeY) { throw new ScriptException("Incompatible types of series."); } } this.x.AddLast(X2V); this.y.AddLast(Y2V); this.callbacks.AddLast(PlotCallback); this.parameters.AddLast(Parameters); }
/// <summary> Creates an array of new, empty vectors based upon the given template /// with the given size of the output vectors.</summary> public static IVector[] CreateVectors(IVector template, int size, int num) { Type[] types = { typeof(int) }; ConstructorInfo ci = template.GetType().GetConstructor( BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance, null, CallingConventions.HasThis, types, null); if (ci == null) { throw new InvalidOperationException("Vector should implement a ctor(int)."); } object[] args = { size }; IVector[] vectors = new IVector[num]; for (int i = 0; i < num; i++) { vectors[i] = (IVector)ci.Invoke(args); } return(vectors); }