Exemple #1
0
 private void InitializeAllFunctions(FunctionTypesToReturn functionTypesToReturn, bool fireUpdateEvents)
 {
     foreach (string providerName in OnGetProviderNames())
     {
         InitializeFunctionsFromProvider(providerName, functionTypesToReturn, fireUpdateEvents);
     }
 }
Exemple #2
0
        private void InitializeFunctionsFromProvider(string providerName, FunctionTypesToReturn functionTypesToReturn, bool fireEvents)
        {
            List <string> loadedFunctionNames = new List <string>();

            foreach (IMetaFunction function in OnGetFunctionsFromProvider(providerName, functionTypesToReturn).OrderBy(f => f.CompositeName()))
            {
                if (function.IsNamespaceCorrectFormat() == false)
                {
                    Log.LogWarning(LogTitle, string.Format("{0} named '{1}' has an invalid namespace '{2}'", this.FunctionType, function.Name, function.Namespace));
                    continue;
                }

                string combinedName = StringExtensionMethods.CreateNamespace(function.Namespace, function.Name, '.');
                if (_excludedFunctionNames.Contains(combinedName))
                {
                    continue;
                }


                if (FunctionExists(combinedName))
                {
                    RemoveFunction(combinedName);
                    _excludedFunctionNames.Add(combinedName);

                    Log.LogWarning(LogTitle, "Function name clash: '{0}'", combinedName);
                    continue;
                }

                try
                {
                    AddFunction(providerName, function);
                    loadedFunctionNames.Add(function.CompositeName());
                }
                catch (Exception ex)
                {
                    Log.LogError(LogTitle, "Error adding  function '{0}'. Function type {0}", combinedName, this.FunctionType);
                    Log.LogError(LogTitle, ex);
                }
            }

            if (_functionNamesByProviderName.ContainsKey(providerName))
            {
                //foreach (string functionName in _functionNamesByProviderName[providerName])
                //{
                //    if (loadedFunctionNames.Contains(functionName))
                //    {
                //        Log.LogVerbose("FunctionProviderRegistry", string.Format("{0} loaded: '{1}' from provider '{2}'", this.FunctionType, functionName, providerName));
                //    }
                //}

                OnFunctionsAdded(_functionNamesByProviderName[providerName].ToList(), fireEvents);
            }
        }
        protected override IEnumerable<IMetaFunction> OnGetFunctionsFromProvider(string providerName, FunctionTypesToReturn functionTypesToReturn)
        {
            IEnumerable<IMetaFunction> functions = new List<IMetaFunction>();

            switch (functionTypesToReturn)
            {
                case FunctionTypesToReturn.StaticDependentFunctions:
                    try
                    {
                        functions = WidgetFunctionProviderPluginFacade.Functions(providerName).Cast<IMetaFunction>();
                    }
                    catch (Exception ex)
                    {
                        LoggingService.LogCritical("FunctionProviderRegistry", ex);
                    }
                    break;
                case FunctionTypesToReturn.DynamicDependentOnlyFunctions:
                    try
                    {
                        functions = WidgetFunctionProviderPluginFacade.DynamicTypeDependentFunctions(providerName).Cast<IMetaFunction>();
                    }
                    catch (Exception ex)
                    {
                        LoggingService.LogCritical("FunctionProviderRegistry", ex);
                    }
                    break;
                case FunctionTypesToReturn.AllFunctions:
                    try
                    {
                        functions = WidgetFunctionProviderPluginFacade.Functions(providerName).Cast<IMetaFunction>();
                    }
                    catch (Exception ex)
                    {
                        LoggingService.LogCritical("FunctionProviderRegistry", ex);
                    }

                    try
                    {
                        functions = functions.Concat(WidgetFunctionProviderPluginFacade.DynamicTypeDependentFunctions(providerName).Cast<IMetaFunction>());
                    }
                    catch (Exception ex)
                    {
                        LoggingService.LogCritical("FunctionProviderRegistry", ex);
                    }
                    break;
                default:
                    throw new NotImplementedException();
            }

            return functions;
        }
        protected override IEnumerable<IMetaFunction> OnGetFunctionsFromProvider(string providerName, FunctionTypesToReturn functionTypesToReturn)
        {
            switch (functionTypesToReturn)
            {
                case FunctionTypesToReturn.StaticDependentFunctions:
                    return FunctionProviderPluginFacade.Functions(providerName);

                case FunctionTypesToReturn.DynamicDependentOnlyFunctions:
                    return FunctionProviderPluginFacade.DynamicTypeDependentFunctions(providerName);

                case FunctionTypesToReturn.AllFunctions:
                    IEnumerable<IMetaFunction> functions = FunctionProviderPluginFacade.Functions(providerName);
                    return functions.Concat(FunctionProviderPluginFacade.DynamicTypeDependentFunctions(providerName));
            }

            throw new NotImplementedException(string.Format("Unexpected FunctionTypesToReturn enumeration value '{0}' from provider '{1}'", functionTypesToReturn, providerName));
        }
        protected override IEnumerable <IMetaFunction> OnGetFunctionsFromProvider(string providerName, FunctionTypesToReturn functionTypesToReturn)
        {
            switch (functionTypesToReturn)
            {
            case FunctionTypesToReturn.StaticDependentFunctions:
                return(FunctionProviderPluginFacade.Functions(providerName));

            case FunctionTypesToReturn.DynamicDependentOnlyFunctions:
                return(FunctionProviderPluginFacade.DynamicTypeDependentFunctions(providerName));

            case FunctionTypesToReturn.AllFunctions:
                IEnumerable <IMetaFunction> functions = FunctionProviderPluginFacade.Functions(providerName);
                return(functions.Concat(FunctionProviderPluginFacade.DynamicTypeDependentFunctions(providerName)));
            }

            throw new NotImplementedException(string.Format("Unexpected FunctionTypesToReturn enumeration value '{0}' from provider '{1}'", functionTypesToReturn, providerName));
        }
