public void Remove(ResourceDataAccessorConfigurationElement element) { if (BaseIndexOf(element) >= 0) { BaseRemove(element.Name); } }
public int IndexOf(ResourceDataAccessorConfigurationElement element) { return(BaseIndexOf(element)); }
public void Add(ResourceDataAccessorConfigurationElement element) { BaseAdd(element); }
public static CompositeResourceDataAccessor Load() { CompositeResourceDataAccessor result = new CompositeResourceDataAccessor(false); ResourceDataAccessorConfigurationSection section = System.Configuration.ConfigurationManager.GetSection(ConfigurationSectionName) as ResourceDataAccessorConfigurationSection; if (section == null || section.ResourceDataAccessors == null || section.ResourceDataAccessors.Count == 0) { // create default/fallback collection result.AddDefaultAccessor(); return(result); } for (int e = 0; e < section.ResourceDataAccessors.Count; ++e) { try { ResourceDataAccessorConfigurationElement element = section.ResourceDataAccessors[e]; System.Type rdaType = Type.GetType(element.Type); if (rdaType == null) { throw new Core.LanguagePlatformException(Core.ErrorCode.ConfigurationCannotResolveType, Core.FaultStatus.Fatal, element.Type.ToString()); } bool found = false; foreach (System.Type t in rdaType.GetInterfaces()) { if (t == typeof(Core.Resources.IResourceDataAccessor)) { found = true; break; } } if (!found) { throw new Core.LanguagePlatformException(Core.ErrorCode.ConfigurationInvalidType, Core.FaultStatus.Fatal, element.Type.ToString()); } if (rdaType.IsAbstract) { throw new Core.LanguagePlatformException(Core.ErrorCode.ConfigurationAbstractType, Core.FaultStatus.Fatal, element.Type.ToString()); } object instance = rdaType.Assembly.CreateInstance(rdaType.FullName, false, System.Reflection.BindingFlags.CreateInstance, null, String.IsNullOrEmpty(element.Parameter) ? null : new object[] { element.Parameter }, System.Globalization.CultureInfo.CurrentCulture, null); // We could check the constructors to test whether they match the parameter if (instance == null) { throw new Core.LanguagePlatformException(Core.ErrorCode.ConfigurationCannotInstantiateOrCastType, Core.FaultStatus.Fatal, element.Type.ToString()); } Core.Resources.IResourceDataAccessor rda = instance as Core.Resources.IResourceDataAccessor; if (rda == null) { throw new Core.LanguagePlatformException(Core.ErrorCode.ConfigurationCannotInstantiateOrCastType, Core.FaultStatus.Fatal, element.Type.ToString()); } result.Add(rda); } catch (System.Exception) { throw; } } if (result.Count == 0) { result.AddDefaultAccessor(); } return(result); }