コード例 #1
0
            public void SetsValuesCorrectlyForEmptyPropertyName()
            {
                var iniEntry = new IniEntry();
                var nullEventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, string.Empty);

                Assert.AreEqual(string.Empty, nullEventArgs.PropertyName);
            }
コード例 #2
0
            public void SetsValuesCorrectlyForNullPropertyName()
            {
                var iniEntry = new IniEntry();
                var nullEventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, (string) null);

                Assert.AreEqual(null, nullEventArgs.PropertyName);
            }
コード例 #3
0
            public void ReturnsRightPropertyNameUsingExpression()
            {
                var iniEntry = new IniEntry();

                Assert.AreEqual("Group", ExpressionHelper.GetPropertyName(() => iniEntry.Group));
                Assert.AreEqual("Key", ExpressionHelper.GetPropertyName(() => iniEntry.Key));
                Assert.AreEqual("Value", ExpressionHelper.GetPropertyName(() => iniEntry.Value));
            }
コード例 #4
0
            public void SetsValuesCorrectlyWithTwoArguments()
            {
                var iniEntry = new IniEntry();
                var iniFile = new IniFile();

                var originalEventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, "PropertyName");

                var eventArgs = new AdvancedPropertyChangedEventArgs(iniFile, originalEventArgs);

                Assert.AreEqual(iniEntry, eventArgs.OriginalSender);
                Assert.AreEqual(iniFile, eventArgs.LatestSender);
                Assert.AreEqual("PropertyName", eventArgs.PropertyName);
            }
コード例 #5
0
            public void SetsValuesCorrectlyWithAllARguments()
            {
                var iniEntry = new IniEntry();

                var eventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, "PropertyName", (object) "old value", "new value");

                Assert.AreEqual(iniEntry, eventArgs.OriginalSender);
                Assert.AreEqual(iniEntry, eventArgs.LatestSender);
                Assert.AreEqual("PropertyName", eventArgs.PropertyName);
                Assert.AreEqual("old value", eventArgs.OldValue);
                Assert.AreEqual("new value", eventArgs.NewValue);
                Assert.AreEqual(true, eventArgs.IsOldValueMeaningful);
                Assert.AreEqual(true, eventArgs.IsNewValueMeaningful);
            }
コード例 #6
0
            public void SetsValuesCorrectlyWithTheeArgumentsExceptOldValue()
            {
                IniEntry iniEntry = new IniEntry();

                var eventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, "PropertyName", (object) "new value");

                Assert.AreEqual(iniEntry, eventArgs.OriginalSender);
                Assert.AreEqual(iniEntry, eventArgs.LatestSender);
                Assert.AreEqual("PropertyName", eventArgs.PropertyName);
                Assert.AreEqual(null, eventArgs.OldValue);
                Assert.AreEqual("new value", eventArgs.NewValue);
                Assert.AreEqual(false, eventArgs.IsOldValueMeaningful);
                Assert.AreEqual(true, eventArgs.IsNewValueMeaningful);
            }
コード例 #7
0
ファイル: ActionUndoFacts.cs プロジェクト: pars87/Catel
            public void SetProperty()
            {
                var instance = new IniEntry();
                var action = new PropertyChangeUndo(instance, "Key", "previousValue", "nextValue");
                var mementoService = new MementoService();

                mementoService.Add(action);
                Assert.AreEqual(IniEntry.KeyProperty.GetDefaultValue(), instance.Key);

                mementoService.Undo();
                Assert.AreEqual("previousValue", instance.Key);

                mementoService.Redo();
                Assert.AreEqual("nextValue", instance.Key);
            }
コード例 #8
0
ファイル: TypeFactoryFacts.cs プロジェクト: pars87/Catel
 public DependencyInjectionTestClass(IniEntry iniEntry, int intValue, string stringValue)
     : this(iniEntry, intValue)
 {
     StringValue = stringValue;
 }
コード例 #9
0
ファイル: TypeFactoryFacts.cs プロジェクト: pars87/Catel
 public DependencyInjectionTestClass(IniEntry iniEntry)
 {
     IniEntry = iniEntry;
 }
コード例 #10
0
ファイル: ModelBaseTest.cs プロジェクト: Catel/Catel
        public void GetValue_Null()
        {
            var entry = new IniEntry();

            ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => entry.GetValue<string>(null));
        }
