Beispiel #1
0
        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); })
                              );
            }
        }
Beispiel #2
0
        private void RegisterProxyRegistration(ComponentRegistryDefinition componentRegistryDefinition, ComponentRegistryDefinition.ProxyInterfaceRegistrationDefinition proxyInterfaceRegistrationDefinition)
        {
            var interfaceType      = TypeResolver.Resolve(proxyInterfaceRegistrationDefinition.Interface);
            var implementationType = TypeResolver.Resolve(proxyInterfaceRegistrationDefinition.Proxy);

            RegisterProxyComponent(
                interfaceType,
                implementationType
                );
        }
Beispiel #3
0
        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
                );
        }
Beispiel #4
0
        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
                );
        }
Beispiel #5
0
 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); })
                       );
     }
 }
Beispiel #6
0
 private void RegisterAssemblyRegistration(ComponentRegistryDefinition componentRegistryDefinition, ComponentRegistryDefinition.AssemblyRegistrationDefinition assemblyRegistrationDefinition)
 {
     TypeResolver.LoadAssembly(assemblyRegistrationDefinition.Dll, componentRegistryDefinition.PluginFolder);
 }