/// <summary>
 ///     Initializes a new instance of the <see cref="DisabledPluginTypeUsedConfigurationParseException" /> class.
 /// </summary>
 /// <param name="configurationFileElement">The configuration file element.</param>
 /// <param name="typeInfoInfo">
 ///     <see cref="ITypeInfo" /> for a type in disabled plugin, or which contains a disabled plugin
 ///     type, if the type is a generic type.
 /// </param>
 /// <param name="disabledPluginTypeInfo">The disabled plugin type information.</param>
 /// <param name="parentElement">The parent element.</param>
 public DisabledPluginTypeUsedConfigurationParseException([NotNull] IConfigurationFileElement configurationFileElement,
                                                          [NotNull] ITypeInfo typeInfoInfo,
                                                          [NotNull] ITypeInfo disabledPluginTypeInfo,
                                                          IConfigurationFileElement parentElement = null) :
     base(configurationFileElement, GenerateErrorMessage(typeInfoInfo, disabledPluginTypeInfo), parentElement, true)
 {
 }
예제 #2
0
 protected CollectionValueElementBase([NotNull] XmlElement xmlElement, IConfigurationFileElement parent,
                                      [NotNull] ITypeHelper typeHelper,
                                      [NotNull] IPluginAssemblyTypeUsageValidator pluginAssemblyTypeUsageValidator) :
     base(xmlElement, parent, typeHelper)
 {
     _pluginAssemblyTypeUsageValidator = pluginAssemblyTypeUsageValidator;
 }
예제 #3
0
        public static void ProcessConfigurationFileElementAndChildren([NotNull] this IConfigurationFileElement configurationFileElement,
                                                                      [NotNull] ProcessConfigurationFileElement processConfigurationFileElement,
                                                                      [CanBeNull] Predicate <IConfigurationFileElement> skipElement = null)
        {
            void processTree(IConfigurationFileElement currConfigurationFileElement,
                             ref bool stopProcessingParam)
            {
                if (stopProcessingParam || skipElement != null && skipElement(currConfigurationFileElement))
                {
                    return;
                }

                processConfigurationFileElement(currConfigurationFileElement, ref stopProcessingParam);

                if (stopProcessingParam)
                {
                    return;
                }

                foreach (var childElement in currConfigurationFileElement.Children)
                {
                    processTree(childElement, ref stopProcessingParam);

                    if (stopProcessingParam)
                    {
                        return;
                    }
                }
            }

            var stopProcessing = false;

            processTree(configurationFileElement, ref stopProcessing);
        }
예제 #4
0
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IPluginImplementationElement pluginImplementationElement)
            {
                PluginImplementationElement = pluginImplementationElement;
            }
            else if (child is ITypeDefinitionsElement typeDefinitionsElement)
            {
                TypeDefinitions = typeDefinitionsElement;
            }
            else if (child is ISettingsElement settingsElement)
            {
                SettingsElement = settingsElement;
            }
            else if (child is IWebApi webApi)
            {
                WebApi = webApi;
            }
            else if (child is IDependencyInjection dependencyInjection)
            {
                DependencyInjection = dependencyInjection;
            }
        }
예제 #5
0
 public ProxyServiceElement([NotNull] XmlElement xmlElement, IConfigurationFileElement parent,
                            [NotNull] ITypeHelper typeHelper,
                            [NotNull] IValidateServiceUsageInPlugin validateServiceUsageInPlugin) : base(xmlElement, parent)
 {
     _validateServiceUsageInPlugin = validateServiceUsageInPlugin;
     _typeHelper = typeHelper;
 }
 public AutoGeneratedServiceElement([NotNull] XmlElement xmlElement, IConfigurationFileElement parent,
                                    [NotNull] ITypeHelper typeHelper,
                                    [NotNull] ITypeMemberLookupHelper typeMemberLookupHelper,
                                    [NotNull] IValidateServiceUsageInPlugin validateServiceUsageInPlugin) :
     base(xmlElement, parent, typeHelper, typeMemberLookupHelper, validateServiceUsageInPlugin)
 {
 }
