Beispiel #1
0
        /// <summary>
        /// Configure options
        /// </summary>
        /// <remarks>Execute only in application startup</remarks>
        public static void Configure <T>(Action <T> configure)
        {
            var          type = typeof(T);
            OptionsEntry entry;

            if (!_options.TryGetValue(type, out entry))
            {
                entry = new OptionsEntry
                {
                    Type = type
                };
                _options.Add(type, entry);
            }
            entry.Configure.Add(o => configure((T)o));
        }
Beispiel #2
0
        /// <summary>
        /// Get options
        /// </summary>
        public static T Get <T>()
        {
            var          type = typeof(T);
            OptionsEntry entry;

            if (!_options.TryGetValue(type, out entry))
            {
                entry = new OptionsEntry
                {
                    Type = type
                };
                _options.Add(type, entry);
            }
            return((T)entry.Value);
        }