/// <summary>
        /// Gets metadata collection of functions and proxies configured.
        /// </summary>
        /// <returns>A metadata collection of functions and proxies configured.</returns>
        private IEnumerable <FunctionMetadata> GetFunctionsMetadata()
        {
            IEnumerable <FunctionMetadata> functionMetadata = _functionMetadataManager.Functions;

            foreach (var error in _functionMetadataManager.Errors)
            {
                FunctionErrors.Add(error.Key, error.Value.ToArray());
            }

            // Get proxies metadata
            var proxyMetadata = _proxyMetadataManager.ProxyMetadata;

            if (!proxyMetadata.Functions.IsDefaultOrEmpty)
            {
                // Add the proxy descriptor provider
                _descriptorProviders.Add(new ProxyFunctionDescriptorProvider(this, ScriptOptions, _bindingProviders, proxyMetadata.ProxyClient, _loggerFactory));
                functionMetadata = proxyMetadata.Functions.Concat(functionMetadata);
            }

            foreach (var error in proxyMetadata.Errors)
            {
                FunctionErrors.Add(error.Key, error.Value.ToArray());
            }

            return(functionMetadata);
        }
        public static Dictionary <string, Func <string[], string> > getMessages(FunctionErrors theLogicOrder)
        {
            Dictionary <string, Func <string[], string> > messages = new Dictionary <string, Func <string[], string> > ();

            messages.Add(FunctionErrorType.cantReturnFromMainScope.ToString(), theLogicOrder.cantReturnFromMainScope);

            return(messages);
        }
        /// <summary>
        /// Gets metadata collection of functions and proxies configured.
        /// </summary>
        /// <returns>A metadata collection of functions and proxies configured.</returns>
        private IEnumerable <FunctionMetadata> GetFunctionsMetadata()
        {
            IEnumerable <FunctionMetadata> functionMetadata = _functionMetadataManager.GetFunctionMetadata();

            foreach (var error in _functionMetadataManager.Errors)
            {
                FunctionErrors.Add(error.Key, error.Value.ToArray());
            }

            return(functionMetadata);
        }
        /// <summary>
        /// Returns true if the specified name is the name of a known function,
        /// regardless of whether the function is in error.
        /// </summary>
        /// <param name="name">The name of the function to check for.</param>
        /// <returns>True if the name matches a function; otherwise, false.</returns>
        public bool IsFunction(string name)
        {
            if (!string.IsNullOrEmpty(name) &&
                (Functions.Any(f => string.Equals(f.Name, name, StringComparison.OrdinalIgnoreCase)) ||
                 FunctionErrors.ContainsKey(name)))
            {
                return(true);
            }

            return(false);
        }
        internal void AddFunctionError(string functionName, string error, bool isFunctionShortName = false)
        {
            functionName = isFunctionShortName ? functionName : Utility.GetFunctionShortName(functionName);

            Collection <string> functionErrors = new Collection <string>();

            if (!FunctionErrors.TryGetValue(functionName, out functionErrors))
            {
                FunctionErrors[functionName] = functionErrors = new Collection <string>();
            }
            functionErrors.Add(error);
        }
