예제 #1
0
 protected bool WithAButtonEditor(ConfigurationEntry Sender, Object Value) {
     //MessageBox.Show(Sender.ControlType.ToString());
     using (var form = new ValueMatrixForm()) {
         form.ShowDialog(this);
     }
     return false;
 }
예제 #2
0
 protected override void Configure(ConfigurationEntry entry)
 {
     entry.Name        = "UrlPingCheck";
     entry.Description = "This check will ping a set of urls (including data apis; use Headers property to control Accept type) and " +
                         "raise notifications if the ping fails or is too slow. You can control the failure threshold using the 'NotificationThreshold' " +
                         "property of the configuration; set it to the number of milliseconds that the endpoint must respond by.";
     entry.Tags.AddIfMissing("Url", "Ping", "Threshold");
 }
 private static void SetIfHasValue(this ConfigurationEntry <string> value, Func <string, IWorldSpawnBuilder> apply)
 {
     if (value is not null &&
         value.Value.IsNotEmpty())
     {
         apply(value.Value);
     }
 }
예제 #4
0
        public FileLoggerImpl(string logFilePath)
            : base(null, null)
        {
            ConfigurationEntry cfg = new ConfigurationEntry("fl");

            cfg.putDetail(ConfigurationParamsEnum.Path.ToString(), logFilePath);

            this.Config = cfg;
        }
예제 #5
0
        void config_ValidateValue(ConfigurationEntry Sender, ref object Value, out bool Valid) {
            var s = (string)Value;
            if (s == null) {
                Value = "";
                Valid = true;
            }

            Valid = s.StartsWith("test");
        }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ConfigurationEntry configurationEntry = new ConfigurationEntry();

        configurationEntry.AlboBanners  = false;
        configurationEntry.numOfBanners = 4;
        Response.Write(JsonConvert.SerializeObject(configurationEntry));

        Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
    }
예제 #7
0
        public string GetRemoteOriginUrl()
        {
            using (var repo = new Repository(_gitRepoPath))
            {
                ConfigurationEntry <string> remote = repo.Config.First(c =>
                                                                       c.Key.Equals("remote.origin.url", StringComparison.InvariantCultureIgnoreCase));

                return(remote.Value);
            }
        }
예제 #8
0
        private void ValueMatrixForm_Load(object sender, EventArgs e) {
            var config = new ConfigurationEntry() {
                Name = "test",
                Value = dict
            };

            config.ValidateValue += new ConfigurationEntry.ValidateEvent(config_ValidateValue);
            config.FormatValue += new ConfigurationEntry.FormatValueHandler(config_FormatValue);

            valueMatrix1.ConfigEntry = config;
        }
예제 #9
0
 public RestCatalogueEntry(ConfigurationEntry entry)
     : this()
 {
     Name               = entry.Name;
     Description        = entry.Description;
     Tags               = entry.Tags;
     InterfaceType      = entry.PluginType;
     ConcreteType       = entry.ConfigurationType;
     Data               = entry.Data;
     RequiredProperties = entry.RequiredProperties.Select(p => new NameValuePair(p)).ToList();
 }
예제 #10
0
 public RestCatalogueEntry(ConfigurationEntry entry)
     : this()
 {
     Name = entry.Name;
     Description = entry.Description;
     Tags = entry.Tags;
     InterfaceType = entry.PluginType;
     ConcreteType = entry.ConfigurationType;
     Data = entry.Data;
     RequiredProperties = entry.RequiredProperties.Select(p => new NameValuePair(p)).ToList();
 }
예제 #11
0
        private string GetSettingValue(string settingKey)
        {
            ConfigurationEntry configurationEntry =
                _avroConfiguration.Bindings.SingleOrDefault(b => b.key.EndsWith(settingKey, StringComparison.OrdinalIgnoreCase));

            if (configurationEntry == null)
            {
                return(string.Empty);
            }

            return(configurationEntry.value);
        }
        public async Task Handle(ConfigurationEntryDeleted message)
        {
            message.ArgumentNotNull(nameof(message));

            await this.UpdateProjectAsync(message);

            ConfigurationEntry entry = this.dbContext.Entries.Single(p => p.Id == message.EntryId);

            this.dbContext.Entries.Remove(entry);

            await this.dbContext.SaveChangesAsync();
        }
