Ejemplo n.º 1
0
        public void test()
        {
            IMath im = XmlRpcProxyGen.Create <IMath>();

            im.Url = "http://www.f**k.com/e/api/xmlrpcV2.aspx";
            var r = im.SearchBook("极品仙府", "", "");
        }
        public void TestMathFloor()
        {
            IMath floorMath   = this.mathMock.Object;
            var   resultFloor = floorMath.Floor(number);

            Assert.AreEqual(resultFloor, -18);
        }
Ejemplo n.º 3
0
 private UpidaContext()
 {
     this.propertyMetaFactory = new PropertyMetaFactory(this);
     this.pathHelper          = new Upida.Validation.Impl.PathHelper();
     this.checker             = new Upida.Validation.Impl.Checker();
     this.math = new Upida.Validation.Impl.Math();
 }
Ejemplo n.º 4
0
 public PlaySlotCommand(ISymbolManager symbolManager, IWriter writer, ISlotFactory slotFactory, IMath mathProvider)
 {
     this.symbolManager = symbolManager;
     this.writer        = writer;
     this.slotFactory   = slotFactory;
     this.mathProvider  = mathProvider;
 }
        public void TestMathAbs()
        {
            IMath absMath   = this.mathMock.Object;
            var   resultAbs = absMath.Abs(number);

            Assert.AreEqual(resultAbs, 17.3);
        }
        private static bool CheckConnection(double tolerance, IODBObject selObj, PointD lineStart, List <IObject> relevantObjects, bool setColor)
        {
            foreach (IODBObject relObject in relevantObjects)
            {
                if (relObject == selObj)
                {
                    continue;
                }

                if (relObject.Type == IObjectType.Line)
                {
                    ILineSpecificsD lineRel = (ILineSpecificsD)relObject.GetSpecificsD();

                    if (IMath.DistancePointToPoint(lineRel.End, lineStart) < tolerance || IMath.DistancePointToPoint(lineRel.Start, lineStart) < tolerance)
                    {
                        setColor = false; break;
                    }
                }
                else if (relObject.Type == IObjectType.Arc)
                {
                    IArcSpecificsD arcRel = (IArcSpecificsD)relObject.GetSpecificsD();

                    if (IMath.DistancePointToPoint(arcRel.End, lineStart) < tolerance || IMath.DistancePointToPoint(arcRel.Start, lineStart) < tolerance)
                    {
                        setColor = false; break;
                    }
                }
            }
            return(setColor);
        }
Ejemplo n.º 7
0
    public void Run()
    {
        // This code is written by an application developer.
        // Create a channel factory.
        BasicHttpBinding myBinding = new BasicHttpBinding();

        EndpointAddress myEndpoint = new EndpointAddress("http://localhost/MathService/Ep1");

        ChannelFactory <IMath> myChannelFactory = new ChannelFactory <IMath>(myBinding, myEndpoint);

        // Create a channel.
        IMath  wcfClient1 = myChannelFactory.CreateChannel();
        double s          = wcfClient1.Add(3, 39);

        Console.WriteLine(s.ToString());
        ((IClientChannel)wcfClient1).Close();

        // Create another channel.
        IMath wcfClient2 = myChannelFactory.CreateChannel();

        s = wcfClient2.Add(15, 27);
        Console.WriteLine(s.ToString());
        ((IClientChannel)wcfClient2).Close();
        myChannelFactory.Close();
    }
