예제 #1
0
        static void Main(string[] args)
        {
            complModelNamedGraph graph = new complModelNamedGraph();

            graph.ReuseOptimization = false;
            LGSPActions actions = new testActions(graph);
            LGSPGraphProcessingEnvironment procEnv = new LGSPGraphProcessingEnvironment(graph, actions);

/*            Node_Process p1 = Node_Process.CreateNode(graph);
 *          p1.name = "Siegfried";
 *          p1.val = 67;
 *
 *          LGSPNode p2 = graph.AddNode(NodeType_Process.typeVar);
 *          p2.SetAttribute("name", "Dieter");
 *          if((int) p2.GetAttribute("val") == 0)
 *              p2.SetAttribute("val", 9);
 *
 * //            INode_Process p1_attr = (INode_Process) p1.attributes;
 * //            p1_attr.name = "Siegfried";
 * //            p1_attr.val = 67;
 *
 *          Edge_connection con = (Edge_connection) graph.AddEdge(EdgeType_connection.typeVar, p1, p2);
 *          con.bandwidth = 1000 + p1.val + p1.name.Length;*/

            D231_4121 n1 = graph.CreateNodeD231_4121();

            n1.a2        = 2;
            n1.a4        = 4;
            n1.a5        = 5;
            n1.b23       = 23;
            n1.b41       = 41;
            n1.b42       = 42;
            n1.d231_4121 = 231;

            n1["a4"] = 2 * (int)n1["a2"]; // dummy for testing indexer

            B21 n2 = graph.CreateNodeB21();

            n2.a2  = 10002;
            n2.b21 = 10021;

            D2211_2222_31 n3 = graph.CreateNodeD2211_2222_31();

            n3.a2            = 20002;
            n3.a3            = 20003;
            n3.a4            = 20004;
            n3.b22           = 20022;
            n3.b41           = 20041;
            n3.c221          = 20221;
            n3.c222_411      = 20222;
            n3.d2211_2222_31 = 22221;

            graph.CreateEdgeEdge(n1, n2);
            graph.CreateEdgeEdge(n2, n3);

            Action_testRule.Instance.Apply(procEnv);

            using (VCGDumper dumper = new VCGDumper("test.vcg"))
                GraphDumper.Dump(graph, dumper);
        }
예제 #2
0
파일: arm.cs 프로젝트: ShSaw/Bandage
 // Start is called before the first frame update
 void Start()
 {
     stopWatch = new Stopwatch();
     stopWatch.Start();
     scoreText.text = "Score: " + score.ToString();
     score          = 0;
     b2             = FindObjectOfType <Bullet2script>();
     b1             = FindObjectOfType <sc>();
     b3             = FindObjectOfType <B3>();
     b4             = FindObjectOfType <B4>();
     b5             = FindObjectOfType <B5>();
     b6             = FindObjectOfType <B6>();
     b7             = FindObjectOfType <B7>();
     b8             = FindObjectOfType <B8>();
     b9             = FindObjectOfType <B9>();
     b10            = FindObjectOfType <B10>();
     b11            = FindObjectOfType <B11>();
     b12            = FindObjectOfType <B12>();
     b13            = FindObjectOfType <B13>();
     b14            = FindObjectOfType <B14>();
     b15            = FindObjectOfType <B15>();
     b16            = FindObjectOfType <B16>();
     b17            = FindObjectOfType <B17>();
     b18            = FindObjectOfType <B18>();
     b19            = FindObjectOfType <B19>();
     b20            = FindObjectOfType <B20>();
     b21            = FindObjectOfType <B21>();
     b22            = FindObjectOfType <B22>();
     b23            = FindObjectOfType <B23>();
     b24            = FindObjectOfType <B24>();
     b25            = FindObjectOfType <B25>();
     b26            = FindObjectOfType <B26>();
     b27            = FindObjectOfType <B27>();
     b28            = FindObjectOfType <B28>();
     b29            = FindObjectOfType <B29>();
     b30            = FindObjectOfType <B30>();
     b31            = FindObjectOfType <B31>();
     b32            = FindObjectOfType <B32>();
     b33            = FindObjectOfType <B33>();
     b34            = FindObjectOfType <B34>();
     b35            = FindObjectOfType <B35>();
     b36            = FindObjectOfType <B36>();
     b37            = FindObjectOfType <B37>();
     b38            = FindObjectOfType <B38>();
     b39            = FindObjectOfType <B39>();
     b40            = FindObjectOfType <B40>();
     b41            = FindObjectOfType <B41>();
 }
