コード例 #1
0
 public void Do(IDo o, Doer doer)
 {
     if (o is A a)
     {
         doer.Do(a);
     }
     else if (o is B b)
     {
         doer.Do(b);
     }
     else if (o is C c)
     {
         doer.Do(c);
     }
     else if (o is D d)
     {
         doer.Do(d);
     }
     else if (o is E e)
     {
         doer.Do(e);
     }
     else if (o is F f)
     {
         doer.Do(f);
     }
 }
コード例 #2
0
        public void Do(IDo o, Doer doer)
        {
            var a = o as A;
            var b = o as B;
            var c = o as C;
            var d = o as D;
            var e = o as E;
            var f = o as F;

            if (a != null)
            {
                doer.Do(a);
            }
            else if (b != null)
            {
                doer.Do(b);
            }
            else if (c != null)
            {
                doer.Do(c);
            }
            else if (d != null)
            {
                doer.Do(d);
            }
            else if (e != null)
            {
                doer.Do(e);
            }
            else if (f != null)
            {
                doer.Do(f);
            }
        }
コード例 #3
0
        public void Do(IDo o, Doer doer)
        {
            var type = o.GetType();

            if (type == typeof(A))
            {
                doer.Do((A)o);
            }
            else if (type == typeof(B))
            {
                doer.Do((B)o);
            }
            else if (type == typeof(C))
            {
                doer.Do((C)o);
            }
            else if (type == typeof(D))
            {
                doer.Do((D)o);
            }
            else if (type == typeof(E))
            {
                doer.Do((E)o);
            }
            else if (type == typeof(F))
            {
                doer.Do((F)o);
            }
        }
コード例 #4
0
 public void Do(IDo o, Doer doer)
 {
     if (o is A)
     {
         ((A)o).Do(doer);
     }
     else if (o is B)
     {
         ((B)o).Do(doer);
     }
     else if (o is C)
     {
         ((C)o).Do(doer);
     }
     else if (o is D)
     {
         ((D)o).Do(doer);
     }
     else if (o is E)
     {
         ((E)o).Do(doer);
     }
     else if (o is F)
     {
         ((F)o).Do(doer);
     }
 }
コード例 #5
0
        public void Do(IDo o, Doer doer)
        {
            var handle = Type.GetTypeHandle(o);

            if (handle.Equals(s_a))
            {
                doer.Do((A)o);
            }
            else if (handle.Equals(s_b))
            {
                doer.Do((B)o);
            }
            else if (handle.Equals(s_c))
            {
                doer.Do((C)o);
            }
            else if (handle.Equals(s_d))
            {
                doer.Do((D)o);
            }
            else if (handle.Equals(s_e))
            {
                doer.Do((E)o);
            }
            else if (handle.Equals(s_f))
            {
                doer.Do((F)o);
            }
        }
コード例 #6
0
        public void Do(IDo o, Doer doer)
        {
            Action <Doer, object> actor;

            s_dict.TryGetValue(o.GetType(), out actor);
            actor(doer, o);
        }
コード例 #7
0
 public Hero(string name, Vector2d position) : base(name, position)
 {
     FullName     = "Hero";
     Foreground   = ConsoleColor.Green;
     DrawLayer    = Layer.Player;
     AttackAction = new Attack(this, null);
     _baseHealth  = 100;
 }
コード例 #8
0
        static void Main(string[] args)
        {
            Console.WriteLine(System.UInt64.MaxValue);

            string str = "Картон";

            Console.WriteLine($"Индекс первой буквы 'о' в слове {str} - " + str.IndexOf('о'));

            char[][] arrSt = new char[3][];
            arrSt[0] = new char[1] {
                'a'
            };
            arrSt[1] = new char[2] {
                'b', 'c'
            };
            arrSt[2] = new char[3] {
                'd', 'e', 'f'
            };

            Console.WriteLine("\n");
            for (int i = 0; i < 1; ++i)
            {
                Console.Write(arrSt[0][i] + "  ");
            }

            Console.WriteLine();
            for (int i = 0; i < 2; ++i)
            {
                Console.Write(arrSt[1][i] + "  ");
            }

            Console.WriteLine();
            for (int i = 0; i < 3; ++i)
            {
                Console.Write(arrSt[2][i] + "  ");
            }



            Button b1  = new Button(100, 40);
            Button b2  = new Button(200, 36);
            bool   res = b1.Equals(b2);

            Console.WriteLine("\nb1 эквивалентно b2? - " + res);
            Button.color = "синий";


            Student st  = new Student();
            IThink  st1 = st;
            IDo     st2 = st;

            st1.Future();
            st2.Future();

            Console.ReadLine();
        }
コード例 #9
0
 /// <summary>
 /// This method is the main loop for the spider threads.
 /// This method will wait for URL's to become available,
 /// and then process them.
 /// </summary>
 public void Process()
 {
     while (!t_manager.Quit)
     {
         m_ido = t_manager.ObtainWork();
         t_manager.SpiderDone.WorkerBegin();
         m_ido.threadManager = t_manager;
         m_ido.Start();
         m_ido.Dispose();
         t_manager.SpiderDone.WorkerEnd();
     }
 }
コード例 #10
0
        public void addURL(IDo _do)
        {
            Monitor.Enter(this);
            if (!m_already.Contains(_do))
            {
                //m_already.Add(_do, Status.STATUS_QUEUED);

                m_workload.Add(_do);
            }
            Monitor.Pulse(this);
            Monitor.Exit(this);
        }
