Esempio n. 1
0
        /// <summary>
        ///     This method will be called by SqlRace framework.
        /// </summary>
        /// <param name="functionManager"></param>
        public void Initialize(IFunctionManager functionManager)
        {
            // create the function definition
            var functionDefinition = functionManager.CreateFunctionDefinition(DotNetFunctionConstants.UniqueId, FunctionMode.Instantaneous, CalculationModeInfoDefinition.EachSamplePoint());

            //var functionDefinition = functionManager.CreateFunctionDefinition(DotNetFunctionConstants.UniqueId);
            functionDefinition.CalculateOverWholeSession = false;
            functionDefinition.InterpolateBetweenSamples = false;
            functionDefinition.JoinGapsAroundNull        = false;
            functionDefinition.Name           = FunctionName;
            functionDefinition.StoreInSession = false;

            // set the implementation
            var implementationDefinition = (DotNetFunctionImplementationDefinition)functionDefinition.ImplementationDefinition;

            implementationDefinition.Function = this;

            // create the single output parameter
            functionDefinition.OutputParameterDefinitions.Add(
                new FunctionOutputParameterDefinition
            {
                ApplicationName = ApplicationName,
                ByteOrder       = ByteOrderType.BigEndian,
                Description     = "HelloDotNet.vCarDoubled",
                FormatOverride  = @"%5.2f",
                Name            = ParameterName,
                Units           = "km/h",
                MaximumValue    = "800",
                MinimumValue    = "0",
                ShowInBrowser   = true
            });

            functionDefinition.InputParameterIdentifiers.Add("vCar:Chassis");

            // build the function
            var buildResults = functionManager.Build(functionDefinition);

            // make sure we have no build errors
            if (buildResults.Errors.Count > 0)
            {
                Console.WriteLine($"Error building DotNet function '{FunctionName}': {buildResults.Errors.FirstOrDefault()?.ErrorText}.");
            }
            else
            {
                Console.WriteLine($"DotNet function '{FunctionName}' created successfully.");
            }
        }