예제 #3
0
        public static int[,] Multiply(this int[,] a, int[,] b)
        {
            // check if the task canceled from UI
            //if (pingpongalgorithmnew.current_token.iscancellationrequested)
            //{
            //    throw new taskcanceledexception("task canceled");
            //}
            //if (a.GetLength(0) == 2)
            //{
            //    int[,] data = new int[2, 2];
            //    data[0, 0] = a[0, 0] * b[0, 0] + a[0, 1] * b[1, 0];
            //    data[0, 1] = a[0, 0] * b[0, 1] + a[0, 1] * b[1, 1];
            //    data[1, 0] = a[1, 0] * b[0, 0] + a[1, 1] * b[1, 0];
            //    data[1, 1] = a[1, 0] * b[0, 1] + a[1, 1] * b[1, 1];
            //    return data;
            //}
            if (a.GetLength(0) < 64)
            {
                return(a.NaiveMultiplication(b));
            }

            (int[,] A11, int[,] A12, int[,] A21, int[,] A22) = a.divide();
            (int[,] B11, int[,] B12, int[,] B21, int[,] B22) = b.divide();
            //M1 = multiplication((A11 + A22), (B11 + B22))
            int[,] M1 = (A11.Add(A22)).Multiply(B11.Add(B22));
            //M2 = multiplication((A21 + A22), B11)
            int[,] M2 = (A21.Add(A22)).Multiply(B11);
            //M3 = multiplication(A11, (B12 - B22))
            int[,] M3 = A11.Multiply(B12.Subtrac(B22));
            //M4 = multiplication(A22, (B21 - B11))
            int[,] M4 = A22.Multiply(B21.Subtrac(B11));
            //M5 = multiplication((A11 + A12), B22)
            int[,] M5 = (A11.Add(A12)).Multiply(B22);
            //M6 = multiplication((A21 - A11), (B11 + B12))
            int[,] M6 = (A21.Subtrac(A11)).Multiply(B11.Add(B12));
            //M7 = multiplication((A12 - A22), (B21 + B22))
            int[,] M7 = (A12.Subtrac(A22)).Multiply(B21.Add(B22));

            //C11 = M1 + M4 - M5 + M7
            int[,] C11 = M1.Add(M4).Subtrac(M5).Add(M7);
            //C12 = M3 + M5
            int[,] C12 = M3.Add(M5);
            //C21 = M2 + M4
            int[,] C21 = M2.Add(M4);
            //C22 = M1 - M2 + M3 + M6
            int[,] C22 = M1.Subtrac(M2).Add(M3).Add(M6);
            return(combine(C11, C12, C21, C22, a.GetLength(0)));
        }
