public void Does_Calculate_Correctly() { var config = new Configuration { Price = 1.00m }; var configItem = new ConfigurationItem { Price = .25m }; configItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { IsSelected = true, Price = 3.10m }); configItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { IsSelected = false, Price = 3.10m }); config.ConfigurationItems.Add(configItem); var calculator = new ConfigurationPriceCalculator(); var result = calculator.Calculate(config); Assert.AreEqual(4.35m, result); }
public ManagementConfiguration() { queueRepositoryType = ConfigurationItem<string>.ReadSetting("QueueRepositoryType", string.Empty); queueRepository = new NullQueueRepository(); HasQueueRepository = false; dataStoreRepositoryType = ConfigurationItem<string>.ReadSetting("DataStoreRepositoryType", string.Empty); dataStoreRepository = new NullDataStoreRepository(); HasDataStoreRepository = false; }
public EMailConfiguration() { attachmentFolder = ConfigurationItem<string>.ReadSetting("AttachmentFolder"); if (!Directory.Exists(AttachmentFolder)) { var message = string.Format("Attachment folder '{0}' does not exist.", AttachmentFolder); Log.Error(message); throw new DirectoryNotFoundException(message); } }
public MsmqQueue(Uri uri, bool isTransactional) { Guard.AgainstNull(uri, "uri"); if (!uri.Scheme.Equals(SCHEME, StringComparison.InvariantCultureIgnoreCase)) { throw new InvalidSchemeException(SCHEME, uri.ToString()); } localQueueTimeout = ConfigurationItem<int>.ReadSetting("LocalQueueTimeout", 0); remoteQueueTimeout = ConfigurationItem<int>.ReadSetting("RemoteQueueTimeout", 2000); log = Log.For(this); var builder = new UriBuilder(uri); host = uri.Host; if (host.Equals(".")) { builder.Host = Environment.MachineName.ToLower(); } if (uri.LocalPath == "/") { throw new UriFormatException(string.Format(ESBResources.UriFormatException, "memory://{{host}}/{{name}}", Uri)); } Uri = builder.Uri; IsLocal = Uri.Host.Equals(Environment.MachineName, StringComparison.InvariantCultureIgnoreCase); IsTransactional = isTransactional; usesIPAddress = regexIPAddress.IsMatch(host); path = IsLocal ? string.Format(@"{0}\private$\{1}", host, uri.Segments[1]) : usesIPAddress ? string.Format(@"FormatName:DIRECT=TCP:{0}\private$\{1}", host, uri.Segments[1]) : string.Format(@"FormatName:DIRECT=OS:{0}\private$\{1}", host, uri.Segments[1]); timeout = IsLocal ? TimeSpan.FromMilliseconds(localQueueTimeout.GetValue()) : TimeSpan.FromMilliseconds(remoteQueueTimeout.GetValue()); }
public override bool TryGetMember(GetMemberBinder binder, out object result) { var rootElement = _configuration.Root; ValidateRoot(rootElement); if (rootElement != null) { var matchingElements = rootElement.Elements().Where(x => x.Name == binder.Name).ToArray(); if (!matchingElements.Any()) throw new ConfigurationItemNotFoundException(string.Format("Configuration item {0} could not be found", binder.Name)); result = new ConfigurationItem(matchingElements); return true; } result = null; return false; }
private ConfigurationItem BuildCrustItem(int sequence) { var configurationItem = new ConfigurationItem { Name = "Crust", Sequence = sequence, EndUserInstructions = "Choose your Crust", Id = Guid.Parse("3F9D2CD2-0EDA-4DE7-9951-E7C457BA3F09") }; configurationItem.ConfigurationRules.Add(new MaxSelectedOptionsRule { Count = 1 }); configurationItem.ConfigurationRules.Add(new MinSelectedOptionsRule { Count = 1 }); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Thin", Sequence = 1, Id = Guid.Parse("BFCFCF8A-45F3-46A3-80FD-2B545715A5B0") }); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Thick", Sequence = 2, Id = Guid.Parse("EC8E351E-8ED6-4308-AD21-F7267551808B") }); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Cheese Filled", Sequence = 3, Id = Guid.Parse("482C3BBC-B6F5-4C36-88BD-216B9D5747DD") }); return configurationItem; }
public ScriptProvider() { ScriptFolder = ConfigurationItem <string> .ReadSetting("ScriptFolder", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "scripts")).GetValue(); ScriptBatchSeparator = ConfigurationItem <string> .ReadSetting("ScriptBatchSeparator", "GO").GetValue(); }
/// <summary> /// Read the application's configuration information from it's configuration item. /// </summary> protected void ReadApplicationConfig() { ConfigurationItem configItem = new ConfigurationItem(HttpRuntime.AppDomainAppPath + CONFIG_ITEM_DIRECTORY, GENERAL_CONFIGURATION_ITEM_NAME, true); // Process each line of the configuration item's value. foreach (string line in configItem.Value.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { // Find the first equals sign in the line. This splits the key from the value on the line. int separatorIndex = line.IndexOf('='); // Check that the line was properly separated. if (separatorIndex != 0) { string key = line.Substring(0, separatorIndex); string value = line.Substring(separatorIndex + 1, line.Length - (separatorIndex + 1)); // Match the key to the application's configuration values. switch (key) { case "Admin Group Name": ADMIN_GROUP_NAME = value; break; case "Overrider Group Name": OVERRIDER_GROUP_NAME = value; break; case "PAN API Key": PAN_API_KEY = value; break; case "Firewall Hostname": FIREWALL_HOSTNAME = value; break; } } } // Check that all application configuration values were loaded. if (string.IsNullOrWhiteSpace(ADMIN_GROUP_NAME) || string.IsNullOrWhiteSpace(OVERRIDER_GROUP_NAME) || string.IsNullOrWhiteSpace(PAN_API_KEY) || string.IsNullOrWhiteSpace(FIREWALL_HOSTNAME)) { Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Error, EVENT_LOG_CATEGORY_GENERAL, "Unable to load application values from general configuration from configuration item named " + GENERAL_CONFIGURATION_ITEM_NAME + " within " + CONFIG_ITEM_DIRECTORY + " .")); throw new ApplicationException("Unable to load application values from general configuration. Check log for more details."); } else { Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Information, EVENT_LOG_CATEGORY_GENERAL, "Loaded from general configuration: Admin Group Name = " + ADMIN_GROUP_NAME)); Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Information, EVENT_LOG_CATEGORY_GENERAL, "Loaded from general configuration: Overrider Group Name = " + OVERRIDER_GROUP_NAME)); // Mask the API key in the log. StringBuilder maskedApiKey = new StringBuilder(); if (PAN_API_KEY.Length >= 4) { int maskedLength = PAN_API_KEY.Length - 4; for (int i = 0; i < maskedLength; i++) { maskedApiKey.Append('*'); } maskedApiKey.Append(PAN_API_KEY.Substring(maskedLength, 4)); } else { maskedApiKey.Append("****"); } Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Information, EVENT_LOG_CATEGORY_GENERAL, "Loaded from general configuration: PAN API KEY = " + maskedApiKey)); Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Information, EVENT_LOG_CATEGORY_GENERAL, "Loaded from general configuration: Firewall Hostname = " + FIREWALL_HOSTNAME)); } }
/// <summary> /// Writes a configuration item. /// </summary> /// <param name="configuration">the configuration item</param> public virtual void writeConfigurationItem(ConfigurationItem configuration) { getConfigurationVisitor().visit(configuration); }
public ActiveTimeRangeConfiguration() { activeFromTime = ConfigurationItem<string>.ReadSetting("ActiveFromTime", "*"); activeToTime = ConfigurationItem<string>.ReadSetting("ActiveToTime", "*"); }
public override void visit(ConfigurationItem item) { VhdlOutputHelper.handleAnnotationsBefore(item, writer); base.visit(item); VhdlOutputHelper.handleAnnotationsAfter(item, writer); }
private void OnLoad() { if ((_item.Properties != null && _item.Properties.Length > 0) || (_item.MethodIds != null && _item.MethodIds.Length > 0)) { TabPage tabPage = new TabPage(_item.ItemType); tabPage.Tag = _item; tabPage.BorderStyle = System.Windows.Forms.BorderStyle.None; tabControl1.Margin = new System.Windows.Forms.Padding(0); tabControl1.TabPages.Add(tabPage); } if (!_item.ChildrenFilled) { _item.Children = _configApiClient.GetChildItems(_item.Path); } _privacyMaskItem = null; foreach (ConfigurationItem child in _item.Children) { if (child.ItemType == ItemTypes.PrivacyMaskFolder) { if (!child.ChildrenFilled) { child.Children = _configApiClient.GetChildItems(child.Path); child.ChildrenFilled = true; } if (child.Children != null && child.Children.Length > 0) { _privacyMaskItem = child.Children[0]; } } } foreach (ConfigurationItem child in _item.Children) { if (MainForm._navItemTypes.Contains(child.ItemType)) // Do not repeat what is on the navigation tree { continue; } if (child.ItemCategory == ItemCategories.Group) { if (!child.ChildrenFilled) { child.Children = _configApiClient.GetChildItems(child.Path); } if (child.Children.Length == 1 && child.ItemType != ItemTypes.PtzPresetFolder) { GenerateTab(child.Children[0]); } else { GenerateTab(child); } } else { GenerateTab(child); } } if (tabControl1.TabCount > 0) { tabControl1.SelectedTab = tabControl1.TabPages[0]; } OnTabSelect(this, null); }
public WeatherController(IMiddleware middleware, IOptions <ConfigurationItem> settings) { this._middleware = middleware; configItem = settings.Value; }
internal static HandleRef getCPtr(ConfigurationItem obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
private void OnTimerTick(object sender, EventArgs e) { try { if (_item != null && _item.ItemType == ItemTypes.InvokeResult || _item.ItemType == ItemTypes.Task) { if (taskPath != null) { _item = _configApiClient.GetItem(taskPath); if (_item != null) { this.SuspendLayout(); scrollPanel1.Clear(); panelActions.Controls.Clear(); FillForm(); this.ResumeLayout(); Property stateProperty = _item.Properties.FirstOrDefault <Property>(p => p.Key == InvokeInfoProperty.State); Property pathProperty = _item.Properties.FirstOrDefault <Property>(p => p.Key == InvokeInfoProperty.Path); if (pathProperty != null) { if (pathProperty.Value.StartsWith("Task")) { taskPath = pathProperty.Value; } } if (stateProperty != null && (stateProperty.Value == "Success" || stateProperty.Value == "Error")) { timer1.Stop(); } } else { timer1.Stop(); } } } else { ConfigurationItem result = _configApiClient.InvokeMethod(_item, _refreshId); if (result != null && result.ItemType == ItemTypes.InvokeResult) { _item = result; this.SuspendLayout(); scrollPanel1.Clear(); panelActions.Controls.Clear(); FillForm(); this.ResumeLayout(); } else { timer1.Stop(); timer1.Dispose(); this.Close(); } } } catch (Exception ex) { _configApiClient.InitializeClientProxy(); timer1.Stop(); timer1.Dispose(); MessageBox.Show(ex.Message); this.Close(); } }
public void AddConfigItem(ConfigurationItem ci) { CreateDocument(COLLECTION_NAME, CreateConfigurationItemDocument(ci)); }
public void TestSetUserValueWithNull() { ConfigurationItem configurationItem = new ConfigurationItem(123, "<description>"); configurationItem.SetUserValue(null); }
public SimpleUserControl(ConfigurationItem item, bool showChildren, ConfigApiClient configApiClient, ConfigurationItem privacyMaskItem) { InitializeComponent(); _configApiClient = configApiClient; _showChildren = showChildren; _item = item; _privacyMaskItem = privacyMaskItem; InitalizeUI(); }
public FolderUserControl(ConfigurationItem item, ConfigurationItem[] childrens) { InitializeComponent(); //this.BackColor = MainForm.MyBackColor; //this.tableLayoutPanel1.BackColor = this.BackColor; if (childrens != null && childrens.Length > 0) { ConfigurationItem first = childrens[0]; int cols = 0; int colsNormal = 0; int importanceToShow = 2; if (first.Properties != null) { foreach (Property pi in first.Properties) // We assume here that the children have same settings! { if (pi.UIImportance == 2) { cols++; } if (pi.UIImportance == 0) { colsNormal++; importanceToShow = 0; } } if (cols == 0) { cols = colsNormal; } } if (cols > 0) { tableLayoutPanel1.ColumnCount = cols; tableLayoutPanel1.RowCount = childrens.Length + 1; for (int col = 0; col < cols; col++) { if (col < tableLayoutPanel1.ColumnStyles.Count) { tableLayoutPanel1.ColumnStyles[col] = new ColumnStyle(SizeType.AutoSize); } else { tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); } } for (int ix = 0; ix < childrens.Length; ix++) { ConfigurationItem child = childrens[ix]; if (MainForm._navItemTypes.Contains(child.ItemType)) // Do not repeat what is on the navigation tree { continue; } int iy = 0; if (ix < tableLayoutPanel1.RowStyles.Count) { tableLayoutPanel1.RowStyles[ix] = new RowStyle(SizeType.AutoSize); } else { tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize)); } foreach (Property pi in child.Properties) // We assume here that the children have same settings! { if (pi.UIImportance == importanceToShow) { if (ix == 0) { tableLayoutPanel1.Controls.Add(MakeControlName(pi), iy, 0); } tableLayoutPanel1.Controls.Add(MakeControl(pi), iy, ix + 1); iy++; } } } tableLayoutPanel1.Height = 25 * (childrens.Length + 1) + 1; } } }
public AddedOrUpdatedConfigurationItemMessage(ConfigurationItem configurationItem, Guid correlationId, Guid tenantId) { Payload = new { Entity = configurationItem, CorrelationId = correlationId }; TenantUniqueId = tenantId; }
public ConfigurationItem get_item(configuration_keys key) { ConfigurationItem ret = new ConfigurationItem(CoolPropPINVOKE.Configuration_get_item(swigCPtr, (int)key), false); if (CoolPropPINVOKE.SWIGPendingException.Pending) throw CoolPropPINVOKE.SWIGPendingException.Retrieve(); return ret; }
private void ProcessWatcherAlerts() { SchedulerSettings settings = _issueManager.UserContext.Config.SchedulerSettings.HasValue() ? _issueManager.UserContext.Config.SchedulerSettings.FromJson<SchedulerSettings>() : new SchedulerSettings(); DateTime lastChecked = settings.LastCheckedWatchers.HasValue ? settings.LastCheckedWatchers.Value : DateTime.UtcNow; IssuesFilter filter = new IssuesFilter(); filter.RevisedAfter = lastChecked.ToString(); filter.IncludeClosed = true; LogDebugMessage("Last checked for watched item alerts: " + lastChecked); List<IssueDto> issues = _issueManager.GetFiltered(filter); LogDebugMessage("Item that have changed: " + issues.Count); if (issues.Count > 0) ProcessWatchers(issues, lastChecked); settings.LastCheckedWatchers = DateTime.UtcNow; /*serviceManager.Admin.UpdateSchedulerSettings(settings);*/ IConfiguration configuration = GeminiApp.Container.Resolve<IConfiguration>(); GeminiConfiguration config = configuration.Get(); config.SchedulerSettings = settings.ToJson(); ConfigurationItem item = new ConfigurationItem(); item.SettingId = GeminiConfigurationOption.SchedulerSettings.ToString(); item.SettingValue = config.SchedulerSettings; configuration.Update(item); GeminiApp.RefreshConfig(config); }
public void TestSetUserValueWithEmptyString() { ConfigurationItem configurationItem = new ConfigurationItem(123, "<description>"); configurationItem.SetUserValue(string.Empty); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ConfigurationItem obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
private void PerformAction(object sender, EventArgs e) { MethodInfo mi = ((Control)sender).Tag as MethodInfo; if (mi != null) { // changed properties are stored directy in the _item class, no need to read here... _refreshId = mi.MethodId; try { ConfigurationItem result = _configApiClient.InvokeMethod(_item, mi.MethodId); if (result != null && result.ItemType == ItemTypes.InvokeInfo) { _item = result; scrollPanel1.Clear(); panelActions.Controls.Clear(); FillForm(); timer1.Stop(); timer1.Dispose(); } else //if (result != null && result.ItemType == ItemTypes.InvokeResult) { _item = result; scrollPanel1.Clear(); panelActions.Controls.Clear(); FillForm(); Property stateProperty = result.Properties.FirstOrDefault <Property>(p => p.Key == InvokeInfoProperty.State); Property pathProperty = result.Properties.FirstOrDefault <Property>(p => p.Key == InvokeInfoProperty.Path); if (stateProperty != null && stateProperty.Value == InvokeInfoStates.Success && !MainForm.ShowInvokeResult) { // All done and no error, just close dialog this.Close(); } if (pathProperty != null) { if (pathProperty.Value.StartsWith("Task")) { taskPath = pathProperty.Value; } } Property sessionDataProperty = result.Properties.FirstOrDefault <Property>(p => p.Key == "SessionDataId"); if (sessionDataProperty != null) { SessionDataId = sessionDataProperty.Value; } } /* * else * { * timer1.Stop(); * timer1.Dispose(); * this.Close(); * }*/ } catch (Exception ex) { timer1.Stop(); timer1.Dispose(); MessageBox.Show(ex.Message); this.Close(); } } }
public void SetConfiguration(ConfigurationItem configurationItem) { _ConfigurationRepository.UpdateConfiguration(configurationItem); }
public void TestSetUserValueWithInvalidType() { ConfigurationItem configurationItem = new ConfigurationItem(123, "<description>"); configurationItem.SetUserValue("1.3"); }
private ConfigurationItem BuildSizeItem(int sequence) { var configurationItem = new ConfigurationItem { Name = "Size", Sequence = sequence, EndUserInstructions = "Choose your Size", Id = Guid.Parse("B7720D93-F578-4704-979E-F1C7D95B49E6") }; configurationItem.ConfigurationRules.Add(new MaxSelectedOptionsRule {Count = 1}); configurationItem.ConfigurationRules.Add(new MinSelectedOptionsRule {Count = 1}); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Small", Description = "4 slices, feeds 1 person", Sequence = 1, Id = Guid.Parse("F2117C46-AAE8-42A9-989C-4F4CCDCA980C") }); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Medium", Description = "8 slices, feeds 2 people", Sequence = 2, Id = Guid.Parse("06FE851B-BF45-4F5D-8B53-D468BF8125B0") }); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Large", Description = "16 slices, feeds 3 or 4 people", Sequence = 3, Id = Guid.Parse("3DDA7F59-7E69-4C03-B343-DAF8EDEB330C") }); return configurationItem; }
private DebugConfig() { #if DEBUG // loading the debug.config file, and reading it if (File.Exists(cerebelloDebugConfigPath)) { var ser = new XmlSerializer(typeof(ConfigurationItem)); using (var reader = XmlReader.Create(cerebelloDebugConfigPath)) { config = (ConfigurationItem)ser.Deserialize(reader); } } if (config != null) { var settingToUse = config.Debug.Settings.Use; setting = config.Debug.Settings.Items.SingleOrDefault(x => scii(x.Name, settingToUse)); if (setting != null && setting.CustomDateTime != null && setting.CustomDateTime.Enabled) { var dt = config.Debug.DatesAndTimes.Items.SingleOrDefault(x => scii(x.Name, setting.CustomDateTime.Use)); if (dt != null) { var now = DateTime.Now; TimeSpan offset; List<Match> matchesOffset = null; if (!TimeSpan.TryParse(dt.Relative, out offset)) { matchesOffset = Regex.Matches(dt.Relative ?? "", @" (?<SIGNAL>\-|\+)? (?: (?<YEARS>\d+) (?:[Yy][Ee][Aa][Rr][Ss]|[Yy]?) )? (?: (?<MONTHS>\d+) (?:[Mm][Oo][Nn][Tt][Hh][Ss]|[Mm]?) )? (?: (?<DAYS>\d+) (?:[Dd][Aa][Yy][Ss]|[Dd]?) )? (?: (?<HOURS>\d+) (?:[Hh][Oo][Uu][Rr][Ss]|[Hh]?) )? (?: (?<MINUTES>\d+) (?:[Mm][Ii][Nn][Uu][Tt][Ee][Ss]|[Mm][Ii][Nn]|[Mm]|'?) )? (?: (?<SECONDS>\d+) (?:[Ss][Ee][Cc][Oo][Nn][Dd][Ss]|[Ss][Ee][Cc]|[Ss]|""?) )? ", RegexOptions.IgnorePatternWhitespace) .Cast<Match>().ToList(); } DateTime absolute; if (!DateTime.TryParse(dt.Absolute, out absolute)) absolute = now; var parts = (dt.Set ?? "").Split(';'); var newDate = MergeDates(now, absolute, parts) + offset; if (matchesOffset != null && matchesOffset.Any()) { foreach (var eachMatch in matchesOffset) { int years, months, days, hours, minutes, seconds; int mul = int.Parse(eachMatch.Groups["SIGNAL"].Value + "1"); if (int.TryParse(eachMatch.Groups["YEARS"].Value, out years)) newDate = newDate.AddYears(mul * years); if (int.TryParse(eachMatch.Groups["MONTHS"].Value, out months)) newDate = newDate.AddMonths(mul * months); if (int.TryParse(eachMatch.Groups["DAYS"].Value, out days)) newDate = newDate.AddDays(mul * days); if (int.TryParse(eachMatch.Groups["HOURS"].Value, out hours)) newDate = newDate.AddHours(mul * hours); if (int.TryParse(eachMatch.Groups["MINUTES"].Value, out minutes)) newDate = newDate.AddMinutes(mul * minutes); if (int.TryParse(eachMatch.Groups["SECONDS"].Value, out seconds)) newDate = newDate.AddSeconds(mul * seconds); } } currentTimeOffset = newDate - now; } } } #endif }
public DbCommandFactory() : this(ConfigurationItem <int> .ReadSetting("Shuttle.Core.Data.DbCommandFactory.CommandTimeout", 15).GetValue()) { }
public void Testout() { ConfigurationLayer cl = new ConfigurationLayer(); ConfigurationItem item1 = new ConfigurationItem(); cl.Items.AddConfigurationItem("plugin1", ConfigurationStatus.Running); Assert.That( item1.Status == ConfigurationStatus.Running ); Assert.That( item1.ServiceOrPluginName == "plugin1" ); ConfigurationItem item2 = new ConfigurationItem(); cl.Items.AddConfigurationItem( "service1", ConfigurationStatus.Running ); Assert.That( item1.Status == ConfigurationStatus.Running ); Assert.That( item1.ServiceOrPluginName == "service1" ); ConfigurationManager cm = new ConfigurationManager(); cm.AddLayer( cl ); Objectgraph Og = new ObjectGraph( cm ); Og.Resolve(); Og.Release(); }
internal static Property GetProperty(ConfigurationItem item, string key) { IEnumerable <Property> properties = item.Properties.Where(p => (string.Compare(p.Key, key, StringComparison.InvariantCultureIgnoreCase) == 0)); return(properties.FirstOrDefault()); }
public void ConfigurationLayerWithoutManagerTests() { int countCollectionChangedEvent = 0; int countPropertyChangedEvent = 0; ConfigurationLayer layer = new ConfigurationLayer(); layer.Items.CollectionChanged += (s, e) => countCollectionChangedEvent++; //initialization tests Assert.That(layer.Items.Count, Is.EqualTo(0)); Assert.Throws <IndexOutOfRangeException>(() => { ConfigurationItem lambdaItem = layer.Items[42]; }); Assert.That(layer.Items["schmurtz"], Is.Null); Assert.That(layer.Items.Contains("schmurtz"), Is.False); //actions without items ConfigurationResult result = layer.Items.Remove("schmurtz"); Assert.That(result == false); //use a implicit cast Assert.That(result.IsSuccessful, Is.False); Assert.That(result.FailureCauses.Count, Is.EqualTo(1)); Assert.That(result.FailureCauses.Contains("Item not found"), Is.True); Assert.That(countCollectionChangedEvent, Is.EqualTo(0)); //exception in add fonction Assert.Throws <ArgumentException>(() => layer.Items.Add(null, ConfigurationStatus.Optional)); Assert.Throws <ArgumentException>(() => layer.Items.Add("", ConfigurationStatus.Optional)); //add function tests result = layer.Items.Add("schmurtz", ConfigurationStatus.Optional); Assert.That(result == true); Assert.That(result.IsSuccessful, Is.True); Assert.That(result.FailureCauses, Is.Not.Null); Assert.That(result.FailureCauses.Count, Is.EqualTo(0)); Assert.That(countCollectionChangedEvent, Is.EqualTo(1)); Assert.That(layer.Items.Count, Is.EqualTo(1)); Assert.That(layer.Items["schmurtz"], Is.Not.Null); Assert.DoesNotThrow(() => { ConfigurationItem lambdaItem = layer.Items[0]; }); Assert.That(layer.Items["schmurtz"].Layer, Is.EqualTo(layer)); Assert.That(layer.Items["schmurtz"].Layer.Items["schmurtz"], Is.Not.Null); Assert.That(layer.Items["schmurtz"].ServiceOrPluginId, Is.EqualTo("schmurtz")); Assert.That(layer.Items["schmurtz"].Status, Is.EqualTo(ConfigurationStatus.Optional)); Assert.That(layer.Items["schmurtz"].StatusReason, Is.EqualTo("")); //basic tests with item reference ConfigurationItem item = layer.Items["schmurtz"]; item.PropertyChanged += (s, e) => countPropertyChangedEvent++; item.StatusReason = null; Assert.That(item.StatusReason, Is.EqualTo("")); Assert.That(countPropertyChangedEvent, Is.EqualTo(1)); Assert.DoesNotThrow(() => item.StatusReason = "schmurtz"); Assert.That(countPropertyChangedEvent, Is.EqualTo(2)); Assert.DoesNotThrow(() => item.StatusReason = ""); Assert.That(countPropertyChangedEvent, Is.EqualTo(3)); //setstatus tests Assert.That(item.SetStatus(ConfigurationStatus.Disable).IsSuccessful, Is.True); Assert.That(item.Status, Is.EqualTo(ConfigurationStatus.Disable)); Assert.That(item.SetStatus(ConfigurationStatus.Optional).IsSuccessful, Is.True); Assert.That(item.Status, Is.EqualTo(ConfigurationStatus.Optional)); Assert.That(item.SetStatus(ConfigurationStatus.Runnable).IsSuccessful, Is.True); Assert.That(item.Status, Is.EqualTo(ConfigurationStatus.Runnable)); Assert.That(item.SetStatus(ConfigurationStatus.Running).IsSuccessful, Is.True); Assert.That(item.Status, Is.EqualTo(ConfigurationStatus.Running)); Assert.That(countPropertyChangedEvent, Is.EqualTo(7)); Assert.DoesNotThrow(() => item.SetStatus(ConfigurationStatus.Optional, null)); Assert.That(item.Status, Is.EqualTo(ConfigurationStatus.Optional)); Assert.That(item.StatusReason, Is.EqualTo("")); Assert.That(countPropertyChangedEvent, Is.EqualTo(9)); //add function tests when the item already exist result = layer.Items.Add("schmurtz", ConfigurationStatus.Disable); Assert.That(result == true); Assert.That(layer.Items.Count, Is.EqualTo(1)); Assert.That(layer.Items["schmurtz"].Status, Is.EqualTo(ConfigurationStatus.Disable)); Assert.That(item.Status, Is.EqualTo(ConfigurationStatus.Disable)); result = layer.Items.Add("schmurtz", ConfigurationStatus.Optional); Assert.That(result == true); Assert.That(layer.Items.Count, Is.EqualTo(1)); Assert.That(layer.Items["schmurtz"].Status, Is.EqualTo(ConfigurationStatus.Optional)); Assert.That(item.Status, Is.EqualTo(ConfigurationStatus.Optional)); result = layer.Items.Add("schmurtz", ConfigurationStatus.Runnable); Assert.That(result == true); Assert.That(layer.Items.Count, Is.EqualTo(1)); Assert.That(layer.Items["schmurtz"].Status, Is.EqualTo(ConfigurationStatus.Runnable)); Assert.That(item.Status, Is.EqualTo(ConfigurationStatus.Runnable)); result = layer.Items.Add("schmurtz", ConfigurationStatus.Running); Assert.That(result == true); Assert.That(layer.Items.Count, Is.EqualTo(1)); Assert.That(layer.Items["schmurtz"].Status, Is.EqualTo(ConfigurationStatus.Running)); Assert.That(item.Status, Is.EqualTo(ConfigurationStatus.Running)); Assert.That(countPropertyChangedEvent, Is.EqualTo(13)); //OnRemoved tests layer.Items.Remove("schmurtz"); Assert.That(result == true); Assert.That(result.IsSuccessful, Is.True); Assert.That(result.FailureCauses, Is.Not.Null); Assert.That(result.FailureCauses.Count, Is.EqualTo(0)); Assert.That(countCollectionChangedEvent, Is.EqualTo(2)); Assert.That(layer.Items["schmurtz"], Is.Null); Assert.Throws <IndexOutOfRangeException>(() => { ConfigurationItem lambdaItem = layer.Items[0]; }); //tests with item reference when item is removed Assert.That(item.Layer, Is.EqualTo(null)); Assert.That(item.ServiceOrPluginId, Is.EqualTo("schmurtz")); Assert.That(item.Status, Is.EqualTo(ConfigurationStatus.Optional)); Assert.That(item.StatusReason, Is.EqualTo(null)); Assert.Throws <InvalidOperationException>(() => item.StatusReason = "schmurtz"); Assert.Throws <InvalidOperationException>(() => item.SetStatus(ConfigurationStatus.Runnable)); //tests with multiple add result = layer.Items.Add("schmurtz2", ConfigurationStatus.Optional, "schmurtz?"); Assert.That(result == true); result = layer.Items.Add("schmurtz1", ConfigurationStatus.Disable, "schmurtz?"); Assert.That(result == true); Assert.That(layer.Items.Count, Is.EqualTo(2)); //sort tests ConfigurationItem schmurtz1 = layer.Items["schmurtz1"]; ConfigurationItem schmurtz2 = layer.Items["schmurtz2"]; Assert.That(schmurtz1, Is.EqualTo(layer.Items[0])); Assert.That(schmurtz2, Is.EqualTo(layer.Items[1])); Assert.That(schmurtz1.StatusReason, Is.EqualTo("schmurtz?")); Assert.That(schmurtz2.StatusReason, Is.EqualTo("schmurtz?")); result = layer.Items.Add("schmurtz0", ConfigurationStatus.Running); ConfigurationItem schmurtz0 = layer.Items["schmurtz0"]; Assert.That(schmurtz0, Is.EqualTo(layer.Items[0])); Assert.That(schmurtz1, Is.EqualTo(layer.Items[1])); Assert.That(schmurtz2, Is.EqualTo(layer.Items[2])); }
internal static string GetPropertyValue(ConfigurationItem item, string key) { Property property = GetProperty(item, key); return(property != null ? property.Value : string.Empty); }
public static LanguageServerOptions WithConfigurationItem(this LanguageServerOptions options, ConfigurationItem configurationItem) { options.Services.AddSingleton(configurationItem); return(options); }
public ConfigItemForm(ConfigurationItem ci) { InitializeComponent(); this.ci = ci; }
public void Given_An_Id_Get_Configuration_Item() { ConfigurationItem item = manager.GetItem(1); Assert.That(item, !Is.Null); }
internal static HandleRef getCPtr(ConfigurationItem obj) { return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr); }
protected void EmailReports(string[] reportFilenames, string messageBody, string from, string to, string subject) { //load the config settings for the email client Gargoyle.Configuration.Configurator.LoadConfigurationFromService(Properties.Settings.Default.SMTPConfigurationModule, false); ConfigurationItem m_smtpSettings = Gargoyle.Configuration.Configurator.CurrentConfigurations[Properties.Settings.Default.SMTPConfigurationModule]; FireInfo("Building email"); //construct the Microsoft MailMessage System.Net.Mail.MailMessage mailToSend = new System.Net.Mail.MailMessage( from, to, subject, messageBody); try { //do not use HTML mailToSend.IsBodyHtml = false; //construct the smtp client that will send the message System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient( m_smtpSettings["ServerAddress"].ValueAsStr, m_smtpSettings["Port"].ValueAsInt); //create credentials that will be passed to the smtp server smtpClient.Credentials = new System.Net.NetworkCredential (m_smtpSettings["UserName"].ValueAsStr, m_smtpSettings["Password"].ValueAsStr); //for each file in reportFileNames[], add it to the MailMessage.Attachments collection if (reportFilenames != null) { foreach (string filename in reportFilenames) { mailToSend.Attachments.Add(new System.Net.Mail.Attachment(filename)); } } string[] ccAddresses = from.Split(new char[] { ',' }); //Now set the addresses that should be CC'd. foreach (string ccAddress in ccAddresses) { mailToSend.CC.Add(ccAddress); } FireInfo("Sending reports"); smtpClient.Send(mailToSend); } catch (Exception) { throw; } finally { if (mailToSend != null) { mailToSend.Dispose(); } } }
// Method used to read the Config File private Dictionary <string, string> Config_Reader() { // Code for this section taken from Will Sykes' Log AI project // Get current directory string currentDirectory = AppDomain.CurrentDomain.BaseDirectory; Dictionary <string, string> appOptionsDictionary = new Dictionary <string, string>(); //when you parse app options don't forget to handle extra = in the connection string AND comments that start with ; try { //the general app specific paramenters ConfigurationItem appConfig = new ConfigurationItem(currentDirectory, APP_CONFIG, false); //Create Reader for config file using (StringReader sr = new StringReader(appConfig.Value)) { // while more lines in file while (sr.Peek() != -1) { string line = sr.ReadLine().Trim(); //Check if leading semi-colon, ignore if there is if (!(line.StartsWith(";", StringComparison.CurrentCulture))) { //Split on equal sign var tmp = line.Split('='); // If equal sign in value it would have been split // If so, restore value with equal sign // Otherwise, check if it has already been set if (tmp.Length > 2) { string parts = ""; for (int i = 1; i < tmp.Length; i++) { // Basically a join for the parts with equal signs //dont add an = to the end of the string if (!(i == tmp.Length - 1)) { parts += tmp[i] + "="; } else { parts += tmp[i]; } } try { // Check if the value had already been specified in the config file // If not set, set it in Dictionary if (!(appOptionsDictionary.ContainsKey(tmp[0].ToLower()))) { appOptionsDictionary.Add(tmp[0].ToLower(), parts.Trim()); } } catch { } } else { // Check if the value had already been specified in the config file // If not set, set it in Dictionary try { if (!(appOptionsDictionary.ContainsKey(tmp[0].ToLower()))) { appOptionsDictionary.Add(tmp[0].ToLower(), tmp[1].Trim()); } } catch { } } } } return(appOptionsDictionary); } } catch (Exception err) { Debug.WriteLine("Within the processappoptions method. Unable to process app options file {0}, {1}", err.Message, err.InnerException); return(null); } }
public static ConfigurationItemApiModel FromConfigurationItem(ConfigurationItem configurationItem) => FromConfigurationItem <ConfigurationItemApiModel>(configurationItem);
private bool HasPasswordValue(ConfigurationItem item) => string.Equals(item.Name, "password", StringComparison.InvariantCultureIgnoreCase);
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ConfigurationItem obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public void AddDynamic(string ID, ConfigurationItem item) => dynamics[ID] = item;
public void add_item(ConfigurationItem item) { CoolPropPINVOKE.Configuration_add_item(swigCPtr, ConfigurationItem.getCPtr(item)); if (CoolPropPINVOKE.SWIGPendingException.Pending) throw CoolPropPINVOKE.SWIGPendingException.Retrieve(); }
private ConfigurationItem BuildToppingsItem(int sequence) { var configurationItem = new ConfigurationItem { Name = "Toppings", Sequence = sequence, EndUserInstructions = "Choose your toppings", Id = Guid.Parse("DFBD54D6-16DB-4363-8966-B4FDBE80E43F") }; configurationItem.ConfigurationRules.Add(new MinSelectedOptionsRule { Count = 1 }); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Extra Cheese", Sequence = 1, Id = Guid.Parse("31874172-560A-4B60-93EE-39999636969C") }); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Pepperoni", Sequence = 2, Id = Guid.Parse("D5F35E1E-7D58-4607-83F5-6EAEF2CB411C") }); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Sausage", Sequence = 3, Id = Guid.Parse("5FAEB33B-65FF-4295-AAD2-D16F6763C986") }); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Canadian Bacon", Sequence = 4, Id = Guid.Parse("2C711877-488D-4DCF-A86F-F24F1D7FDC2F") }); configurationItem.ConfigurationItemOptions.Add(new ConfigurationItemOption { Name = "Mushrooms", Sequence = 5, Id = Guid.Parse("78ED2669-DEDC-41C0-9B15-31DC9C4B749D") }); return configurationItem; }