예제 #13
0
        /// <summary>
        /// Applies the configuration settings from the given dictionary of setting entries, into the configuration object.
        /// </summary>
        /// <param name="entries"></param>
        internal static void ApplyConfigurationSettings(Dictionary <string, ConfigurationEntry> entries)
        {
            foreach (var config_instance in GetConfigurationInstances())
            {
                if (!entries.ContainsKey(config_instance.EntryName))
                {
                    continue;
                }
                ConfigurationEntry config_entry = entries[config_instance.EntryName];

                config_entry.Apply(config_instance.Instance);
            }
        }
예제 #14
0
 private AvroConfiguration ToAvroConfiguration()
 {
     HashSet<ConfigurationEntry> b = new HashSet<ConfigurationEntry>();
     ConfigurationEntry e1 = new ConfigurationEntry();
     e1.key = "a";
     e1.value = "a1";
     ConfigurationEntry e2 = new ConfigurationEntry();
     e2.key = "b";
     e2.value = "b1=b2";
     b.Add(e1);
     b.Add(e2);
     var a = new AvroConfiguration(Language.Cs.ToString(), b);
     return a;
 }
예제 #15
0
        private async Task LoadServiceDefinitionAsync(CancellationToken cancelToken)
        {
            var getServiceDefinitionResponse = await m_client.ServiceMethods.GetServiceDefinition(
                new ServiceDefinitionResponseSections[] { ServiceDefinitionResponseSections.Platform },
                cancelToken);

            ConfigurationEntry[] entires = getServiceDefinitionResponse.Platform.ConfigurationEntries;

            ConfigurationEntry liveIdAuthPolicyConfig = entires.FirstOrDefault(configEntry => configEntry.Key.Equals("liveIdAuthPolicy"));

            m_serviceDefinition = new ServiceDefinitionProxy {
                LiveIdAuthPolicy = liveIdAuthPolicyConfig.Value
            };
        }
예제 #16
0
        private void ShowUser(bool isGlobal)
        {
            ConfigurationLevel level = isGlobal ? ConfigurationLevel.Global : ConfigurationLevel.Local;

            using Repository repo = new Repository(Environment.CurrentDirectory);

            ConfigurationEntry <string> emailEntry = repo.Config.Get <string>("user.email", level);

            if (emailEntry == null)
            {
                Log.Red($"{level.ToString()} user is not set.");
                return;
            }

            Log.Green($"The {level.ToString()} user is set to {emailEntry.Value}");
        }
예제 #17
0
        public T Get <T>(string key, T defaultValue)
        {
            var entry = _dbContext.Configuration.SingleOrDefault(c => c.Key == key);

            if (entry != null)
            {
                return(JsonConvert.DeserializeObject <T>(entry.Value));
            }

            var newEntry = new ConfigurationEntry {
                Key = key, Value = JsonConvert.SerializeObject(defaultValue)
            };

            _dbContext.Configuration.Add(newEntry);
            _dbContext.SaveChanges();
            return(defaultValue);
        }
예제 #18
0
        private AvroConfiguration ToAvroConfiguration()
        {
            HashSet <ConfigurationEntry> b  = new HashSet <ConfigurationEntry>();
            ConfigurationEntry           e1 = new ConfigurationEntry();

            e1.key   = "a";
            e1.value = "a1";
            ConfigurationEntry e2 = new ConfigurationEntry();

            e2.key   = "b";
            e2.value = "b1=b2";
            b.Add(e1);
            b.Add(e2);
            var a = new AvroConfiguration(b);

            return(a);
        }
예제 #19
0
        public static bool ModifyBool(string key, bool newVal)
        {
            if (!DefaultBooleanProperties.ContainsKey(key))
            {
                return(false);
            }

            if (CachedBooleanSettings.ContainsKey(key))
            {
                CachedBooleanSettings[key].Modify(newVal);
            }
            else
            {
                CachedBooleanSettings[key] = new ConfigurationEntry <bool>(true, newVal, DefaultBooleanProperties[key].Description);
            }
            return(true);
        }
예제 #20
0
        public static bool ModifyDouble(string key, double newVal)
        {
            if (!DefaultDoubleProperties.ContainsKey(key))
            {
                return(false);
            }

            if (CachedDoubleSettings.ContainsKey(key))
            {
                CachedDoubleSettings[key].Modify(newVal);
            }
            else
            {
                CachedDoubleSettings[key] = new ConfigurationEntry <double>(true, newVal, DefaultDoubleProperties[key].Description);
            }
            return(true);
        }
