public void CacheResultOfMethodThatReturnsNullWithSerializingCache()
        {
            MethodInfo method = new VoidMethod(cacheResultTarget.ReturnsNothing).Method;
            object     expectedReturnValue = null;

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, null);
            ExpectCacheInstanceRetrieval("results", binaryFormatterCache);
            ExpectCallToProceed(expectedReturnValue);

            // check that the null retVal is cached as well - it might be
            // the result of an expensive webservice/database call etc.
            object returnValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);

            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(1, binaryFormatterCache.Count);

            // and again, but without Proceed()...
            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, null);
            ExpectCacheInstanceRetrieval("results", binaryFormatterCache);

            // cached value should be returned
            object cachedValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);

            Assert.IsNull(cachedValue, "Should recognize cached value as null-value marker.");

            mockInvocation.Verify();
            mockContext.Verify();
        }
Exemplo n.º 2
0
        private void GetDelegateInformation(string methodName, ref SimpleBitVector32 flags,
                                            int hasHandlerBit, int isArglessBit)
        {
            // First, try to get a delegate to the two parameter handler
            EventHandler e = null;

            try {
                e = (EventHandler)Delegate.CreateDelegate(typeof(EventHandler), this,
                                                          methodName, true /*ignoreCase*/);
            }
            catch {
            }

            // If there isn't one, try the argless one
            if (e == null)
            {
                try {
                    VoidMethod vm = (VoidMethod)Delegate.CreateDelegate(typeof(VoidMethod), this,
                                                                        methodName, true /*ignoreCase*/);
                    e = new ArglessEventHandlerDelegateProxy(vm).Handler;
                    flags[isArglessBit] = true;
                }
                catch {
                }
            }

            flags[hasHandlerBit] = (e != null);
        }
Exemplo n.º 3
0
        public static string BenchMark(VoidMethod method, out long executionTime, string description = "Method Execution", BenchmarkUnit unit = 0)
        {
            executionTime = 0;
            if (method == null)
            {
                return("No method present");
            }
            stopWatch.Reset();
            stopWatch.Start();
            method();
            stopWatch.Stop();
            switch (unit)
            {
            case BenchmarkUnit.MilliSecond:
            default:
                executionTime = stopWatch.ElapsedMilliseconds;
                break;

            case BenchmarkUnit.MicroSecond:
                executionTime = stopWatch.ElapsedMilliseconds * 1000;
                break;

            case BenchmarkUnit.Tick:
                executionTime = stopWatch.ElapsedTicks;
                break;

            case BenchmarkUnit.Second:
                executionTime = stopWatch.ElapsedMilliseconds / 1000;
                break;
            }
            return(description + "  takes: " + executionTime + " " + unit.ToString() + "s");
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            VoidMethod vm = new VoidMethod();

            vm.VoidMeth(2, 7);
            vm.VoidMeth(x: 5, y: 15);
        }
Exemplo n.º 5
0
    public void startMoving( GameObject target, VoidMethod callback = null )
    {
        CollectResources collecting = GetComponent<CollectResources>();
        if( collecting != null )
            collecting.CancelInvoke();

        this.callback = callback;

        this.target = target.transform;
        if ( seeker != null ) seeker.StartPath(transform.position, target.transform.position, OnPathComplete);

        targetPos = target.transform.position;
        targetPosAux = targetPos;
        hasTarget = true;

        // Cancel all animations and play walk
        if (animator != null)
        {
            foreach(AnimatorControllerParameter param in animator.parameters)
            {
                animator.SetBool(param.name, false);
            }
            animator.SetBool("walk", true);
        }
        status = Status.running;
    }
Exemplo n.º 6
0
        public FFuncPersonTable(string tableName,
                                DataSet dataSet, VoidMethod saveDataMethod)
            : base(tableName, dataSet, saveDataMethod)
        {
            //InitializeComponent(); //якщо SetDataBinding new

            //SetDataBinding(); //якщо new
        }
Exemplo n.º 7
0
        public Hook(VoidMethod method)
        {
            ArgumentNullException.ThrowIfNull(method);

            methodType = MethodType.Void;
            voidMethod = method;
            Unsafe.SkipInit(out valueTaskMethod);
            Unsafe.SkipInit(out taskMethod);
        }
