예제 #1
0
        internal static ErrorStore Get(ErrorStoreSettings settings)
        {
            if (settings?.Type == null)
            {
                return(new MemoryErrorStore());
            }

            // a bit of validation
            if (settings.Size < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(settings), "ErrorStore 'size' must be at least 1");
            }

            // Search by convention first
            // or...free for all!
            Type match = KnownStoreTypes.Find(s => s.Name == settings.Type + nameof(ErrorStore))
                         ?? KnownStoreTypes.Find(s => s.Name.Contains(settings.Type));

            if (match == null)
            {
                throw new Exception("Could not find error store type: " + settings.Type);
            }

            try
            {
                return((ErrorStore)Activator.CreateInstance(match, settings));
            }
            catch (Exception ex)
            {
                throw new Exception("Error creating a " + settings.Type + " error store: " + ex.Message, ex);
            }
        }
        private static ErrorStore GetFromSettings(ErrorStoreSettings settings)
        {
            if (settings == null)
            {
                return(null);
            }

            // a bit of validation
            if (settings.Type.IsNullOrEmpty())
            {
                throw new ArgumentOutOfRangeException("settings", "ErrorStore 'type' must be specified");
            }
            if (settings.Size < 1)
            {
                throw new ArgumentOutOfRangeException("settings", "ErrorStore 'size' must be positive");
            }

            switch (settings.Type)
            {
            case "JSON":
                return(new JSONErrorStore(settings));

            case "Memory":
                return(new MemoryErrorStore(settings));

            case "SQL":
                return(new SQLErrorStore(settings));

            default:
                throw new Exception("Unknwon error store type: " + settings.Type);
            }
        }
예제 #3
0
        private static ErrorStore GetFromSettings(ErrorStoreSettings settings)
        {
            if (settings == null)
            {
                return(null);
            }

            // a bit of validation
            if (settings.Type.IsNullOrEmpty())
            {
                throw new ArgumentOutOfRangeException(nameof(settings), "ErrorStore 'type' must be specified");
            }
            if (settings.Size < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(settings), "ErrorStore 'size' must be positive");
            }

            var storeTypes = GetErrorStores();
            // Search by convention first
            var match = storeTypes.FirstOrDefault(s => s.Name == settings.Type + "ErrorStore");

            if (match == null)
            {
                // well shit, free for all!
                match = storeTypes.FirstOrDefault(s => s.Name.Contains(settings.Type));
            }

            if (match == null)
            {
                throw new Exception("Could not find error store type: " + settings.Type);
            }

            try
            {
                return((ErrorStore)Activator.CreateInstance(match, settings));
            }
            catch (Exception ex)
            {
                throw new Exception("Error creating a " + settings.Type + " error store: " + ex.Message, ex);
            }
        }
 /// <summary>
 /// Base constructor of the error store to set common properties
 /// </summary>
 protected ErrorStore(ErrorStoreSettings settings) : this(settings.RollupSeconds, settings.BackupQueueSize) { }
        private static ErrorStore GetFromSettings(ErrorStoreSettings settings)
        {
            if (settings == null) return null;

            // a bit of validation
            if (settings.Type.IsNullOrEmpty())
                throw new ArgumentOutOfRangeException("settings", "ErrorStore 'type' must be specified");
            if (settings.Size < 1) 
                throw new ArgumentOutOfRangeException("settings","ErrorStore 'size' must be positive");

            switch (settings.Type)
            {
                case "JSON":
                    return new JSONErrorStore(settings);
                case "Memory":
                    return new MemoryErrorStore(settings);
                case "SQL":
                    return new SQLErrorStore(settings);
                default:
                    throw new Exception("Unknwon error store type: " + settings.Type);
            }
        }
예제 #6
0
 /// <summary>
 /// Base constructor of the error store to set common properties
 /// </summary>
 protected ErrorStore(ErrorStoreSettings settings) : this(settings.RollupSeconds, settings.BackupQueueSize)
 {
 }
예제 #7
0
 /// <summary>
 /// Base constructor of the error store to set common properties.
 /// </summary>
 /// <param name="settings">The <see cref="ErrorStoreSettings"/> for this store.</param>
 protected ErrorStore(ErrorStoreSettings settings)
 {
     Settings = settings;
 }
        private static ErrorStore GetFromSettings(ErrorStoreSettings settings)
        {
            if (settings == null) return null;

            // a bit of validation
            if (settings.Type.IsNullOrEmpty())
                throw new ArgumentOutOfRangeException(nameof(settings), "ErrorStore 'type' must be specified");
            if (settings.Size < 1) 
                throw new ArgumentOutOfRangeException(nameof(settings),"ErrorStore 'size' must be positive");

            var storeTypes = GetErrorStores();
            // Search by convention first
            var match = storeTypes.FirstOrDefault(s => s.Name == settings.Type + "ErrorStore");
            if (match == null)
            {
                // well shit, free for all!
                match = storeTypes.FirstOrDefault(s => s.Name.Contains(settings.Type));
            }

            if (match == null)
            {
                throw new Exception("Could not find error store type: " + settings.Type);
            }

            try
            {
                return (ErrorStore) Activator.CreateInstance(match, settings);
            }
            catch (Exception ex)
            {
                throw new Exception("Error creating a " + settings.Type + " error store: " + ex.Message, ex);
            }
        }