예제 #21
0
        public void Set <T>(string key, T value)
        {
            var entry = _dbContext.Configuration.SingleOrDefault(c => c.Key == key);

            if (entry != null)
            {
                entry.Value = JsonConvert.SerializeObject(value);
            }
            else
            {
                entry = new ConfigurationEntry {
                    Key = key, Value = JsonConvert.SerializeObject(value)
                };
                _dbContext.Configuration.Add(entry);
            }
            _dbContext.SaveChanges();
        }
예제 #22
0
        public void DoesNothingWithoutQueuedMessage()
        {
            var configuration = new ConfigurationEntry {
                Alias = "#1", RedriveUrl = "http://here.com/", Active = true
            };
            var queueClientMock = new Mock <IQueueClient>(MockBehavior.Strict);

            queueClientMock.Setup(x => x.GetMessage()).Callback(() => Thread.Sleep(2000)).Returns((SqsMessage)null).Verifiable();

            var processor = new QueueProcessor();

            processor.Init(queueClientMock.Object, null, configuration);
            processor.Start();
            Thread.Sleep(1000);
            processor.Stop();

            queueClientMock.Verify(x => x.GetMessage(), Times.Exactly(1));
        }
예제 #23
0
        public static ConfigurationEntryModel ToModel(this ConfigurationEntry entity)
        {
            if (entity == null)
            {
                return(null);
            }

            return(new ConfigurationEntryModel
            {
                Id = entity.Id,
                Key = entity.Key,
                Value = entity.Value,
                Description = entity.Description,
                IsSensitive = entity.IsSensitive,
                CreatedDateTime = entity.CreatedDateTime,
                UpdatedDateTime = entity.UpdatedDateTime,
            });
        }
예제 #24
0
        public object getDefaultValue(ConfigurationEntry confEntry)
        {
            switch (confEntry)
            {
            case ConfigurationEntry.DefaultNamespace:
                return(DEFAULT_NAMESPACE);

            case ConfigurationEntry.IntegrityConstraints:
                return(false);

            case ConfigurationEntry.ReasoningProfile:
                return(ReasoningConfiguration.OWLRLP.ToString());

            case ConfigurationEntry.ReasoningRadius:
                return(3);

            case ConfigurationEntry.BreakingChangeRadius:
                return(3);

            case ConfigurationEntry.PublicSPARQLEndpoint:
                return(false);

            case ConfigurationEntry.DatabaseVersion:
                return(databaseVersion.ToString());

            case ConfigurationEntry.GraphDatabase:
                return(DEFAULT_GRAPH_DB.ToString());

            case ConfigurationEntry.CacheEnabled:
                return(false);

            case ConfigurationEntry.DomainAndRangeMaterialization:
                return(false);

            case ConfigurationEntry.CacheDatabase:
                return(CacheBackend.InMemory.ToString());

            case ConfigurationEntry.NamespaceModularizationEnabled:
                return(false);

            default:
                throw new Exception("No default value specified for ConfigurationEntry " + confEntry.ToString());
            }
        }
예제 #25
0
        private void OnConfigurationResetCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 2)
            {
                bot.SendReply(e, "Usage: configuration reset [plugin] [key]");
                return;
            }
            if (!bot.Configuration.IsRegistered(e.Args[0], e.Args[1]))
            {
                bot.SendReply(e, "No such configuration entry");
                return;
            }
            string             section = e.Args[0].ToLower();
            string             key     = e.Args[1].ToLower();
            ConfigurationEntry entry   = bot.Configuration.GetRegistered(section, key);

            bot.Configuration.Set(entry.Type, section, key, entry.DefaultValue);
            bot.Configuration.Delete(section, key);
            bot.SendReply(e, "Configuration entry " + HTML.CreateColorString(bot.ColorHeaderHex, section + "::" + key) + " has been reset to it's default value");
        }
        public static string CurrentBranchLeafName(this Flow gitflow)
        {
            var repo           = gitflow.Repository;
            var fullBranchName = repo.Head.CanonicalName;
            ConfigurationEntry <string> prefix = null;

            if (gitflow.IsOnFeatureBranch())
            {
                prefix = repo.Config.Get <string>(GitFlowSetting.Feature.GetAttribute <GitFlowConfigAttribute>().ConfigName);
            }
            if (gitflow.IsOnReleaseBranch())
            {
                prefix = repo.Config.Get <string>(GitFlowSetting.Release.GetAttribute <GitFlowConfigAttribute>().ConfigName);
            }
            if (gitflow.IsOnHotfixBranch())
            {
                prefix = repo.Config.Get <string>(GitFlowSetting.HotFix.GetAttribute <GitFlowConfigAttribute>().ConfigName);
            }
            return(prefix != null?fullBranchName.Replace(prefix.Value, "") : fullBranchName);
        }