Exemplo n.º 8
0
        public static double SW(VoidMethod method)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            method();
            stopwatch.Stop();
            return(stopwatch.ElapsedTicks / (double)Stopwatch.Frequency);
        }
Exemplo n.º 9
0
 public Buffer(VoidMethod i_ActivationMehod, VoidMethod i_DeactivationMethod, T[] copyObjects)
 {
     _Objects = new List <T>();
     for (int i = 0; i < copyObjects.Length; i++)
     {
         _Objects.Add(copyObjects[i]);
     }
     _ObjectBools = new List <bool>(copyObjects.Length);
 }
Exemplo n.º 10
0
            public override AbstractGenerator CreateGenerator(GameObject go)
            {
                var pos       = UITestUtils.CenterPointOfObject(go.GetComponent <RectTransform>());
                var anyCamera = GameObject.FindObjectOfType <Camera>();

                pos.x = pos.x / anyCamera.pixelWidth;
                pos.y = pos.y / anyCamera.pixelHeight;
                return(VoidMethod.Path(go).Float(pos.x).Float(pos.y).Float(pos.x).Float(pos.y).Float(1));
            }
Exemplo n.º 11
0
 public void SetMethod(VoidMethod method, EventType _eventType = EventType.Start)
 {
     eventType            = _eventType;
     voidMethod           = method;
     methodParameterCount = 0;
     if (method != null)
     {
         SetMethodParameters(method.Target, method.Method);
     }
 }
Exemplo n.º 12
0
        /// <summary>
        ///     字句分割
        ///     "[1] あ [2] いうえ "を"[1]"," ", "あ"," ","[2]"," ","いうえ"," "に分割
        /// </summary>
        /// <param name="st"></param>
        /// <returns></returns>
        private static List <string> lex(StringStream st)
        {
            var        strs       = new List <string>();
            var        state      = 0;
            var        startIndex = 0;
            VoidMethod reduce     = delegate
            {
                if (st.CurrentPosition == startIndex)
                {
                    return;
                }
                var length = st.CurrentPosition - startIndex;
                strs.Add(st.Substring(startIndex, length));
                startIndex = st.CurrentPosition;
            };

            while (!st.EOS)
            {
                if (st.Current == '[')
                {
                    if (state == 1) //"["内部
                    {
                        goto unanalyzable;
                    }
                    reduce();
                    state = 1;
                    st.ShiftNext();
                }
                else if (st.Current == ']')
                {
                    if (state != 1) //"["外部
                    {
                        goto unanalyzable;
                    }
                    st.ShiftNext();
                    reduce();
                    state = 0;
                }
                else if (state == 0 && LexicalAnalyzer.IsWhiteSpace(st.Current))
                {
                    reduce();
                    LexicalAnalyzer.SkipAllSpace(st);
                    reduce();
                }
                else
                {
                    st.ShiftNext();
                }
            }
            reduce();
            return(strs);

unanalyzable:
            return(null);
        }
 private void VerifyWillThrow <ExpectedException>(VoidMethod proc)
 {
     try
     {
         proc();
         Assert.Fail("Exception expected to be thrown");
     }
     catch (Exception e)
     {
         Assert.IsInstanceOfType(typeof(ExpectedException), e);
     }
 }
Exemplo n.º 14
0
 public static void SetControlProperty <TControl>(this TControl control, VoidMethod <TControl> assignmentAction)
     where TControl : Control
 {
     if (control.InvokeRequired)
     {
         control.Invoke(new ControlAction <TControl>(SetControlProperty), new object[] { control, assignmentAction });
     }
     else
     {
         assignmentAction(control);
     }
 }
Exemplo n.º 15
0
        private EventHandler GetDelegateFromMethodName(string methodName, bool isArgless)
        {
            if (isArgless)
            {
                VoidMethod vm = (VoidMethod)Delegate.CreateDelegate(typeof(VoidMethod), this,
                                                                    methodName, true /*ignoreCase*/);
                return(new ArglessEventHandlerDelegateProxy(vm).Handler);
            }

            return((EventHandler)Delegate.CreateDelegate(typeof(EventHandler), this,
                                                         methodName, true /*ignoreCase*/));
        }
Exemplo n.º 16
0
            public Hook(VoidMethod method)
            {
                if (method is null)
                {
                    throw new ArgumentNullException(nameof(method));
                }

                methodType = MethodType.Void;
                voidMethod = method;
                Unsafe.SkipInit(out valueTaskMethod);
                Unsafe.SkipInit(out taskMethod);
            }
