Example #1
0
        public void SendSettingsChangeEvent (SettingName settingName)
        {
            string label;

            switch (settingName) {
            case SettingName.AskForProject:
                label = "AskForProject";
                break;
            case SettingName.IdleNotification:
                label = "IdleNotification";
                break;
            case SettingName.DefaultMobileTag:
                label = "DefaultMobileTag";
                break;
            case SettingName.GroupedTimeEntries:
                label = "GroupedTimeEntries";
                break;
            case SettingName.ShowNotification:
                label = "ShowNotification";
                break;
            default:
                #if DEBUG
                throw new ArgumentException ("Invalid value", "settingName");
                #else
                return;
                #endif
            }

            SendEvent ("Settings", "Change", label);
        }
        public void GenerateNames_BaseName_NamesByFrequency()
        {
            var settingNameGenerator = new SettingNameGenerator();

            CollectionAssert.AreEqual(
                new[]
            {
                "baz.qux",
                "qux",
                "foo.bar+baz.qux",
            },
                settingNameGenerator.GenerateSettingNames(SettingName.Parse("foo.bar+baz.qux")).Select(name => (string)name).ToList());
        }
Example #3
0
    public static void SaveSetting(SettingName setting)
    {
        if (settingValues == null)
        {
            Load();
        }
        object value;

        if (settingValues.TryGetValue(setting, out value))
        {
            Util.SaveToPlayerPrefs("Settings" + Enum.GetName(typeof(SettingName), setting), value);
            //Debug.Log (Enum.GetName(typeof(SettingName),setting) + " saved as " + value.ToString());
        }
    }
Example #4
0
        /// <summary>Snippet for GetSettingAsync</summary>
        public async Task GetSettingResourceNamesAsync()
        {
            // Snippet: GetSettingAsync(SettingName, CallSettings)
            // Additional: GetSettingAsync(SettingName, CancellationToken)
            // Create client
            ResourceSettingsServiceClient resourceSettingsServiceClient = await ResourceSettingsServiceClient.CreateAsync();

            // Initialize request argument(s)
            SettingName name = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]");
            // Make the request
            Setting response = await resourceSettingsServiceClient.GetSettingAsync(name);

            // End snippet
        }
Example #5
0
        public static String[] GetAutoComplete(SettingName name, Context ctx)
        {
            SettingsServiceLocalDB svc = new SettingsServiceLocalDB(ctx);
            Settings setting           = svc.GetByName(name);

            if (setting == null)
            {
                setting       = new Settings();
                setting.Name  = name;
                setting.Val_1 = ",";
                svc.Insert(setting);
            }
            string[] result = setting.Val_1.Split(',');
            return(result);
        }
Example #6
0
 /// <summary>Snippet for GetSetting</summary>
 public void GetSettingRequestObject()
 {
     // Snippet: GetSetting(GetSettingRequest, CallSettings)
     // Create client
     ResourceSettingsServiceClient resourceSettingsServiceClient = ResourceSettingsServiceClient.Create();
     // Initialize request argument(s)
     GetSettingRequest request = new GetSettingRequest
     {
         SettingName = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
         View        = SettingView.Unspecified,
     };
     // Make the request
     Setting response = resourceSettingsServiceClient.GetSetting(request);
     // End snippet
 }
        public void TryFindSetting_DoesNotFindNotExistingSetting()
        {
            var provider = Mock.Create <ISettingProvider>();

            provider
            .Arrange(x => x.Read(Arg.IsAny <SelectQuery>()))
            .Returns(default(ISetting));

            var settingFound = FirstSettingFinder.TryFindSetting
                               (
                new SelectQuery(SettingName.Parse("Type.Member"), typeof(string)),
                new[] { provider },
                out var result
                               );

            Assert.IsFalse(settingFound);
        }
Example #8
0
        protected override void _Initialize()
        {
            if (_keyCodes.Count == 0)
            {
                foreach (KeyCode kc in Enum.GetValues(typeof(KeyCode)))
                {
                    _keyCodes.Add(kc);
                }
            }

            var path   = SettingName.Split('/');
            var header = path[1];

            _action = path[2];
            Setting.SetLabel($"{header}/{_action}");
            _button.onClick.AddListener(OnClick);
        }