Ejemplo n.º 8
0
        private static void CreateSplittedLines(IStep step, IFilter filter, IODBObject evtlLine2, ILineSpecificsD line2, PointD pDest, ref List <IODBObject> selectedElements)
        {
            PointD lastEnd = line2.End;

            line2.End = pDest;
            if (Math.Abs(IMath.DistancePointToPoint(line2.End, line2.Start)) < errorLevel)
            {
                line2.End   = lastEnd;
                line2.Start = pDest;
                if (Math.Abs(IMath.DistancePointToPoint(line2.End, line2.Start)) > errorLevel)
                {
                    evtlLine2.SetSpecifics(line2);
                }
                else
                {
                    Debug.WriteLine("Line with length 0!");
                }
            }
            else
            {
                evtlLine2.SetSpecifics(line2);

                ILayer parentLayer = step.GetLayer(evtlLine2.GetParentLayerName());
                if (parentLayer != null)
                {
                    IODBObject line2Part2 = filter.CreateLine((IODBLayer)parentLayer);
                    line2.End   = lastEnd;
                    line2.Start = pDest;
                    line2Part2.SetSpecifics(line2);
                    selectedElements.Add(line2Part2);
                }
            }
        }
Ejemplo n.º 9
0
    void        AttachItem(int itemID)
    {
        Body body = UToolS.SelectBody();

        if (body != null)
        {
            var       partlist = Creation.ReadShipObject(body.gameObject); OpShip.OSIDE seldir;
            var       selpart = OpShip.GetInsertParent(partlist, itemID, out seldir);
            TablePart newpart = OpShip.NewInsertItem(selpart, seldir, itemID);

            Item item = Creation.MakeItemObject(newpart, body.transform);
            item.renderer.material = MainRenderer.GetMeterial(item.gameObject, body.tone);

            if (newpart.posx != 0)
            {
                TablePart newpair = newpart;
                newpair.posx = -newpart.posx;
                newpair.flip = (byte)(newpart.flip == 1 ? 0 : 1);
                if (newpart.angle == 90 || newpart.angle == -90 || newpart.angle == 270)
                {
                    newpair.angle = IMath.GetCenterDegree(newpart.angle + 180);
                }

                Item itemPair = Creation.MakeItemObject(newpair, body.transform);
                itemPair.renderer.material = MainRenderer.GetMeterial(itemPair.gameObject, body.tone);
            }

            Creation.DepthSort(body.transform);
        }
    }
 public PseudoProbability(IMath math, IRandom rand)
 {
     this.math    = math ?? throw new ArgumentNullException(nameof(rand));
     this.rand    = rand ?? throw new ArgumentNullException(nameof(rand));
     this.cValues = new Dictionary <int, float>();
     Generate();
 }
            public static float GetCFromP(float p, IMath math)
            {
                var   upperC = p;
                var   lowerC = 0f;
                var   p2     = 1f;
                float midC;
                float p1;

                while (true)
                {
                    midC = (upperC + lowerC) / 2f;
                    p1   = GetPFromC(midC, math);

                    if (math.Abs(p1 - p2) <= 0f)
                    {
                        break;
                    }

                    if (p1 > p)
                    {
                        upperC = midC;
                    }
                    else
                    {
                        lowerC = midC;
                    }

                    p2 = p1;
                }

                return(midC);
            }