예제 #27
0
        private string CreateSql(ICollection <string> requestedParams,
                                 IReadOnlyList <string> passedParams,
                                 IReadOnlyList <string> passedValues,
                                 ConfigurationEntry config)
        {
            var sql = config.SqlCommand;

            for (var i = 0; i < passedParams.Count; i++)
            {
                var p = passedParams[i];

                if (!requestedParams.Contains(p))
                {
                    throw new BadRequestException($"Parameter {p} is unknown");
                }

                sql = sql.Replace($"${p}$", passedValues[i]);
            }

            return(sql);
        }
예제 #28
0
        public void Set <T>(string category, string key, T value, bool persist = false)
        {
            if (string.IsNullOrWhiteSpace(category))
            {
                throw new ArgumentNullException(nameof(category));
            }
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            var predicate = new Func <ConfigurationEntry, bool>(e => e.Category == category && e.Key == key);

            ConfigurationEntry entry = null;
            var exist = _entries.Any(predicate);

            if (exist)
            {
                entry         = _entries.Single(predicate);
                entry.Value   = value;
                entry.Persist = persist;
            }
            else
            {
                entry = new ConfigurationEntry
                {
                    Category = category,
                    Key      = key,
                    Persist  = persist,
                    Value    = value,
                    Source   = null
                };
                _entries.Add(entry);
            }

            if (persist)
            {
                _repository.SaveEntry(entry);
            }
        }
예제 #29
0
        private BaseLogger getLogger()
        {
            ConfigurationRoot  tmp   = this.ConfigurationManager.iParseConfiguratation(this.Config.get(ConfigurationParamsEnum.ConfigurationPath.ToString()).KeyValue);
            ConfigurationBlock block = tmp.getBlock(ConfigurationBlocksEnum.Loggers.ToString());

            for (int i = 0; i < block.BlockEntries.Length; i++)
            {
                ConfigurationEntry entry = block.BlockEntries[i];
                if (!entry.Key.Equals(this.Config.get(LoggerParamsEnum.DefaultLogger.ToString()).KeyValue))
                {
                    continue;
                }

                string     impl   = entry.get(ConfigurationParamsEnum.ImplementationClass.ToString()).KeyValue;
                BaseLogger result = this.ClassFactory.createInstance <BaseLogger>(impl, new object[] { entry.Key, entry });
                result.Initialize();

                return(result);
            }

            return(null);
        }
예제 #30
0
        public void CanSetLocalTrackedBranch()
        {
            const string testBranchName         = "branchToSetUpstreamInfoFor";
            const string localTrackedBranchName = "refs/heads/master";

            string path = SandboxStandardTestRepo();

            using (var repo = new Repository(path))
            {
                Branch trackedBranch = repo.Branches[localTrackedBranchName];
                Assert.False(trackedBranch.IsRemote);

                Branch branch = repo.CreateBranch(testBranchName, trackedBranch.Tip);
                Assert.False(branch.IsTracking);

                repo.Branches.Update(branch,
                                     b => b.TrackedBranch = trackedBranch.CanonicalName);

                // Get the updated branch information.
                branch = repo.Branches[testBranchName];

                // Branches that track the local remote do not have the "Remote" property set.
                // Verify (through the configuration entry) that the local remote is set as expected.
                Assert.Null(branch.RemoteName);
                ConfigurationEntry <string> remoteConfigEntry = repo.Config.Get <string>("branch", testBranchName, "remote");
                Assert.NotNull(remoteConfigEntry);
                Assert.Equal(".", remoteConfigEntry.Value);

                ConfigurationEntry <string> mergeConfigEntry = repo.Config.Get <string>("branch", testBranchName, "merge");
                Assert.NotNull(mergeConfigEntry);
                Assert.Equal("refs/heads/master", mergeConfigEntry.Value);

                // Verify the IsTracking and TrackedBranch properties.
                Assert.True(branch.IsTracking);
                Assert.Equal(trackedBranch, branch.TrackedBranch);
                Assert.Equal("refs/heads/master", branch.UpstreamBranchCanonicalName);
            }
        }