Example #9
0
        /// <summary>Snippet for GetSettingAsync</summary>
        public async Task GetSettingRequestObjectAsync()
        {
            // Snippet: GetSettingAsync(GetSettingRequest, CallSettings)
            // Additional: GetSettingAsync(GetSettingRequest, CancellationToken)
            // Create client
            ResourceSettingsServiceClient resourceSettingsServiceClient = await ResourceSettingsServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetSettingRequest request = new GetSettingRequest
            {
                SettingName = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
                View        = SettingView.Unspecified,
            };
            // Make the request
            Setting response = await resourceSettingsServiceClient.GetSettingAsync(request);

            // End snippet
        }
        public IActionResult GetByName(string name)
        {
            if (name == null)
            {
                return(new BadRequestResult());
            }

            SettingName returnedSettingName = settingNameRepository.GetByName(name);

            if (returnedSettingName != null)
            {
                return(new OkObjectResult(returnedSettingName));
            }
            else
            {
                return(new NotFoundResult());
            }
        }
        public IActionResult Put([FromBody] SettingName settingName)
        {
            if (settingName == null)
            {
                return(new BadRequestResult());
            }

            bool isUpdated = settingNameRepository.Update(settingName);

            if (isUpdated)
            {
                return(new OkResult());
            }
            else
            {
                return(new BadRequestResult());
            }
        }
Example #12
0
        public void Read_CallsServicesAndInternalOverload()
        {
            var settingName        = new SettingName("prefix", "namespace", "type", "member", "instance");
            var settingNameFactory = Mock.Create <ISettingNameFactory>();
            var settingConverter   = Mock.Create <ISettingConverter>();

            settingNameFactory
            .Arrange(x => x.CreateProviderSettingName(
                         Arg.Matches <SettingName>(sn => sn == settingName),
                         Arg.IsAny <SettingProviderNaming>())
                     )
            .Returns(settingName)
            .OccursOnce();

            settingConverter
            .Arrange(x => x.Deserialize(
                         Arg.Matches <object>(value => value == (object)"TestValue"),
                         Arg.Matches <Type>(type => type == typeof(string))
                         ))
            .Returns("TestValue")
            .OccursOnce();

            var settingProvider = Mock.Create <SettingProvider>(Behavior.CallOriginal, settingNameFactory, settingConverter);

            Mock
            .NonPublic
            .Arrange <ISetting>(
                settingProvider,
                nameof(SettingProvider.Read),
                ArgExpr.Matches <SettingName>(sn => sn == settingName)
                )
            .Returns(new Setting(settingName.ToString(), "TestValue"))
            .MustBeCalled();

            var setting = settingProvider.Read(new SelectQuery(settingName, typeof(string)));

            settingNameFactory.Assert();
            settingProvider.Assert();
            settingConverter.Assert();

            Assert.IsNotNull(setting);
            Assert.AreEqual(settingName, setting.Name);
            Assert.AreEqual("TestValue", setting.Value);
        }
Example #13
0
        private void Setup(SettingName settingName, string url)
        {
            var componentName = settingName.ToString().Replace("Path", "");

            logger.Trace($"Install {componentName} started.");

            var downloadPath = FileHelper.GetUnusedFileName(Path.GetTempPath(), $"{componentName}.7z");

            logger.Trace($"{componentName} setup file path is {downloadPath}");

            var urlTesseract = "https://drive.google.com/uc?export=download&id=1tVu45QDZJK_x2jmpHJP9w2zD3DodhJ23";

            urlTesseract = url;

            (FindName($"RadProgressBarDownload{componentName}") as FrameworkElement).Visibility = Visibility.Visible;

            (FindName($"StatusInstall{componentName}") as RadMaskedTextInput).Value = "Downloading";

            (FindName($"BtnInstall{componentName}") as RadButton).IsEnabled = false;

            try
            {
                logger.Trace($"{componentName} setup file will be downloaded from {urlTesseract}");

                (FindName($"RadProgressBarDownload{componentName}") as RadProgressBar).Visibility = Visibility.Visible;

                using (WebClient webClient = new WebClient())
                {
                    webClient.DownloadProgressChanged += DownloadProgressChanged;
                    webClient.DownloadFileCompleted   += DownloadFileCompleted;
                    webClient.DownloadFileAsync(new Uri(urlTesseract), downloadPath, new DownloadFileAsyncState()
                    {
                        DownloadPath = downloadPath, SettingName = settingName
                    });
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"Exception has been thrown when downloading {componentName} setup file.");

                (FindName($"BtnInstall{componentName}") as RadButton).IsEnabled = true;
            }
        }