Ejemplo n.º 12
0
        public static void Execute(IPCBIWindow parent)
        {
            //check all selected lines, if lines on lines cut them

            IStep   step   = parent.GetCurrentStep();
            IFilter filter = new IFilter(parent);

            if (step == null)
            {
                return;
            }

            List <IODBObject> selectedElements = step.GetSelectedElements();

            PCB_Investigator.PCBIWindows.PCBIWorkingDialog working = new PCB_Investigator.PCBIWindows.PCBIWorkingDialog();
            StopCutting = false;
            working.SetStatusText("Working on splitting lines...");
            working.CancelPressed += Working_CancelPressed;
            working.CanCancel(true);
            working.SetAnimationStatus(false);

            working.ShowWorkingDlgAsThread();

            for (int i = 0; i < selectedElements.Count; i++)
            {
                if (StopCutting)
                {
                    break;
                }

                working.SetStatusPercent(i * 100 / selectedElements.Count);

                IODBObject evtlLine = selectedElements[i];
                if (evtlLine.Type != IObjectType.Line)
                {
                    continue;
                }

                ILineSpecificsD line = (ILineSpecificsD)evtlLine.GetSpecificsD();
                for (int j = i + 1; j < selectedElements.Count; j++)
                {
                    IODBObject evtlLine2 = selectedElements[j];
                    if (evtlLine2.Type != IObjectType.Line || evtlLine == evtlLine2)
                    {
                        continue;
                    }
                    ILineSpecificsD line2 = (ILineSpecificsD)evtlLine2.GetSpecificsD();

                    PointD crossingP = IMath.CrossingPoint(line.Start, line.End, line2.Start, line2.End, true);
                    if (PointD.InfPoint != crossingP)
                    {
                        CreateSplittedLines(step, filter, evtlLine2, line2, crossingP, ref selectedElements);
                        CreateSplittedLines(step, filter, evtlLine, line, crossingP, ref selectedElements);
                        line = (ILineSpecificsD)evtlLine.GetSpecificsD(); //changed, get it new
                    }
                }
            }
            working.DoClose();
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes new instance of the ValidationContext class
 /// </summary>
 public UpidaValidationContext(IUpidaContext context)
 {
     this.math       = context.Math;
     this.pathHelper = context.PathHelper;
     this.checker    = context.Checker;
     this.path       = this.pathHelper.CreateNew();
     this.isValid    = true;
 }
        public static void InvokeIMath()
        {
            IMath math = comObj as IMath;
            int   x    = math.Add(4, 5);
            int   y    = math.Sub(5, 4);

            Alert.Show("Methods from IMath in the COM invoked for Add(4,5): " + x + " Sub(5,4): " + y);
        }
Ejemplo n.º 15
0
 private void DrawNode(IAgent from, IAgent to, IMath probability)
 {
     if (to.CanConsumeFrom(from) && probability.TryLuck())
     {
         var newEdge = to.AddChild(from);
         edges.Add(newEdge);
     }
 }
Ejemplo n.º 16
0
 // creates service definition that can be registered with a server
 public static ServerServiceDefinition BindService(IMath serviceImpl)
 {
     return(ServerServiceDefinition.CreateBuilder(__ServiceName)
            .AddMethod(__Method_Div, serviceImpl.Div)
            .AddMethod(__Method_DivMany, serviceImpl.DivMany)
            .AddMethod(__Method_Fib, serviceImpl.Fib)
            .AddMethod(__Method_Sum, serviceImpl.Sum).Build());
 }
Ejemplo n.º 17
0
 public void Setup()
 {
     mathIf            = math;
     instanceMax       = math.InstanceMax;
     instanceMaxInline = math.InstanceMaxInline;
     classMax          = MathEx.ClassMax;
     classMaxInline    = MathEx.ClassMaxInline;
 }
Ejemplo n.º 18
0
        //Долгая операция, треует создания замещаемого обьекта
        public int Sum(int a, int b)
        {
            if (math == null)
            {
                math = new Math();
            }

            return(math.Sum(a, b));
        }
Ejemplo n.º 19
0
 public CasinoEngine(IReader reader, IWriter writer, ICommandManager commandManager, IBalanceManager balanceManager, IMath mathProvider, IPlaySlotCommand playSlotCommand)
 {
     this.reader          = reader;
     this.writer          = writer;
     this.commandManager  = commandManager;
     this.balanceManager  = balanceManager;
     this.mathProvider    = mathProvider;
     this.playSlotCommand = playSlotCommand;
 }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            IMath math = Factory.CreateMaths();
            int   c    = math.Add(10, 10);

            IMathComplex math1 = Factory.CreateMaths();
            int          d1    = math1.Add(10, 10);
            int          c1    = math1.Devide(10, 10);
        }
Ejemplo n.º 21
0
		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			mathProxy = XmlRpcProxyGen.Create<IMath>();
			txtUrl.Text = "http://www.cookcomputing.com/xmlrpcsamples/math.rem";
		}
