private static bool IsFromOptions(Type type, SettingsOptions options)
        {
            try
            {
                var info = type.GetTypeInfo();

                if (info.GetCustomAttribute(options.AttributeType, true) != null)
                {
                    return(true);
                }

                if (options.InterfaceBase.GetTypeInfo().IsAssignableFrom(info))
                {
                    return(true);
                }

                if (info.Name.ToLower().EndsWith(options.SettingsSuffix.Trim().ToLower()))
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception e)
            {
                throw new SettingsExtractionException(type, e);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generate AWS Settings file(s)
        /// </summary>
        /// <param name="settingsOptions"></param>
        /// <returns></returns>
        public static int RunSettings(SettingsOptions settingsOptions)
        {
            var logger = new Logger();

            try
            {
                if (string.IsNullOrEmpty(settingsOptions.StackName))
                {
                    throw new Exception($"Error: no StackName provided");
                }

                var json = (settingsOptions.MethodMap)
                    ? AwsConfig.GenerateMethodMapJsonAsync(
                    settingsOptions.ProfileName,
                    settingsOptions.StackName).GetAwaiter().GetResult()
                    : AwsConfig.GenerateSettingsJsonAsync(
                    settingsOptions.ProfileName,
                    settingsOptions.StackName).GetAwaiter().GetResult();

                if (string.IsNullOrEmpty(settingsOptions.OutputFilePath))
                {
                    Console.Write(json);
                }
                else
                {
                    File.WriteAllText(settingsOptions.OutputFilePath, json);
                }
            }
            catch (Exception e)
            {
                logger.Error(e, e.Message);
                return(-1);
            }
            return(1);
        }
Exemplo n.º 3
0
        public object ConvertValue(object value, PropertyInfo propertyInfo, SettingsOptions options)
        {
            var propertyType = propertyInfo.PropertyType;

            if (value == null)
            {
                ValidateNullAcceptance(propertyInfo);

                if (!propertyType.IsEnumerable())
                {
                    return(propertyType.GetTypeInfo().IsValueType ? Activator.CreateInstance(propertyType) : null);
                }

                var genericType     = propertyType.GetTypeInfo().GetGenericArguments().First();
                var method          = typeof(Enumerable).GetTypeInfo().GetMethod("Empty").MakeGenericMethod(genericType);
                var emptyEnumerable = method.Invoke(null, null);
                return(emptyEnumerable);
            }

            var strippedType = StripIfNullable(propertyType);

            var settingsTypeConverter = GetConverter(strippedType, propertyInfo, options);

            return(settingsTypeConverter.Convert(value, strippedType));
        }
Exemplo n.º 4
0
        public void ValidateOptions(SettingsOptions settingsOptions)
        {
            if (settingsOptions.AttributeType == null &&
                settingsOptions.InterfaceBase == null &&
                string.IsNullOrWhiteSpace(settingsOptions.SettingsSuffix))
            {
                throw new SettingsOptionsArgumentNullException();
            }

            if (!typeof(Attribute).GetTypeInfo().IsAssignableFrom(settingsOptions.AttributeType))
            {
                throw new SettingsOptionNonAttributeException(settingsOptions.AttributeType);
            }


            if (string.IsNullOrWhiteSpace(settingsOptions.ArraySplitDelimiter))
            {
                throw new SettingsOptionsArgumentMissingException(nameof(settingsOptions.ArraySplitDelimiter));
            }

            if (string.IsNullOrWhiteSpace(settingsOptions.DateTimeFormat))
            {
                throw new SettingsOptionsArgumentMissingException(nameof(settingsOptions.DateTimeFormat));
            }

            if (settingsOptions.SectionNameFormatter == null)
            {
                throw new SettingsOptionsArgumentMissingException("SectionNameFormatter");
            }
        }
Exemplo n.º 5
0
        public static string GetSectionName(this Type settingsClass, SettingsOptions options)
        {
            var attribute = settingsClass.GetTypeInfo().GetCustomAttribute <SettingsSectionAttribute>(true);

            return(!string.IsNullOrWhiteSpace(attribute?.Name)
                                ? attribute.Name
                                : options.SectionNameFormatter(settingsClass));
        }
Exemplo n.º 6
0
    public static void SavingOptionData(string savePath)
    {
        File saveData = new File();

        saveData.Open(savePath, File.ModeFlags.Write);
        saveData.StoreLine(JSON.Print(SettingsOptions.GetData()));
        saveData.Close();
    }
 public TypeConvertersCollections(SettingsOptions settingsOptions)
 {
     AddLast(new DateTimeTypeConverter(settingsOptions));
     AddLast(new UriTypeConvertor());
     AddLast(new ArrayTypeConverter(settingsOptions, this));
     AddLast(new EnumerableTypeConverter(settingsOptions, this));
     AddLast(new DefaultTypeConverter());
 }
Exemplo n.º 8
0
    public void UpdatingKeyConfig()
    {
        InputEventKey updatedKey = SettingsOptions.GetInputFromKey(input);

        InputHandler.SetActionFromInput(InputHandler.GetNameFromKey(input), updatedKey);
        button.Text  = OS.GetScancodeString(updatedKey.Scancode);
        previousText = button.Text;
    }
Exemplo n.º 9
0
 public MyAccountController(IDbContextFetcher dbContextFetcher, UserManager <MoxUser> userManager, RoleManager <IdentityRole> roleManager, IUserRolesFetcher rolesFetcher, SignInManager <MoxUser> signInManager, IOptions <SettingsOptions> settingsExtension)
 {
     this._context           = dbContextFetcher.FetchDbContext <Data.MoxIdentityDbContext>();
     this._userManager       = userManager;
     this._roleManager       = roleManager;
     this._rolesFetcher      = rolesFetcher as Services.UserRolesFetcher;
     this._signinManager     = signInManager;
     this._settingsExtension = settingsExtension.Value;
 }
Exemplo n.º 10
0
 public RevendedorService(AppDbContext context, HistoricoService historicoService, HelperService helperService,
                          IOptions <SettingsOptions> settingsOptions, ILogger <RevendedorService> logger)
 {
     this.context          = context;
     this.historicoService = historicoService;
     this.helperService    = helperService;
     this.settingsOptions  = settingsOptions.Value;
     this.logger           = logger;
 }
Exemplo n.º 11
0
        public TasksInicializer(IOptions <SettingsOptions> settingsOptions, ILoggerFactory loggerFactory, IServiceProvider serviceProvider)
        {
            _settingsOptions = settingsOptions?.Value;
            _loggerFactory   = loggerFactory;
            _logger          = loggerFactory.CreateLogger <TasksInicializer>();
            _serviceProvider = serviceProvider;

            InstanceId = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
        }
Exemplo n.º 12
0
 public override void _Ready()
 {
     button      = GetChild <Button>(0);
     button.Text = ((InputEvent)InputMap.GetActionList(InputHandler.GetNameFromKey(input))[0]).AsText();
     GetChild <RichTextLabel>(1).Text = text;
     button.Connect("pressed", this, nameof(ButtonPressed));
     SettingsOptions.RegisterUpdatedEvent(UpdatingKeyConfig);
     previousText = button.Text;
 }
Exemplo n.º 13
0
    public override void _Ready()
    {
        Button holder = GetChild <Button>(0);

        holder.Pressed = SettingsOptions.GetSetting <bool>(optionName);
        holder.Connect("toggled", this, nameof(ChangeSetting));
        button = holder;
        SettingsOptions.RegisterUpdatedEvent(UpdateValue);
        button.Text = text;
    }
Exemplo n.º 14
0
 public override void _Ready()
 {
     instance = this;
     datas[0] = SavingAndLoading.LoadingGameSaveData(savePath + "0" + savePathEnd);
     datas[1] = SavingAndLoading.LoadingGameSaveData(savePath + "1" + savePathEnd);
     datas[2] = SavingAndLoading.LoadingGameSaveData(savePath + "2" + savePathEnd);
     SavingAndLoading.LoadingOptionsSaveData("user://Option.save");
     AllDataLoaded = true;
     SettingsOptions.RegisterUpdatedEvent(UpdateGameSettings);
 }
Exemplo n.º 15
0
        public void ValidateOptions_WhenHasNoSectionNameFormater_ShouldThrowException()
        {
            var options = new SettingsOptions
            {
                SectionNameFormatter = null
            };
            var sut = GetSut();

            Assert.Throws <SettingsOptionsArgumentMissingException>(() => sut.ValidateOptions(options));
        }
Exemplo n.º 16
0
 public async Task <IActionResult> Get()
 {
     using (var repository = new Repository(HttpContext.GetUserGuid()))
     {
         var settingsOptions = new SettingsOptions();
         settingsOptions.IsPlayerAdmin = AuthorizeService.HashRight(repository.ServiceUser?.Role, Rights.EditPlayer);
         settingsOptions.Roles         = repository.Context.Roles.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
         return(Ok(settingsOptions));
     }
 }
Exemplo n.º 17
0
        public void ValidateOptions_WhenHasNoArrayDelimiter_ShouldThrowException(string delimiter)
        {
            var options = new SettingsOptions()
            {
                ArraySplitDelimiter = delimiter
            };

            var sut = GetSut();

            Assert.Throws <SettingsOptionsArgumentMissingException>(() => sut.ValidateOptions(options));
        }
Exemplo n.º 18
0
        public void ValidateOptions_WhenHasNoDateTimeFormat_ShouldThrowException(string format)
        {
            var options = new SettingsOptions()
            {
                DateTimeFormat = format
            };

            var sut = GetSut();

            Assert.Throws <SettingsOptionsArgumentMissingException>(() => sut.ValidateOptions(options));
        }
Exemplo n.º 19
0
        public void ValidateOptions_WhenAttributeTypeIAnAttribute_ShouldPassValidation()
        {
            var options = new SettingsOptions()
            {
                AttributeType = typeof(SomeAttribute)
            };

            var sut = GetSut();

            sut.ValidateOptions(options);
        }
Exemplo n.º 20
0
        public void ValidateOptions_WhenAttributeTypeIsNotAnAttribute_ShouldThrowException()
        {
            var options = new SettingsOptions()
            {
                AttributeType = typeof(NotAttribute)
            };

            var sut = GetSut();

            Assert.Throws <SettingsOptionNonAttributeException>(() => sut.ValidateOptions(options));
        }
Exemplo n.º 21
0
 private bool SprintOutput()
 {
     if (SettingsOptions.GetSetting <bool>(SettingsNames.toggleSprint))
     {
         if (Input.IsActionJustPressed("Sprint"))
         {
             sprintToggleOn = !sprintToggleOn;
         }
         return(sprintToggleOn);
     }
     return(Input.IsActionPressed("Sprint"));
 }
Exemplo n.º 22
0
 public UserManagementController(IDbContextFetcher dbContextFetcher, IUserValidator <MoxUser> userValidator, UserManager <MoxUser> userManager, RoleManager <IdentityRole> roleManager, IUserRolesFetcher rolesFetcher, SignInManager <MoxUser> signInManager, IStringLocalizer localizer, IOptions <SettingsOptions> settingsExtension, IOptions <MoxIdentityOptions> identityOptions)
 {
     this._context           = dbContextFetcher.FetchDbContext <Data.MoxIdentityDbContext>();
     this._userValidator     = userValidator;
     this._userManager       = userManager;
     this._roleManager       = roleManager;
     this._rolesFetcher      = rolesFetcher as Services.UserRolesFetcher;
     this._signinManager     = signInManager;
     this._localizer         = localizer;
     this._settingsExtension = settingsExtension.Value;
     this._identityOptions   = identityOptions.Value;
 }
Exemplo n.º 23
0
    public static void LoadingOptionsSaveData(string savePath)
    {
        File saveData = new File();

        if (saveData.FileExists(savePath))
        {
            saveData.Open(savePath, File.ModeFlags.Read);
            Dictionary settingsOption = (Dictionary)JSON.Parse(saveData.GetLine()).Result;
            SettingsOptions.SetData(settingsOption);
        }
        saveData.Close();
    }
        public Settings GetSettings(SettingsOptions options)
        {
            var tenderOptions = new List <TenderOption>();

            if (options.TenderTypes?.Count > 0)
            {
                tenderOptions.AddRange(options.TenderTypes);
            }

            // Create receipt options and add a default value
            var receiptOptions = new List <ReceiptOption>();

            receiptOptions.Add(new ReceiptOption()
            {
                Id          = "0",
                ReceiptType = ReceiptType.Order,
                DisplayName = "Customer"
            });

            if (options.IsMultiplePrintOptions)
            {
                receiptOptions.Add(new ReceiptOption()
                {
                    Id          = "1",
                    ReceiptType = ReceiptType.Order,
                    DisplayName = "Extended"
                });
            }

            //Create Header printer options
            var printerOption = new PrinterOption()
            {
                PrintMode     = PrinterMode.POS,
                Location      = options.CustomReceiptLocation,
                StaticReceipt = new List <string>()
                {
                    "------------------------",
                    "Some generic text",
                    "that will print before",
                    "every eftpos receipt",
                    "if PrintMode = STATIC",
                    "and location = header",
                }
            };

            return(new Settings()
            {
                TenderOptions = tenderOptions,
                ReceiptOptions = receiptOptions,
                PrinterOption = printerOption
            });
        }
Exemplo n.º 25
0
 protected override bool OnSwap()
 {
     if (SettingsOptions.ChangesMade())
     {
         if (confirm == null)
         {
             confirm = GetNode <Control>(confirmPath);
         }
         GameManager.Instance.currentMenu.AddonToCurrent(confirm);
         return(false);
     }
     return(true);
 }
Exemplo n.º 26
0
 public ApiKeyAuthenticationHandler(
     IOptionsMonitor <ApiKeyAuthenticationOptions> options,
     ILoggerFactory logger,
     UrlEncoder encoder,
     ISystemClock clock, IOptionsMonitor <SettingsOptions> settingsOptions) : base(options, logger, encoder, clock)
 {
     _logger          = logger.CreateLogger(nameof(ApiKeyAuthenticationHandler));
     _settingsOptions = settingsOptions.CurrentValue;
     settingsOptions.OnChange(config =>
     {
         _settingsOptions = config;
         _logger.LogInformation("The SettingsOptions has been updated.");
     });
 }
Exemplo n.º 27
0
 public void ToggleMenu(bool state)
 {
     if (state)
     {
         SwapToHud();
         SettingsOptions.ResetNewSettings();
         mainNode = menu;
     }
     else
     {
         hud.Visible      = false;
         mainNode.Visible = true;
     }
 }
Exemplo n.º 28
0
 public override void _Input(InputEvent @event)
 {
     if (readingInput)
     {
         if (@event is InputEventKey key)
         {
             readingInput = false;
             string newName = OS.GetScancodeString(key.Scancode);
             button.Text  = newName;
             previousText = button.Text;
             SettingsOptions.UpdateKeyData(input, key);
         }
     }
 }
Exemplo n.º 29
0
 public override void _Ready()
 {
     number = GetChild <SpinBox>(0);
     slider = GetChild <Slider>(1);
     number.Connect("value_changed", this, nameof(ValuesChanged));
     slider.Connect("value_changed", this, nameof(ValuesChanged));
     number.MaxValue = max;
     slider.MaxValue = max;
     slider.MinValue = min;
     number.MinValue = min;
     GetChild <RichTextLabel>(2).BbcodeText = "[center]" + name + "[/center]";
     number.Value = SettingsOptions.GetSetting <float>(optionName) * multiplier;
     slider.Value = number.Value;
     SettingsOptions.RegisterUpdatedEvent(UpdateValue);
 }
Exemplo n.º 30
0
        public void ValidateOptions_WhenAttributeAndInterfaceAndSuffixAreMissing_ShouldThrowException(Type attributeType,
                                                                                                      Type interfaceType,
                                                                                                      string suffix)
        {
            var options = new SettingsOptions()
            {
                AttributeType  = attributeType,
                InterfaceBase  = interfaceType,
                SettingsSuffix = suffix
            };

            var sut = GetSut();

            Assert.Throws <SettingsOptionsArgumentNullException>(() => sut.ValidateOptions(options));
        }