Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            MyClock myClock = new MyClock();

            myClock.alarmClock.Run();
        }
        public void SetUp()
        {
            runtimeFaker = new RuntimeFaker();
            clock        = new Clock();
            runtimeFaker.Register(clock);

            mock = new MyClock(new DateTime());
        }
Exemple #3
0
        static void Main(string[] args)
        {
            GenericList <int> list = new GenericList <int>();
            Random            ra   = new Random();

            for (int i = 0; i < 10; i++)
            {
                int randomRecord = ra.Next(10, 100);
                list.Add(randomRecord);
            }
            list.ForEach(data => Console.WriteLine(data));
            //make a sum
            int sum = 0;

            list.ForEach(data => sum += data);
            Console.WriteLine($"sum:{sum}");

            //get the minimum value
            int min = list.Head.Data;

            list.ForEach(data => min = data < min?data:min);
            Console.WriteLine($"minimum:{ min}");
            //get the maximum value
            int max = list.Head.Data;

            list.ForEach(data => max = data > max?data:max);
            Console.WriteLine($"maximum:{max}");


            //clock(第四题:)
            Clock   clk     = new Clock(22, 49);
            MyClock myClock = clk.Tick;

            myClock += clk.Alarm;
            myClock();
            Console.ReadLine();
        }
Exemple #4
0
        private static async Task RunAsync()
        {
            //This path is used to save in memory storage
            string strTempDataFolderPath = AppDomain.CurrentDomain.BaseDirectory + @"App_Data\";

            //create temp directory if it doesn't exist
            new FileInfo(strTempDataFolderPath).Directory?.Create();

            var inMemoryEventStorePath     = $@"{strTempDataFolderPath}events.stream.dump";
            var inMemorySnapshotStorePath  = $@"{strTempDataFolderPath}events.snapshot.dump";
            var inMemoryReadModelStorePath = $@"{strTempDataFolderPath}events.readmodel.dump";

            File.Delete(inMemoryEventStorePath);
            File.Delete(inMemorySnapshotStorePath);
            File.Delete(inMemoryReadModelStorePath);

            IClock clock = new MyClock();

            IEventStorageProvider <Guid, Schedule, Guid> eventStorage =
                new InMemoryEventStorageProvider <Guid, Schedule, Guid>(inMemoryEventStorePath);

            ISnapshotStorageProvider <ScheduleSnapshot, Guid, Guid> snapshotStorage =
                new InMemorySnapshotStorageProvider <ScheduleSnapshot, Guid, Guid>(2, inMemorySnapshotStorePath);

            IEventPublisher <Guid, Schedule, Guid> eventPublisher = new EventPublisher <Guid, Schedule, Guid>();

            IRepository <Schedule, Guid, Guid> repository =
                new Repository <Schedule, Guid, Guid, ScheduleSnapshot, Guid>(clock, eventStorage, eventPublisher, snapshotStorage);

            // repository = new EventOnlyRepository<Schedule, Guid, Guid>(clock, eventStorage, eventPublisher);

            var schedule = new Schedule("test schedule");
            await repository.SaveAsync(schedule);

            schedule = await repository.GetByIdAsync(schedule.Id);

            schedule.AddTodo("test todo 1");
            await repository.SaveAsync(schedule);

            schedule = await repository.GetByIdAsync(schedule.Id);

            schedule.AddTodo("test todo 2");
            await repository.SaveAsync(schedule);

            schedule = await repository.GetByIdAsync(schedule.Id);

            schedule.AddTodo("test todo 3");
            await repository.SaveAsync(schedule);

            schedule = await repository.GetByIdAsync(schedule.Id);

            var todo = schedule.Todos.First();

            schedule.UpdateTodo(todo.Id, todo.Text + " updated");
            await repository.SaveAsync(schedule);

            schedule = await repository.GetByIdAsync(schedule.Id);

            todo = schedule.Todos.Last();
            await schedule.CompleteTodoAsync(todo.Id);

            await repository.SaveAsync(schedule);

            Console.WriteLine();
            Console.WriteLine("Schedule loaded from Repository:");
            Console.WriteLine(JsonConvert.SerializeObject(schedule, Formatting.Indented));
        }
 public void InitializeComponent()
 {
     SampleControl.ScopeAttribute scopeAttribute1 = new SampleControl.ScopeAttribute();
     this.thermoMeterControl1 = new SampleControl.ThermoMeterControl();
     this.myClock1            = new SampleControl.MyClock();
     this.myLabel1            = new SampleControl.MyLabel();
     this.myControl           = new SampleControl.FirstControl();
     this.myTrackBar          = new SampleControl.FlashTrackBar();
     this.myButton            = new SampleControl.MyButton();
     this.myListControl       = new SampleControl.MyListControl();
     this.SuspendLayout();
     //
     // thermoMeterControl1
     //
     this.thermoMeterControl1.BigScale         = 5;
     this.thermoMeterControl1.BigScaleColor    = System.Drawing.Color.MediumBlue;
     this.thermoMeterControl1.DialBackColor    = System.Drawing.Color.Gray;
     this.thermoMeterControl1.DialOutLineColor = System.Drawing.Color.Gray;
     this.thermoMeterControl1.DrawColor        = System.Drawing.Color.Black;
     this.thermoMeterControl1.DrawFont         = new System.Drawing.Font("Microsoft Sans Serif", 9F);
     this.thermoMeterControl1.HighTemperature  = 100F;
     this.thermoMeterControl1.Location         = new System.Drawing.Point(346, 211);
     this.thermoMeterControl1.LowTemperature   = 0F;
     this.thermoMeterControl1.MercuryBackColor = System.Drawing.Color.LightGray;
     this.thermoMeterControl1.MercuryColor     = System.Drawing.Color.Red;
     this.thermoMeterControl1.Name             = "thermoMeterControl1";
     this.thermoMeterControl1.Size             = new System.Drawing.Size(58, 200);
     this.thermoMeterControl1.SmallScale       = 5;
     this.thermoMeterControl1.SmallScaleColor  = System.Drawing.Color.DarkOrange;
     this.thermoMeterControl1.TabIndex         = 5;
     this.thermoMeterControl1.TempColor        = System.Drawing.Color.Black;
     this.thermoMeterControl1.Temperature      = 0F;
     this.thermoMeterControl1.TempFont         = new System.Drawing.Font("宋体", 12F);
     //
     // myClock1
     //
     this.myClock1.ClockForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
     this.myClock1.HourColor      = System.Drawing.Color.Lime;
     this.myClock1.Location       = new System.Drawing.Point(246, 12);
     this.myClock1.MinuteColor    = System.Drawing.Color.Blue;
     this.myClock1.Name           = "myClock1";
     this.myClock1.SecondColor    = System.Drawing.Color.Red;
     this.myClock1.Size           = new System.Drawing.Size(200, 200);
     this.myClock1.TabIndex       = 4;
     this.myClock1.Text           = "myClock1";
     this.myClock1.MouseDown     += new System.Windows.Forms.MouseEventHandler(this.mouseDownEvent);
     this.myClock1.MouseMove     += new System.Windows.Forms.MouseEventHandler(this.mouseMoveEvent);
     this.myClock1.MouseUp       += new System.Windows.Forms.MouseEventHandler(this.mouseUpEvent);
     //
     // myLabel1
     //
     this.myLabel1.AutoSize       = true;
     this.myLabel1.ClockBackColor = System.Drawing.Color.DarkSlateGray;
     this.myLabel1.ClockForeColor = System.Drawing.Color.LavenderBlush;
     this.myLabel1.Location       = new System.Drawing.Point(27, 127);
     this.myLabel1.Margin         = new System.Windows.Forms.Padding(0);
     this.myLabel1.Name           = "myLabel1";
     this.myLabel1.Size           = new System.Drawing.Size(97, 20);
     this.myLabel1.TabIndex       = 2;
     //
     // myControl
     //
     this.myControl.BackColor     = System.Drawing.Color.Cornsilk;
     this.myControl.Location      = new System.Drawing.Point(75, 82);
     this.myControl.Name          = "myControl";
     this.myControl.Size          = new System.Drawing.Size(98, 28);
     this.myControl.TabIndex      = 0;
     this.myControl.Text          = "Hello,I am the firstControl!";
     this.myControl.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
     this.myControl.MouseDown    += new System.Windows.Forms.MouseEventHandler(this.mouseDownEvent);
     this.myControl.MouseMove    += new System.Windows.Forms.MouseEventHandler(this.mouseMoveEvent);
     this.myControl.MouseUp      += new System.Windows.Forms.MouseEventHandler(this.mouseUpEvent);
     //
     // myTrackBar
     //
     this.myTrackBar.AllowDrop      = true;
     this.myTrackBar.AllowUserEdit  = false;
     this.myTrackBar.BackColor      = System.Drawing.Color.Black;
     this.myTrackBar.DarkenBy       = ((byte)(255));
     this.myTrackBar.ForeColor      = System.Drawing.Color.White;
     this.myTrackBar.Location       = new System.Drawing.Point(27, 43);
     this.myTrackBar.Name           = "myTrackBar";
     this.myTrackBar.ShowPercentage = true;
     this.myTrackBar.Size           = new System.Drawing.Size(146, 20);
     this.myTrackBar.TabIndex       = 1;
     this.myTrackBar.Text           = "程序进度条";
     //
     // myButton
     //
     this.myButton.BackColor         = System.Drawing.Color.SandyBrown;
     this.myButton.ButtonBorder      = 1;
     this.myButton.ButtonBorderColor = System.Drawing.Color.Sienna;
     this.myButton.Cursor            = System.Windows.Forms.Cursors.Default;
     this.myButton.Location          = new System.Drawing.Point(-3, 178);
     this.myButton.Name     = "myButton";
     this.myButton.Size     = new System.Drawing.Size(107, 51);
     this.myButton.TabIndex = 3;
     this.myButton.Text     = "I am a button";
     this.myButton.UseVisualStyleBackColor = false;
     //
     // myListControl
     //
     this.myListControl.BackColor = System.Drawing.SystemColors.Control;
     this.myListControl.Cursor    = System.Windows.Forms.Cursors.Default;
     this.myListControl.ForeColor = System.Drawing.Color.Cornsilk;
     this.myListControl.Location  = new System.Drawing.Point(195, 237);
     this.myListControl.Name      = "myListControl";
     scopeAttribute1.Max          = 100;
     scopeAttribute1.Min          = 3;
     this.myListControl.Scope     = scopeAttribute1;
     this.myListControl.Size      = new System.Drawing.Size(30, 100);
     this.myListControl.TabIndex  = 6;
     //
     // MyForm
     //
     this.ClientSize = new System.Drawing.Size(448, 423);
     this.Controls.Add(this.thermoMeterControl1);
     this.Controls.Add(this.myClock1);
     this.Controls.Add(this.myLabel1);
     this.Controls.Add(this.myControl);
     this.Controls.Add(this.myTrackBar);
     this.Controls.Add(this.myButton);
     this.Controls.Add(this.myListControl);
     this.Location = new System.Drawing.Point(300, 100);
     this.Name     = "MyForm";
     this.Text     = "控件窗口";
     this.ResumeLayout(false);
     this.PerformLayout();
 }
        static void Main(string[] args)
        {
            MyClock myClock = new MyClock();

            myClock.alarmClock.Run();
        }
 public bool DeleteLog(Employee log)
 {
     return(MyClock.DeleteLog(log));
 }
 public bool DeleteMonth(Employee[] logs)
 {
     return(MyClock.DeleteMonth(logs));
 }
 public void UpdateLog(Employee newLog)
 {
     MyClock.Update(newLog);
 }
 //need to make sure that the sql file as well saves only one year and not all the time
 public void StartOperation(string logLocation)
 {
     MyClock.StartOperation(logLocation);
 }