예제 #4
0
        static void Main(string[] args)
        {
            #region Типы данных
            DateTime time = new DateTime();

            /* оператор == будет передавать свои операнды в разные допустимые типы,
             * чтобы получить общий тип, который он может затем сравнить */
            if (time == null)
            {
                /* do something */
            }
            #endregion

            #region Делегаты

            /*
             *  delegate добавляется циклически, однако параметр i передаётся по ссылке
             */
            List <Printer> printers = new List <Printer>();
            for (int i = 0; i < 10; i++)
            {
                printers.Add(delegate { Console.WriteLine(i); });
            }
            foreach (var printer in printers)
            {
                printer();
            }

            Action greet = delegate { Console.WriteLine("Hello!"); };
            greet.Invoke();
            //greet.BeginInvoke
            greet();
            #endregion

            #region Virtual
            Person p = new Person("Tom");
            p.Display();
            //p.NotOverrided();

            Employee e = new Employee("Tom", "Microsoft");
            e.Display();

            Person tom = new Employee("Tom", "Microsoft");
            tom.Display();

            //ошибка
            //Employee e1 = (Employee)new Person("Tom");

            //сокрытие
            (new Person("")).Hided();
            (new Employee("", "")).Hided();

            (new Person("")).Hided2();
            (new Employee("", "")).Hided2();

            Animal a    = new Animal();
            Dog    dog1 = new Dog();
            Animal dog2 = new Dog();

            // ошибка design time (вверх по иерархии нельзя)
            //Dog dog3 = new Animal();
            // ошибка run time (вверх по иерархии нельзя)
            // Dog dog4 = (Dog)new Animal();
            // Не виртуальный метод - вызовется метод класса, указанного у переменной
            dog1.Info(); // напишет Dog
            dog2.Info(); // напишет Animal
                         // Виртуальный метод - вызовется метод класса, которого переменная реально имеет
            a.Say();     // напишет nothing to say
            dog1.Say();  // напишет Woof
            dog2.Say();  // напишет Woof


            //B obj1 = new A();
            //obj1.Foo();
            B obj2 = new B();
            obj2.Foo();
            A obj3 = new B();
            obj3.Foo();
            #endregion

            #region Async/Await
            //new AsyncAwait().HttpRequest();
            //new AsyncAwait().HttpRequestAsync();
            new AsyncAwait().TaskDelay();
            new AsyncAwait().CancellationTokenMicrosoft();
            new AsyncAwait().CancellationTokenSimple();
            //new AsyncAwait().CancellationTokenSimple2();
            #endregion



            int[] arr = new int[4] {
                2, 1, 3, 4
            };
            Array.Sort(arr);



            var  a1       = new A2(103);
            A2[] arrayOfA = new A2[4];
            arrayOfA[0] = new A2(103);
            arrayOfA[1] = new A2(4);
            arrayOfA[2] = new A2(58);
            arrayOfA[3] = new A2(31);
            Array.Sort(arrayOfA);

            // X = 100, Y = 100
            Point p2 = new Point(10, 16)
            {
                X = 100, Y = 100
            };
            // X = 10, Y = 16
            Point p3 = new Point(10, 16);


            var a3 = new Derived1().className;
            var a4 = new Derived2().className;

            Console.WriteLine(CAPTION_END);
            new A3().Print();


            Console.WriteLine(CAPTION_END);
            Bus.Drive();
            Console.WriteLine(SUB_CAPTION);
            new Bus().Drive2();

            Console.WriteLine(CAPTION_END);
            Person2     p4 = new Person2();
            Student     s  = new Student();
            C <Person2> cp = new C <Person2>();
            C <Student> cs = new C <Student>();
            p4 = s;
            //s = p4;
            s = (Student)p4;
            //cp = cs;
            cp.x = p4;
            //cs = cp;
            s = cs.x;


            Console.WriteLine(CAPTION_END);
            new B6("Quizful");
            Console.WriteLine(SUB_CAPTION);
            new C6();

            Console.WriteLine(CAPTION_END);
            new B8().Somework();
            (new B8() as IA).Somework();

            Console.WriteLine(CAPTION_END);
            new Child();
            Console.WriteLine(SUB_CAPTION);
            // вызывается статический конструктор (убрать new Child())
            Child.field1 = 1;
            // вызывается статический конструктор (или этот вариант или выше)
            Type type = typeof(Child);
            System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(type.TypeHandle);
            // не вызывается статический конструктор
            Child.Foo();

            Console.WriteLine(CAPTION_END);
            //A9 a9 = new A9();
            //B9 b9 = new B9();
            //a9.M();
            //b9.M();
            //a9 = b9;
            //a9.M();
            //b9.M();

            B9 b9 = new B9();
            A9 a9 = b9;
            a9.M();
            //b9.M();

            Console.WriteLine(CAPTION_END);
            A10 a10 = new A10();
            Console.WriteLine(B10.x);

            Console.WriteLine(CAPTION_END);
            A11 a11 = new B11();
            B11 b11 = new B11();

            Console.WriteLine(CAPTION_END);
            A13 a13 = new B13();
            Console.WriteLine(a13.GetType() == typeof(A13));
            Console.WriteLine(a13.GetType() == typeof(B13));
            Console.WriteLine(a13 is A13);
            Console.WriteLine(a13 is B13);
            Console.WriteLine(SUB_CAPTION);
            Console.WriteLine(new A13() is B13);
            Console.WriteLine(new B13() is A13);
            Console.WriteLine(new A13() is A13);
            Console.WriteLine(new B13() is B13);
            Console.WriteLine(SUB_CAPTION);
            B13 b13 = new B13();
            //if (a13 as B13) { }
            //         Type
            //if (a13 is typeof(B13)) { }
            //if (B13 as B13) { }
            if (a13 is B13)
            {
            }
            //if (a13 is b13) { }
            if (a13 is B13 == null)
            {
            }
            //if (a as B == null) { }
            Console.WriteLine(CAPTION_END);
            B14 a1_ = new B14();
            A14 a2_ = new B14();
            A14 a3_ = a1_;
            C14 a4_ = new C14();
            A14 a5_ = a4_;

            a1_.Method();
            a2_.Method();
            a3_.Method();
            a4_.Method();
            a5_.Method();

            Console.WriteLine($"{CAPTION_BEGIN} OOP {CAPTION_END}");
            new A15();

            #region OOP
            Console.WriteLine($"{CAPTION_BEGIN} OOP {CAPTION_END}");


            int value = 10;
            A16 a16   = new A16();
            B16 b16   = new B16();
            A16 a17   = new B16();
            a16.GetValue(value);
            b16.GetValue(value);
            a17.GetValue(value);
            OOP.Ex1();
            OOP.Ex2();
            OOP.UpcastingDowncasting();

            // Static
            InstanceClassStaticConstructor ICSC;
            new InstanceClassStaticConstructor();
            //StaticClassStaticConstructor SCSC; // не удаётся объявить переменную статического типа
            //new StaticClassStaticConstructor(); // не удаётся создать экземпляр статического класса
            StaticClassStaticConstructor.foo = 100;
            StaticClassStaticConstructor.GetFoo();

            // Strings
            var strings = new Strings();
            strings.TestEquality();
            strings.TestEquality2();
            strings.TestIntern();
            #endregion

            #region
            TypeA       a18 = new TypeA();
            TypeA.TypeB b18 = new TypeA.TypeB();
            a18.MethodA();
            b18.MethodA();
            #endregion

            #region OOP
            Console.WriteLine(SUB_CAPTION);
            int    i2 = 10;
            string s2 = "HelloWorld";

            Console.WriteLine("i = " + i2);
            OOP.ModifyInt(i2);
            Console.WriteLine("i = " + i2);

            Console.WriteLine("s = " + s2);
            // строка не меняется
            OOP.ModifyString(s2);
            Console.WriteLine("s = " + s2);

            new Square();
            #endregion

            #region
            Console.WriteLine(SUB_CAPTION);
            OOP.Ex3();
            #endregion

            #region
            Console.WriteLine(SUB_CAPTION);
            A21 a21 = new A21();
            B21 b21 = new B21();
            C21 c21 = new C21();
            a21.Print();
            b21.Print();
            c21.Print();
            #endregion

            #region LINQ
            Console.WriteLine($"{CAPTION_BEGIN} LINQ {CAPTION_END}");
            LINQ.Ex1();   // так можно
            LINQ.Ex2();
            LINQ.Ex3();
            LINQ.Ex4();
            LINQ.LazyInitialization();
            LINQ.LINQ1();
            #endregion

            #region DELEGATES
            Console.WriteLine($"{CAPTION_BEGIN} DELEGATES LAMBDA {CAPTION_END}");
            delegatesLambda.Ex1();
            delegatesLambda.Ex3();
            delegatesLambda.TestFunc();
            #endregion

            #region OBJECTS
            Console.WriteLine($"{CAPTION_BEGIN} OBJECTS {CAPTION_END}");
            //new Objects().CompareObjects();
            //new Objects().Ex0();
            //new Objects().Ex1();
            //new Objects().Ex2();
            //new Objects().Ex3();
            new Objects().Nullable();

            new Objects().DoRefObj();
            #endregion

            #region EXCEPTIONS
            Console.WriteLine($"{CAPTION_BEGIN} EXCEPTIONS {CAPTION_END}");
            //new Exceptions().Ex1();
            //new Exceptions().Ex2();
            //var exc_ex3 = exceptions().Ex3();
            //exceptions.TestThrow();
            //exceptions.Ex4();
            exceptions.Ex5();
            exceptions.TryCatchFinally();
            #endregion

            #region COMMON
            Console.WriteLine($"{CAPTION_BEGIN} COMMON {CAPTION_END}");
            common.Ex1();
            common.Ex2();
            common.Ex3();
            common.Ex5();
            common.Ex6();
            common.Ex7();
            common.Ex8();
            common.Nullable();
            #endregion

            #region KEYWORDS
            Console.WriteLine($"{CAPTION_BEGIN} KEYWORDS {CAPTION_END}");
            keywords.As();
            //new Keywords().Checked();
            keywords.Unchecked();
            keywords.Default();
            keywords.Enum();
            keywords.Is();
            keywords.Is2();

            #region Yield
            Console.WriteLine($"{SUB_CAPTION} Yield {SUB_CAPTION}");
            foreach (string s_ in Keywords.GetStrings())
            {
                Console.WriteLine(s_);
                Console.WriteLine("C#");
            }

            foreach (char ch in Keywords.GetLetters())
            {
                Console.WriteLine(ch);
            }
            #endregion


            keywords.Params();


            Console.WriteLine($"{SUB_CAPTION} New1 {SUB_CAPTION}");
            keywords.New1();

            keywords.ImplicitExplicitOperator();
            keywords.Operator();
            keywords.This1();
            keywords.This2();
            #endregion

            #region OPERATORS
            Console.WriteLine($"{CAPTION_BEGIN} OPERATORS {CAPTION_END}");
            new Operators().NullCoalescing();
            #endregion

            #region ASYNC/AWAIT
            Console.WriteLine($"{CAPTION_BEGIN} ASYNC/AWAIT {CAPTION_END}");
            AsyncAwait.Process();
            Console.WriteLine("C");
            #endregion

            Console.ReadKey();
        }