/// \deprecated Use `QueryRoot.productByHandle` instead. /// <summary> /// Find a product by its handle. /// </summary> /// <param name="handle"> /// The handle of the product. /// </param> public ShopQuery productByHandle(ProductDelegate buildQuery, string handle, string alias = null) { Log.DeprecatedQueryField("Shop", "productByHandle", "Use `QueryRoot.productByHandle` instead."); if (alias != null) { ValidationUtils.ValidateAlias(alias); Query.Append("productByHandle___"); Query.Append(alias); Query.Append(":"); } Query.Append("productByHandle "); Arguments args = new Arguments(); args.Add("handle", handle); Query.Append(args.ToString()); Query.Append("{"); buildQuery(new ProductQuery(Query)); Query.Append("}"); return(this); }
/// <summary> /// will allow you to write queries on Product. /// </summary> public MetafieldParentResourceQuery onProduct(ProductDelegate buildQuery) { Query.Append("...on Product{"); buildQuery(new ProductQuery(Query)); Query.Append("}"); return(this); }
/// <summary> /// will allow you to write queries on Product. /// </summary> public NodeQuery onProduct(ProductDelegate buildQuery) { Query.Append("...on Product{"); buildQuery(new ProductQuery(Query)); Query.Append("}"); return(this); }
/// <summary> /// Find a product by its handle. /// </summary> /// <param name="handle"> /// The handle of the product. /// </param> public QueryRootQuery productByHandle(ProductDelegate buildQuery, string handle, string alias = null) { if (alias != null) { ValidationUtils.ValidateAlias(alias); Query.Append("productByHandle___"); Query.Append(alias); Query.Append(":"); } Query.Append("productByHandle "); Arguments args = new Arguments(); args.Add("handle", handle); Query.Append(args.ToString()); Query.Append("{"); buildQuery(new ProductQuery(Query)); Query.Append("}"); return(this); }
public void OnProduceComplete(IAsyncResult asyncResult) { //stateList.Add("执行中"); AsyncResult result = (AsyncResult)asyncResult; ProductDelegate del = (ProductDelegate)result.AsyncDelegate; string product = del.EndInvoke(asyncResult); base.Complete(produce.Result, false); //stateList.Add("执行结束"); }
/// <summary> /// The product object that the product variant belongs to. /// </summary> public ProductVariantQuery product(ProductDelegate buildQuery) { Query.Append("product "); Query.Append("{"); buildQuery(new ProductQuery(Query)); Query.Append("}"); return(this); }
/// <summary> /// The item at the end of ProductEdge. /// </summary> public ProductEdgeQuery node(ProductDelegate buildQuery) { Query.Append("node "); Query.Append("{"); buildQuery(new ProductQuery(Query)); Query.Append("}"); return(this); }
static void Main() { Product productChar = new Product(); Conveyer conveyer = new Conveyer(); ProductDelegate productDelegate = new ProductDelegate(conveyer.SizesRemoved); productDelegate += conveyer.Wrapped; productDelegate += conveyer.Drilled; productDelegate.Invoke(productChar); Console.WriteLine(productChar.ShowProperties()); Console.ReadKey(); }
XInt IFactorialFunction.Factorial(int n) { if (n < 0) { throw new System.ArgumentOutOfRangeException( this.Name + ": " + nameof(n) + " >= 0 required, but was " + n); } if (n < 2) { return(XInt.One); } var log2N = XMath.FloorLog2(n); ProductDelegate prodDelegate = Product; var results = new IAsyncResult[log2N]; int high = n, low = n >> 1, shift = low, taskCounter = 0; // -- It is more efficient to add the big intervals // -- first and the small ones later! while ((low + 1) < high) { results[taskCounter++] = prodDelegate.BeginInvoke(low + 1, high, null, null); high = low; low >>= 1; shift += low; } XInt p = XInt.One, r = XInt.One; while (--taskCounter >= 0) { var I = Task.Factory.StartNew(() => r * p); var t = p * prodDelegate.EndInvoke(results[taskCounter]); r = I.Result; p = t; } return((r * p) << shift); }
public Model_Invoke_Result(Invoke_Produce produce, AsyncCallback callback, object state) : base(callback, state) { this.produce = produce; //this.State=new List<string>(); //stateList = this.State as List<string>; //Turn the expression into an array of bytes produce.RunWork(); //string sta1 = "开始执行"; //stateList.Add(sta1); ProductDelegate del = new ProductDelegate(produce.Product); AsyncCallback callBack = new AsyncCallback(OnProduceComplete); //string currentState = "kaishi"; IAsyncResult asyncResult = del.BeginInvoke(callBack, this); if (!produce.Finish) { return; } base.Complete(produce.Result, true); //begin writing asynchronously //IAsyncResult result = fs.BeginWrite(bytes, 0, bytes.Length, new AsyncCallback(OnWrite), thi }
/// <summary> /// Computes the product and re-projection in SH of 2 vectors of SH coefficients of the specified order using Clebsch-Gordan coefficients /// </summary> /// <param name="_Vector0">First vector</param> /// <param name="_Vector1">Second vector</param> /// <param name="_Order">The order of the vectors (i.e. vectors must have a length of Order²)</param> /// <returns>The convolution of the 2 vectors</returns> /// <remarks>This method is quite time-consuming as the convolution is computed using 5 loops but, as an optimisation, we can notice that most Clebsh-Gordan are 0 /// and a vector of non-null coefficients could be precomputed as only the SH vectors' coefficients change</remarks> public static double[] ProductClebschGordan( double[] _Vector0, double[] _Vector1, int _Order, ProductDelegate _Delegate ) { if ( _Vector0 == null || _Vector1 == null ) throw new Exception( "Invalid coefficients!" ); if ( _Vector0.Length != _Vector1.Length ) throw new Exception( "Coefficient vectors length mismatch!" ); if ( _Order * _Order != _Vector0.Length ) throw new Exception( "Coefficient vectors are not of the specified order!" ); double[] ConvolvedCoeffs = new double[_Vector0.Length]; // Compute convolution int TotalCoeffIndex = 0; for ( int l=0; l < _Order; l++ ) for ( int m=-l; m <= +l; m++, TotalCoeffIndex++ ) { ConvolvedCoeffs[TotalCoeffIndex] = 0.0; int InnerTotalCoeffIndex = 0; for ( int l1=0; l1 < _Order; l1++ ) for ( int m1=-l1; m1 <= +l1; m1++, InnerTotalCoeffIndex++ ) for ( int l2=0; l2 < _Order; l2++ ) { int Bl2m1mIndex = l2*(l2+1) + m1 - m; if ( Bl2m1mIndex < 0 || Bl2m1mIndex >= _Order * _Order ) continue; double Sign = ((m1 - m) & 1) == 0 ? +1 : -1; double Sqrt = Math.Sqrt( (2.0 * l1 + 1) * (2.0 * l2 + 1) / (4.0 * Math.PI * (2.0 * l + 1)) ); double CGC0 = ComputeClebschGordan( l1, l2, 0, 0, l, 0 ); if ( Math.Abs( CGC0 ) < 1e-4 ) continue; double CGC1 = ComputeClebschGordan( l1, l2, m1, m - m1, l, m ); if ( Math.Abs( CGC1 ) < 1e-4 ) continue; double A = _Vector0[InnerTotalCoeffIndex]; double B = _Vector1[Bl2m1mIndex]; double FinalCoeff = Sqrt * CGC0 * CGC1; ConvolvedCoeffs[TotalCoeffIndex] += Sign * A * B * FinalCoeff; if ( _Delegate != null ) _Delegate( TotalCoeffIndex, InnerTotalCoeffIndex, Bl2m1mIndex, Sign * FinalCoeff < 0.0 ? -1.0 : +1.0, Math.Abs( FinalCoeff ) ); } } return ConvolvedCoeffs; }