コード例 #11
0
        public IDo ObtainWork()
        {
            Monitor.Enter(this);
            while (m_workload.Count < 1)
            {
                Monitor.Wait(this);
            }
            IDo next = m_workload.OrderBy(m => m.Priority).FirstOrDefault();

            m_workload.Remove(next);
            Monitor.Exit(this);
            return(next);
        }
コード例 #12
0
    public static string stringForEyeID()
    {
        object IDo;
        bool   isID = gazeDictionary.TryGetValue("id", out IDo);

        if (isID)
        {
            return(IDo.ToString());
        }
        else
        {
            return(null);
        }
    }
コード例 #13
0
        public void Move(Vector2d newPos, BaseTile t)
        {
            if (canGoTo(t))
            {
                Position = newPos;
                onTile   = t;
            }
            // Cast til Base Enemy, hvis den tile jeg står på er en BaseEnemy
            BaseEnemy e = onTile as BaseEnemy;

            if (e != null)
            {
                onTile       = e;
                AttackAction = new Attack(this, e);
            }
            //
        }
コード例 #14
0
        public void Do(IDo o, Doer doer)
        {
            switch (o)
            {
            case A a: doer.Do(a); break;

            case B b: doer.Do(b); break;

            case C c: doer.Do(c); break;

            case D d: doer.Do(d); break;

            case E e: doer.Do(e); break;

            case F f: doer.Do(f); break;
            }
        }
コード例 #15
0
ファイル: kr_3var.cs プロジェクト: klepaski/OOP-labs-3-sem-
        static void Main(string[] args)
        {
            Console.WriteLine(Decimal.MaxValue);

            Console.WriteLine("Введите две строки: ");
            string s1     = Console.ReadLine();
            string s2     = Console.ReadLine();
            int    result = String.Compare(s1, s2);

            if (result == 0)
            {
                Console.WriteLine("Строки {0} и {1} идентичны", s1, s2);
            }
            else
            {
                Console.WriteLine("Строки {0} и {1} разные", s1, s2);
            }


            string[] arr = new string[3];
            arr[0] = "один";
            arr[1] = "два";
            arr[2] = "три";
            for (int i = arr.Length; i < 0; i--)
            {
                Console.Write(arr[i] + "  ");
            }

            Month m = new Month();

            Console.WriteLine("\nОбращение к элементам массива по индексу:");
            Console.WriteLine(m[0]);
            Console.WriteLine(m[7]);
            Console.WriteLine(m[13]);

            Student st = new Student();

            st.name = "Никита";
            IDo inter_st = st;

            st.coding();
            inter_st.coding();

            Console.ReadLine();
        }
コード例 #16
0
        public static async Task <HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]
            HttpRequestMessage req,
            [Inject(typeof(IDo))] IDo myDo,
            TraceWriter log)
        {
            string  name = req.GetQueryNameValuePairs().FirstOrDefault(q => string.Compare(q.Key, "name", StringComparison.Ordinal) == 0).Value;
            dynamic data = await req.Content.ReadAsAsync <object>();

            name = name ?? data?.name;

            string message = myDo.GetNameMessage(name);

            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(message), Encoding.UTF8, "application/json")
            });
        }
コード例 #17
0
        public void VirtualTry()
        {
            bool caught = false;
            IDo  a      = new ExcpetionClass();
            IDo  b      = new B();
            IDo  a_     = null;
            IDo  b_     = null;

            try {
                b_ = b.Do();
                a_ = a.Do();
            } catch (Exception e) {
                caught = true;
            }

            Assert.IsTrue(caught);
            Assert.IsTrue(b_ != null);
            Assert.IsTrue(a_ == null);
        }
コード例 #18
0
        public void DoWork(IDo task)
        {
            if (_isIdle)
            {
                _tasks.Enqueue(task);
                //Thread.Sleep(1);

                if (null == _thread)
                {
                    _thread = new Thread(DoTask);
                    _thread.IsBackground = true;
                    _threadID            = _thread.ManagedThreadId;
                    _thread.Start();
                }
                else
                {
                    _newJobWaitHandle.Set();
                }
            }
            else
            {
                throw (new ThreadStateException());
            }
        }
コード例 #19
0
 public void AddNewWork(IDo task)
 {
     _tasks.Enqueue(task);
 }
コード例 #20
0
 public FooService(IDo @do)
 {
     Do = @do;
 }
コード例 #21
0
ファイル: Server.cs プロジェクト: kzu/Sensorium
 public void Send(IDo command)
 {
     // TODO: error handling?
     tracer.Info("{0}: Sending command '{1}' to device.", Id, command.Topic);
     channel.SendAsync(new Topic(command.Topic, command.Payload));
 }
コード例 #22
0
ファイル: TestDevice.cs プロジェクト: kzu/Sensorium
 public void Send(IDo command)
 {
     Commands.Add(command);
 }
コード例 #23
0
 public void Do(IDo o, Doer doer)
 {
     o.Do(doer);
 }
コード例 #24
0
 public void AddDo(IDo _do)
 {
     t_manager.addURL(_do);
 }
コード例 #25
0
 public void Do(IDo o, Doer doer)
 {
 }
コード例 #26
0
ファイル: DeviceInfo.cs プロジェクト: kzu/Sensorium
 public void Send(IDo command)
 {
     throw new NotSupportedException();
 }
コード例 #27
0
 public void Do(IDo o, Doer doer)
 {
     s_dict[Type.GetTypeHandle(o)](doer, o);
 }