Exemplo n.º 17
0
        /// <summary>
        /// run method in transaction of DbContext with rollback
        /// </summary>
        public static void RollBack(DbContext session, VoidMethod voidMethod)
        {
            if (session == null)
            {
                return;
            }


            Method <bool> wrapper = x =>
            {
                voidMethod();
                return(true);
            };

            RollBack <bool>(session, wrapper);
        }
Exemplo n.º 18
0
        public void CacheResultOfMethodThatReturnsNull()
        {
            MethodInfo method = new VoidMethod(cacheResultTarget.ReturnsNothing).Method;
            object     expectedReturnValue = null;

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, null);
            ExpectCacheInstanceRetrieval("results", resultCache);
            ExpectCallToProceed(expectedReturnValue);

            // check that the null retVal is cached as well - it might be
            // the result of an expensive webservice/database call etc.
            object returnValue = advice.Invoke(mockInvocation);

            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(1, resultCache.Count);
        }
Exemplo n.º 19
0
        private bool GetDelegateInformationFromMethod(string methodName, IDictionary dictionary)
        {
            EventHandler handler = (EventHandler)Delegate.CreateDelegate(typeof(EventHandler), this, methodName, true, false);

            if (handler != null)
            {
                dictionary[methodName] = new EventMethodInfo(handler.Method, false);
                return(true);
            }
            VoidMethod method = (VoidMethod)Delegate.CreateDelegate(typeof(VoidMethod), this, methodName, true, false);

            if (method != null)
            {
                dictionary[methodName] = new EventMethodInfo(method.Method, true);
                return(true);
            }
            return(false);
        }
Exemplo n.º 20
0
        public void CacheResultOfMethodThatReturnsNull()
        {
            MethodInfo method = new VoidMethod( cacheResultTarget.ReturnsNothing ).Method;
            object expectedReturnValue = null;

            ExpectAttributeRetrieval( method );
            ExpectCacheKeyGeneration( method, null );
            ExpectCacheInstanceRetrieval( "results", resultCache );
            ExpectCallToProceed( expectedReturnValue );

            // check that the null retVal is cached as well - it might be 
            // the result of an expensive webservice/database call etc.
            object returnValue = advice.Invoke( (IMethodInvocation)mockInvocation.Object );
            Assert.AreEqual( expectedReturnValue, returnValue );
            Assert.AreEqual( 1, resultCache.Count );

            mockInvocation.Verify();
            mockContext.Verify();
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            Program    p   = new Program();
            VoidMethod doA = p.doA;
            VoidMethod doB = p.doB;

            doA.Invoke("Hello Cuccu");
            doB.Invoke("Hello Cuccu");

            invokeMethod(p.doA, "Meo meo");
            invokeMethod(p.doB, "Meo meo");

            p.doA("Heheh");

            VoidMethod doC = doA + doB;

            doC.Invoke("Shit");
            Console.ReadKey();
        }
Exemplo n.º 22
0
            public override AbstractGenerator CreateGenerator(GameObject go)
            {
                var image = UITestUtils.FindGameObjectWithComponentInParents <Image>(go);
                var sr    = UITestUtils.FindGameObjectWithComponentInParents <SpriteRenderer>(go);

                if (image != null)
                {
                    if (image.sprite != null)
                    {
                        return(VoidMethod.Path(go).String(image.sprite.name));
                    }
                    return(VoidMethod.Path(go).String(string.Empty));
                }
                if (sr != null)
                {
                    if (sr.sprite != null)
                    {
                        return(VoidMethod.Path(go).String(sr.sprite.name));
                    }
                    return(VoidMethod.Path(go).String(string.Empty));
                }
                throw new ArgumentException();
            }
Exemplo n.º 23
0
        public void CacheResultOfMethodThatReturnsNullWithSerializingCache()
        {
		    MethodInfo method = new VoidMethod(cacheResultTarget.ReturnsNothing).Method;
		    object expectedReturnValue = null;

		    ExpectAttributeRetrieval(method);
		    ExpectCacheKeyGeneration(method, null);
		    ExpectCacheInstanceRetrieval("results", binaryFormatterCache);
		    ExpectCallToProceed(expectedReturnValue);

		    // check that the null retVal is cached as well - it might be 
		    // the result of an expensive webservice/database call etc.
		    object returnValue = advice.Invoke((IMethodInvocation) mockInvocation.Object);
		    Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(1, binaryFormatterCache.Count);

            // and again, but without Proceed()...
            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, null);
            ExpectCacheInstanceRetrieval("results", binaryFormatterCache);

            // cached value should be returned
            object cachedValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);
            Assert.IsNull(cachedValue, "Should recognize cached value as null-value marker.");

		    mockInvocation.Verify();
		    mockContext.Verify();
        }
