Exemplo n.º 1
0
 public void RemoveErrorByGrid(GridData gridedit)
 {
     if (this.InvokeRequired)
     {
         DelegateInvoke d = delegate { _RemoveErrorByGrid(gridedit); };
         this.BeginInvoke(d);
     }
     else
     {
         _RemoveErrorByGrid(gridedit);
     }
 }
Exemplo n.º 2
0
        public static object Invoke(this Type objectType, string methodName)
        {
            MethodInfo inf = objectType.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static);

            if (inf == null)
            {
                throw new ApplicationException($"Method {methodName} or Object {objectType.Name} not found");
            }

            DelegateInvoke delegateInvoke = (DelegateInvoke)Delegate.CreateDelegate(typeof(DelegateInvoke), inf);

            return(delegateInvoke);
        }
Exemplo n.º 3
0
        public void DelegateInvoke()
        {
            var c = new Dictionary <string, object>();

            Func <string, int, string> testDeleg = (a1, a2) => {
                return(String.Format(a1, a2));
            };
            var invDelegSt = new DelegateInvoke(testDeleg, new[] {
                (Func <IDictionary <string, object>, object>)((cntx) => { return("-{0}-"); }),
                (Func <IDictionary <string, object>, object>)((cntx) => { return("5"); })             // should be converted to int
            }, "test");

            invDelegSt.Execute(c);

            Assert.AreEqual("-5-", c["test"]);
        }
Exemplo n.º 4
0
        public void RemoveError(GridData.Cell cell, Property.IProperty p)
        {
            if (IsDisposed) // 某些 verify 是异步的,可能在窗口关闭后返回。
            {
                return;
            }

            if (this.InvokeRequired)
            {
                DelegateInvoke d = delegate { _RemoveError(cell, p); };
                this.BeginInvoke(d);
            }
            else
            {
                _RemoveError(cell, p);
            }
        }
Exemplo n.º 5
0
        public static IStatement ComposeCombinedStatement()
        {
            var set1 = new SetSt("sum", 0);
            var if1  = new If((cntx) => {
                return(!cntx.ContainsKey("sum"));
            }, set1);

            var set2  = new SetSt("items", new double[] { 1, 1, 2, 3, 5, 8, 13 });
            var sumSt = new DelegateInvoke(
                (Func <double, double, double>)((sum, a) => { return(sum + a); }),
                new Func <IDictionary <string, object>, object>[] {
                (cntx) => { return(cntx["sum"]); },
                (cntx) => { return(cntx["itm"]); }
            },
                "sum"
                );
            var each1 = new Each((cntx) => { return(cntx["items"] as IEnumerable); }, sumSt, "itm");
            var sq1   = new Sequence(new IStatement[] {
                if1, set2, each1
            });

            return(sq1);
        }
Exemplo n.º 6
0
        public void AddError(GridData.Cell cell, Property.IProperty p, Property.ErrorLevel level, string desc)
        {
            if (IsDisposed) // 某些 verify 是异步的,可能在窗口关闭后返回。
            {
                return;
            }

            // 在调用线程中回调。
            if (OnAddError != null)
            {
                OnAddError(cell, p, level, desc);
            }

            if (this.InvokeRequired)
            {
                DelegateInvoke d = delegate { _AddError(cell, p, level, desc); };
                this.BeginInvoke(d);
            }
            else
            {
                _AddError(cell, p, level, desc);
            }
        }