コード例 #11
0
ファイル: ModelBaseTest.cs プロジェクト: Catel/Catel
        public void NotifyPropertyChanged_OldValueSupport()
        {
            var obj = new IniEntry();

            object oldValue = null;
            object newValue = null;

            obj.PropertyChanged += (sender, e) =>
                                       {
                                           var advancedE = (AdvancedPropertyChangedEventArgs)e;

                                           if (advancedE.PropertyName == "Key")
                                           {
                                               Assert.IsTrue(advancedE.IsOldValueMeaningful);
                                               Assert.IsTrue(advancedE.IsNewValueMeaningful);

                                               oldValue = advancedE.OldValue;
                                               newValue = advancedE.NewValue;
                                           }
                                       };

            obj.Key = "new value";

            Assert.AreEqual(IniEntry.KeyProperty.GetDefaultValue(), oldValue);
            Assert.AreEqual("new value", newValue);
        }
コード例 #12
0
ファイル: TypeFactoryFacts.cs プロジェクト: xubinvc/Catel
 public DependencyInjectionTestClass(IniEntry iniEntry)
 {
     IniEntry = iniEntry;
 }
コード例 #13
0
 public DependencyInjectionTestClass(IniEntry iniEntry, int intValue, string stringValue)
     : this(iniEntry, intValue)
 {
     StringValue = stringValue;
 }
コード例 #14
0
 public DependencyInjectionTestClass(IniEntry iniEntry, int intValue)
     : this(iniEntry)
 {
     IntValue = intValue;
 }
コード例 #15
0
            public void SetsValuesCorrectlyWithPropertyNameOnly()
            {
                var iniEntry = new IniEntry();
                var iniFile = new IniFile();

                var eventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, iniFile, "PropertyName");

                Assert.AreEqual(iniEntry, eventArgs.OriginalSender);
                Assert.AreEqual(iniFile, eventArgs.LatestSender);
                Assert.AreEqual("PropertyName", eventArgs.PropertyName);
                Assert.AreEqual(null, eventArgs.OldValue);
                Assert.AreEqual(null, eventArgs.NewValue);
                Assert.AreEqual(false, eventArgs.IsOldValueMeaningful);
                Assert.AreEqual(false, eventArgs.IsNewValueMeaningful);
            }
コード例 #16
0
ファイル: ModelBaseTest.cs プロジェクト: Catel/Catel
        public void GetValue_NonExistingProperty()
        {
            var entry = new IniEntry();

            ExceptionTester.CallMethodAndExpectException<PropertyNotRegisteredException>(() => entry.GetValue<string>("Non-existing property"));
        }
コード例 #17
0
ファイル: TypeFactoryFacts.cs プロジェクト: pars87/Catel
            public void ResolvesTypeUsingDependencyInjectionUsesConstructorWithMostParametersFirst()
            {
                var serviceLocator = new ServiceLocator();
                var typeFactory = serviceLocator.ResolveType<ITypeFactory>();

                var iniEntry = new IniEntry { Group = "group", Key = "key", Value = "value" };
                serviceLocator.RegisterInstance(iniEntry);
                serviceLocator.RegisterInstance(42);
                serviceLocator.RegisterInstance("hi there");

                var instance = typeFactory.CreateInstance<DependencyInjectionTestClass>();

                Assert.IsFalse(instance.UsedDefaultConstructor);
                Assert.AreEqual(iniEntry, instance.IniEntry);
                Assert.AreEqual(42, instance.IntValue);
                Assert.AreEqual("hi there", instance.StringValue);
            }
コード例 #18
0
ファイル: ModelBaseTest.cs プロジェクト: Catel/Catel
 public void GetValue_ExistingProperty()
 {
     var entry = new IniEntry();
     entry.Key = "key value";
     var value = entry.GetValue<string>(IniEntry.KeyProperty.Name);
     Assert.AreEqual("key value", value);
 }
コード例 #19
0
ファイル: TypeFactoryFacts.cs プロジェクト: pars87/Catel
 public DependencyInjectionTestClass(IniEntry iniEntry, int intValue)
     : this(iniEntry)
 {
     IntValue = intValue;
 }
コード例 #20
0
            public void CanAutomaticallyDetectNewValue()
            {
                var iniEntry = new IniEntry();
                iniEntry.Key = "mykey";

                var eventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, "Key");

                Assert.AreEqual(iniEntry, eventArgs.OriginalSender);
                Assert.AreEqual(iniEntry, eventArgs.LatestSender);
                Assert.AreEqual("Key", eventArgs.PropertyName);
                Assert.AreEqual(null, eventArgs.OldValue);
                Assert.AreEqual("mykey", eventArgs.NewValue);
                Assert.AreEqual(false, eventArgs.IsOldValueMeaningful);
                Assert.AreEqual(true, eventArgs.IsNewValueMeaningful);
            }