예제 #7
0
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IServiceElement serviceElement)
            {
                if (_serviceTypeToServiceMap.ContainsKey(serviceElement.ServiceTypeInfo.Type))
                {
                    throw new ConfigurationParseException(child, $"Multiple occurrences of service with the value of attribute '{ConfigurationFileAttributeNames.Type}' equal to '{serviceElement.ServiceTypeInfo.TypeCSharpFullName}'.", this);
                }

                if (serviceElement.ServiceTypeInfo.Type == typeof(ISettingsRequestor))
                {
                    ThrowOnProhibitedServiceType(serviceElement, $"/{ConfigurationFileElementNames.RootElement}/{ConfigurationFileElementNames.SettingsRequestor}");
                }

                if (serviceElement.ServiceTypeInfo.Type == typeof(IStartupAction) || serviceElement.ServiceTypeInfo.Type == typeof(IEnumerable <IStartupAction>))
                {
                    ThrowOnProhibitedServiceType(serviceElement, $"/{ConfigurationFileElementNames.RootElement}/{ConfigurationFileElementNames.StartupActions}/{ConfigurationFileElementNames.StartupAction}");
                }

                if (serviceElement.ServiceTypeInfo.Type == typeof(IPlugin))
                {
                    ThrowOnProhibitedServiceType(serviceElement, $"/{ConfigurationFileElementNames.RootElement}/{ConfigurationFileElementNames.PluginsSetup}/{ConfigurationFileElementNames.PluginSetup}/{ConfigurationFileElementNames.PluginImplementation}");
                }

                if (!IoCServiceFactoryAmbientContext.Context.GetProhibitedServiceTypesInServicesElementChecker().IsServiceTypeAllowed(serviceElement.ServiceTypeInfo.Type))
                {
                    throw new ConfigurationParseException(serviceElement, $"Type '{serviceElement.ServiceTypeInfo.TypeCSharpFullName}' cannot be used a service type in 'service' element.");
                }

                _serviceTypeToServiceMap[serviceElement.ServiceTypeInfo.Type] = serviceElement;
                _allServices.AddLast(serviceElement);
            }
        }
 public PluginImplementationElement([NotNull] XmlElement xmlElement, [NotNull] IConfigurationFileElement parent,
                                    [NotNull] IImplementedTypeValidator implementedTypeValidator,
                                    [NotNull] IInjectedPropertiesValidator injectedPropertiesValidator,
                                    [NotNull] ITypeHelper typeHelper)
     : base(xmlElement, parent, typeof(IPlugin), implementedTypeValidator, injectedPropertiesValidator, typeHelper)
 {
 }
예제 #9
0
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IPluginSetup)
            {
                var pluginSetup = (IPluginSetup)child;

                if (_pluginNameToPluginSetupMap.ContainsKey(pluginSetup.Plugin.Name))
                {
                    throw new ConfigurationParseException(pluginSetup, $"Multiple occurrences of '{pluginSetup.ElementName}' for the same plugin name '{pluginSetup.Plugin.Name}'.", this);
                }

                _pluginNameToPluginSetupMap[pluginSetup.Plugin.Name] = pluginSetup;

                if (_pluginTypeToPluginSetupMap.ContainsKey(pluginSetup.PluginImplementationElement.ValueTypeInfo.Type))
                {
                    throw new ConfigurationParseException(pluginSetup.PluginImplementationElement, $"Multiple occurrences of '{pluginSetup.PluginImplementationElement.ElementName}' for the same plugin type '{pluginSetup.PluginImplementationElement.ValueTypeInfo.TypeCSharpFullName}'.", this);
                }
                _pluginTypeToPluginSetupMap[pluginSetup.PluginImplementationElement.ValueTypeInfo.Type] = pluginSetup;

                if (pluginSetup.Enabled)
                {
                    _allPluginSetups.AddLast(pluginSetup);
                }
            }
        }
예제 #10
0
 public ConfigurationParseException([NotNull] IConfigurationFileElement configurationFileElement, [NotNull] string originalMessage, IConfigurationFileElement parentElement = null, bool generateErrorLocationData = true) :
     base(generateErrorLocationData ? ErrorHelperAmbientContext.Context.GenerateElementError(configurationFileElement, originalMessage, parentElement) : originalMessage)
 {
     ConfigurationFileElement       = configurationFileElement;
     ParentConfigurationFileElement = parentElement;
     OriginalMessage = originalMessage;
 }
예제 #11
0
 public void Validate(IConfigurationFileElement configurationFileElement, string attributeName, string alias)
 {
     if (!Regex.IsMatch(alias, "^([a-zA-Z_]+[0-9]*)+$"))
     {
         throw new ConfigurationParseException(configurationFileElement, $"The value of attribute '{attributeName}' is not a valid identifier. The attribute value can contain only alphanumeric characters and an underscore and should start with a number.");
     }
 }
 protected ConstructedValueElementBase([NotNull] XmlElement xmlElement, IConfigurationFileElement parent,
                                       [NotNull] ITypeHelper typeHelper,
                                       [NotNull] IImplementedTypeValidator implementedTypeValidator) :
     base(xmlElement, parent, typeHelper)
 {
     _implementedTypeValidator = implementedTypeValidator;
 }
