public ConfigurationService(IConfigurationRepository configurationRepository, IConfiguration configuration)
 {
     _configurationRepository = configurationRepository;
     if (DateTime.UtcNow > _lastCache.AddMinutes(CacheRefreshMinutes))
     {
         ConfigurationSettings.Load(configurationRepository, configuration);
         _lastCache = DateTime.UtcNow;
     }
 }
        public CodeInspectSetting()
        {
            InitializeComponent();
            configurationSettings = new ConfigurationSettings();
            configurationSettings = configurationSettings.Load();
            if (configurationSettings == null || (configurationSettings != null && configurationSettings.CodingRules.Count == 0))
            {
                Rules = new ObservableCollection<CodingRule>();
                Rules.Add(new CodingRule() { RuleName = "Class Property Name", Type=CodingRulesTypeEnum.ClassPropertyName, RuleCase = CodingRuleCaseEnum.Normal, RuleFirstLetter = "" });
                Rules.Add(new CodingRule() { RuleName = "Class Variable Name", Type = CodingRulesTypeEnum.ClassVariableName, RuleCase = CodingRuleCaseEnum.UpperCamelCase, RuleFirstLetter = "_" });
            }
            else
            {
                Rules = configurationSettings.CodingRules;

            }
            //listOfRules.ItemsSource = rules;
        }
예제 #3
0
        /// <summary>
        /// Check for class property matching rules
        /// </summary>
        /// <param name="neosSdiMef"></param>
        public static void ParseProperty(this NeosSdiMef neosSdiMef)
        {
            ConfigurationSettings configurationSettings = new ConfigurationSettings();
            configurationSettings = configurationSettings.Load();

            CodingRule rule = configurationSettings.CodingRules.Where(p => p.Type == NeosSdiConfiguration.Controls.Helpers.CodingRulesTypeEnum.ClassPropertyName).SingleOrDefault();

            var root = (CompilationUnitSyntax)neosSdiMef.tree.Root;
            var _properties = root.DescendentNodes()
                        .OfType<Roslyn.Compilers.CSharp.PropertyDeclarationSyntax>()
                        .ToList();

            foreach (var _property in _properties)
            {
                string text = _property.Identifier.ValueText;
                string textFull = _property.ToString().Replace(System.Environment.NewLine, "");
                CheckFormat.CheckForFormat(neosSdiMef, rule, _property, text, textFull, _property.Identifier.Span.Start, _property.Identifier.Span.End);
            }
        }
        public void ConfigurationSettings_ReturnsCorrectValueForConfiguration()
        {
            //Arrange
            const string configKey   = "KeyStoreLocation";
            const string configValue = "SomeLocation";

            var configurationMock           = new Mock <IConfiguration>();
            var configurationRepositoryMock = new Mock <IConfigurationRepository>();

            configurationRepositoryMock.Setup(x => x.GetValueByKey(It.IsAny <string>())).Returns <string>(x => x == configKey ? configValue : "");

            var configurationSettings = new ConfigurationSettings();

            //Act
            configurationSettings.Load(configurationRepositoryMock.Object, configurationMock.Object);

            //Assert
            Assert.AreEqual(configurationSettings.KeyStoreLocation, configValue);
        }
예제 #5
0
        public static IConfigurationService GetConfigurationSettings(Dictionary <string, string> configurations = null, List <KeyValuePair <string, string> > appSettingsConfigs = null)
        {
            var defaultConfigruations = new Dictionary <string, string>()
            {
                { "FncConnectKey", "5Y1YOS2Y7KACO5CBUPCBZXV7A5UP0N72UV2Y875D" },
                { "FncConnectSecret", "YUOL3E70K2VL8F8143ABSVUJC3ZAJSZRBCI4N1G7" },
                { "FncConnectUrl", "https://dev.fncconnect.com/" },
                { "FncFileVaultUrl", "https://devbravo.fncinc.com/FileVault/" }
            };

            configurations = configurations ?? new Dictionary <string, string>();

            foreach (var entry in configurations)
            {
                if (defaultConfigruations.ContainsKey(entry.Key))
                {
                    defaultConfigruations[entry.Key] = entry.Value;
                }
                else
                {
                    defaultConfigruations.Add(entry.Key, entry.Value);
                }
            }

            appSettingsConfigs = appSettingsConfigs ?? new List <KeyValuePair <string, string> >();

            var configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(appSettingsConfigs)
                                    .Build();

            var configurationRepositoryMock = new Mock <IConfigurationRepository>();

            configurationRepositoryMock.Setup(x => x.GetValueByKey(It.IsAny <string>())).Returns <string>(x => defaultConfigruations.ContainsKey(x) ? defaultConfigruations[x] : "");

            var configurationSettings = new ConfigurationSettings();

            configurationSettings.Load(configurationRepositoryMock.Object, configurationRoot);
            return(new ConfigurationService(configurationRepositoryMock.Object, configurationRoot));
        }