예제 #31
0
        protected static void WriteConfigFile(ConfigurationEntry entry, string filepath)
        {
            string newname;

            if (!entry.RequiredProperties.TryGetValue(ConfigurationEntry.RequiredPropertyNames.NAME, out newname))
            {
                throw new InvalidOperationException(string.Format("Unable to update configuration, '{0}' property is missing",
                                                                  ConfigurationEntry.RequiredPropertyNames.NAME));
            }

            var folder = Path.GetDirectoryName(filepath) ?? string.Empty;

            // detect a name change...
            if (!string.IsNullOrWhiteSpace(newname) &&
                !newname.Equals(entry.Name, StringComparison.InvariantCultureIgnoreCase))
            {
                var ext         = Path.GetExtension(filepath);
                var newfilepath = Path.Combine(folder, Path.ChangeExtension(newname, ext));

                if (File.Exists(newfilepath))
                {
                    throw new InvalidOperationException(string.Format(
                                                            "Unable to rename configuration, entry with name '{0}' already exists in '{1}'", newname, folder));
                }

                // update entry properties
                entry.Name = newname;

                // do the disk work...
                Serialiser.ToJsonInFile(newfilepath, entry);
                File.Delete(filepath);
            }
            else
            {
                // just save it
                Serialiser.ToJsonInFile(filepath, entry);
            }
        }
예제 #32
0
        internal static void ApplyConfigurationSettings(Dictionary <string, ConfigurationEntry> entries)
        {
            foreach (var config_instance in GetConfigurationInstances())
            {
                if (!entries.ContainsKey(config_instance.EntryName))
                {
                    continue;
                }
                ConfigurationEntry config_entry = entries[config_instance.EntryName];

                var config_setting_props = config_instance.Type
                                           .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                                           .Where(_ => _.GetCustomAttribute <ConfigSettingAttribute>() != null);

                foreach (var config_setting in config_setting_props)
                {
                    if (config_entry.Settings != null && config_entry.Settings.ContainsKey(config_setting.Name))
                    {
                        config_setting.SetValue(config_instance.Instance, config_entry.Settings[config_setting.Name].GetValue(config_setting.PropertyType));
                    }
                }
            }
        }
예제 #33
0
        private void Validate(string name,
                              string parameters,
                              string values,
                              out List <string> requestedParams,
                              out List <string> passedParams,
                              out List <string> passedValues,
                              out ConfigurationEntry config)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new BadRequestException("No config requested");
            }

            var configs = _configurationReader.ReadConfiguration();

            config = configs.FirstOrDefault(x => string.Equals(x.Name.ToLower(), name.ToLower(), StringComparison.InvariantCulture));

            if (config == null)
            {
                throw new ConfigurationNotFoundException("Configuration not found");
            }

            requestedParams = Parse(config.Parameters);
            passedParams    = Parse(parameters);
            passedValues    = Parse(values);

            if (requestedParams.Count != passedParams.Count)
            {
                throw new BadRequestException("Parameters passed are incorrect");
            }

            if (passedParams.Count != passedValues.Count)
            {
                throw new BadRequestException("Passed values are incorrect");
            }
        }
예제 #34
0
 protected override void Configure(ConfigurationEntry entry)
 {
     entry.Name        = "MsmqQueueInfoCheck";
     entry.Description = "This check will monitor a MSMQ Queue for breaches of too many items. If there are more items than the threshold set it will generate failure notifications.";
     entry.Tags.AddIfMissing("MSMQ", "Threshold");
 }
예제 #35
0
 private string ButtonLinkFormatValue(ConfigurationEntry Sender, Object Value) {
     if (Value is String)
         return (Value as String);
     else
         return "test";
 }
예제 #36
0
 private bool ButtonLinkEditor(ConfigurationEntry Sender, IWin32Window Owner) {
     MessageBox.Show("test");
     Sender.Value = "new value";
     return true;
 }
예제 #37
0
 string config_FormatValue(ConfigurationEntry Sender, object Value) {
     return (Value == null ? "" : Value.ToString());
 }