Exemplo n.º 1
0
        static void Main(string[] args)
        {
            int time;

            Console.WriteLine("Enter time value, please");
            time = Convert.ToInt32(Console.ReadLine());

            var firstSubscriber  = new FirstSubscriber();
            var secondSubscriber = new SecondSubscriber();
            var manager          = new MessageManager();

            firstSubscriber.Register(manager);
            manager.SimulateNewMessage(time, "1-st event");

            secondSubscriber.Register(manager);
            manager.SimulateNewMessage(time, "2-nd event");

            firstSubscriber.Unregister(manager);

            var secManager = new MessageManager();

            firstSubscriber.Register(secManager);

            manager.SimulateNewMessage(time, "3-rd event");
            secManager.SimulateNewMessage(time, "4-th event");

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            TimerLibrary.Timer timer            = new TimerLibrary.Timer();
            FirstSubscriber    firstSubscriber  = new FirstSubscriber();
            SecondSubscriber   secondSubscriber = new SecondSubscriber();

            firstSubscriber.Subscribe(timer);
            secondSubscriber.Subscribe(timer);

            timer.StartTimer(10, "test");

            secondSubscriber.Unsubscribe(timer);

            timer.StartTimer(5, "test1");

            System.Console.ReadLine();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            ClockManager clockManager = new ClockManager();

            FirstSubscriber  sub1 = new FirstSubscriber();
            SecondSubscriber sub2 = new SecondSubscriber();

            sub1.Register(clockManager);
            sub2.Register(clockManager);

            clockManager.SimulateTimeOut(5);
            Thread.Sleep(5000);
            clockManager.SimulateTimeOut(3);
            Thread.Sleep(5000);
            sub1.Unregister(clockManager);
            clockManager.SimulateTimeOut(4);


            Console.ReadKey();
        }
 public SecondSubscriber(FirstSubscriber parent, ISubscriber <T> actual)
 {
     this.parent = parent;
     this.actual = actual;
 }
Exemplo n.º 5
0
    static void Main()
    {
        // TODO: Create an object of type ClassWithDelegate.
        ClassWithDelegate cwd = new ClassWithDelegate();

        // TODO: Create a FirstSubscriber object and call its Subscribe method.
        FirstSubscriber fs = new FirstSubscriber();
        fs.Subscribe(cwd);

        // TODO: Create a SecondSubscriber object and call its Subscribe method.
        SecondSubscriber ss = new SecondSubscriber();
        ss.Subscribe(cwd);

        // TODO: Call the Run method in the ClassWithDelegate class.
        cwd.Run();
    }
Exemplo n.º 6
0
 private FirstSubscriber FetchFirstSubscriber(FirstSubscriber Subscriber, SafeDataReader dr)
 {
     Subscriber.FirstSubscriberID = dr.GetInt32("PersonID");
     Subscriber.FirstSubscriberName = dr.GetString("PersonName");
     return Subscriber;
 }
Exemplo n.º 7
0
            /// <summary>
            /// Description  : Get Auditors Details from database.
            /// Created By   : Pavan
            /// Created Date : 23 August 2014
            /// Modified By  :
            /// Modified Date:
            /// </summary>
            /// <returns></returns>
            public static List<FirstSubscriber> GetddlPrincipalDetails(int WOID)
            {
                var data = new List<FirstSubscriber>();

                System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
                System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
                log.Debug("Start: " + methodBase.Name);
                try
                {
                    SqlParameter[] sqlParams = new SqlParameter[1];
                    sqlParams[0] = new SqlParameter("@WOID", WOID);
                    var reader = SqlHelper.ExecuteReader(ConnectionUtility.GetConnectionString(), CommandType.StoredProcedure, "[SpGetPrincipalDetailsByWOID]", sqlParams);
                    var safe = new SafeDataReader(reader);
                    while (reader.Read())
                    {
                        var FirstSubscriber = new FirstSubscriber();
                        FirstSubscriber.FetchFirstSubscriber(FirstSubscriber, safe);
                        data.Add(FirstSubscriber);
                    }
                }
                catch (Exception ex)
                {
                    log.Error("Error: " + ex);
                    return data;
                }
                finally
                {
                    log.Debug("End: " + methodBase.Name);
                }
                return data;
            }