Ejemplo n.º 1
0
        private void ResetAndSaveAppSettings()
        {
            ASettings.Reset();
            ASettings.Save();

            tbxMessasge.AppendText("app reset" + nl);
            DisplayAppSettingData();
        }
Ejemplo n.º 2
0
        public ADBContext(string hostname, int port, string dbname, string username, string password)
        {
            //todo: DBContext, need to be replaced with "connection strings in web.config"
            this.hostname = hostname;
            this.dbport   = port;
            this.dbname   = dbname;
            this.username = username;
            this.password = password;

            if (!ASettings.HasConnection("obieg"))
            {
                ASettings.AddConnection("obieg", hostname, dbport, false, dbname, username, password);
            }
        }
Ejemplo n.º 3
0
        private void ModifyAndSaveAppSettings()
        {
            ASet.AppS     = "generic app data " + V;
            ASet.AppB     = false;
            ASet.AppD     = V + 0.1;
            ASet.AppI     = V;
            ASet.AppIs[0] = V;

            ASettings.Save();

            tbxMessasge.AppendText("app after" + nl);

            DisplayAppSettingData();
        }
            public void Test()
            {
                var s = new ASettings
                {
                    StrValue = "test-str-value",
                    Nested   = new NestedSettings
                    {
                        Value = 42
                    }
                };
                var          container = Container(b => b.BindDependencyValue(typeof(A), typeof(ASettings), s));
                var          a         = container.Resolve <A>();
                const string expectedConstructionLog = @"
A
	ASettings const
		Nested
			Value -> 42
		StrValue -> test-str-value"        ;

                Assert.That(a.GetConstructionLog(), Is.EqualTo(FormatExpectedMessage(expectedConstructionLog)));
            }
Ejemplo n.º 5
0
        static Database()
        {
            TestDatabaseOneTime = "testOneTimeDatabase001xyzLatif";
            TestDatabaseGeneral = "testDatabaseGeneral001xyzLatif";

            TestDocumentCollectionName = "testDocumentCollection001xyzLatif";
            TestEdgeCollectionName     = "testEdgeCollection001xyzLatif";

            Alias       = "testAlias";
            SystemAlias = "systemAlias";
            Hostname    = "localhost";
            Port        = 8529;
            IsSecured   = false;
            UserName    = "******";
            Password    = "******";

            ASettings.AddConnection(
                SystemAlias,
                Hostname,
                Port,
                IsSecured,
                "_system",
                UserName,
                Password
                );

            ASettings.AddConnection(
                Alias,
                Hostname,
                Port,
                IsSecured,
                TestDatabaseGeneral,
                UserName,
                Password
                );
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 执行宏设置指令
        /// </summary>
        private void ExecuteMacroSet()
        {
            // get: @set settingItem
            // set: @set settingItem value
            List <string> paramList = GetMacroInstructionParametersList();

            switch (paramList.Count)
            {
            case 0:
                // List setting items.
                //string retnMessage = "可用的设置项: \n";
                string retnMessage = "Available setting items: ";
                foreach (string propertyName in ASettings.GetSettingsPropertiesName())
                {
                    retnMessage += propertyName + " ";
                }
                throw new NotImplementedException(retnMessage);

            case 1:
                // List available value and current value.
                if (0 == ASettings.GetSettingsPropertiesName().Where(p => p == paramList[0]).Count())
                {
                    //throw new NotImplementedException("设置项 [" + paramList[0] + "] 没有找到。");
                    throw new NotImplementedException("Setting item [" + paramList[0] + "] is not found.");
                }
                string targetPropertyName = paramList[0].Trim();
                //string availableValues = "可选值: ";
                string availableValues = "Available values: ";
                Type   t = typeof(ASettings).GetProperty(paramList[0]).GetValue(null).GetType();
                if (t.Equals(true.GetType()))
                {
                    availableValues += "True / False";
                }
                else if (t.Equals(typeof(AlterfulTheme)))
                {
                    foreach (AlterfulTheme theme in Enum.GetValues(typeof(AlterfulTheme)))
                    {
                        availableValues += theme + " / ";
                    }
                    availableValues = availableValues.Substring(0, availableValues.Length - 3);
                }
                throw new NotImplementedException(targetPropertyName + ": " + typeof(ASettings).GetProperty(paramList[0]).GetValue(null) as string + Environment.NewLine + availableValues);

            case 2:
                // Set value.
                if (0 == ASettings.GetSettingsPropertiesName().Where(p => p == paramList[0]).Count())
                {
                    //throw new NotImplementedException("设置项 [" + paramList[0] + "] 没有找到。");
                    throw new NotImplementedException("Setting item [" + paramList[0] + "] is not found.");
                }
                string targetPropertyName2 = paramList[0].Trim();
                string setValue            = paramList[1].Trim();
                //string availableValues2 = "可选值: ";
                string availableValues2 = "Available values: ";
                Type   t2 = typeof(ASettings).GetProperty(paramList[0]).GetValue(null).GetType();
                if (t2.Equals(true.GetType()))
                {
                    switch (setValue)
                    {
                    case "True":
                    case "true":
                        typeof(ASettings).GetProperty(paramList[0]).SetValue(null, true);
                        break;

                    case "False":
                    case "false":
                        typeof(ASettings).GetProperty(paramList[0]).SetValue(null, false);
                        break;

                    default:
                        // throw new NotImplementedException("无效的值。");
                        throw new NotImplementedException("Invalid value.");
                    }
                    availableValues2 += "True / False";
                }
                else if (t2.Equals(typeof(AlterfulTheme)))
                {
                    bool found = false;
                    foreach (AlterfulTheme theme in Enum.GetValues(typeof(AlterfulTheme)))
                    {
                        string a = theme.ToString();
                        if (theme.ToString().ToLower().Trim() == setValue.ToLower())
                        {
                            ATheme.Theme = theme;
                            found        = true;
                            //ReportInfo.Add("主题设置已经生效,但之前的内容样式不会更新,可用 @restart 来重启 Alterful。");
                            ReportInfo.Add("Theme config have changed, but early content won't be appply, you can @restart Alterful.");
                        }
                    }
                    if (!found)
                    {
                        throw new NotImplementedException("Theme [" + setValue + "] is not found.");             //throw new NotImplementedException("主题 [" + setValue + "] 没有找到。");
                    }
                }
                break;

            default:
                throw new MacroFormatException();
            }
        }
 public A(ASettings settings)
 {
     this.settings = settings;
 }