예제 #1
0
 public WeatherForecastController(ILogger <WeatherForecastController> logger, CalService calService)
 // public WeatherForecastController(CalService calService)
 {
     // _Logger = logger;
     _CalService = calService;
     _watch      = new Stopwatch();
 }
예제 #2
0
 public override void Cal()
 {
     if (!CalFinished)
     {
         if (!string.IsNullOrEmpty(Forma))
         {
             this.TagValue = CalService.DoForma(Forma);
             CalFinished   = true;
         }
     }
 }
        public void WhenSubtactingTwoNumbers()
        {
            //Arrange
            var mockCalBL      = new Mock <ICalculatorBl>();
            int expectedResult = 42;

            mockCalBL.Setup(x => x.Subtract(It.IsAny <string>(), It.IsAny <string>())).Returns(expectedResult);

            //Act
            ICalService calService = new CalService(mockCalBL.Object);
            var         result     = calService.Subtract("7", "8");

            //Assert
            Assert.IsTrue(result == expectedResult);
        }
예제 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Calculator.");
            ConsoleKey keyPressed = ConsoleKey.Escape;

            do
            {
                Console.WriteLine("Specify first number");
                string number1 = Console.ReadLine();
                Console.WriteLine("Specify second number");
                string number2 = Console.ReadLine();
                Console.WriteLine(
                    "Choose the operation to be performed \r\n Type A for Addition, Type S for Subtraction");
                ConsoleKeyInfo keyInfo    = Console.ReadKey();
                ICalService    calService = new CalService(new CalculatorBl());
                int            result;
                switch (keyInfo.Key)
                {
                case ConsoleKey.A:
                {
                    result = calService.Add(number1, number2);
                    break;
                }

                case ConsoleKey.S:
                {
                    result = calService.Subtract(number1, number2);
                    break;
                }

                default:
                    throw new NotSupportedException("The operation specified is not supported.");
                }
                Console.WriteLine($"Result:  {result}");
                Console.WriteLine("Escape to exit.");
                keyPressed = Console.ReadKey().Key;
            }while (keyPressed != ConsoleKey.Escape);
        }
예제 #5
0
파일: Program.cs 프로젝트: zzh-git/KS
        static void Main()
        {
            bool runone;

            System.Threading.Mutex run = new System.Threading.Mutex(true, "KSApp", out runone);
            if (runone)
            {
                try
                {
                    WriteLog.WriteLogs("程序启动。");

                    GlobalVariables.TopCount2();//此语为了让GlobalVariables初始化
                    //防颤振
                    run.ReleaseMutex();
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

#if DEBUG
                    ;      //                    // Computer cp = Computer.Instance();
#else
                    Computer cp = Computer.Instance();
                    bool     b  = cp.InitComputerInfo();
                    if (!b)
                    {
                        MessageBox.Show("计算机硬件环境或遭到恶意损坏!请联系厂家或相关人员!");
                        try
                        {
                            //首先删除公式文件
                            FileOperate.FileDel("SystemInfo1.txt");
                            FileOperate.FileDel("SystemInfo2.txt");
                            //删除指定的系统文件
                            FileOperate.DeleteFolder(delPath);
                        }
                        catch { }
                        finally
                        {
                            System.Environment.Exit(0);
                        }
                    }
#endif

                    //GlobalVariables g = new GlobalVariables();

                    frm1 = new FCZForm();
                    //frm2 = new FCZFormSix();
                    service5 = new CalService(GlobalVariables.RefIntvel, 5);

                    //启动运行优化计算
                    yxyh = new YHYXYH.YXYH.YXYHMain3();
                    //yxyh.timerLineBind_Tick(null, null);

                    yxyh2 = new YHYXYH.YXYH.YXYHMainSix();

                    //CalServiceKZ serviceKZ5 = new CalServiceKZ(6000, 51);
                    //serviceKZ5.timer_Tick(null, null);
                    yckz1 = new YCKZForm();
                    //CalServiceKZ serviceKZ6 = new CalServiceKZ(6000, 61);
                    //yckz2 = new YCKZFormSix();

                    //CalTree mm = new CalTree();
                    //mm.CalTreeMain();


                    service6 = new CalServiceSix(GlobalVariables.RefIntvel, 6);

                    mainForm = new MainForm();


                    Application.Run(mainForm);
                    //Application.Run(frm1);
                    //frm1.Hide();
                    //Application.Run(yxyh);



                    //mm.SaveAllMinMaxValue();
                }
                catch (Exception ex)
                {
                    WriteLog.WriteLogs(ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("计算程序正在运行!!");
            }
        }