Ejemplo n.º 1
0
        private bool isTest(SimpleClass fixture, SimpleMethod method)
        {
            var specFound       = method.ReturnType.StartsWith("Simple.Testing.ClientFramework.Specification");
            var enumerableFound = method.ReturnType.StartsWith("IEnumerable<Simple.Testing.ClientFramework.Specification>");

            return(!fixture.IsAbstract && (specFound || enumerableFound));
        }
Ejemplo n.º 2
0
 public Module(string id, long timeout, SimpleMethod method)
 {
     this.id         = id;
     this.timeout    = timeout;
     this.method     = method;
     this.reportTime = DateTimeHelper.DateTimeToUnixTimestamp(DateTime.Now);
 }
Ejemplo n.º 3
0
 public ThreadData(SimpleMethod method, string name, bool isNetworkSensitive)
 {
     this.thread             = new Thread(new ThreadStart(ThreadLoop));
     this.method             = method;
     this.name               = name;
     this.isNetworkSensitive = isNetworkSensitive;
 }
Ejemplo n.º 4
0
    public static Timer AddTimer(float time, SimpleMethod callback)
    {
        Timer timer = new GameObject().AddComponent <Timer>();

        timer.time     = time;
        timer.OnTimer += callback;
        timer.Run();
        return(timer);
    }
Ejemplo n.º 5
0
        public static void ReportAlive(string id, long timeout, SimpleMethod method)
        {
            if (TrackedModules == null)
            {
                TrackedModules = new Dictionary <string, Module>();
            }

            lock (TrackedModules) {
                TrackedModules.Remove(id);
                TrackedModules.Add(id, new Module(id, timeout, method));
            }
        }
Ejemplo n.º 6
0
        public void BuiltInTypeHash_02()
        {
            var method_01 = new SimpleMethod
            {
                BusinessId = "hello",
                FullName   = @"world"
            };

            var method_02 = new SimpleMethod
            {
                BusinessId = "hello",
                FullName   = @"freaks"
            };

            var hasher = new BuiltInTypeHashProcessor();

            Assert.AreNotEqual(hasher.GetHash(method_01), hasher.GetHash(method_02));
        }
Ejemplo n.º 7
0
        // Статические методы, обычно, выполняют какую-нибудь глобальную, общую функцию, обрабатывают «внешние данные».
        //Например, сортировка массива, обработка строки, возведение числа в степень и другое.
        static void Main(string[] args)
        {
            //Простой
            SimpleMethod sm1 = new SimpleMethod();
            SimpleMethod sm2 = new SimpleMethod();
            int          a   = sm1.Suma(2, 3);
            int          b   = sm2.Suma(45, 67);

            Console.WriteLine(a);
            Console.WriteLine(b);
            //Статический
            int c = StaticMethod.Multiply(34, 45);
            int d = StaticMethod.Multiply(100, 34);

            Console.WriteLine(c);
            Console.WriteLine(d);
            Console.ReadKey();
        }
Ejemplo n.º 8
0
        public static Thread Register(SimpleMethod method, string threadName, bool networkSensitive, int sortPriority)
        {
            ThreadData td = new ThreadData(method, threadName, networkSensitive);

            td.sortPriority = sortPriority;

            ThreadData[] currThreads = Threads.Values.ToArray();
            for (int i = 0; i < currThreads.Length; i++)
            {
                if (currThreads[i].name == threadName)
                {
                    Threads.Remove(currThreads[i].thread);
                    break;
                }
            }

            Threads.Add(td.thread, td);

            td.thread.Start();
            return(td.thread);
        }
Ejemplo n.º 9
0
 void ExecuteMethodAndPumpThreadMain(object untyped_method)
 {
     SimpleMethod method = (SimpleMethod)untyped_method;
 }
Ejemplo n.º 10
0
        unsafe void ExecuteMethodAndPump(SimpleMethod method)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            if (_disableMessagePumping)
            {
                LogMessage("Message pumping is disabled - executing method directly");
                method();
                return;
            }

            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.MTA)
            {
                LogMessage("Message pumping is disabled - this thread is an MTA thread");
                method();
                return;
            }

            bool quit         = false;
            uint mainThreadId = Kernel32.GetCurrentThreadId();
            // LogMessage("main thread id = " + mainThreadId);
            Exception worker_exception = null;

            Thread thread = new Thread(delegate()
            {
                try {
                    method();
                    worker_exception = null;
                }
                catch (Exception ex) {
                    worker_exception = ex;
                }
                quit = true;
                User32.PostThreadMessageW(mainThreadId, User32.WM_NULL, IntPtr.Zero, IntPtr.Zero);
            });

            thread.Start();

            for (;;)
            {
                if (quit)
                {
                    // LogMessage("Main thread received quit notification.  Quitting.");
                    break;
                }

                MSG msg = new MSG();
                if (Windows.User32.GetMessageW(&msg, IntPtr.Zero, 0, 0))
                {
                    User32.TranslateMessage(&msg);
                    User32.DispatchMessageW(&msg);
                }
                else
                {
                    LogMessage("Received WM_QUIT or GetMessage failed!  Bailing.");
                    break;
                }
            }

            // LogMessage("Waiting for worker thread to finish...");
            thread.Join();
            // LogMessage("Worker thread is done.");

            if (worker_exception != null)
            {
                throw worker_exception;
            }
        }
Ejemplo n.º 11
0
 public TimedInvoke Call(SimpleMethod callback)
 {
     _callbacks.Add(callback);
     return(this);
 }
Ejemplo n.º 12
0
		public void Display_SetExit( object o, MethodInfo mi )
		{
			Delegate d = Delegate.CreateDelegate( typeof( SimpleMethod ), o, mi );
			Exit = (SimpleMethod)d;// mi.CreateDelegate( typeof(SimpleMethod), o );
		}
Ejemplo n.º 13
0
 public static Thread Register(SimpleMethod method, string threadName, bool networkSensitive)
 {
     return(Register(method, threadName, networkSensitive, 0));
 }