예제 #13
0
        public override void AddChild(IConfigurationFileElement child)
        {
            if (child is IAssembly assembly)
            {
                if (_nameToAssemblyMap.ContainsKey(assembly.Name))
                {
                    throw new ConfigurationParseException(child, $"Assembly with name '{assembly.Name}' appears multiple times.", this);
                }

                if (_aliasToAssemblyMap.ContainsKey(assembly.Alias))
                {
                    throw new ConfigurationParseException(child, $"Assembly with alias '{assembly.Alias}' appears multiple times.", this);
                }

                _nameToAssemblyMap[assembly.Name]   = assembly;
                _aliasToAssemblyMap[assembly.Alias] = assembly;

                if (MsCorlibAssembly.Name.Equals(assembly.Name, StringComparison.OrdinalIgnoreCase))
                {
                    MsCorlibAssembly = assembly;
                }
                else if (IoCConfigurationAssembly.Name.Equals(assembly.Name, StringComparison.OrdinalIgnoreCase))
                {
                    IoCConfigurationAssembly = assembly;
                }
                else if (OROptimizerSharedAssembly.Name.Equals(assembly.Name, StringComparison.OrdinalIgnoreCase))
                {
                    OROptimizerSharedAssembly = assembly;
                }
            }

            base.AddChild(child);
        }
예제 #14
0
        public ISettingElement GetSettingElement(IConfigurationFileElement requestingConfigurationFileElement, string settingName)
        {
            if (string.IsNullOrEmpty(settingName))
            {
                throw new ConfigurationParseException(requestingConfigurationFileElement, "The setting name cannot be empty.");
            }

            ISettingElement _settingElement = null;

            if (requestingConfigurationFileElement.OwningPluginElement != null)
            {
                _settingElement = requestingConfigurationFileElement.GetPluginSetupElement().SettingsElement?.GetSettingElement(settingName);
            }

            if (_settingElement == null)
            {
                _settingElement = requestingConfigurationFileElement.Configuration.SettingsElement?.GetSettingElement(settingName);
            }

            if (_settingElement == null)
            {
                throw new ConfigurationParseException(requestingConfigurationFileElement, $"Setting with name '{settingName}' was not found.");
            }

            return(_settingElement);
        }
예제 #15
0
 public ModuleElement([NotNull] XmlElement xmlElement, [CanBeNull] IConfigurationFileElement parent,
                      [NotNull] ITypeHelper typeHelper,
                      [NotNull] ICreateInstanceFromTypeAndConstructorParameters createInstanceFromTypeAndConstructorParameters) : base(xmlElement, parent)
 {
     _typeHelper = typeHelper;
     _createInstanceFromTypeAndConstructorParameters = createInstanceFromTypeAndConstructorParameters;
 }
예제 #16
0
        public static void LogElementDisabledWarning([NotNull] IConfigurationFileElement configurationFileElement, [CanBeNull] IAssembly assembly, bool logInfo = false)
        {
            if (configurationFileElement.Enabled)
            {
                return;
            }

            // Lets see if this element is a child of PluginSetup element, in which case we do not want to log any warning
            // since we already logged a warning for plugin is disabled.
            if (configurationFileElement.GetPluginSetupElement() != null)
            {
                return;
            }

            var warning = new StringBuilder();

            warning.AppendLine($"Element '{configurationFileElement}' is disabled.");

            var pluginElement = assembly?.Plugin ?? configurationFileElement.OwningPluginElement;

            if (pluginElement != null && !pluginElement.Enabled)
            {
                warning.AppendLine($"   To enable this element enable the plugin '{pluginElement.Name}'.");
            }

            if (logInfo)
            {
                LogHelper.Context.Log.Info(warning.ToString());
            }
            else
            {
                LogHelper.Context.Log.Warn(warning.ToString());
            }
        }
예제 #17
0
 public ClassMemberValueInitializer([NotNull] IConfigurationFileElement configurationFileElement,
                                    [NotNull] IClassMemberValueInitializerHelper classMemberValueInitializerHelper,
                                    [NotNull] ClassMemberData classMemberData)
 {
     _configurationFileElement          = configurationFileElement;
     _classMemberValueInitializerHelper = classMemberValueInitializerHelper;
     ClassMemberData = classMemberData;
 }