Example #14
0
        public Settings GetByName(SettingName settingname)
        {
            String[] projection =
            {
                FeedEntry.Id,
                FeedEntry.COLUMN_NAME_NAME,
                FeedEntry.COLUMN_NAME_VAL_1,
                FeedEntry.COLUMN_NAME_VAL_2,
                FeedEntry.COLUMN_NAME_VAL_3,
                FeedEntry.COLUMN_NAME_VAL_4,
                FeedEntry.COLUMN_NAME_VAL_5,
            };
            String selection = FeedEntry.COLUMN_NAME_NAME + " = ?";

            String[]     selectionArgs = { settingname.ToString() };
            String       sortOrder     = FeedEntry.COLUMN_NAME_NAME + " DESC";
            SQLiteCursor cursor        = (SQLiteCursor)db.Query(
                FeedEntry.TABLE_NAME,                     // The table to query
                projection,                               // The columns to return
                selection,                                // The columns for the WHERE clause
                selectionArgs,                            // The values for the WHERE clause
                null,                                     // don't group the rows
                null,                                     // don't filter by row groups
                sortOrder                                 // The sort order
                );

            cursor.MoveToFirst();
            Settings result = null;

            if (cursor.Count > 0)
            {
                result       = new Settings();
                result.Id    = cursor.GetLong(cursor.GetColumnIndexOrThrow(FeedEntry.Id));
                result.Name  = (SettingName)Enum.Parse(typeof(SettingName), cursor.GetString(cursor.GetColumnIndexOrThrow(FeedEntry.COLUMN_NAME_NAME)));
                result.Val_1 = cursor.GetString(cursor.GetColumnIndexOrThrow(FeedEntry.COLUMN_NAME_VAL_1));
                result.Val_2 = cursor.GetString(cursor.GetColumnIndexOrThrow(FeedEntry.COLUMN_NAME_VAL_2));
                result.Val_3 = cursor.GetString(cursor.GetColumnIndexOrThrow(FeedEntry.COLUMN_NAME_VAL_3));
                result.Val_4 = cursor.GetString(cursor.GetColumnIndexOrThrow(FeedEntry.COLUMN_NAME_VAL_4));
                result.Val_5 = cursor.GetString(cursor.GetColumnIndexOrThrow(FeedEntry.COLUMN_NAME_VAL_5));
                cursor.Close();
            }
            return(result);
        }
Example #15
0
        public static UpdateQuery CreateSetValueQuery <T>(SettingMetadata settingMetadata, T value, string instance)
        {
            var settingName = new SettingName
                              (
                prefix: settingMetadata.Prefix,
                schema: settingMetadata.Namespace,
                type: settingMetadata.TypeName,
                member: settingMetadata.MemberName,
                instance: instance
                              );

            return(new UpdateQuery(settingName, value)
            {
                ProviderName = settingMetadata.ProviderName,
                Strength = settingMetadata.SettingNameStrength,
                PrefixHandling = settingMetadata.PrefixHandling,
                ProviderType = settingMetadata.ProviderType
            });
        }
Example #16
0
        public SettingName CreateProviderSettingName(SettingName settingName, SettingProviderNaming providerNaming)
        {
            if (settingName == null)
            {
                throw new ArgumentNullException(nameof(settingName));
            }

            var tokens = TokenCombinations[(int)providerNaming.Strength].ToDictionary(t => t, t => settingName[t]);

            if (!settingName[Token.Instance].IsEmpty)
            {
                tokens.Add(Token.Instance, settingName[SettingNameToken.Instance]);
            }

            if (providerNaming.PrefixHandling == PrefixHandling.Enable && providerNaming.Prefix.IsNotNullOrEmpty())
            {
                tokens.Add(SettingNameToken.Prefix, providerNaming.Prefix.AsMemory());
            }

            return(new SettingName(tokens));
        }
