private ConfigurationDictionary GetConfiguration(Friend friend) { var configuration = new ConfigurationDictionary { ["title_text"] = friend.Name }; switch (friend.State) { case FriendState.Accepted: configuration["subtitle_text"] = "Zaproś do gry"; configuration["subtitle_color"] = Color.green; break; case FriendState.Invitation: configuration["subtitle_text"] = "Zaakceptuj znajomość!"; configuration["subtitle_color"] = Color.yellow; break; default: configuration["subtitle_text"] = "Error"; configuration["subtitle_color"] = Color.black; break; } return(configuration); }
public void Setup() { SecuritySettings settings = new SecuritySettings(); settings.DefaultProfileProviderName = "provider2"; CustomProfileProviderData provider1Data = new CustomProfileProviderData(); provider1Data.Name = "provider1"; provider1Data.TypeName = typeof(MockProfileProvider).AssemblyQualifiedName; settings.ProfileProviders.Add(provider1Data); CustomProfileProviderData provider2Data = new CustomProfileProviderData(); // provider2Data.Default = true; provider2Data.Name = "provider2"; provider2Data.TypeName = typeof(Mock2ProfileProvider).AssemblyQualifiedName; settings.ProfileProviders.Add(provider2Data); ConfigurationDictionary dictionary = new ConfigurationDictionary(); dictionary[SecuritySettings.SectionName] = settings; ConfigurationContext context = ConfigurationManager.CreateContext(dictionary); this.factory = new ProfileProviderFactory(context); }
public void CopyToTests() { var testContext = _propertyTestData.GetContext(); var x = new ConfigurationDictionary <IChildElement>(null, testContext.ChildConfigurationDictionaryPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings()); var a = testContext.GetChildElement("a"); var b = testContext.GetChildElement("b"); var c = testContext.GetChildElement("c"); x.AddCopy("a", a); x.AddCopy("b", b); x.AddCopy("c", c); var array = new KeyValuePair <string, IChildElement> [3]; x.CopyTo(array, 0); Assert.Equal(a, array[0].Value, ConfigurationObjectComparer.Instance); Assert.Equal(b, array[1].Value, ConfigurationObjectComparer.Instance); Assert.Equal(c, array[2].Value, ConfigurationObjectComparer.Instance); Assert.Throws <ArgumentException>(() => x.CopyTo(array, 1)); Assert.Throws <ArgumentOutOfRangeException>(() => x.CopyTo(array, -1)); array = new KeyValuePair <string, IChildElement> [2]; Assert.Throws <ArgumentException>(() => x.CopyTo(array, 0)); x.Dispose(); Assert.Throws <ObjectDisposedException>(() => x.CopyTo(array, 0)); }
public void ContainsTests() { var testContext = _propertyTestData.GetContext(); var x = new ConfigurationDictionary <IChildElement>(null, testContext.ChildConfigurationDictionaryPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings()); var a = testContext.GetChildElement("a"); var b = testContext.GetChildElement("b"); var c = testContext.GetChildElement("c"); var d = testContext.GetChildElement("d"); x.AddCopy("a", a); x.AddCopy("b", b); Assert.True(x.Contains(a)); Assert.True(x.Contains(b)); Assert.False(x.Contains(c)); Assert.False(x.Contains(null)); Assert.True(((ICollection <KeyValuePair <string, IChildElement> >)x).Contains(new KeyValuePair <string, IChildElement>("a", a))); Assert.False(((ICollection <KeyValuePair <string, IChildElement> >)x).Contains(new KeyValuePair <string, IChildElement>("d", d))); x.Dispose(); Assert.Throws <ObjectDisposedException>(() => x.Contains(a)); Assert.Throws <ObjectDisposedException>(() => ((ICollection <KeyValuePair <string, IChildElement> >)x).Contains(new KeyValuePair <string, IChildElement>("a", a))); }
public void Setup() { SecuritySettings data = new SecuritySettings(); data.DefaultAuthenticationProviderName = "provider2"; CustomAuthenticationProviderData provider1Data = new CustomAuthenticationProviderData(); provider1Data.Name = "provider1"; provider1Data.TypeName = typeof(MockAuthenticationProvider).AssemblyQualifiedName; data.AuthenticationProviders.Add(provider1Data); CustomAuthenticationProviderData provider2Data = new CustomAuthenticationProviderData(); provider2Data.Name = "provider2"; provider2Data.TypeName = typeof(Mock2AuthenticationProvider).AssemblyQualifiedName; // provider2Data.Default = true; data.AuthenticationProviders.Add(provider2Data); ConfigurationDictionary dictionary = new ConfigurationDictionary(); dictionary[SecuritySettings.SectionName] = data; ConfigurationContext context = ConfigurationManager.CreateContext(dictionary); this.factory = new AuthenticationProviderFactory(context); }
/// <summary> /// Serializes to a stream /// </summary> /// <param name="data">The map</param> /// <param name="output">The output stream</param> public void Serialize(ConfigurationDictionary data, TextWriter output) { var stack = new Stack<IEnumerator<KeyValuePair<string, object>>>(); stack.Push(data.GetEnumerator()); while(stack.Count > 0) { var en = stack.Peek(); if (en.MoveNext()) { var kvp = en.Current; if (kvp.Value == null | kvp.Key == null) continue; var valueAsMap = kvp.Value as ConfigurationDictionary; if (valueAsMap != null) { output.WriteLine("[{0}]", kvp.Key); stack.Push(valueAsMap.GetEnumerator()); } else { output.WriteLine("{0}={1}", kvp.Key, kvp.Value); } } else stack.Pop(); } }
public void CanReadCachedServerConfig() { var serverConfig = new ConfigurationDictionary { { "FromServer", "Server" } }; var client = new ExceptionlessClient(); ClientConfiguration.ProcessServerConfigResponse(client, serverConfig, DEFAULT_STORE); ClientConfiguration config = ClientConfiguration.Create(client); Assert.NotNull(config); Assert.True(config.ContainsKey("FromServer")); Assert.Equal(config["FromServer"], "Server"); Assert.True(config.ContainsKey("AttributeOnly")); Assert.Equal(config["AttributeOnly"], "Attribute"); Assert.True(config.ContainsKey("UserNamespaces")); Assert.Equal(config["UserNamespaces"], "Exceptionless,FromConfig"); Assert.True(config.ContainsKey("ConfigAndAttribute")); Assert.Equal(config["ConfigAndAttribute"], "Config"); Assert.True(config.ContainsKey("AppConfigOnly")); Assert.Equal(config["AppConfigOnly"], "Config"); }
public static void Configuration(TextWriter fout, IEnumerable<KeyValuePair<string, object>> config) { //Console.WriteLine(new PHPSerializer().Serialize(config)); var data = new ConfigurationDictionary(config); string generatorName; IGenerator generator; if (data.TryGetValueAs("Generator", out generatorName)) { if (!TryParseGenerator(generatorName, out generator)) { Console.Error.WriteLine($"Unknown generator \"{generatorName}\""); return; } } else { Console.Error.WriteLine("No generator specified"); return; } using (fout) { generator.Generate(data, fout); } }
/// <summary> /// Creates a named database instance from the data configuration types /// </summary> /// <param name="instanceName">The instance name to use for the database</param> /// <param name="connectionData">The connection string data</param> /// <param name="providerData">The type provider data</param> /// <returns>An initialized database provider</returns> public static Database CreateDatabase(string instanceName, ConnectionStringData connectionData, DatabaseTypeData providerData) { ArgumentValidation.CheckForEmptyString(instanceName, "Instance Name"); ArgumentValidation.CheckForNullReference(connectionData, "Connection Data"); ArgumentValidation.CheckForNullReference(providerData, "Provider Data"); DatabaseSettings settings = new DatabaseSettings(); // Setup the provider and connection string data settings.DatabaseTypes.Add(providerData); settings.ConnectionStrings.Add(connectionData); // The instance data binds the provider and connection string together InstanceData instanceData = new InstanceData(); instanceData.ConnectionString = connectionData.Name; instanceData.DatabaseTypeName = providerData.Name; instanceData.Name = instanceName; // setup your instanceData settings.Instances.Add(instanceData); // Setup a data dictionary ConfigurationDictionary configDictionary = new ConfigurationDictionary(); configDictionary.Add(_configName, settings); ConfigurationContext context = ConfigurationManager.CreateContext(configDictionary); return(new DatabaseProviderFactory(context).CreateDatabase(instanceName)); }
public void ClearTests() { var testContext = _propertyTestData.GetContext(); var a = testContext.GetChildElement("a"); var b = testContext.GetChildElement("b"); var c = testContext.GetChildElement("c"); var d = testContext.GetChildElement("d"); var x = new ConfigurationDictionary <IChildElement>(null, testContext.ChildConfigurationDictionaryPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), Get("a", a), Get("b", b), Get("c", c), Get("d", d)); Assert.Equal(4, x.Count); var change = (NotifyCollectionChangedAction)(-1); x.CollectionChanged += (sender, args) => { change = args.Action; }; x.Clear(); Assert.Equal(0, x.Count); Assert.Equal(NotifyCollectionChangedAction.Reset, change); foreach (var item in x) { Assert.True(false); } x.Dispose(); Assert.Throws <ObjectDisposedException>(() => x.Clear()); }
public void TestConstructor() { var testContext = _propertyTestData.GetContext(); var propertyDef = testContext.ChildConfigurationDictionaryPropertyDef; var x = new ConfigurationDictionary <IChildElement>(null, propertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings()); Assert.NotNull(x); Assert.Equal(0, x.Count); Assert.Equal(propertyDef.PropertyName, x.PropertyDef.PropertyName); x = new ConfigurationDictionary <IChildElement>(null, propertyDef, testContext.Configuration.ConfigurationRoot, (IEnumerable <KeyValuePair <string, IChildElement> >)null, new ConfigurationObjectSettings()); Assert.NotNull(x); Assert.Equal(0, x.Count); Assert.Equal(propertyDef.PropertyName, x.PropertyDef.PropertyName); var a = testContext.GetChildElement("a"); var b = testContext.GetChildElement("b"); x = new ConfigurationDictionary <IChildElement>(null, propertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), Get("a", a), Get("b", b)); Assert.NotNull(x); Assert.Equal(2, x.Count); Assert.Equal(propertyDef.PropertyName, x.PropertyDef.PropertyName); x = new ConfigurationDictionary <IChildElement>(null, propertyDef, testContext.Configuration.ConfigurationRoot, (IEnumerable <KeyValuePair <string, IChildElement> >)(new[] { Get("a", a), Get("b", b) }), new ConfigurationObjectSettings()); Assert.NotNull(x); Assert.Equal(2, x.Count); Assert.Equal(propertyDef.PropertyName, x.PropertyDef.PropertyName); }
public IObservable <Unit> AddItem(ConfigurationDictionary configuration) { var item = Instantiate(_listItemPrefab, transform); item.SetActive(true); item.GetComponent <IConfigurable>().Configure(configuration); return(item.GetComponent <Button>().OnClickAsObservable()); }
public void BuildContext() { ConfigurationDictionary dictionary = new ConfigurationDictionary(); Assert.AreEqual(0, dictionary.Count); manager.BuildContext(Host, dictionary); Assert.AreEqual(1, dictionary.Count); Assert.AreEqual(typeof(ConfigurationSettings), dictionary[ConfigurationSettings.SectionName].GetType()); }
/// <summary> /// Generates code /// </summary> /// <param name="data">The data</param> /// <param name="output">The output</param> public void Generate(ConfigurationDictionary data, TextWriter output) { CSharpCodeProvider provider = new CSharpCodeProvider(); LexerConfig config = GenerateConfig(data); GenerateLexer(config, output); }
public void Configure <T2>(ConfigurationDictionary <T2> _conf) where T2 : InputOutputConfig { // in this line, you need the class template T, not the inner T2 configuration = new ConfigurationDictionary <T>(); foreach (KeyValuePair <string, T2> kvp in _conf) { } }
public void IsReadOnlyTests() { var testContext = _propertyTestData.GetContext(); var x = new ConfigurationDictionary <IChildElement>(null, testContext.ChildConfigurationDictionaryPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings()); Assert.False(x.IsReadOnly); }
/// <summary> /// Serializes to a string /// </summary> /// <param name="data">The map</param> /// <returns>The INI data</returns> public string Serialize(ConfigurationDictionary data) { using (var sw = new StringWriter()) { Serialize(data, sw); return sw.ToString(); } }
public void DisposeTests() { var testContext = _propertyTestData.GetContext(); var x = new ConfigurationDictionary <IChildElement>(null, testContext.ChildConfigurationDictionaryPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings()); x.Dispose(); Assert.Throws <ObjectDisposedException>(() => x.ContainsKey("A")); }
public MetroNotification(ConfigurationDictionary configuration) { this.Configuration = configuration; if (configuration.IsTrue("debuginstall")) { DebugInstall(); } }
public void InMemoryInvalidSectionTest() { ConfigurationDictionary dictionary = new ConfigurationDictionary(); using (ConfigurationBuilder builder = new ConfigurationBuilder(dictionary)) { builder.ReadConfiguration("invalidSection"); } }
public writing() { Entry = new ConfigurationDictionary <Config> { { "sauron", new Config { Evil = "great" } } }; when_saving_configuration("sauron"); }
public void ConstructorWithConfigurationDictionaryTest() { ConfigurationDictionary dictionary = new ConfigurationDictionary(); object expected = new object(); dictionary.Add("section1", expected); ConfigurationContext context = ConfigurationManager.CreateContext(dictionary); object actual = context.GetConfiguration("section1"); Assert.AreSame(expected, actual); }
private static ConfigurationDictionary GenerateConfigurationDictionary() { ConfigurationDictionary dictionary = new ConfigurationDictionary(); dictionary = new ConfigurationDictionary(); dictionary.Add(ConfigurationSettings.SectionName, GenerateConfigurationSettings()); dictionary.Add(ExceptionHandlingSettings.SectionName, GenerateExceptionHandlingSettings()); return(dictionary); }
/// <devdoc> /// Build the context for the design. /// </devdoc> internal ConfigurationContext BuildContext() { ConfigurationDictionary dictionary = new ConfigurationDictionary(); foreach (IConfigurationDesignManager manager in managers) { manager.BuildContext(serviceProvider, dictionary); } return ConfigurationManager.CreateContext(dictionary); }
/// <summary> /// <para>Adds to the dictionary configuration data for /// the enterpriselibrary.configurationSettings configuration section.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="configurationDictionary"> /// <para>A <see cref="ConfigurationDictionary"/> to add /// configuration data to.</para></param> public override void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { ClientSettingsNode node = GetClientSettingsNode(serviceProvider); if (node != null) { LoggingSettings settings = node.LoggingSettings; configurationDictionary[LoggingSettings.SectionName] = settings; } }
public void BuildContextTest() { HierarchyService.SelectedHierarchy.Open(); ExceptionHandlingConfigurationDesignManager b = new ExceptionHandlingConfigurationDesignManager(); ConfigurationDictionary dictionary = new ConfigurationDictionary(); b.BuildContext(Host, dictionary); Assert.AreEqual(1, dictionary.Count); Assert.IsTrue(dictionary.Contains("exceptionHandlingConfiguration")); }
/// <summary> /// <para>Adds to the dictionary configuration data for /// the enterpriselibrary.configurationSettings configuration section.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="configurationDictionary"> /// <para>A <see cref="ConfigurationDictionary"/> to add /// configuration data to.</para></param> public void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { SecuritySettingsNode node = GetSecuritySettingsNode(serviceProvider); if (node != null) { SecuritySettings settings = node.SecuritySettings; configurationDictionary[SecuritySettings.SectionName] = settings; } }
/// <summary> /// <para>Adds to the dictionary configuration data for /// the enterpriselibrary.configurationSettings configuration section.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="configurationDictionary"> /// <para>A <see cref="ConfigurationDictionary"/> to add /// configuration data to.</para></param> public override void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { DistributorSettingsNode node = GetDistributorSettingsNode(serviceProvider); if (node != null) { DistributorSettings settings = node.DistributorSettings; configurationDictionary[DistributorSettings.SectionName] = settings; } }
/// <summary> /// <para>Adds to the dictionary configuration data for /// the enterpriselibrary.configurationSettings configuration section.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="configurationDictionary"> /// <para>A <see cref="ConfigurationDictionary"/> to add /// configuration data to.</para></param> public void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { ExceptionHandlingSettingsNode node = GetExceptionHandlingSettingsNode(serviceProvider); if (node != null) { ExceptionHandlingSettings settings = node.ExceptionHandlingSettings; configurationDictionary[ExceptionHandlingSettings.SectionName] = settings; } }
private static ConfigurationDictionary GenerateConfigurationDictionary() { if (dictionary == null) { dictionary = new ConfigurationDictionary(); dictionary.Add(ConfigurationSettings.SectionName, GenerateConfigurationSettings()); dictionary.Add(CryptographySettings.SectionName, GenerateBlockSettings()); } return(dictionary); }
private static ConfigurationDictionary GenerateConfigurationDictionary() { ConfigurationDictionary dictionary = new ConfigurationDictionary(); dictionary = new ConfigurationDictionary(); dictionary.Add(ConfigurationSettings.SectionName, GenerateConfigurationSettings()); dictionary.Add(CacheManagerSettings.SectionName, GenerateCachingSettings()); return(dictionary); }
private static ConfigurationDictionary GenerateConfigurationDictionary() { if (dictionary == null) { dictionary = new ConfigurationDictionary(); dictionary.Add(ConfigurationSettings.SectionName, GenerateConfigurationSettings()); dictionary.Add(DatabaseSettings.SectionName, GenerateDataSettings()); } return(dictionary); }
/// <summary> /// <para>Adds to the dictionary configuration data for /// the enterpriselibrary.configurationSettings configuration section.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="configurationDictionary"> /// <para>A <see cref="ConfigurationDictionary"/> to add /// configuration data to.</para></param> public void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { CacheManagerSettingsNode node = GetCacheManagerSettingsNode(serviceProvider); if (node != null) { CacheManagerSettings settings = node.CacheManagerSettings; configurationDictionary[CacheManagerSettings.SectionName] = settings; } }
private ConfigurationContext GetContext() { ConfigurationContext context = currentNode.Hierarchy.BuildConfigurationContext(); ConfigurationSettings settings = context.GetMetaConfiguration(); ConfigurationDictionary config = new ConfigurationDictionary(); config.Add(ConfigurationSettings.SectionName, settings); context = new ConfigurationContext(config); return(context); }
/// <devdoc> /// Build the context for the design. /// </devdoc> internal ConfigurationContext BuildContext() { ConfigurationDictionary dictionary = new ConfigurationDictionary(); foreach (IConfigurationDesignManager manager in managers) { manager.BuildContext(serviceProvider, dictionary); } return(ConfigurationManager.CreateContext(dictionary)); }
public void RemoveTests() { var testContext = _propertyTestData.GetContext(); var x = new ConfigurationDictionary <IChildElement>(null, testContext.ChildConfigurationDictionaryPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings()); var a = testContext.GetChildElement("a"); var b = testContext.GetChildElement("b"); var c = testContext.GetChildElement("c"); var d = testContext.GetChildElement("d"); x.AddCopy("a", a); x.AddCopy("b", b); x.AddCopy("c", c); var change = (NotifyCollectionChangedAction)(-1); x.CollectionChanged += (sender, args) => { change = args.Action; }; Assert.True(x.Remove(b)); Assert.Equal(NotifyCollectionChangedAction.Remove, change); change = (NotifyCollectionChangedAction)(-1); Assert.False(x.Remove(b)); Assert.Equal((NotifyCollectionChangedAction)(-1), change); Assert.Equal(2, x.Count); var n = 0; foreach (var item in x) { switch (n++) { case 0: Assert.Equal(a, item.Value, ConfigurationObjectComparer.Instance); break; case 1: Assert.Equal(c, item.Value, ConfigurationObjectComparer.Instance); break; default: Assert.True(false); break; } } x.AddCopy("b", b); Assert.True(x.Remove(new KeyValuePair <string, IChildElement>("b", b))); Assert.False(x.Remove(new KeyValuePair <string, IChildElement>("b", b))); x.Dispose(); Assert.Throws <ObjectDisposedException>(() => x.Remove(a)); }
/// <summary> /// Generates a config from a map /// </summary> /// <param name="data">The map</param> /// <returns>The config</returns> public LexerConfig GenerateConfig(ConfigurationDictionary data) { LexerConfig config = new LexerConfig(); { var stringData = data.Caster<string>(); config.Namespace = stringData["Namespace"]; config.Name = stringData["Name"]; config.Enum = stringData["Enum"]; config.Method = stringData["Method"]; config.ExceptionMethod = stringData["ExceptionMethod"]; config.Partial = data.ValueAs<bool>("Partial", false); } var ic = new SortedDictionary<string, LexerConfig.State.Case.Instruction.InstructionCode>(StringComparer.CurrentCultureIgnoreCase); ic["Clear"] = LexerConfig.State.Case.Instruction.InstructionCode.Clear; ic["InPos"] = LexerConfig.State.Case.Instruction.InstructionCode.InPos; ic["PushInput"] = LexerConfig.State.Case.Instruction.InstructionCode.PushInput; ic["Push"] = LexerConfig.State.Case.Instruction.InstructionCode.Push; ic["PushCode"] = LexerConfig.State.Case.Instruction.InstructionCode.PushCode; ic["InPos"] = LexerConfig.State.Case.Instruction.InstructionCode.InPos; ic["InCode"] = LexerConfig.State.Case.Instruction.InstructionCode.InCode; ic["FMA"] = LexerConfig.State.Case.Instruction.InstructionCode.FMA; ic["FSO"] = LexerConfig.State.Case.Instruction.InstructionCode.FSO; ic["Code"] = LexerConfig.State.Case.Instruction.InstructionCode.Code; ic["Xor"] = LexerConfig.State.Case.Instruction.InstructionCode.Xor; ic["Or"] = LexerConfig.State.Case.Instruction.InstructionCode.Or; ic["And"] = LexerConfig.State.Case.Instruction.InstructionCode.And; ic["State"] = LexerConfig.State.Case.Instruction.InstructionCode.State; ic["Die"] = LexerConfig.State.Case.Instruction.InstructionCode.Die; ic["Yield"] = LexerConfig.State.Case.Instruction.InstructionCode.Yield; ic["YieldInput"] = LexerConfig.State.Case.Instruction.InstructionCode.YieldInput; ic["ToLower"] = LexerConfig.State.Case.Instruction.InstructionCode.ToLower; ic["ToUpper"] = LexerConfig.State.Case.Instruction.InstructionCode.ToUpper; { var states = new List<LexerConfig.State>(); foreach (var state in data.ValueAs<ConfigurationDictionary>("States")) { ProcessState(state, states, ic); } config.States = states.ToArray(); } return config; }
public void EncryptTest() { string keyPhrase = "test-key"; var target = new ConfigurationDictionary(); target.Add("bool", "true"); target.Add("int", "123"); target.Add("date", new DateTime(2000, 1, 1).ToString()); target.Add("guid", Guid.NewGuid().ToString()); string encrypt = target.Encrypt(keyPhrase); var result = new ConfigurationDictionary(); result.Decrypt(encrypt, keyPhrase); Assert.AreNotSame(target, result); Assert.AreEqual(target.Count, result.Count); }
// TODO: Add support for user public key token on signed assemblies public ErrorSignature(ErrorInfo error, IEnumerable<string> userNamespaces = null, IEnumerable<string> userCommonMethods = null, bool emptyNamespaceIsUserMethod = true, bool shouldFlagSignatureTarget = true) { if (error == null) throw new ArgumentNullException("error"); Error = error; _userNamespaces = userNamespaces == null ? new HashSet<string>() : new HashSet<string>(userNamespaces); _userCommonMethods = userCommonMethods == null ? new HashSet<string>() : new HashSet<string>(userCommonMethods); EmptyNamespaceIsUserMethod = emptyNamespaceIsUserMethod; SignatureInfo = new ConfigurationDictionary(); ShouldFlagSignatureTarget = shouldFlagSignatureTarget; Parse(); }
/// <summary> /// Deserializes a stream /// </summary> /// <param name="input">The input</param> /// <returns>The map</returns> public ConfigurationDictionary Deserialize(TextReader input) { string line; ConfigurationDictionary map = new ConfigurationDictionary(); ConfigurationDictionary section = map; while((line = input.ReadLine()) != null) { if (line.Length >= 2 && line[0] == '[' && line[line.Length - 1] == ']') { map.Add(line.Substring(1, line.Length - 2), section = new ConfigurationDictionary()); } int eql; if ((eql = line.IndexOf('=')) != -1) { section.Add(line.Substring(0, eql), line.Substring(eql + 1)); } } return map; }
public JSONSerializeState(ConfigurationDictionary List, int Index) { this.List = List; this.Index = Index; this.IsArray = this.List.IsArray; }
public JSONDeserializeState2(ConfigurationDictionary List, bool IsArray, JSONDeserializeSubstate Substate) { this.List = List; this.IsArray = IsArray; this.Substate = Substate; }
private ConfigurationContext GetContext() { IUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(provider); ConfigurationContext context = hierarchy.BuildConfigurationContext(); ConfigurationSettings settings = context.GetMetaConfiguration(); ConfigurationDictionary config = new ConfigurationDictionary(); config.Add(ConfigurationSettings.SectionName, settings); context = new ConfigurationContext(config); return context; }
void IConfigurationDesignManager.BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary dictionary) { dictionary.Add("mySection", "My Configuration Data"); }
private ConfigurationContext GetContext() { ConfigurationContext context = currentNode.Hierarchy.BuildConfigurationContext(); ConfigurationSettings settings = context.GetMetaConfiguration(); ConfigurationDictionary config = new ConfigurationDictionary(); config.Add(ConfigurationSettings.SectionName, settings); context = new ConfigurationContext(config); return context; }
public ClientConfiguration() { Settings = new ConfigurationDictionary(); }
public void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { CallCheck.BuildCalled = true; CallCheck.ServiceProvider = serviceProvider; }
public void WhenCreatingAContextMakeSureThatAllSectionsAreAddedToTheCache() { const string sectionA = "SectionA"; const string sectionB = "SectionB"; const string sectionAData = "SectionAData"; const string sectionBData = "SectionBData"; ConfigurationDictionary configurationDictionary = new ConfigurationDictionary(); configurationDictionary.Add(sectionA, sectionAData); configurationDictionary.Add(sectionB, sectionBData); configurationDictionary.Add(ConfigurationSettings.SectionName, new ConfigurationSettings()); ConfigurationContext context = ConfigurationManager.CreateContext(configurationDictionary); Assert.IsFalse(context.disposableWrapper.ConfigurationBuilder.CacheContains(ConfigurationSettings.SectionName), "Cache should not " + ConfigurationSettings.SectionName); Assert.IsTrue(context.disposableWrapper.ConfigurationBuilder.CacheContains(sectionA)); Assert.IsTrue(context.disposableWrapper.ConfigurationBuilder.CacheContains(sectionB)); Assert.AreEqual(sectionAData, context.GetConfiguration(sectionA)); Assert.AreEqual(sectionBData, context.GetConfiguration(sectionB)); }
public void InMemoryConfigurationManagerTest() { ConfigurationDictionary dictionary = new ConfigurationDictionary(); object configurationData = new object(); dictionary.Add("mySection", configurationData); using (ConfigurationBuilder builder = new ConfigurationBuilder(dictionary)) { object actual = builder.ReadConfiguration("mySection"); Assert.AreSame(configurationData, actual); } }
public void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { }
public SeqState(ConfigurationDictionary Map) { this.Index = 0; this.List = Map; this.IsArray = Map.IsArray; }
public PHPSerializeState(ConfigurationDictionary Map) { this.Map = Map; this.Index = 0; }
internal static void ProcessServerConfigResponse(IConfigurationAndLogAccessor accessors, ConfigurationDictionary serverConfig, string storeId) { if (serverConfig == null) return; try { // only allow one save at a time using (new SingleGlobalInstance(String.Concat(storeId, CachedServerConfigFile).GetHashCode().ToString(), 500)) { // retry loop for (int retry = 0; retry < 2; retry++) { using (var dir = new IsolatedStorageDirectory(storeId)) { try { dir.WriteFile(CachedServerConfigFile, serverConfig); break; } catch (Exception ex) { // File is being used by another process or thread or the file does not exist. accessors.Log.FormattedError(ex, "Unable to save server config to local storage: {0}", ex.Message); Thread.Sleep(50); } } } } } catch (Exception ex) { accessors.Log.Error(ex, "An error occurred while saving client configuration"); } // apply the config values from the server to the current client configuration foreach (string k in serverConfig.Keys) accessors.Configuration[k] = serverConfig[k]; // if a set of data exclusions are not sent down, then it means that there aren't any exclusions. if (!serverConfig.ContainsKey("@@DataExclusions")) accessors.Configuration["@@DataExclusions"] = String.Empty; }
public void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { this.manager.BuildContext(serviceProvider, configurationDictionary); }
private ConfigurationContext CreateContext(string xmlToUse) { XmlTextReader xmlReader = new XmlTextReader(new StringReader(xmlToUse)); XmlSerializer xmlSerializer = new XmlSerializer(typeof(ConfigurationSettings)); ConfigurationSettings configurationSettings = xmlSerializer.Deserialize(xmlReader) as ConfigurationSettings; ConfigurationDictionary dictionary = new ConfigurationDictionary(); dictionary.Add(ConfigurationSettings.SectionName, configurationSettings); ConfigurationContext context = new ConfigurationContext(dictionary); return context; }
/// <summary> /// <para>Adds the <see cref="ConfigurationSettings"/> to the <see cref="ConfigurationDictionary"/>.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="configurationDictionary"> /// <para>A <see cref="ConfigurationDictionary"/> object that will contain the configuration data.</para></param> public void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { configurationDictionary[ConfigurationSettings.SectionName] = GetConfigurationSettings(serviceProvider); }
private static void ProcessCase(ConfigurationDictionary scase, List<LexerConfig.State.Case> mcases, SortedDictionary<string, LexerConfig.State.Case.Instruction.InstructionCode> ic) { var matches = new SortedSet<int>(); var instructions = new List<LexerConfig.State.Case.Instruction>(); ProcessMatches(scase[0].Value, matches, ic); for (int i = 1; i < scase.Count; i++) { var inspair = scase[i].Value; if (inspair is string) { try { instructions.Add(new LexerConfig.State.Case.Instruction() { Code = ic[inspair.ToString()], Arguments = null }); } catch (Exception) { throw new Exception(inspair.ToString()); } } else if (inspair is ConfigurationDictionary) { var insmap = (ConfigurationDictionary)inspair; var args = new List<object>(); for (int j = 1; j < insmap.Count; j++) args.Add(insmap[j].Value); instructions.Add(new LexerConfig.State.Case.Instruction() { Code = ic[insmap[0].Value.ToString()], Arguments = args.ToArray() }); } } mcases.Add(new LexerConfig.State.Case() { Matches = matches.ToArray(), Instructions = instructions.ToArray() }); }