예제 #18
0
 public DiManagerElement([NotNull] XmlElement xmlElement, [NotNull] IConfigurationFileElement parent,
                         [NotNull] ITypeHelper typeHelper,
                         [NotNull] ICreateInstanceFromTypeAndConstructorParameters createInstanceFromTypeAndConstructorParameters,
                         [NotNull] IValidateDiManagerCompatibility validateDiManagerCompatibility) :
     base(xmlElement, parent, typeHelper, createInstanceFromTypeAndConstructorParameters)
 {
     _validateDiManagerCompatibility = validateDiManagerCompatibility;
 }
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IMethodSignatureParameterElement methodSignatureParameter)
            {
                _parameters.Add(methodSignatureParameter);
            }
        }
    public static INamedTypeDefinitionElement GetTypeDefinition([NotNull] this IConfigurationFileElement configurationFileElement, [NotNull] string alias)
    {
        var pluginSetupElement = configurationFileElement.GetPluginSetupElement();

        var typeDefinitions = pluginSetupElement != null && pluginSetupElement.TypeDefinitions != null ?
                              pluginSetupElement.TypeDefinitions : configurationFileElement.Configuration.TypeDefinitions;

        return(typeDefinitions?.GetTypeDefinition(alias));
    }
예제 #21
0
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IGenericTypeParametersElement genericTypeParameters)
            {
                GenericTypeParameters = genericTypeParameters;
            }
        }
예제 #22
0
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IApplicationDataDirectory)
            {
                ApplicationDataDirectory = (IApplicationDataDirectory)child;
            }
            else if (child is IPlugins)
            {
                Plugins = (IPlugins)child;
            }
            else if (child is IAdditionalAssemblyProbingPaths)
            {
                AdditionalAssemblyProbingPaths = (IAdditionalAssemblyProbingPaths)child;
            }
            else if (child is IAssemblies)
            {
                Assemblies = (IAssemblies)child;
            }
            else if (child is ITypeDefinitionsElement)
            {
                TypeDefinitions = (ITypeDefinitionsElement)child;
            }
            else if (child is IParameterSerializers)
            {
                ParameterSerializers = (IParameterSerializers)child;
            }
            else if (child is IDiManagersElement)
            {
                DiManagers = (IDiManagersElement)child;
            }
            else if (child is ISettingsElement)
            {
                SettingsElement = (ISettingsElement)child;
            }
            else if (child is IWebApi)
            {
                WebApi = (IWebApi)child;
            }
            else if (child is IDependencyInjection)
            {
                DependencyInjection = (IDependencyInjection)child;
            }
            else if (child is ISettingsRequestorImplementationElement)
            {
                SettingsRequestor = (ISettingsRequestorImplementationElement)child;
            }
            else if (child is IStartupActionsElement)
            {
                StartupActions = (IStartupActionsElement)child;
            }
            else if (child is IPluginsSetup)
            {
                PluginsSetup = (IPluginsSetup)child;
            }
        }
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IInjectedProperties injectedProperties)
            {
                InjectedProperties = injectedProperties;
            }
        }
예제 #24
0
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IWebApiControllerAssemblies webApiControllerAssemblies)
            {
                ControllerAssemblies = webApiControllerAssemblies;
            }
        }
예제 #25
0
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IStartupActionElement)
            {
                _startupActions.Add((IStartupActionElement)child);
            }
        }
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is ITypeDefinitionElement typeDefinitionElement)
            {
                _typeParameterElements.Add(typeDefinitionElement);
            }
        }
 // The value of ImplementedInterfaceTypeInfo is initialized in overridden method Initialize().
 // ReSharper disable once NotNullMemberIsNotInitialized
 protected AutoGeneratedServiceElementBase([NotNull] XmlElement xmlElement, IConfigurationFileElement parent,
                                           [NotNull] ITypeHelper typeHelper,
                                           [NotNull] ITypeMemberLookupHelper typeMemberLookupHelper,
                                           [NotNull] IValidateServiceUsageInPlugin validateServiceUsageInPlugin) : base(xmlElement, parent)
 {
     TypeHelper                   = typeHelper;
     TypeMemberLookupHelper       = typeMemberLookupHelper;
     ValidateServiceUsageInPlugin = validateServiceUsageInPlugin;
 }
예제 #28
0
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IWebApiControllerAssembly webApiControllerAssembly)
            {
                _assemblies.Add(webApiControllerAssembly);
            }
        }
예제 #29
0
        public override void AddChild(IConfigurationFileElement child)
        {
            base.AddChild(child);

            if (child is IParameters parameters)
            {
                _parameters = parameters;
            }
        }
        public override void BeforeChildInitialize(IConfigurationFileElement child)
        {
            base.BeforeChildInitialize(child);

            if (child is IAutoGeneratedMemberReturnValuesSelectorElement || child is IAutoGeneratedMemberReturnValuesIfSelectorElement)
            {
                InitMethodInfo();
            }
        }