/// <summary> /// Creates the provider proxy. /// </summary> private static IPluginProviderProxy CreateProviderProxy(IPluginConfiguration pluginConfiguration) { Debug.Assert(pluginConfiguration != null); var cfgType = pluginConfiguration.GetType(); var attributes = cfgType.GetCustomAttributes(true).OfType <PluginProviderTypeAttribute>().ToArray(); if (attributes.Length == 0) { throw new IgniteException(string.Format("{0} of type {1} has no {2}", typeof(IPluginConfiguration), cfgType, typeof(PluginProviderTypeAttribute))); } if (attributes.Length > 1) { throw new IgniteException(string.Format("{0} of type {1} has more than one {2}", typeof(IPluginConfiguration), cfgType, typeof(PluginProviderTypeAttribute))); } var providerType = attributes[0].PluginProviderType; var iface = providerType.GetInterfaces() .SingleOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IPluginProvider <>) && i.GetGenericArguments()[0] == cfgType); if (iface == null) { throw new IgniteException(string.Format("{0} does not implement {1}", providerType, typeof(IPluginProvider <>).MakeGenericType(cfgType))); } var pluginProvider = Activator.CreateInstance(providerType); var providerProxyType = typeof(PluginProviderProxy <>).MakeGenericType(cfgType); return((IPluginProviderProxy)Activator.CreateInstance( providerProxyType, pluginConfiguration, pluginProvider)); }
private void AddConfigurationOverride(IPluginConfiguration configuration) => _configurationOverrides[configuration.GetType().Name] = configuration;