public static bool TryCreate(out IConfigTestDataService service)
        {
            var section = ConfigurationManager.GetSection(SectionName) as TestDataSection;

            if (section == null)
            {
                service = null;
                return false;
            }

            service = new SectionConfigTestDataService(section);
            return true;
        }
        public static bool TryCreate(out IConfigTestDataService service)
        {
            var section = ConfigurationManager.GetSection(SectionName) as TestDataSection;

            if (section == null)
            {
                service = null;
                return(false);
            }

            service = new SectionConfigTestDataService(section);
            return(true);
        }
        public static void SetService(IConfigTestDataService service)
        {
            if (service == null)
                throw new ArgumentNullException(nameof(service));

            lock (ServiceLock)
            {
                if (_service != null)
                    throw new InvalidOperationException("IConfigTestDataService already set");

                _service = service;
            }
        }
        public static bool TryCreate(out IConfigTestDataService service)
        {
            var hasKeys = ConfigurationManager.AppSettings.AllKeys.Any(k => PrefixRegex.IsMatch(k));

            if (hasKeys)
            {
                service = new AppConfigTestDataService(ConfigurationManager.AppSettings);
                return(true);;
            }

            service = null;
            return(false);
        }
        public static bool TryCreate(out IConfigTestDataService service)
        {
            var hasKeys = ConfigurationManager.AppSettings.AllKeys.Any(k => PrefixRegex.IsMatch(k));

            if (hasKeys)
            {
                service = new AppConfigTestDataService(ConfigurationManager.AppSettings);
                return true;;
            }
            
            service = null;
            return false;
        }
Пример #6
0
        public static void SetService(IConfigTestDataService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            lock (ServiceLock)
            {
                if (_service != null)
                {
                    throw new InvalidOperationException("IConfigTestDataService already set");
                }

                _service = service;
            }
        }