Exemple #1
0
 private Injector demoExtensions()
 {
     return(new DelegateInjector(compiler =>
     {
         Asynch.Apply(compiler);
         Match.Apply(compiler);
         Contract.Apply(compiler);
     }));
 }
Exemple #2
0
        //init
        public TCPClient(UInt32 datalengh,UInt32 sleepsend , UInt32 sleepRec,Asynch receive)
        {
            this.Receiveing = receive;
            this.sleepsend = sleepsend;
            this.sleeprec = sleepRec;
            this.DataLengh = datalengh;

            //init TcpClient
            tcpclient = new TcpClient(AddressFamily.InterNetwork);
            if (ConsoleStatus) Text.WriteLine("Client initialized!",ConsoleColor.Black,ConsoleColor.Green);
        }
Exemple #3
0
        public void AsynchUsage()
        {
            RoslynCompiler compiler = new RoslynCompiler();

            Asynch.Apply(compiler);

            SyntaxTree tree = null;
            string     text = null;

            //event handler usage
            var AsynchText = @"
                class foo
                {
                    void bar()
                    {
                        asynch()
                        {
                            foobar();
                        }
                    }
                }";

            tree = compiler.ApplySemanticalPass(AsynchText, out text);
            Assert.IsTrue(tree.GetRoot()
                          .DescendantNodes()
                          .OfType <ParenthesizedLambdaExpressionSyntax>()
                          .Count() == 1); //must have added a callback

            Assert.IsTrue(tree.GetRoot()
                          .DescendantNodes()
                          .OfType <InvocationExpressionSyntax>()
                          .Where(invocation => invocation.Expression.ToString() == "Task.Factory.StartNew")
                          .Count() == 1); //must have added a task factory invocation

            Assert.IsTrue(tree.GetRoot()
                          .DescendantNodes()
                          .OfType <LocalDeclarationStatementSyntax>()
                          .Count() == 1); //must have added a local variable for the asynch context

            var Synch = @"
                class foo
                {
                    void bar()
                    {
                        asynch()
                        {
                            foobar();
                            synch()
                            {
                                barfoo();
                            }
                        }
                    }
                }";

            tree = compiler.ApplySemanticalPass(Synch, out text);
            Assert.IsTrue(tree.GetRoot()
                          .DescendantNodes()
                          .OfType <ParenthesizedLambdaExpressionSyntax>()
                          .Count() == 2); //must have added a callback for asynch and another for synch
        }
Exemple #4
0
 public static void New(Asynch method,object  obj)
 {
     Thread thread = new Thread(new ParameterizedThreadStart(method));
     thread.Start(obj);
 }