public override ICacheProvider Create(string typeName) { if (string.IsNullOrWhiteSpace(typeName) || typeName.Length <= 1 || !base.IsValidTypeName(typeName)) { throw new System.ArgumentException("The type is invalid!"); } return(FactoryBase <ICacheProvider> .CreateProductInternal(this.AssemblyString, string.Format("{0}.{1}Provider", this.AssemblyString, typeName))); }
protected static T CreateProductInternal(string assemblyString, string typeName) { if (!FactoryBase <T> .ExistsProduct(typeName)) { object product = System.Reflection.Assembly.Load(assemblyString).CreateInstance(typeName); FactoryBase <T> .AddProduct(typeName, product); } return(FactoryBase <T> ._cachedInstances[typeName] as T); }
protected static void AddProduct(string typeName, object instance) { if (string.IsNullOrWhiteSpace(typeName) || instance == null) { return; } if (FactoryBase <T> .ExistsProduct(typeName)) { return; } FactoryBase <T> ._cachedInstances.Add(typeName, instance); }
public override ICacheProvider CreateDefault() { string typeName = this.DefaultTypeName; return(FactoryBase <ICacheProvider> .CreateProductInternal(this.AssemblyString, string.Format("{0}.{1}Provider", this.AssemblyString, typeName))); }