Example #1
0
        static void Main(string[] args)
        {
            // Initialize the interfaces
            using (var myhelloworldApi = new ApiWrapper <helloworldApi>())
            {
                ClientApiOptions clientApiOptions = new ClientApiOptions(); //fill this object to override default xcApi parameters

                myhelloworldApi.Api.HelloWorld_Component.HelloResponse_StateMachine.InstanceUpdated += instance => Console.WriteLine(instance.PublicMember.Text);

                if (myhelloworldApi.Init(myhelloworldApi.Api.DefaultXcApiFileName, clientApiOptions))
                {
                    var context = myhelloworldApi.Api.HelloWorld_Component.GetEntryPoint().Context;

                    var name = GetName();
                    while (!string.IsNullOrWhiteSpace(name))
                    {
                        myhelloworldApi.Api.HelloWorld_Component.HelloWorldManager_StateMachine.EntryPoint_State.SayHello(context, new SayHello {
                            Name = name
                        });
                        name = GetName();
                    }
                }
                else
                {
                    AnalyseReport(myhelloworldApi.Report);
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            // Initialize the interfaces
            using (var myRestConsumerApiApi = new ApiWrapper <RestConsumerApiApi>())
            {
                ClientApiOptions clientApiOptions = new ClientApiOptions();
                //fill this object to override default xcApi parameters

                if (myRestConsumerApiApi.Init(myRestConsumerApiApi.Api.DefaultXcApiFileName, clientApiOptions))
                {
                    RunPetStore(myRestConsumerApiApi);
                }
                else
                {
                    AnalyseReport(myRestConsumerApiApi.Report);
                }
            }
        }
        public bool Init()
        {
            try
            {
                // Initialize the interfaces
                var mySequenceDiagramProjectApi = new ApiWrapper <SequenceDiagramProjectApi>();
                {
                    ClientApiOptions clientApiOptions = new ClientApiOptions(); //fill this object to override default xcApi parameters

                    if (mySequenceDiagramProjectApi.Init(mySequenceDiagramProjectApi.Api.DefaultXcApiFileName, clientApiOptions))
                    {
                        _api = mySequenceDiagramProjectApi.Api;

                        return(true);
                    }
                }
            }
            catch (Exception)
            {
            }

            return(false);
        }
Example #4
0
        static void Main(string[] args)
        {
            // Initialize the interfaces
            using (var myauthenticationserviceApi = new ApiWrapper <authenticationserviceApi>())
            {
                ClientApiOptions clientApiOptions = new ClientApiOptions();                 //fill this object to override default xcApi parameters

                if (myauthenticationserviceApi.Init(myauthenticationserviceApi.Api.DefaultXcApiFileName, clientApiOptions))
                {
                    var entryPoint = myauthenticationserviceApi.Api.Authentication_Component.GetEntryPoint();
                    if (entryPoint.StateCode == (int)Authentication_StateMachine.AuthenticationStateEnum.Up)
                    {
                        string requestId1 = Guid.NewGuid().ToString();
                        string requestId2 = Guid.NewGuid().ToString();
                        using (AutoResetEvent resetEvent = new AutoResetEvent(false))
                        {
                            myauthenticationserviceApi.Api.Authentication_Component.LoginStatus_StateMachine.LoginError_State.InstanceUpdated +=
                                delegate(LoginStatusInstance instance)
                            {
                                if (instance.PublicMember.RequestId == requestId1 ||
                                    instance.PublicMember.RequestId == requestId2)
                                {
                                    Console.WriteLine("Authentication failed");
                                    resetEvent.Set();
                                }
                            };

                            myauthenticationserviceApi.Api.Authentication_Component.LoginStatus_StateMachine.LoginSuccess_State.InstanceUpdated +=
                                delegate(LoginStatusInstance instance)
                            {
                                if (instance.PublicMember.RequestId == requestId1 ||
                                    instance.PublicMember.RequestId == requestId2)
                                {
                                    Console.WriteLine("Authentication succeeded");
                                    resetEvent.Set();
                                }
                            };

                            var checkLogin = new CheckLogin()
                            {
                                RequestId = requestId1,
                                Login     = "******",
                                Password  = "******"
                            };
                            Console.WriteLine("Authenticate as {0} with password: {1}", checkLogin.Login, checkLogin.Password);
                            myauthenticationserviceApi.Api.Authentication_Component.Authentication_StateMachine.SendEvent(entryPoint.Context, checkLogin);
                            resetEvent.WaitOne();

                            checkLogin = new CheckLogin()
                            {
                                RequestId = requestId1,
                                Login     = "******",
                                Password  = "******"
                            };

                            Console.WriteLine("Authenticate as {0} with password: {1}", checkLogin.Login, checkLogin.Password);
                            myauthenticationserviceApi.Api.Authentication_Component.Authentication_StateMachine.SendEvent(entryPoint.Context, checkLogin);

                            resetEvent.WaitOne();
                        }
                    }
                    else
                    {
                        Console.WriteLine("Authentication service is not up.");
                    }
                }
                else
                {
                    AnalyseReport(myauthenticationserviceApi.Report);
                }
            }

            Console.WriteLine("");
            Console.WriteLine("Type any key to leave...");
            Console.ReadKey();
        }
Example #5
0
        static void Main(string[] args)
        {
            // Initialize the interfaces
            using (var myOrderProcessingApi = new ApiWrapper <OrderProcessingAPI>())
            {
                ClientApiOptions clientApiOptions = new ClientApiOptions(); //fill this object to override default xcApi parameters

                if (myOrderProcessingApi.Init(myOrderProcessingApi.Api.DefaultXcApiFileName, clientApiOptions))
                {
                    int orderId = 0;
                    using (var orderCreationEvent = new AutoResetEvent(false))
                    {
                        // Subscribe to new order instances
                        myOrderProcessingApi.Api.Order_Component.Order_StateMachine.Pending_State.InstanceUpdated +=
                            instance =>
                        {
                            Console.WriteLine("New order pending for execution: " + DisplayOrder(instance));
                            orderId = instance.PublicMember.Id;
                            orderCreationEvent.Set();
                        };

                        myOrderProcessingApi.Api.Order_Component.Order_StateMachine.PartiallyExecuted_State
                        .InstanceUpdated +=
                            instance =>
                        {
                            Console.WriteLine("Order partially filled: " + DisplayOrder(instance));
                        };

                        myOrderProcessingApi.Api.Order_Component.Order_StateMachine.Executed_State.InstanceUpdated +=
                            instance =>
                        {
                            Console.WriteLine("Order filled: " + DisplayOrder(instance));
                        };

                        myOrderProcessingApi.Api.Trade_Component.Trade_StateMachine.WaitingForExecution_State
                        .InstanceUpdated +=
                            instance =>
                        {
                            Console.WriteLine("Trade waiting for execution: " + DisplayTrade(instance));
                        };

                        myOrderProcessingApi.Api.Trade_Component.Trade_StateMachine.Executed_State.InstanceUpdated +=
                            instance =>
                        {
                            Console.WriteLine("Trade executed : " + DisplayTrade(instance));
                        };

                        // Create an order
                        OrderInput orderInput = new OrderInput
                        {
                            AssetName = "INVIVOO",
                            Quantity  = 1000
                        };

                        myOrderProcessingApi.Api.Order_Component.OrderProcessor_StateMachine.SendEvent(orderInput);
                        orderCreationEvent.WaitOne(1000);

                        // Partially fill the order
                        ExecutionInput executionInput = new ExecutionInput
                        {
                            OrderId  = orderId,
                            Quantity = 250,
                            Price    = 102
                        };

                        myOrderProcessingApi.Api.Order_Component.Order_StateMachine.SendEvent(executionInput);

                        // Fill the order
                        executionInput = new ExecutionInput
                        {
                            OrderId  = orderId,
                            Quantity = 750,
                            Price    = 101.5,
                        };
                        myOrderProcessingApi.Api.Order_Component.Order_StateMachine.SendEvent(executionInput);

                        Console.ReadKey();
                    }
                }
                else
                {
                    AnalyseReport(myOrderProcessingApi.Report);
                }
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            int nbFork = 100000;

            // Initialize the interfaces
            using (var myBenchSimpleForkApi = new ApiWrapper <BenchSimpleForkApi>())
            {
                ClientApiOptions clientApiOptions = new ClientApiOptions(); //fill this object to override default xcApi parameters

                if (myBenchSimpleForkApi.Init(myBenchSimpleForkApi.Api.DefaultXcApiFileName, clientApiOptions))
                {
                    Queue <Action> benchs = new Queue <Action>();

                    myBenchSimpleForkApi.Api.BenchSimpleFork_Component.BenchResult_StateMachine.InstanceUpdated +=
                        benchResultInstance =>
                    {
                        Console.WriteLine("----------- Bench finished -----------");
                        Console.WriteLine($"Instances received: {benchResultInstance.PublicMember.NbInstances}");
                        Console.WriteLine($"Total time: {benchResultInstance.PublicMember.TotalTimeMilliseconds}ms");
                        if (benchs.Count > 0)
                        {
                            benchs.Dequeue()();
                        }
                    };

                    BenchManagerInstance ep = myBenchSimpleForkApi.Api.BenchSimpleFork_Component.GetEntryPoint();

                    benchs.Enqueue(() =>
                    {
                        Console.WriteLine("Starting simple fork bench...");
                        StartSimpleForkBench startBench = new StartSimpleForkBench()
                        {
                            NbInstances = nbFork
                        };
                        myBenchSimpleForkApi.Api.BenchSimpleFork_Component.BenchManager_StateMachine.BenchReady_State.StartSimpleForkBench(ep.Context, startBench);
                    }
                                   );

                    benchs.Enqueue(() =>
                    {
                        Console.WriteLine("Starting loop fork bench...");
                        StartLoopBench startLoopBench = new StartLoopBench()
                        {
                            NbInstances = nbFork
                        };
                        myBenchSimpleForkApi.Api.BenchSimpleFork_Component.BenchManager_StateMachine.BenchReady_State.StartLoopBench(ep.Context, startLoopBench);
                    }
                                   );

                    benchs.Enqueue(() =>
                    {
                        Console.WriteLine("Starting triggering rules loop bench...");
                        StartLoopRuleBench startloopruleBench = new StartLoopRuleBench()
                        {
                            NbInstances = nbFork
                        };
                        myBenchSimpleForkApi.Api.BenchSimpleFork_Component.BenchManager_StateMachine.BenchReady_State.StartLoopRuleBench(ep.Context, startloopruleBench);
                    }
                                   );

                    benchs.Enqueue(() =>
                    {
                        Console.WriteLine("Starting triggering rules bench...");
                        StartTriggeringRulesBench startTriggeringBench = new StartTriggeringRulesBench()
                        {
                            NbInstances = nbFork
                        };
                        myBenchSimpleForkApi.Api.BenchSimpleFork_Component.BenchManager_StateMachine.BenchReady_State.StartTriggeringRulesBench(ep.Context, startTriggeringBench);
                    }
                                   );


                    benchs.Dequeue()();


                    //CreateChild child = new CreateChild() { IsFirst = true };
                    //myBenchSimpleForkApi.Api.BenchSimpleFork_Component.BenchManager_StateMachine.BenchReady_State.CreateChild(ep.Context, child);
                    //child = new CreateChild();
                    //for (int i = 0; i < nbFork - 2; i++)
                    //{
                    //    myBenchSimpleForkApi.Api.BenchSimpleFork_Component.BenchManager_StateMachine.BenchReady_State.CreateChild(ep.Context, child);
                    //}
                    //child = new CreateChild() { IsLast = true };
                    //myBenchSimpleForkApi.Api.BenchSimpleFork_Component.BenchManager_StateMachine.BenchReady_State.CreateChild(ep.Context, child);

                    //myBenchSimpleForkApi.Api.BenchSimpleFork_Component.BenchResult_StateMachine.InstanceUpdated += BenchResult_StateMachine_InstanceUpdated;


                    Console.ReadLine();
                }
                else
                {
                    AnalyseReport(myBenchSimpleForkApi.Report);
                }
            }
        }
Example #7
0
        private static void Main(string[] args)
        {
            CmdLineOptions cmdLineOptions    = new CmdLineOptions();
            var            commandLineParser = new Parser();

            if (!commandLineParser.ParseArguments(args, cmdLineOptions))
            {
                Console.WriteLine("Enter Slack WebHook url:");
                cmdLineOptions.WebHookUrl = Console.ReadLine();
                Console.WriteLine("Enter Slack channel:");
                cmdLineOptions.Channel = Console.ReadLine();
                Console.WriteLine("Enter Slack user:"******"Message has been successfully published!");
                            autoResetEvent.Set();
                        };

                        mySlackGateway.Api.SlackProxy_Component.PublishMessage_StateMachine.Error_State.InstanceUpdated +=
                            instance =>
                        {
                            Console.WriteLine("Error while publishing message: " + instance.PublicMember.Message);
                            autoResetEvent.Set();
                        };

                        SendMessage slackMessage = new SendMessage()
                        {
                            SlackChannel      = cmdLineOptions.Channel,
                            SlackUrlWithToken = cmdLineOptions.WebHookUrl,
                            SlackUser         = cmdLineOptions.User,
                            // MessageTitle = "My first slack message",
                            // Text = "Hello from slack",
                            //  MessageImage = "https://raw.githubusercontent.com/xcomponent/xcomponent/master/Examples/xcomponent.slack/images/XCChristmasLogo.png",
                            // IconEmoji = ":tv:" // http://www.emoji-cheat-sheet.com/
                        };

                        mySlackGateway.Api.SlackProxy_Component.SlackProxy_StateMachine.SendEvent(slackMessage);

                        autoResetEvent.WaitOne();
                    }

                    Console.WriteLine("Press any key to leave...");
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("Can't initialize client Api !");
                }
            }
        }