public async Task <bool> DeleteUserFunctionAsync(IUserDefinedFunction UserFunction) { return(await Task.Run(() => { return DeleteUserFunction(UserFunction); })); }
private IList <Parameter> queryForUserDefinedFunctionParameters(IUserDefinedFunction func) { var sql = new Sql(@"SELECT PM.name AS ParameterName , IP.CHARACTER_MAXIMUM_LENGTH AS [MaximumLength] , CONVERT(INT, IP.NUMERIC_PRECISION) AS Precision , CONVERT(INT, IP.NUMERIC_SCALE) AS Scale , IP.DATA_TYPE AS DataType , EP.value AS [Description] FROM sys.objects AS J INNER JOIN sys.parameters AS PM ON ( J.object_id = PM.object_id ) INNER JOIN sys.schemas AS S ON ( J.schema_id = S.schema_id ) INNER JOIN INFORMATION_SCHEMA.PARAMETERS AS IP ON ( IP.SPECIFIC_SCHEMA = S.[name] AND IP.SPECIFIC_NAME = J.[name] AND IP.PARAMETER_NAME = PM.[name] ) LEFT OUTER JOIN sys.extended_properties AS EP ON ( EP.class = 2 AND EP.[name] = 'MS_Description' AND EP.major_id = J.object_id AND EP.minor_id = PM.parameter_id ) WHERE J.object_id = @0 AND IP.IS_RESULT = 'NO' AND J.[type] IN ( 'FN', 'TF' ) ORDER BY IP.ORDINAL_POSITION, IP.PARAMETER_NAME;", func.FunctionId); return(this.peta.Fetch <Parameter>(sql)); }
public Context(Memory DS2, Memory DS1, IUserDefinedFunction userFunc) { this.userFunc = userFunc; this.DS2 = DS2; this.DS1 = DS1; this.DS0 = new Memory(); Init(DS0); }
protected virtual bool SaveUserFunction(IUserDefinedFunction UserFunction) { var UserFunctionsBuffer = UserTelemetryUserFunctions.ToList(); UserFunctionsBuffer.Add(UserFunction); if (!UserFunctionsListIsValid(UserFunctionsBuffer)) { return(false); } DeleteUserFunction(UserFunction); UserTelemetryUserFunctions.Add(UserFunction); return(true); }
public Context(Memory DS2, IUserDefinedFunction userFunc) : this(DS2, null, userFunc) { this.DS1 = Computer.DS1; }
private IList<Parameter> queryForUserDefinedFunctionParameters(IUserDefinedFunction func) { var sql = new Sql(@"SELECT PM.name AS ParameterName , IP.CHARACTER_MAXIMUM_LENGTH AS [MaximumLength] , CONVERT(INT, IP.NUMERIC_PRECISION) AS Precision , CONVERT(INT, IP.NUMERIC_SCALE) AS Scale , IP.DATA_TYPE AS DataType , EP.value AS [Description] FROM sys.objects AS J INNER JOIN sys.parameters AS PM ON ( J.object_id = PM.object_id ) INNER JOIN sys.schemas AS S ON ( J.schema_id = S.schema_id ) INNER JOIN INFORMATION_SCHEMA.PARAMETERS AS IP ON ( IP.SPECIFIC_SCHEMA = S.[name] AND IP.SPECIFIC_NAME = J.[name] AND IP.PARAMETER_NAME = PM.[name] ) LEFT OUTER JOIN sys.extended_properties AS EP ON ( EP.class = 2 AND EP.[name] = 'MS_Description' AND EP.major_id = J.object_id AND EP.minor_id = PM.parameter_id ) WHERE J.object_id = @0 AND IP.IS_RESULT = 'NO' AND J.[type] IN ( 'FN', 'TF' ) ORDER BY IP.ORDINAL_POSITION, IP.PARAMETER_NAME;", func.FunctionId); return this.peta.Fetch<Parameter>(sql); }
//here tring function is complete Tie function defintion,such as: "function(a,b) { return a+b;}" /// <summary> /// invoke a Tie script global function or method /// </summary> /// <param name="memory"></param> /// <param name="instance"></param> /// <param name="function">function definiton, e.g. "function(a,b) { return a+b;}" </param> /// <param name="parameters"></param> /// <param name="userFunc"></param> /// <returns></returns> public static VAL InvokeFunction(Memory memory, VAL instance, string function, object[] parameters, IUserDefinedFunction userFunc) { Module module = new Module(); if (module.CompileCodeBlock("", function, CodeType.expression, CodeMode.Overwritten)) { Context context = new Context(memory, userFunc); VAL funcEntry = Computer.Run(module, context); if (funcEntry.ty != VALTYPE.funccon && funcEntry.ty != VALTYPE.classcon) { throw new TieException("invalid function/class: " + function); } VAL arguments = new VAL(parameters); CPU cpu = new CPU(module, context); return(cpu.InternalUserFuncCall((int)funcEntry.value, instance, arguments)); } return(new VAL()); }
/// <summary> /// Evaluate expression, keyword "this" can be used in the expression. /// </summary> /// <param name="scope">the value of "this" </param> /// <param name="code"></param> /// <param name="memory"></param> /// <param name="userFunc"></param> /// <returns></returns> public static VAL Evaluate(string scope, string code, Memory memory, IUserDefinedFunction userFunc) { return(Computer.Run(scope, code, CodeType.expression, new Context(memory, userFunc))); }
/// <summary> /// Execute statements by using user defined .NET function and scope "this" /// </summary> /// <param name="scope"></param> /// <param name="code">value of keyword "this"</param> /// <param name="memory"></param> /// <param name="userFunc"></param> /// <returns></returns> public static VAL Execute(string scope, string code, Memory memory, IUserDefinedFunction userFunc) { return(Computer.Run(scope, code, CodeType.statements, new Context(memory, userFunc))); }
/// <summary> /// Add function into chain with interface implementation /// </summary> /// <param name="func"></param> /// <returns></returns> public FunctionChain Add(IUserDefinedFunction func) { functions.Insert(0, func); return(this); }
/// <summary> /// Remove function from chain /// </summary> /// <param name="func"></param> /// <returns></returns> public FunctionChain Remove(IUserDefinedFunction func) { functions.Remove(func); return(this); }
protected virtual bool DeleteUserFunction(IUserDefinedFunction UserFunction) { return(DeleteUserFunction(UserFunction.Key)); }