Exemple #6
0
 protected abstract IEnumerable <IMetaFunction> OnGetFunctionsFromProvider(string providerName, FunctionTypesToReturn functionTypesToReturn);
        protected override IEnumerable <IMetaFunction> OnGetFunctionsFromProvider(string providerName, FunctionTypesToReturn functionTypesToReturn)
        {
            IEnumerable <IMetaFunction> functions = new List <IMetaFunction>();

            switch (functionTypesToReturn)
            {
            case FunctionTypesToReturn.StaticDependentFunctions:
                try
                {
                    functions = WidgetFunctionProviderPluginFacade.Functions(providerName).Cast <IMetaFunction>();
                }
                catch (Exception ex)
                {
                    LoggingService.LogCritical("FunctionProviderRegistry", ex);
                }
                break;

            case FunctionTypesToReturn.DynamicDependentOnlyFunctions:
                try
                {
                    functions = WidgetFunctionProviderPluginFacade.DynamicTypeDependentFunctions(providerName).Cast <IMetaFunction>();
                }
                catch (Exception ex)
                {
                    LoggingService.LogCritical("FunctionProviderRegistry", ex);
                }
                break;

            case FunctionTypesToReturn.AllFunctions:
                try
                {
                    functions = WidgetFunctionProviderPluginFacade.Functions(providerName).Cast <IMetaFunction>();
                }
                catch (Exception ex)
                {
                    LoggingService.LogCritical("FunctionProviderRegistry", ex);
                }

                try
                {
                    functions = functions.Concat(WidgetFunctionProviderPluginFacade.DynamicTypeDependentFunctions(providerName).Cast <IMetaFunction>());
                }
                catch (Exception ex)
                {
                    LoggingService.LogCritical("FunctionProviderRegistry", ex);
                }
                break;

            default:
                throw new NotImplementedException();
            }

            return(functions);
        }
        private void InitializeFunctionsFromProvider(string providerName, FunctionTypesToReturn functionTypesToReturn,bool fireEvents)
        {
            List<string> loadedFunctionNames = new List<string>();

            foreach (IMetaFunction function in OnGetFunctionsFromProvider(providerName, functionTypesToReturn).OrderBy(f => f.CompositeName()))
            {
                if (function.IsNamespaceCorrectFormat() == false)
                {
                    Log.LogWarning(LogTitle, string.Format("{0} named '{1}' has an invalid namespace '{2}'", this.FunctionType, function.Name, function.Namespace));
                    continue;
                }

                string combinedName = StringExtensionMethods.CreateNamespace(function.Namespace, function.Name, '.');
                if (_excludedFunctionNames.Contains(combinedName))
                {
                    continue;
                }

                if (FunctionExists(combinedName))
                {
                    RemoveFunction(combinedName);
                    _excludedFunctionNames.Add(combinedName);

                    Log.LogWarning(LogTitle, "Function name clash: '{0}'", combinedName);
                    continue;
                }

                try
                {
                    AddFunction(providerName, function);
                    loadedFunctionNames.Add(function.CompositeName());
                }
                catch (Exception ex)
                {
                    Log.LogError(LogTitle, "Error adding  function '{0}'. Function type {0}", combinedName, this.FunctionType);
                    Log.LogError(LogTitle, ex);
                }
            }

            if (_functionNamesByProviderName.ContainsKey(providerName))
            {
                //foreach (string functionName in _functionNamesByProviderName[providerName])
                //{
                //    if (loadedFunctionNames.Contains(functionName))
                //    {
                //        Log.LogVerbose("FunctionProviderRegistry", string.Format("{0} loaded: '{1}' from provider '{2}'", this.FunctionType, functionName, providerName));
                //    }
                //}

                OnFunctionsAdded(_functionNamesByProviderName[providerName].ToList(), fireEvents);
            }
        }
 private void InitializeAllFunctions(FunctionTypesToReturn functionTypesToReturn, bool fireUpdateEvents)
 {
     foreach (string providerName in OnGetProviderNames())
     {
         InitializeFunctionsFromProvider(providerName, functionTypesToReturn, fireUpdateEvents);
     }
 }
 protected abstract IEnumerable<IMetaFunction> OnGetFunctionsFromProvider(string providerName, FunctionTypesToReturn functionTypesToReturn);