Ejemplo n.º 22
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            mathProxy   = XmlRpcProxyGen.Create <IMath>();
            txtUrl.Text = "http://www.cookcomputing.com/xmlrpcsamples/math.rem";
        }
 public void Execute(IPCBIWindow parent)
 {
     //your code here
     if (parent.JobIsLoaded)
     {
         List <string> columheader = new List <string>();
         columheader.Add("Layer Name");
         columheader.Add("Layer Thickness µm");
         columheader.Add("Layer Position µm");
         PCB_Investigator.PCBIWindows.PCBIResultDialog layerDlg = new PCBIResultDialog(columheader, "Matrix");
         IStep   step   = parent.GetCurrentStep();
         IMatrix matrix = parent.GetMatrix();
         //	bool toggle = true;
         foreach (string layername in matrix.GetAllLayerNames())
         {
             ListViewItem lvi = new ListViewItem(layername);
             // if (toggle)
             //  {
             //      lvi.BackColor = Color.LightBlue;
             //   }
             //  toggle = !toggle;
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Signal)
             {
                 lvi.BackColor = Color.Orange;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Power_ground)
             {
                 lvi.BackColor = Color.Orange;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_mask)
             {
                 lvi.BackColor = Color.LightGreen;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_paste)
             {
                 lvi.BackColor = Color.LightYellow;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Dielectric)
             {
                 lvi.BackColor = Color.GreenYellow;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Component)
             {
                 lvi.BackColor = Color.LightSteelBlue;
             }
             double Layerpos       = IMath.Mils2MM(MatrixHelpers.GetLayerPositionInStackUp(layername, step, matrix)) * 1000;
             double layerthickness = IMath.Mils2MM(step.GetHeightOfLayer(layername)) * 1000;
             lvi.SubItems.Add(layerthickness.ToString("N2"));
             lvi.SubItems.Add(Layerpos.ToString("N2"));
             layerDlg.AddListViewItem(lvi);
         }
         layerDlg.ShowDlg(PCBIResultDialog.WindowType.Modal);
         parent.UpdateView();
     }
 }