コード例 #21
0
ファイル: TypeFactoryFacts.cs プロジェクト: pars87/Catel
            public void ResolvesTypeUsingDependencyInjectionFallBackToFirstConstructor()
            {
                var serviceLocator = new ServiceLocator();
                var typeFactory = serviceLocator.ResolveType<ITypeFactory>();

                var iniEntry = new IniEntry { Group = "group", Key = "key", Value = "value" };
                serviceLocator.RegisterInstance(iniEntry);

                var instance = typeFactory.CreateInstance<DependencyInjectionTestClass>();

                Assert.IsFalse(instance.UsedDefaultConstructor);
                Assert.AreEqual(iniEntry, instance.IniEntry);
                Assert.AreEqual(0, instance.IntValue);
                Assert.AreEqual(null, instance.StringValue);
            }
コード例 #22
0
        static void Main()
        {
            #region Exception Process
            AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) =>
            {
                HandleException(e.ExceptionObject as Exception);
            };
            // 处理UI线程异常
            Application.ThreadException += (object sender, ThreadExceptionEventArgs e) =>
            {
                HandleException(e.Exception);
            };
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadExit += new EventHandler(Application_ThreadExit);

            #endregion  Exception Process

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.EnableVisualStyles();
            Application.DoEvents();
            //Application.Run(new Waiting());
            Waiting.Show("正在加载程序,请稍候...", 20);

            bool existRunningInstance = ExistRunInstance();
            if (existRunningInstance)
            {
                CCMsgBox.Show("对不起,你已经运行了该程序!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);
                return;
            }

            Waiting.Show("正在测试数据库连接,请稍候...", 40);
            if (!TestDbConnect())
            {
                CCMsgBox.Show("对不起!数据库连接失败,请联系相关管理人员!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);
                return;
            }

            Waiting.Show("正在检测INI配置文件,请稍候...", 50);
            string iniFilePath = Path.Combine(Application.StartupPath, "ODConfig.ini");
            if (File.Exists(iniFilePath))
            {
                IniManager.Open(iniFilePath);
            }
            else
            {
                CreateIniFile(iniFilePath);
                CCMsgBox.Show("对不起!INI配置文件,请联系相关管理人员!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);
            }

            Waiting.Show("正在检测客户端信息,请稍候...", 60);
            SalesPointBusiness salesPointManage = new SalesPointBusiness();
            string             localMacAddress  = NetHelper.GetLocalMACAddress();
            if (!salesPointManage.ExistsMacAddress(localMacAddress))
            {
                CCMsgBox.Show("对不起!客户端信息不对,请先注册客户端信息或联系相关管理人员!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);
                return;
            }
            else
            {
            }

            Waiting.Show("正在检测营业点信息,请稍候...", 60);
            IniEntry iniEntry       = new IniEntry(iniFilePath);
            string   salesPointName = iniEntry.Sections["ClientInfo"]["SalesPointName"].ToString();
            if (!salesPointManage.Exists(salesPointName))
            {
                CCMsgBox.Show("对不起!营业点信息不对,请先注册营业点信息或联系相关管理人员!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);

                return;
            }
            else
            {
                CurrentSystemInfo.SalesPoint = salesPointManage.GetInstanceObj(new SalesPoint {
                    Name = salesPointName
                });
            }

            Waiting.Show("正在检测餐牌信息,请稍候...", 80);
            RestaurantTypeBusiness typeManage = new RestaurantTypeBusiness();

            if (!typeManage.Exists(iniEntry.Sections["ClientInfo"]["DishType"]))
            {
                CCMsgBox.Show("对不起!餐牌信息不对,请先配制餐牌信息或联系相关管理人员!", Application.ProductName, CCMsgBox.CButtons.OK, CCMsgBox.CIcon.Error);
                return;
            }
            else
            {
                CurrentSystemInfo.RestaurantType = typeManage.GetInstanceObj(new RestaurantType {
                    Name = iniEntry.Sections["ClientInfo"]["DishType"]
                });
            }

            Waiting.Show("正在读取餐段信息,请稍候...", 90);

            //string mealTypeId = new MealTimeManage().GetMealTimeId();

            MealTimesBusiness workShiftManager = new MealTimesBusiness();

            if (workShiftManager.GetInstanceList().Count < 1)
            {
                MessageBox.Show("对不起,没有找着餐段信息,请先配制餐牌信息!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
            }

            //Waiting.Show("正在同步系统时间,请稍候....", 80);
            // 同步时间
            //GetDbDateTime dbcomm = new GetDbDateTime();
            //dbcomm.SynchoronizeServerTime();

            ////InitForm();

            Waiting.Show("准备登录界面,请稍候....", 90);
            frmLogin login = new frmLogin();

            Waiting.Show("程序加载完成", 100);
            Waiting.Hide();



            //new FormMain().ShowDialog();
            while (login.ShowDialog() == DialogResult.OK)
            {
                //    dbcomm.SynchoronizeServerTime();                        // 再次同步时间

                login.Close();
            }
        }