Example #17
0
        public bool CheckSetting(SettingName settingName)
        {
            bool ret = true;
            try
            {
                // var settings = IsolatedStorageSettings.ApplicationSettings;
                // txtInput is a TextBox defined in XAML.
                if (settings.Contains(settingName.ToString()))
                {

                    var store = IsolatedStorageFile.GetUserStoreForApplication();
                    switch (settingName)
                    {
                        case SettingName.Shares:
                            ret =  store.DirectoryExists("/Shares");
                            break;
                        case SettingName.Users:
                            ret = store.FileExists("/Users/Users.xml");
                            break;
                        case SettingName.Activity:
                            ret = store.FileExists("/Activity/Activity.xml");
                            break;
                        default:
                            throw new Exception("Setting not implemented " + settingName.ToString() + "!!!");
                    }

                }
                else
                {
                    ret = false;
                }

            } catch(Exception)
            {
                // insabbiamento
                ret = false;
            }

            return ret;
        }
Example #18
0
        /// <summary>
        /// Update an existing settingName
        /// </summary>
        /// <param name="settingName"></param>
        public bool Update(SettingName settingName)
        {
            // First Check to make sure input values are valid
            // rules:
            // no duplicate values
            // SettingName.name less than 50 nchar
            // SettingName.name != null
            if (settingName.Name == null)
            {
                return(false);
            }

            if (GetByName(settingName.Name) != null || settingName.Name.Length > 50 || settingName.Name == "")
            {
                return(false);
            }

            using (IDbConnection dbConnection = Connection)
            {
                // update record with params at id location
                string sqlQueryUpdate = "Update SettingName " +
                                        "SET " +
                                        "Name = @Name " +
                                        "WHERE  SettingNameId = @Id";

                dbConnection.Open();

                try
                {
                    // update record
                    int rowsAffected = dbConnection.Execute(sqlQueryUpdate, settingName);
                    return(true);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
Example #19
0
        public void Equals_CanCompareSimilarObjects()
        {
            Assert.AreEqual(
                SettingName.Parse("foo.bar+baz.qux,quux"),
                SettingName.Parse("foo.bar+baz.qux,quux"));

            Assert.AreEqual(
                SettingName.Parse("baz.qux,quux"),
                SettingName.Parse("baz.qux,quux"));

            Assert.AreEqual(
                SettingName.Parse("qux,quux"),
                SettingName.Parse("qux,quux"));

            Assert.AreEqual(
                SettingName.Parse("foo.bar+baz.qux"),
                SettingName.Parse("foo.bar+baz.qux"));

            Assert.AreEqual(
                SettingName.Parse("qux"),
                SettingName.Parse("qux"));
        }
Example #20
0
        public void Write_CallsServicesAndInternalOverload()
        {
            var settingName        = new SettingName("prefix", "namespace", "type", "member", "instance");
            var settingNameFactory = Mock.Create <ISettingNameFactory>();
            var settingConverter   = Mock.Create <ISettingConverter>();

            settingNameFactory
            .Arrange(x => x.CreateProviderSettingName(
                         Arg.Matches <SettingName>(sn => sn == settingName),
                         Arg.IsAny <SettingProviderNaming>())
                     )
            .Returns(settingName)
            .OccursOnce();

            settingConverter
            .Arrange(x => x.Serialize(
                         Arg.Matches <object>(value => value == (object)"TestValue"))
                     )
            .Returns("TestValue")
            .OccursOnce();

            var settingProvider = Mock.Create <SettingProvider>(Behavior.CallOriginal, settingNameFactory, settingConverter);

            Mock
            .NonPublic
            .Arrange(
                settingProvider,
                nameof(SettingProvider.Write),
                ArgExpr.Matches <ISetting>(s => s.Name == settingName)
                )
            .MustBeCalled();

            settingProvider.Write(new UpdateQuery(settingName, "TestValue"));

            settingNameFactory.Assert();
            settingProvider.Assert();
            settingConverter.Assert();
        }
Example #21
0
        public void GetSetting()
        {
            moq::Mock <ResourceSettingsService.ResourceSettingsServiceClient> mockGrpcClient = new moq::Mock <ResourceSettingsService.ResourceSettingsServiceClient>(moq::MockBehavior.Strict);
            GetSettingRequest request = new GetSettingRequest
            {
                SettingName = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
            };
            Setting expectedResponse = new Setting
            {
                SettingName    = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
                Metadata       = new SettingMetadata(),
                LocalValue     = new Value(),
                EffectiveValue = new Value(),
                Etag           = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetSetting(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ResourceSettingsServiceClient client = new ResourceSettingsServiceClientImpl(mockGrpcClient.Object, null);
            Setting response = client.GetSetting(request.Name);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #22
0
        private void Check(SettingName settingName)
        {
            var componentName = settingName.ToString().Replace("Path", "");

            (FindName($"Installed{componentName}") as FrameworkElement).Visibility              = Visibility.Collapsed;
            (FindName($"NotInstalled{componentName}") as FrameworkElement).Visibility           = Visibility.Visible;
            (FindName($"RadProgressBarDownload{componentName}") as FrameworkElement).Visibility = Visibility.Hidden;

            bool isOk = false;

            if (settingName == SettingName.ImageMagickPath)
            {
                isOk = SetupManager.Instance.IsImageMagickInstalled;
            }

            //if (SetupManager.CheckOcrComponent(settingName))
            {
                (FindName($"Installed{componentName}") as FrameworkElement).Visibility    = Visibility.Visible;
                (FindName($"NotInstalled{componentName}") as FrameworkElement).Visibility = Visibility.Collapsed;
                (FindName($"BtnInstall{componentName}") as RadButton).Content             = "Reinstall";
            }

            (FindName($"BtnInstall{componentName}") as RadButton).IsEnabled = true;
        }
Example #23
0
        public void SendSettingsChangeEvent(SettingName settingName)
        {
            string label;

            switch (settingName)
            {
            case SettingName.AskForProject:
                label = "AskForProject";
                break;

            case SettingName.IdleNotification:
                label = "IdleNotification";
                break;

            case SettingName.DefaultMobileTag:
                label = "DefaultMobileTag";
                break;

            case SettingName.GroupedTimeEntries:
                label = "GroupedTimeEntries";
                break;

            case SettingName.ShowNotification:
                label = "ShowNotification";
                break;

            default:
                #if DEBUG
                throw new ArgumentException("Invalid value", "settingName");
                #else
                return;
                #endif
            }

            SendEvent("Settings", "Change", label);
        }
Example #24
0
 /// <summary>
 /// Gets the values of the Wiki Settings.
 /// </summary>
 /// <param name="name">The Setting's Name.</param>
 /// <returns>The Setting's value.</returns>
 public string GetSettingValue(SettingName name)
 {
     switch(name) {
         case SettingName.ContactEmail:
             return Settings.ContactEmail;
         case SettingName.DateTimeFormat:
             return Settings.DateTimeFormat;
         case SettingName.DefaultLanguage:
             return Settings.DefaultLanguage;
         case SettingName.RootNamespaceDefaultPage:
             return Settings.DefaultPage;
         case SettingName.DefaultTimeZone:
             return Settings.DefaultTimezone.ToString();
         case SettingName.MainUrl:
             return Settings.MainUrl;
         case SettingName.SenderEmail:
             return Settings.SenderEmail;
         case SettingName.WikiTitle:
             return Settings.WikiTitle;
         case SettingName.ThemesDirectory:
             return Settings.ThemesDirectory;
         case SettingName.PublicDirectory:
             return Settings.PublicDirectory;
         case SettingName.UsersCanRegister:
             return Settings.UsersCanRegister.ToString();
         case SettingName.UsernameRegex:
             return Settings.UsernameRegex;
         case SettingName.PasswordRegex:
             return Settings.PasswordRegex;
         case SettingName.EmailRegex:
             return Settings.EmailRegex;
         case SettingName.MainUrlRegex:
             return Settings.MainUrlRegex;
         case SettingName.EnableDoubleClickEditing:
             return Settings.EnableDoubleClickEditing.ToString();
         case SettingName.ProcessSingleLineBreaks:
             return Settings.ProcessSingleLineBreaks.ToString();
         case SettingName.AccountActivationMode:
             return Settings.AccountActivationMode.ToString();
         case SettingName.AllowedFileTypes:
             StringBuilder sb = new StringBuilder(50);
             foreach(string s in Settings.AllowedFileTypes) sb.Append(s + ",");
             return sb.ToString().TrimEnd(',');
         case SettingName.DisableAutomaticVersionCheck:
             return Settings.DisableAutomaticVersionCheck.ToString();
         case SettingName.DisableBreadcrumbsTrail:
             return Settings.DisableBreadcrumbsTrail.ToString();
         case SettingName.DisableCache:
             return Settings.DisableCache.ToString();
         case SettingName.DisableCaptchaControl:
             return Settings.DisableCaptchaControl.ToString();
         case SettingName.DisableConcurrentEditing:
             return Settings.DisableConcurrentEditing.ToString();
         case SettingName.EnableHttpCompression:
             return Settings.EnableHttpCompression.ToString();
         case SettingName.EnableViewStateCompression:
             return Settings.EnableViewStateCompression.ToString();
         case SettingName.LoggingLevel:
             return Settings.LoggingLevel.ToString();
         case SettingName.MaxFileSize:
             return Settings.MaxFileSize.ToString();
         case SettingName.PageExtension:
             return Settings.PageExtension;
         case SettingName.ScriptTagsAllowed:
             return Settings.ScriptTagsAllowed.ToString();
         case SettingName.WikiVersion:
             return Settings.WikiVersion;
         case SettingName.MaxLogSize:
             return Settings.MaxLogSize.ToString();
         case SettingName.MaxRecentChanges:
             return Settings.MaxRecentChanges.ToString();
         case SettingName.CacheSize:
             return Settings.CacheSize.ToString();
         case SettingName.CacheCutSize:
             return Settings.CacheCutSize.ToString();
         case SettingName.EditingSessionTimeout:
             return Collisions.EditingSessionTimeout.ToString();
         case SettingName.AdministratorsGroup:
             return Settings.AdministratorsGroup;
         case SettingName.UsersGroup:
             return Settings.UsersGroup;
         case SettingName.AnonymousGroup:
             return Settings.AnonymousGroup;
         case SettingName.ChangeModerationMode:
             return Settings.ChangeModerationMode.ToString();
         case SettingName.DefaultPagesStorageProvider:
             return Settings.DefaultPagesProvider;
         case SettingName.DefaultUsersStorageProvider:
             return Settings.DefaultUsersProvider;
         case SettingName.DefaultFilesStorageProvider:
             return Settings.DefaultFilesProvider;
         case SettingName.DefaultCacheProvider:
             return Settings.DefaultCacheProvider;
         case SettingName.RootNamespaceTheme:
             return Settings.GetTheme(null);
         case SettingName.ListSize:
             return Settings.ListSize.ToString();
     }
     return "";
 }
Example #25
0
 protected void AddSection(SettingName settingName)
 {
     CreateConfigurationDir(settingName.ToString() as string);
     CreateConfigurationFile(settingName.ToString(), settingName.ToString());
 }
Example #26
0
 protected void AddSection(SettingName settingName)
 {
     var node = CreateElement(settingName.ToString());
     FirstChild.AppendChild(node);
 }
Example #27
0
 private void Remove(SettingName section)
 {
     Remove(section.ToString());
 }
 public async Task <SettingEntity> FindNamedAsync(SettingName name)
 {
     return(await GroupGetAsync <SettingEntity>(name.ToString()).ConfigureAwait(false));
 }
Example #29
0
 public async Task<SettingEntity> FindNamedAsync(SettingName name)
 {
     return await GroupGetAsync<SettingEntity>(name.ToString()).ConfigureAwait(false);
 }
Example #30
0
 /// <summary>
 /// Gets the setting.
 /// </summary>
 /// <param name="setting">The setting.</param>
 /// <returns></returns>
 public string getSetting(SettingName setting)
 {
     return(ConfigurationManager.AppSettings[settingNames[setting]]);
 }
Example #31
0
 public Setting(SettingName settingName, string settingsValue, SettingType type)
 {
     Name  = settingName;
     Value = settingsValue;
     Type  = type;
 }
Example #32
0
 private static void Validate(this IEnumerable <ValidationAttribute> validations, SettingName settingName, object value)
 {
     foreach (var validation in validations)
     {
         validation.Validate(value, $"Setting {settingName.ToString().QuoteWith("'")} is not valid.");
     }
 }
Example #33
0
 public void Equals_CanCompareDifferentObjects()
 {
     Assert.AreNotEqual(
         SettingName.Parse("foo.bar+baz.qux,quux"),
         SettingName.Parse("foo.bar+baz.qux"));
 }
Example #34
0
 private static string SettingNameAsString(SettingName setting)
 {
     return(setting
            .ToString()
            .Replace('_', '-'));
 }
Example #35
0
 public void Parse_DisallowsInvalidFormat()
 {
     Assert.That.Throws <DynamicException>(() => SettingName.Parse("foo+bar+baz"), filter => filter.When(name: "^SettingNameFormat"));
 }
Example #36
0
    public void OpenSetting(SettingName settingName)
    {
        ClearInputView();

        m_activeSetting = settingName;

        if (settingName == SettingName.ConduitDiameter || settingName == SettingName.BenderRadius)
        {
            SettingNumeric setting = (SettingNumeric)Instantiate(settingNumericPrefab, inputView, false);

            SettingNumeric.OnValue onValueFn;
            float unitMultiplier,
                  bigIncDec,
                  smallIncDec,
                  minValue,
                  maxValue,
                  value;
            string description;

            if (settingName == SettingName.ConduitDiameter)
            {
                settingHeaderText.text = "Conduit Diameter";

                if (Engine.unitType == Units.Type.Metric)
                {
                    bigIncDec      = 1f;
                    smallIncDec    = 0.1f;
                    unitMultiplier = Units.k_MToCm;
                }
                else
                {
                    bigIncDec      = 1f;
                    smallIncDec    = 0.0625f;
                    unitMultiplier = Units.k_MToIn;
                }

                minValue    = Settings.k_minConduitDiameterM * unitMultiplier;
                maxValue    = Settings.k_maxConduitDiameterM * unitMultiplier;
                value       = Engine.conduitDiameterM * unitMultiplier;
                description = k_conduitDiameterDescription;
                onValueFn   = OnConduitDiameter;
            }
            else
            {
                settingHeaderText.text = "Bender Radius";

                if (Engine.unitType == Units.Type.Metric)
                {
                    bigIncDec      = 1f;
                    smallIncDec    = 0.1f;
                    unitMultiplier = Units.k_MToCm;
                }
                else
                {
                    bigIncDec      = 1f;
                    smallIncDec    = 0.0625f;
                    unitMultiplier = Units.k_MToIn;
                }

                minValue    = Settings.k_minBenderRadiusM * unitMultiplier;
                maxValue    = Settings.k_maxBenderRadiusM * unitMultiplier;
                value       = Engine.benderRadiusM * unitMultiplier;
                description = k_benderRadiusDescription;
                onValueFn   = OnBenderRadius;
            }

            // Setup the Numeric input widget
            setting.Setup(minValue, maxValue,
                          bigIncDec, smallIncDec,
                          description,
                          Engine.unitType == Units.Type.Metric ? Units.RulerUnit.Centimeters : Units.RulerUnit.Inches);
            setting.value          = value;
            setting.onPresetClick += OpenPresets;
            setting.onValue       += onValueFn;
        }
        else if (settingName == SettingName.CameraControls)
        {
            settingHeaderText.text = "Camera Controls";

            SettingSliders setting = (SettingSliders)Instantiate(settingSlidersPrefab, inputView, false);

            setting.Setup(k_cameraControlsDescription);
            setting.AddSlider("Tilt", Engine.cameraTiltSensitivity, 2f, OnTiltSensitivity);
            setting.AddSlider("Movement", Engine.cameraRailSensitivity, 2f, OnMovementSensitivity);
        }
        else if (settingName == SettingName.Audio)
        {
            // TODO
        }
    }
 public override string Id()
 {
     return($"{PortalID}{IdSep}{SettingName.Replace(IdSep, IdSepReplace)}{IdSep}{CultureCode}");
 }
        public string GetSettingValue(SettingName name)
        {
            switch (name)
            {
                case SettingName.PublicDirectory:
                    return this.workingDirectory;

                case SettingName.CacheSize:
                    return "1000";

                default:
                    throw new NotImplementedException();
            }
        }