private void RegisterMultipleComponentsRegistration(ComponentRegistryDefinition componentRegistryDefinition, ComponentRegistryDefinition.ComponentSetRegistrationDefinition componentSetRegistrationDefinition) { if (componentSetRegistrationDefinition.RegistrationsDefinition == null) { return; } foreach (var registration in componentSetRegistrationDefinition.RegistrationsDefinition) { TypeSwitch.Do(registration, TypeSwitch.Case <ComponentRegistryDefinition.ComponentRegistrationDefinition>(componentRegistration => { componentRegistration.Interface = componentSetRegistrationDefinition.Interface; RegisterMutipleComponentComponentRegistration( componentRegistryDefinition, componentRegistration ); }), TypeSwitch.Case <ComponentRegistryDefinition.ProxyInterfaceRegistrationDefinition>(proxyRegistration => { proxyRegistration.Interface = componentSetRegistrationDefinition.Interface; RegisterMultipleComponentProxyRegistration( componentRegistryDefinition, proxyRegistration ); }), TypeSwitch.Default(() => { throw new NotSupportedException(registration.GetType().FullName); }) ); } }
private void RegisterProxyRegistration(ComponentRegistryDefinition componentRegistryDefinition, ComponentRegistryDefinition.ProxyInterfaceRegistrationDefinition proxyInterfaceRegistrationDefinition) { var interfaceType = TypeResolver.Resolve(proxyInterfaceRegistrationDefinition.Interface); var implementationType = TypeResolver.Resolve(proxyInterfaceRegistrationDefinition.Proxy); RegisterProxyComponent( interfaceType, implementationType ); }
private void RegisterMutipleComponentComponentRegistration(ComponentRegistryDefinition componentRegistryDefinition, ComponentRegistryDefinition.ComponentRegistrationDefinition componentRegistrationDefinition) { var interfaceType = TypeResolver.Resolve(componentRegistrationDefinition.Interface, assemblyHint: componentRegistrationDefinition.Dll); var implementationType = TypeResolver.Resolve(componentRegistrationDefinition.Implementation, componentRegistrationDefinition.Dll, componentRegistryDefinition.PluginFolder); RegisterComponent( interfaceType, implementationType, componentRegistrationDefinition.ResolveKey ?? implementationType.FullName, componentRegistrationDefinition.Activation ?? ActivationType.Instance ); }
private void RegisterComponentRegistration(ComponentRegistryDefinition componentRegistryDefinition, ComponentRegistryDefinition.ComponentRegistrationDefinition componentRegistrationDefinition) { if (string.IsNullOrWhiteSpace(componentRegistrationDefinition.Implementation)) { throw new ArgumentException("No implementation field provided in component registry definition"); } var interfaceType = TypeResolver.Resolve(componentRegistrationDefinition.Interface, assemblyHint: componentRegistrationDefinition.Dll); var implementationType = TypeResolver.Resolve(componentRegistrationDefinition.Implementation, componentRegistrationDefinition.Dll, componentRegistryDefinition.PluginFolder); var activation = componentRegistrationDefinition.Activation; RegisterComponent( interfaceType, implementationType, componentRegistrationDefinition.ResolveKey, activation ?? ActivationType.Instance ); }
public void RegisterDefinition(ComponentRegistryDefinition componentRegistryDefinition) { if (componentRegistryDefinition.RegistrationsDefinition == null) { return; } foreach (var registration in componentRegistryDefinition.RegistrationsDefinition) { TypeSwitch.Do(registration, TypeSwitch.Case <ComponentRegistryDefinition.AssemblyRegistrationDefinition>(assemblyRegistration => RegisterAssemblyRegistration( componentRegistryDefinition, assemblyRegistration ) ), TypeSwitch.Case <ComponentRegistryDefinition.ComponentRegistrationDefinition>(componentRegistration => RegisterComponentRegistration( componentRegistryDefinition, componentRegistration ) ), TypeSwitch.Case <ComponentRegistryDefinition.ProxyInterfaceRegistrationDefinition>(proxyRegistration => RegisterProxyRegistration( componentRegistryDefinition, proxyRegistration ) ), TypeSwitch.Case <ComponentRegistryDefinition.ComponentSetRegistrationDefinition>(multipleComponentsRegistration => RegisterMultipleComponentsRegistration( componentRegistryDefinition, multipleComponentsRegistration ) ), TypeSwitch.Default(() => { throw new NotSupportedException(registration.GetType().FullName); }) ); } }
private void RegisterAssemblyRegistration(ComponentRegistryDefinition componentRegistryDefinition, ComponentRegistryDefinition.AssemblyRegistrationDefinition assemblyRegistrationDefinition) { TypeResolver.LoadAssembly(assemblyRegistrationDefinition.Dll, componentRegistryDefinition.PluginFolder); }