Example #6
0
        public sealed override FunctionResult Execute(object[] args, ExecuteContext context)
        {
            var itemType = context.CurrentType.GetEnumerableItemType();

            if (itemType == null)
            {
                throw FunctionErrors.OnlyCanUseFunctionInCollectionType(this.Name);
            }

            if (!typeof(IQueryable <>).MakeGenericType(itemType).IsAssignableFrom(context.CurrentType))
            {
                var queryableExpression = Expression.Call(
                    MethodFinder.GetAsQueryable(itemType),
                    context.CurrentExpression);
                return(OnExecuteQueryable(new CollectionFunctionContext(context, itemType, queryableExpression)));
            }
            else
            {
                return(OnExecuteQueryable(new CollectionFunctionContext(context, itemType, context.CurrentExpression)));
            }
        }
        /// <summary>
        /// Gets metadata collection of functions configured.
        /// </summary>
        /// <returns>A metadata collection of functions and proxies configured.</returns>
        private IEnumerable <FunctionMetadata> GetFunctionsMetadata(bool workerIndexing)
        {
            IEnumerable <FunctionMetadata> functionMetadata;

            if (workerIndexing)
            {
                _logger.LogInformation("Worker indexing is enabled");
                functionMetadata = _functionMetadataManager.GetFunctionMetadata(forceRefresh: false, dispatcher: _functionDispatcher);
            }
            else
            {
                functionMetadata = _functionMetadataManager.GetFunctionMetadata(false);
                _workerRuntime   = _workerRuntime ?? Utility.GetWorkerRuntime(functionMetadata);
            }
            foreach (var error in _functionMetadataManager.Errors)
            {
                FunctionErrors.Add(error.Key, error.Value.ToArray());
            }

            return(functionMetadata);
        }
        public static void setLanguage()
        {
            currentLanguage = new SwedishLanguage();
            IErrorSender theSender = (currentLanguage as IErrorSender);

            IfStatementErrors   ifError     = theSender.ifStatementErrors;
            ElseStatementErrors elseError   = theSender.elseStatementErrors;
            ForLoopErrors       forError    = theSender.forLoopErrors;
            IndentationErrors   indentError = theSender.indentErrors;
            TextErrors          txtError    = theSender.textErrors;
            VariableErrors      varError    = theSender.variableErrors;

            WhileLoopErrors     whileError   = theSender.whileLoopErrors;
            NumberErrors        numError     = theSender.numberErrors;
            KeywordErrors       keywordError = theSender.keywordErrors;
            FunctionErrors      funcError    = theSender.functionErrors;
            OtherErrors         otherError   = theSender.otherErrors;
            SystemFailureErrors systemErrors = theSender.systemErrors;

            currentLanguage.initLanguageErrors1(ifError, elseError, forError, indentError, txtError, varError);
            currentLanguage.initLanguageErrors2(whileError, numError, keywordError, funcError, otherError, systemErrors);
        }
Example #9
0
 /// Inits second part of the language errors. Stores error messages in dictionary.
 public void initLanguageErrors2(WhileLoopErrors While, NumberErrors Number, KeywordErrors Keyword, FunctionErrors Function, OtherErrors Other, SystemFailureErrors system)
 {
     errorMessages.Add(ErrorType.WhileLoop, WhileErrorsOrder.getMessages(While));
     errorMessages.Add(ErrorType.Number, NumberErrorsOrder.getMessages(Number));
     errorMessages.Add(ErrorType.Keyword, KeywordErrorsOrder.getMessages(Keyword));
     errorMessages.Add(ErrorType.Function, FunctionErrorsOrder.getMessages(Function));
     errorMessages.Add(ErrorType.Other, OtherErrorsOrder.getMessages(Other));
     errorMessages.Add(ErrorType.System, SystemFailureErrorsOrder.getMessages(system));
 }
Example #10
0
        protected override void Serialize(IDictionary <string, object> json)
        {
            if (FunctionData.HasValue())
            {
                json.Add("data", FunctionData);
            }
            else
            {
                FluentDictionary.For(json).Add("data", Data, string.Empty);
            }

            if (FunctionTotal.HasValue())
            {
                json.Add("total", FunctionTotal);
            }
            else
            {
                FluentDictionary.For(json).Add("total", Total, string.Empty);
            }

            if (FunctionErrors.HasValue())
            {
                json.Add("errors", FunctionErrors);
            }
            else
            {
                FluentDictionary.For(json).Add("errors", Errors, string.Empty);
            }

            if (FunctionAggregates.HasValue())
            {
                json.Add("aggregates", FunctionAggregates);
            }
            else
            {
                FluentDictionary.For(json).Add("aggregates", Aggregates, string.Empty);
            }

            if (FunctionGroups.HasValue())
            {
                json.Add("groups", FunctionGroups);
            }
            else
            {
                FluentDictionary.For(json).Add("groups", Groups, string.Empty);
            }

            if (Model != null)
            {
                json.Add("model", Model.ToJson());
            }

            if (!string.IsNullOrEmpty(Type))
            {
                json.Add("type", Type);
            }

            if (Parse.HasValue())
            {
                json.Add("parse", Parse);
            }
        }