Exemplo n.º 24
0
        VoidMethod SetVoidMethod()
        {
            Enum.TryParse(cmbGradient.SelectedItem + "", true, out MnM.GWS.Gradient grad);
            IFillStyle fStyle;

            if (lstColors.Items.Count > 0)
            {
                object[] all = new object[lstColors.Items.Count];
                lstColors.Items.CopyTo(all, 0);
                fStyle = Factory.newFillStyle(grad, all.Select(x => ((System.Drawing.Color)x).ToArgb()).ToArray());
            }
            else
            {
                fStyle = Factory.newFillStyle(grad, MnM.GWS.Colour.Silver);
            }

            Renderer.ReadContext = fStyle;

            VoidMethod gwsMethod = null;
            var        stroke    = (float)numStroke.Value;

            Renderer.CopySettings(pse, stroke, StrokeMode.Middle, chkAA.Checked ? LineDraw.AA : LineDraw.NonAA);

            mnmCanvas.ApplyBackground(MnM.GWS.Colour.White);

            if (rotate1.Valid)
            {
                Renderer.RotateTransform(Entity.Buffer, rotate1);
            }
            else
            {
                Renderer.ResetTransform(Entity.Buffer);
            }

            curveType = 0;
            foreach (var item in lstCurveOption.CheckedItems)
            {
                curveType |= (CurveType)item;
            }
            IDrawStyle ds = new DrawStyle();

            ds.Angle = rotate;
            var font = gwsFont ?? Factory.SystemFont;

            ds.LineHeight = (font?.Info?.LineHeight ?? 0).Ceiling();

            switch (cmbShape.Text)
            {
            case "Line":
                if (drawPoints == null || drawPoints.Length < 4)
                {
                    System.Windows.Forms.MessageBox.Show("Please provide 2 coordinates to create a line by clicking 2 points on GWS picture box!");
                    return(null);
                }
                gwsMethod = () => mnmCanvas.DrawLines(true, rotate, drawPoints);
                break;

            case "Trapezium":
                if (drawPoints == null || drawPoints.Length < 4)
                {
                    System.Windows.Forms.MessageBox.Show("Please provide 2 coordinates to create a line by clicking 2 points on GWS picture box!");
                    return(null);
                }
                gwsMethod = () => mnmCanvas.DrawTrapezium(
                    new float[] { drawPoints[0], drawPoints[1], drawPoints[2], drawPoints[3],
                                  (float)numSize.Value, (float)numSizeDiff.Value }, rotate);
                break;

            case "Circle":
                if (drawPoints?.Length >= 4)
                {
                    gwsMethod = () => mnmCanvas.DrawCircle(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                           new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), rotate);
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawEllipse(x, y, w, w, rotate);
                }

                break;

            case "Ellipse":
                if (drawPoints?.Length >= 6)
                {
                    gwsMethod = () => mnmCanvas.DrawEllipse(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                            new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), new MnM.GWS.PointF(drawPoints[4], drawPoints[5]), rotate);
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawEllipse(x, y, w, h, rotate);
                }
                break;

            case "Arc":
                if (drawPoints?.Length >= 6)
                {
                    gwsMethod = () => mnmCanvas.DrawArc(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                        new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), new MnM.GWS.PointF(drawPoints[4], drawPoints[5]), rotate, curveType | CurveType.Arc);
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawArc(x, y, w, h, startA, endA, rotate, curveType | CurveType.Arc);
                }
                break;

            case "Pie":
                if (drawPoints?.Length >= 6)
                {
                    gwsMethod = () => mnmCanvas.DrawPie(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                        new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), new MnM.GWS.PointF(drawPoints[4], drawPoints[5]), rotate, curveType | CurveType.Pie);
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawPie(x, y, w, h, startA, endA, rotate, curveType | CurveType.Pie);
                }
                break;

            case "BezierArc":
                if (drawPoints?.Length >= 6)
                {
                    gwsMethod = () => mnmCanvas.DrawBezierArc(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                              new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), new MnM.GWS.PointF(drawPoints[4], drawPoints[5]), rotate, curveType.HasFlag(CurveType.NoSweepAngle));
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawBezierArc(x, y, w, h, startA, endA, rotate, curveType.HasFlag(CurveType.NoSweepAngle));
                }
                break;

            case "BezierPie":
                if (drawPoints?.Length >= 6)
                {
                    gwsMethod = () => mnmCanvas.DrawBezierPie(new MnM.GWS.PointF(drawPoints[0], drawPoints[1]),
                                                              new MnM.GWS.PointF(drawPoints[2], drawPoints[3]), new MnM.GWS.PointF(drawPoints[4], drawPoints[5]), rotate, curveType.HasFlag(CurveType.NoSweepAngle));
                }
                else
                {
                    gwsMethod = () => mnmCanvas.DrawBezierPie(x, y, w, h, startA, endA, rotate, curveType.HasFlag(CurveType.NoSweepAngle));
                }
                break;

            case "Square":
                gwsMethod = () => mnmCanvas.DrawRhombus(x, y, w, w, rotate);
                break;

            case "Rectangle":
                gwsMethod = () => mnmCanvas.DrawRectangle(x, y, w, h, rotate);
                break;

            case "RoundedArea":
                gwsMethod = () => mnmCanvas.DrawRoundedBox(x, y, w, h, (float)numCornerRadius.Value, rotate);
                break;

            case "Rhombus":
                gwsMethod = () => mnmCanvas.DrawRhombus(x, y, w, h, rotate);

                break;

            case "Triangle":
                if (drawPoints == null || drawPoints.Length < 6)
                {
                    System.Windows.Forms.MessageBox.Show("Please provide 3 coordinates to create a triangle by clicking 3 points on GWS picture box!");
                    return(null);
                }
                gwsMethod = () => mnmCanvas.DrawTriangle(drawPoints[0], drawPoints[1],
                                                         drawPoints[2], drawPoints[3], drawPoints[4], drawPoints[5], rotate);
                break;

            case "Polygon":
                if (drawPoints == null)
                {
                    return(null);
                }
                gwsMethod = () => mnmCanvas.DrawPolygon(rotate, drawPoints.Select(p => p + 0f).ToArray());
                break;

            case "Bezier":
                var type = cmbBezier.SelectedIndex != -1 ?
                           ((KeyValuePair <string, BezierType>)cmbBezier.SelectedItem).Value : BezierType.Cubic;
                if (type.HasFlag(BezierType.Multiple))
                {
                    if (drawPoints == null || drawPoints.Length < 6)
                    {
                        return(null);
                    }
                    gwsMethod = () => mnmCanvas.DrawBezier(type, rotate, drawPoints.Select(p => (float)p).ToArray());
                }
                else
                {
                    if (drawPoints == null || drawPoints.Length < 3)
                    {
                        System.Windows.Forms.MessageBox.Show("Please provide at least 3 coordinates to create a bezier by clicking 3 points on GWS picture box!");
                        return(null);
                    }
                    gwsMethod = () => mnmCanvas.DrawBezier(type, rotate, drawPoints.Select(p => (float)p).ToArray());
                }
                break;

            case "Glyphs":
                gwsMethod = () => mnmCanvas.DrawText(font, 130, 130 + font.Size, txtPts.Text, ds);
                break;
            }
            return(gwsMethod);
        }