Ejemplo n.º 24
0
        static void Main()
        {
            // Create math proxy
            IMath math = MathFactory.GetMath();

            // Do the math
            Console.WriteLine("4 + 2 = " + math.Add(4, 2));
            Console.WriteLine("4 - 2 = " + math.Sub(4, 2));
            Console.WriteLine("4 * 2 = " + math.Mul(4, 2));
            Console.WriteLine("4 / 2 = " + math.Div(4, 2));
        }
        void Parent_PCBIFormGraphicPaneDrawing(Graphics g, int ClientWidth, int ClientHeight)
        {
            if (!parent.JobIsLoaded)
            {
                return;
            }
            int   pcbCount  = 0;
            IStep PanelStep = parent.GetCurrentStep();

            if (PanelStep == null)
            {
                return;
            }

            RectangleF PanelSize = PanelStep.GetBounds();

            if (PanelSize == RectangleF.Empty)
            {
                return;
            }
            DrawSingleBoard(g, PanelSize, new PointD(0, 0), pcbCount, PanelStep.Name, "0");
            pcbCount++;
            List <IStep.StepAndRepeatClass> srList = PanelStep.GetChildStepClasses();

            foreach (IStep.StepAndRepeatClass sr in srList)
            {
                IStep step = parent.GetStep(sr.NAME);
                System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
                matrix.Rotate(-(float)sr.ANGLE, System.Drawing.Drawing2D.MatrixOrder.Append);
                matrix.Translate((float)sr.X, (float)sr.Y, System.Drawing.Drawing2D.MatrixOrder.Append);
                RectangleF BoardSize     = IMath.RectangleTransformWithMatrix(step.GetBoundsD(), matrix).ToRectangleF();
                PointD     originOfBoard = new PointD(sr.X, sr.Y);
                IMath.TransformPoint(matrix, originOfBoard);
                DrawSingleBoard(g, BoardSize, originOfBoard, pcbCount, sr.NAME, sr.ANGLE.ToString("N2"));
                if (sr.NX > 1 || sr.NY > 1)
                {
                    for (int iy = 0; iy < sr.NY; iy++)
                    {
                        for (int ix = 0; ix < sr.NX; ix++)
                        {
                            System.Drawing.Drawing2D.Matrix matrixsr = matrix.Clone();
                            double offsetX = sr.DX * ix;
                            double offsetY = sr.DY * iy;
                            matrixsr.Translate((float)offsetX, (float)offsetY, System.Drawing.Drawing2D.MatrixOrder.Append);
                            BoardSize     = IMath.RectangleTransformWithMatrix(step.GetBoundsD(), matrixsr).ToRectangleF();
                            originOfBoard = new PointD(sr.X + offsetX, sr.Y + offsetY);
                            DrawSingleBoard(g, BoardSize, originOfBoard, pcbCount, sr.NAME, sr.ANGLE.ToString("N2"));
                            pcbCount++;
                        }
                    }
                }
                pcbCount++;
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public CollectBaseV2()
        {
            this.CollectStatus = new StatusObject();
            this.BH            = new Voodoo.Basement.Client.BookHelper(RulesOperate.GetSetting().TargetUrl);

            googleProxy     = XmlRpcProxyGen.Create <IMath>();
            googleProxy.Url = "http://blogsearch.google.com/ping/RPC2";

            baiduProxy     = XmlRpcProxyGen.Create <IMath>();
            baiduProxy.Url = "http://ping.baidu.com/ping/RPC2";
        }
Ejemplo n.º 27
0
        static void Main(string[] args)
        {
            MyMath m = new MyMath();

            m.Add(2, 5);
            IMath im = m;

            im.Print();
            IYourMath y = m;

            y.Print();
        }
Ejemplo n.º 28
0
        public void Init()
        {
            var mock = new Mock <IMath>();

            for (int i = 0; i < AmountOfTestNumbers; i++)
            {
                mock.Setup(m => m.Abs(this.absTestNumbers[i].Key)).Returns(this.absTestNumbers[i].Value);
                mock.Setup(m => m.Floor(this.floorTestNumbers[i].Key)).Returns(this.floorTestNumbers[i].Value);
            }

            this.math = mock.Object;
        }
Ejemplo n.º 29
0
        public static int CalculateSum(params int[] numbers)
        {
            IMath math = MathFactory.CreateMath();

            int sum = 0;

            foreach (int number in numbers)
            {
                sum = math.Add(sum, number);
            }

            return(sum);
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            MyMath math = new MyMath();

            Console.WriteLine(math.Add(2, 3));
            math.Print();
            IMath m = math;

            m.Print();
            IYourMath y = math;

            y.Print();
        }
Ejemplo n.º 31
0
        static Rotator()
        {
            var rotation   = Enumerable.Range(0, MaxPositions).ToArray();
            var sideLength = IMath.Sqrt(MaxPositions);

            for (var rot = 0; rot < MaxRotations; rot++)
            {
                for (var pos = 0; pos < MaxPositions; pos++)
                {
                    RotationsArray[(pos * MaxRotations) + rot] = rotation[pos];
                }
                rotation = rotation.RotateClockwise(sideLength);
            }
        }
Ejemplo n.º 32
0
 public MainForm()
 {
     InitializeComponent();
     mathProxy = XmlRpcProxyGen.Create<IMath>();
 }
Ejemplo n.º 33
0
        public XmlRpcClient()
        {

            mathProxy = XmlRpcProxyGen.Create<IMath>();

        }
Ejemplo n.º 34
0
            private static object DoMath(IMath remoteObject)
            {
                Console.WriteLine("\nWhat operation would you like to perform?\nMultiply - 1\nAdd - 2\nSubtract - 3\nDivide - 4\nEcho - 5\nGet Server Instance of MathClass - 6\nThrow Exception Remotely - 7\n" + 
                    "Get last result using property - 8\nGet last result multiplied by an int using an indexer - 9\nTrigger an echo event after a delay - 0\n");

                int selectedOperation;
                while (true)
                {
                    bool parseSucces = int.TryParse(Console.ReadKey(true).KeyChar.ToString(), out selectedOperation);
                    if (parseSucces && selectedOperation <= 9 && selectedOperation >= 0) break;
                    Console.WriteLine("Invalid operation choice. Please try again.");
                }

                double a, b;
                switch (selectedOperation)
                {
                    case 1:
                        Console.WriteLine("You selected to Multiply two numbers.");
                        Console.Write("Please enter first number: ");
                        if (!double.TryParse(Console.ReadLine(), out a)) break;
                        Console.Write("Please enter second number: ");
                        if (!double.TryParse(Console.ReadLine(), out b)) break;
                        return remoteObject.Multiply(a, b);
                    case 2:
                        Console.WriteLine("You selected to Add two numbers.");
                        Console.Write("Please enter first number: ");
                        if (!double.TryParse(Console.ReadLine(), out a)) break;
                        Console.Write("Please enter second number: ");
                        if (!double.TryParse(Console.ReadLine(), out b)) break;
                        return remoteObject.Add(a, b);
                    case 3:
                        Console.WriteLine("You selected to Subtract two numbers.");
                        Console.Write("Please enter first number: ");
                        if (!double.TryParse(Console.ReadLine(), out a)) break;
                        Console.Write("Please enter second number: ");
                        if (!double.TryParse(Console.ReadLine(), out b)) break;
                        return remoteObject.Subtract(a, b);
                    case 4:
                        Console.WriteLine("You selected to Divide two numbers.");
                        Console.Write("Please enter first number: ");
                        if (!double.TryParse(Console.ReadLine(), out a)) break;
                        Console.Write("Please enter second number: ");
                        if (!double.TryParse(Console.ReadLine(), out b)) break;
                        return remoteObject.Divide(a, b);
                    case 5:
                        Console.WriteLine("Please enter string. This will be sent to the server and 'echoed' back:");
                        return remoteObject.Echo(Console.ReadLine());
                    case 6:
                        return remoteObject.GetServerObjectCopy();
                    case 7:
                        try
                        {
                            remoteObject.ThrowTestException();
                        }
                        catch (Exception e)
                        {
                            return e.ToString();
                        }
                        return null;
                    case 8:
                        Console.WriteLine("Last result was.");
                        return remoteObject.LastResult;
                    case 9:
                        int temp;
                        Console.WriteLine("You selected to get the last result multiplied by an int via an indexer");
                        Console.WriteLine("Please enter an integer to multiply by");
                        if (!int.TryParse(Console.ReadLine(), out temp)) break;
                        return remoteObject[temp];                        
                    case 0:
                        int delay;
                        string echoVal;
                        Console.WriteLine("You selected to trigger an echo event after a delay");
                        Console.WriteLine("Please enter the number of milliseconds to delay");
                        if (!int.TryParse(Console.ReadLine(), out delay)) break;
                        Console.WriteLine("Please enter string to echo");
                        echoVal = Console.ReadLine();
                        remoteObject.TriggerEchoEventAfterDelay(delay, echoVal);
                        return "Will echo " + echoVal + " in " + delay + "ms\n";                    
                }

                throw new Exception("How have you managed to get execution to this point? Maybe you entered something that was BAD");
            }
Ejemplo n.º 35
0
 // creates service definition that can be registered with a server
 public static ServerServiceDefinition BindService(IMath serviceImpl)
 {
     return ServerServiceDefinition.CreateBuilder(__ServiceName)
       .AddMethod(__Method_Div, serviceImpl.Div)
       .AddMethod(__Method_DivMany, serviceImpl.DivMany)
       .AddMethod(__Method_Fib, serviceImpl.Fib)
       .AddMethod(__Method_Sum, serviceImpl.Sum).Build();
 }