Abp.Configuration.DictionaryBasedConfig.Get(string)

Here are the examples of the csharp api class Abp.Configuration.DictionaryBasedConfig.Get(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

1. Example

Project: aspnetboilerplate
Source File: DictionaryBasedConfig_Test.cs
[Fact]
        public void Should_Get_Value()
        {
            var testObject = new TestClass {Value = 42};

            _config["IntValue"] = 42;
            _config["StringValue"] = "Test string";
            _config["ObjectValue"] = testObject;

            _config["IntValue"].ShouldBe(42);
            _config.Get<int>("IntValue").ShouldBe(42);

            _config["StringValue"].ShouldBe("Test string");
            _config.Get<string>("StringValue").ShouldBe("Test string");

            _config["ObjectValue"].ShouldBeSameAs(testObject);
            _config.Get<TestClass>("ObjectValue").ShouldBeSameAs(testObject);
            _config.Get<TestClass>("ObjectValue").Value.ShouldBe(42);
        }

2. Example

Project: aspnetboilerplate
Source File: DictionaryBasedConfig_Test.cs
[Fact]
        public void Should_Get_Default_If_No_Value()
        {
            _config["MyUndefinedName"].ShouldBe(null);
            _config.Get<string>("MyUndefinedName").ShouldBe(null);
            _config.Get<MyConfig>("MyUndefinedName").ShouldBe(null);
            _config.Get<int>("MyUndefinedName").ShouldBe(0);
        }

3. Example

Project: aspnetboilerplate
Source File: DictionaryBasedConfig.cs
public T GetOrCreate<T>(string name, Func<T> creator)
        {
            var value = Get(name);
            if (value == null)
            {
                value = creator();
                Set(name, value);
            }
            return (T) value;
        }