Exemplo n.º 25
0
 // Use this for initialization
 void Awake()
 {
     seeker = GetComponent<Seeker>();
     characterController = GetComponent<CharacterController>();
     attack = GetComponent<AttackController> ();
     animator = GetComponent<Animator>();
     hasTarget = false;
     status = Status.idle;
     callback = null;
 }
Exemplo n.º 26
0
 public FOrderTable(string tableName, DataSet dataSet, VoidMethod saveDataMethod)
     : base(tableName, dataSet, saveDataMethod)
 {
 }
Exemplo n.º 27
0
 public EntityTableForm(string tableName, DataSet dataSet, VoidMethod saveDataMethod)
     : base(tableName, dataSet, saveDataMethod)
 {
 }
Exemplo n.º 28
0
        public static Rest <T> Void <T>(Rest <T> rest)
        {
            var root = new VoidMethod <T>(rest);

            return(root.RootAsync);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Verify worker thread.
        /// </summary>
        private void VerifyWorker2(VerifyMode mode)
        {
            //
            // delegates for messaging UI thread
            //
            AppendText appendText     = new AppendText(this.txtOutput.AppendText);
            VoidMethod updateControls = new VoidMethod(this.UpdateControls);

            try
            {
                if ((mode & VerifyMode.VerifyProgram) == VerifyMode.VerifyProgram)
                {
                    //
                    // start stopwatch
                    //
                    this.stopwatch.Reset();
                    this.stopwatch.Start();
                    //
                    // display verifying message
                    //
                    this.Invoke(appendText, Strings.VerifyingProgramMemory);
                    //
                    // verify program memory
                    //
                    this.programmer.Verify(0x000000, this.programMemory, this.selectedDevice.ProgramMemroySize, 0x000000, false, this.selectedDevice);
                    //
                    // stop the stopwatch
                    //
                    this.stopwatch.Stop();
                    //
                    // display success message
                    //
                    this.Invoke(appendText, Strings.Success);
                    this.Invoke(appendText, string.Format(" ({0})", this.stopwatch.Elapsed.ToString()));
                    this.Invoke(appendText, Environment.NewLine);
                }

                if ((mode & VerifyMode.VerifyConfiguration) == VerifyMode.VerifyConfiguration)
                {
                    //
                    // restart the stopwatch
                    //
                    this.stopwatch.Reset();
                    this.stopwatch.Start();
                    //
                    // display message
                    //
                    this.Invoke(appendText, "Verifying configuration bits...");
                    //
                    // verify configuration memory
                    //
                    this.programmer.Verify(this.selectedDevice.ConfigAddress, this.configMemory, this.selectedDevice.ConfigBytes / 3, 0x000000, true, this.selectedDevice);
                    //
                    // stop the stopwatch
                    //
                    this.stopwatch.Stop();
                    //
                    // display success mmessage
                    //
                    this.Invoke(appendText, Strings.Success);
                    this.Invoke(appendText, string.Format(" ({0})", this.stopwatch.Elapsed.ToString()));
                    this.Invoke(appendText, Environment.NewLine);
                }
            }
            catch (ThreadAbortException)
            {
                //
                // display abort message
                //
                //this.Invoke(appendText, Strings.Aborted);
                //this.Invoke(appendText, Environment.NewLine);
            }
            catch (AddressException)
            {
                //
                // display error
                //
                this.Invoke(appendText, Strings.Failed);
                this.Invoke(appendText, Environment.NewLine);
                this.Invoke(appendText, Strings.AddressError);
                this.Invoke(appendText, Environment.NewLine);
            }
            catch (VerifyException)
            {
                //
                // display error
                //
                this.Invoke(appendText, Strings.Failed);
                this.Invoke(appendText, Environment.NewLine);
            }
            catch (Exception ex)
            {
                //
                // display error
                //
                this.Invoke(appendText, Strings.Failed);
                this.Invoke(appendText, Environment.NewLine);
                this.Invoke(appendText, ex.Message);
                this.Invoke(appendText, Environment.NewLine);
            }
            finally
            {
                //
                // stop the stopwatch
                //
                if (this.stopwatch.IsRunning)
                {
                    this.stopwatch.Stop();
                }
                //
                // update controls
                //
                this.Invoke(updateControls);
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Writes to program memory.
        /// </summary>
        private void WriteProgramMemoryWorker()
        {
            //
            // delegates for messaging UI thread
            //
            AppendText appendText = new AppendText(this.txtOutput.AppendText);
            //VoidMethod verify = new VoidMethod(this.Verify);
            VoidMethod updateControls = new VoidMethod(this.UpdateControls);

            //
            // start stopwatch
            //
            this.stopwatch.Reset();
            this.stopwatch.Start();

            try
            {
                //
                // program device
                //
                this.programmer.WriteProgramMemory(0x000000, this.programMemory, 0x000000);
                this.stopwatch.Stop();
                //
                // show completed message
                //
                this.Invoke(appendText, Strings.Success);
                this.Invoke(appendText, string.Format(" ({0})", this.stopwatch.Elapsed.ToString()));
                this.Invoke(appendText, Environment.NewLine);
                //
                // verify program memory
                //
                //this.VerifyWorker2(VerifyMode.VerifyProgram);
                //
                // restart stopwatch
                //
                this.stopwatch.Reset();
                this.stopwatch.Start();
                //
                // write configuration bits programming message
                //
                this.Invoke(appendText, Strings.ProgrammingConfigBits);
                //
                // write configuration bits
                //
                this.programmer.WriteProgramMemory(this.selectedDevice.ConfigAddress, this.configMemory, 0x000000);
                //
                // stop the stopwatch
                //
                this.stopwatch.Stop();
                //
                // display success message
                //
                this.Invoke(appendText, Strings.Success);
                this.Invoke(appendText, string.Format(" ({0})", this.stopwatch.Elapsed.ToString()));
                this.Invoke(appendText, Environment.NewLine);
                //
                // verify program memory
                //
                this.VerifyWorker2(VerifyMode.VerifyConfiguration);
            }
            catch (ThreadAbortException)
            {
                //this.Invoke(appendText, Strings.Aborted);
                //this.Invoke(appendText, Environment.NewLine);
            }
            catch (Exception ex)
            {
                //
                // display error message
                //
                this.Invoke(appendText, Strings.Failed);
                this.Invoke(appendText, Environment.NewLine);
                this.Invoke(appendText, ex.Message);
                this.Invoke(appendText, Environment.NewLine);
            }
            finally
            {
                this.Invoke(updateControls);
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// Reads program memory in a background thread.
        /// </summary>
        private void ReadMemoryWorker()
        {
            //
            // delegates for messaging UI thread
            //
            AppendText appendText       = new AppendText(this.txtOutput.AppendText);
            VoidMethod populateListView = new VoidMethod(this.LoadProgramWords);
            VoidMethod updateControls   = new VoidMethod(this.UpdateCOMPortList);

            //
            // start stopwatch
            //
            this.stopwatch.Reset();
            this.stopwatch.Start();

            try
            {
                //
                // download the program from the device's memory
                //
                if (rbPartialProgramming.Checked == true)
                {
                    uint start = uint.Parse(this.txtPMStart.Text, NumberStyles.HexNumber);
                    uint end   = uint.Parse(this.txtPMEnd.Text, NumberStyles.HexNumber);
                    //
                    // read programm memory range
                    //
                    byte[] readBytes = this.programmer.ReadProgramMemory(start, (end - start) / 2);
                    //
                    // allocate program memory array
                    //
                    this.AllocateProgramArray();
                    //
                    // copy read bytes to program memory array
                    //
                    Array.Copy(readBytes, 0, this.programMemory, (start / 2) * 3, (end - start) / 2);
                }
                else
                {
                    //
                    // read program memory
                    //
                    uint totalWords = this.selectedDevice.ProgramMemroySize + (this.selectedDevice.ConfigBytes / 3);
                    this.programMemory = this.programmer.ReadProgramMemory(0x000000, totalWords);
                }
                //
                // stop timer
                //
                this.stopwatch.Stop();
                //
                // display success message
                //
                this.Invoke(appendText, Strings.Success);
                this.Invoke(appendText, string.Format(" ({0})", this.stopwatch.Elapsed.ToString()));
                this.Invoke(appendText, Environment.NewLine);
                //
                // populate listview
                //
                this.Invoke(populateListView);
            }
            catch (ThreadAbortException)
            {
                //this.Invoke(appendText, Strings.Aborted);
                //this.Invoke(appendText, Environment.NewLine);
            }
            catch (Exception ex)
            {
                this.stopwatch.Stop();
                //
                // display error message
                //
                this.Invoke(appendText, Strings.Failed);
                this.Invoke(appendText, Environment.NewLine);
                this.Invoke(appendText, ex.Message);
                this.Invoke(appendText, Environment.NewLine);
                MessageBox.Show(ex.Message, Strings.Error);
            }
            finally
            {
                this.Invoke(updateControls);
            }
        }
 internal ArglessEventHandlerDelegateProxy(VoidMethod vm)
 {
     _vm = vm;
 }
Exemplo n.º 33
0
 public FEditionBooksTable(string tableName,
                           DataSet dataSet, VoidMethod saveDataMethod)
     : base(tableName, dataSet, saveDataMethod)
 {
 }
Exemplo n.º 34
0
        private static List <ButtonPrimitive> syn(string printBuffer)
        {
            var printString = printBuffer;
            var ret         = new List <ButtonPrimitive>();

            if (printString.Length == 0)
            {
                goto nonButton;
            }
            List <string> strs = null;

            if (!printString.Contains("[") || !printString.Contains("]"))
            {
                goto nonButton;
            }
            strs = lex(new StringStream(printString));
            if (strs == null)
            {
                goto nonButton;
            }
            var  beforeButton = false; //最初のボタン("[1]"とか)より前にテキストがある
            var  afterButton  = false; //最後のボタン("[1]"とか)より後にテキストがある
            var  buttonCount  = 0;
            long inpL         = 0;

            for (var i = 0; i < strs.Count; i++)
            {
                if (strs[i].Length == 0)
                {
                    continue;
                }
                var c = strs[i][0];
                if (LexicalAnalyzer.IsWhiteSpace(c))
                {
//ただの空白
                }
                //数値以外はボタン化しない方向にした。
                //else if ((c == '[') && (!isSymbols(strArray[i])))
                else if (isButtonCore(strs[i], ref inpL))
                {
//[]で囲まれた文字列。選択肢の核となるかどうかはこの段階では判定しない。
                    buttonCount++;
                    afterButton = false;
                }
                else
                {
//選択肢の説明になるかもしれない文字列
                    afterButton = true;
                    if (buttonCount == 0)
                    {
                        beforeButton = true;
                    }
                }
            }
            if (buttonCount <= 1)
            {
                var button = new ButtonPrimitive();
                button.Str       = printBuffer;
                button.CanSelect = buttonCount >= 1;
                button.Input     = inpL;
                ret.Add(button);
                return(ret);
            }
            buttonCount = 0;
            var  alignmentRight = !beforeButton && afterButton;      //説明はボタンの右固定
            var  alignmentLeft  = beforeButton && !afterButton;      //説明はボタンの左固定
            var  alignmentEtc   = !alignmentRight && !alignmentLeft; //臨機応変に
            var  canSelect      = false;
            long input          = 0;

            var        state  = 0;
            var        buffer = new StringBuilder();
            VoidMethod reduce = delegate
            {
                if (buffer.Length == 0)
                {
                    return;
                }
                var button = new ButtonPrimitive();
                button.Str       = buffer.ToString();
                button.CanSelect = canSelect;
                button.Input     = input;
                ret.Add(button);
                buffer.Remove(0, buffer.Length);
                canSelect = false;
                input     = 0;
            };

            for (var i = 0; i < strs.Count; i++)
            {
                if (strs[i].Length == 0)
                {
                    continue;
                }
                var c = strs[i][0];
                if (LexicalAnalyzer.IsWhiteSpace(c))
                {
//ただの空白
                    if ((state & 3) == 3 && alignmentEtc && strs[i].Length >= 2)
                    {
//核と説明を含んだものが完成していればボタン生成。
                        //一文字以下のスペースはキニシナイ。キャラ購入画面対策
                        reduce();
                        buffer.Append(strs[i]);
                        state = 0;
                    }
                    else
                    {
                        buffer.Append(strs[i]);
                    }
                    continue;
                }
                if (isButtonCore(strs[i], ref inpL))
                {
                    buttonCount++;
                    if ((state & 1) == 1 || alignmentRight)
                    {
//bufferが既に核を含んでいる、又は強制的に右配置
                        reduce();
                        buffer.Append(strs[i]);
                        input     = inpL;
                        canSelect = true;
                        state     = 1;
                    } //((state & 2) == 2) ||
                    else if (alignmentLeft)
                    {
//bufferが説明を含んでいる、又は強制的に左配置
                        buffer.Append(strs[i]);
                        input     = inpL;
                        canSelect = true;
                        reduce();
                        state = 0;
                    }
                    else
                    {
//bufferが空または空白文字列
                        buffer.Append(strs[i]);
                        input     = inpL;
                        canSelect = true;
                        state     = 1;
                    }
                    continue;
                }
                //else
                //{//選択肢の説明になるかもしれない文字列

                buffer.Append(strs[i]);
                state |= 2;
                //}
            }
            ;
            reduce();
            return(ret);

nonButton:
            ret = new List <ButtonPrimitive>();
            var singleButton = new ButtonPrimitive();

            singleButton.Str = printString;
            ret.Add(singleButton);
            return(ret);
        }