Example #1
0
 public DynamicFunction(string name, ParseNode node, Variables args, int minParameters = 0, int maxParameters = 0)
 {
     Node = node;
                 Arguments = args;
                 MinParameters = minParameters;
                 MaxParameters = maxParameters;
 }
Example #2
0
        public NewtonSystem(QpProblem data, Variables initialPoint)
        {
            this.Q = data.Q;
            this.A = data.A;

            this.initialCholeskyFactor = this.Factorize(initialPoint);
        }
        public override void FinalizeProject(Variables.Root variables)
        {
            base.FinalizeProject(variables);

            variables.Average(Key+"LinesAvg", Key+"LinesTotal", Key+"CodeFiles");
            variables.Average(Key+"CharsAvg", Key+"CharsTotal", Key+"CodeFiles");
            variables.Average(Key+"CharsPerLineAvg", Key+"CharsTotal", Key+"LinesTotal");

            State state = variables.GetStateObject<State>(stateOwner);

            foreach(FileIntValue fi in state.MaxLines){
                variables.AddToArray(Key+"LinesTop", GetFileObject(fi, variables));
            }

            foreach(FileIntValue fi in state.MinLines.Reverse()){
                variables.AddToArray(Key+"LinesBottom", GetFileObject(fi, variables));
            }

            foreach(FileIntValue fi in state.MaxChars){
                variables.AddToArray(Key+"CharsTop", GetFileObject(fi, variables));
            }

            foreach(FileIntValue fi in state.MinChars.Reverse()){
                variables.AddToArray(Key+"CharsBottom", GetFileObject(fi, variables));
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="variable"></param>
 /// <param name="previousValue"></param>
 /// <param name="newValue"></param>
 public Change(Variables.IVariable variable, Values.IValue previousValue, Values.IValue newValue)
 {
     Variable = variable;
     PreviousValue = previousValue;
     NewValue = newValue;
     Applied = false;
 }
 public QpProgressReport(QpTerminationCode status, int iterations, double meritFunction, Variables currentIterate)
 {
     this.solveStatus = status;
     this.iterations = iterations;
     this.currentIterate = currentIterate == null ? null : currentIterate.Clone();
     this.meritFunction = meritFunction;
 }
Example #6
0
 public void Write(FieldsParser information, string formName)
 {
     Variables variables = new Variables();
     SqlTransaction sqlTransaction = SqlConn.BeginTransaction();
     try
     {
         MasterConnection.SP.Execute(SqlConn, sqlTransaction, information.Master, variables);
         foreach (FieldsGroupConnection detailConnection in DetailConnections)
         {
             foreach (FieldsParser.Fields fields in information.Details)
             {
                 if (fields.NodeName == detailConnection.Name)
                 {
                     detailConnection.SP.Execute(SqlConn, sqlTransaction, fields, variables);
                 }
             }
         }
         sqlTransaction.Commit();
     }
     catch
     {
         sqlTransaction.Rollback();
         throw;
     }
 }
Example #7
0
        private void ButtonGenerate_Click(object sender, EventArgs e)
        {
            List<Variables> vList = new List<Variables>();

            for (int i = 0; i < DGVProperties.Rows.Count - 1; i++)
            {
                Variables v = new Variables();
                v.Name = DGVProperties.Rows[i].Cells[0].Value.ToString();
                v.SQLType = DGVProperties.Rows[i].Cells[1].Value.ToString();

                if (v.SQLType != null && v.SQLType != "")
                    v.CSharpType = SelectCSharpType(v.SQLType.ToLower());

                if (DGVProperties.Rows[i].Cells[2].Value != null && DGVProperties.Rows[i].Cells[2].Value.ToString() != "")
                    v.VariableSize = Convert.ToInt32(DGVProperties.Rows[i].Cells[2].Value.ToString());
                else
                    v.VariableSize = 0;
                v.AllowNulls = Convert.ToBoolean(DGVProperties.Rows[i].Cells[3].Value);
                vList.Add(v);
            }

            if (textBoxPath.Text.Length != 0 && textBoxPath.Text[textBoxPath.Text.Length - 1] != '\\')
                textBoxPath.Text += "\\";

            CreateClass.WriteProperties(vList, _className, textBoxPath.Text);
            CreateClass.WriteData(vList, _className, textBoxPath.Text);
            CreateClass.WriteBusiness(vList, _className, textBoxPath.Text);
            CreateClass.WriteList(vList, _className, textBoxPath.Text);
        }
        /// <summary>
        /// The edit.
        /// </summary>
        /// <param name="parentWindow">
        /// The parent window.
        /// </param>
        /// <param name="variables">
        /// The variables.
        /// </param>
        /// <param name="connections">
        /// The connections.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Edit(IWin32Window parentWindow, Variables variables, Connections connections)
        {
            string jsonString = string.Empty;
            var value = this.metaData.CustomPropertyCollection["Settings"].Value;

            if (value != null)
            {
                jsonString = value.ToString();
            }

            List<InputColumnInfo> inputColumnInfos = new List<InputColumnInfo>();
            foreach (IDTSInputColumn100  col in this.metaData.InputCollection[0].InputColumnCollection)
            {
                inputColumnInfos.Add(
                    new InputColumnInfo() { ColumnName = col.Name, DataType = col.DataType, LineageId = col.LineageID });
            }

            FillablePdfDestinationUIForm editor = new FillablePdfDestinationUIForm(
                jsonString,
                inputColumnInfos.ToArray());

            editor.ShowDialog(parentWindow);

            if (editor.DialogResult == DialogResult.OK || editor.DialogResult == DialogResult.Yes)
            {
                this.metaData.CustomPropertyCollection["Settings"].Value = editor.OutputConfigJsonString;
                return true;
            }

            return false;
        }
        public QpProgressReport DetermineProgress(Variables iterate, Residuals residuals, double mu, int count)
        {
            var code = QpTerminationCode.InProgress;

            double residualsNorm = residuals.InfinityNorm();
            double phi = ComputeMeritFunction(residuals, residualsNorm);
            this.UpdateMeritFunctionHistory(phi, count);

            bool isMuSatisfied = (mu < Tolerance);
            bool isRnormSatisfied = (residualsNorm < Tolerance * this.dataInfinityNorm);

            if (isMuSatisfied && isRnormSatisfied)
            {
                code = QpTerminationCode.Success;
            }
            else if (count >= MaxIterations)
            {
                code = QpTerminationCode.MaxIterationsExceeded;
            }
            else if (count > 20 && phi >= 1e-8 && phi >= 1e4 * this.phiMinimumHistory[count - 1])
            {
                code = QpTerminationCode.Infeasible;
            }
            else if (count >= 30 && this.phiMinimumHistory[count] >= .5 * this.phiMinimumHistory[count - 30])
            {
                code = QpTerminationCode.Unknown;
            }

            return includeDetailedReport || code != QpTerminationCode.InProgress ?
                new QpProgressReport(code, count, phi, iterate.Clone()) :
                new QpProgressReport(code, count, phi, null);
        }
Example #10
0
        public void Constructor_DetectsAdjacentCyclicalReference()
        {
            using (TestHostContext hc = new TestHostContext(this))
            {
                // Arrange.
                var copy = new Dictionary<string, string>
                {
                    { "variable1", "1_$(variable2)" },
                    { "variable2", "2_$(variable3)" },
                    { "variable3", "3_$(variable2)" },
                };

                // Act.
                List<string> warnings;
                var variables = new Variables(hc, copy, new List<MaskHint>(), out warnings);

                // Assert.
                Assert.Equal(3, warnings.Count);
                Assert.True(warnings.Any(x => string.Equals(x, StringUtil.Loc("Variable0ContainsCyclicalReference", "variable1"))));
                Assert.True(warnings.Any(x => string.Equals(x, StringUtil.Loc("Variable0ContainsCyclicalReference", "variable2"))));
                Assert.True(warnings.Any(x => string.Equals(x, StringUtil.Loc("Variable0ContainsCyclicalReference", "variable3"))));
                Assert.Equal("1_$(variable2)", variables.Get("variable1"));
                Assert.Equal("2_$(variable3)", variables.Get("variable2"));
                Assert.Equal("3_$(variable2)", variables.Get("variable3"));
            }
        }
Example #11
0
        public void Constructor_AppliesMaskHints()
        {
            using (TestHostContext hc = new TestHostContext(this))
            {
                // Arrange.
                var copy = new Dictionary<string, string>
                {
                    { "MySecretName", "My secret value" },
                    { "MyPublicVariable", "My public value" },
                };
                var maskHints = new List<MaskHint>
                {
                    new MaskHint() { Type = MaskType.Variable, Value = "MySecretName" },
                };
                List<string> warnings;
                var variables = new Variables(hc, copy, maskHints, out warnings);

                // Act.
                KeyValuePair<string, string>[] publicVariables = variables.Public.ToArray();

                // Assert.
                Assert.Equal(0, warnings.Count);
                Assert.Equal(1, publicVariables.Length);
                Assert.Equal("MyPublicVariable", publicVariables[0].Key);
                Assert.Equal("My public value", publicVariables[0].Value);
                Assert.Equal("My secret value", variables.Get("MySecretName"));
            }
        }
        protected virtual void ProcessFileContents(File file, Variables.Root variables)
        {
            string[] contents = file.Contents.Split('\n');

            int lineCount = 0, charCount = 0, maxCharsPerLine = 0;

            foreach(string line in contents){
                if (!line.Trim().Equals("{")){
                    ++lineCount;
                }

                if (line.Length > 0){
                    int realLength = ParseUtils.CountCharacters(line);

                    charCount += realLength;
                    maxCharsPerLine = Math.Max(maxCharsPerLine, realLength);
                }
            }

            variables.Increment(Key+"LinesTotal", lineCount);
            variables.Increment(Key+"CharsTotal", charCount);
            variables.Maximum(Key+"LinesMax", lineCount);
            variables.Maximum(Key+"CharsMax", charCount);
            variables.Maximum(Key+"CharsPerLineMax", maxCharsPerLine);

            State state = variables.GetStateObject<State>(stateOwner);

            FileIntValue fileLines = new FileIntValue(file, lineCount);
            state.MaxLines.Add(fileLines);
            state.MinLines.Add(fileLines);

            FileIntValue fileChars = new FileIntValue(file, charCount);
            state.MaxChars.Add(fileChars);
            state.MinChars.Add(fileChars);
        }
Example #13
0
        public ISolver<double> Factorize(Variables currentIterate, int iteration)
        {
            if (iteration == 0)
            {
                return this.initialCholeskyFactor;
            }

            return this.Factorize(currentIterate);
        }
        public override void Process(File file, Variables.Root variables)
        {
            base.Process(file, variables);

            variables.Increment("fileTypeCode");
            variables.Increment(Key+"CodeFiles");

            ProcessFileContents(file, variables);
        }
Example #15
0
        public Residuals(QpProblem data, Variables iterate)
        {
            this.Q = data.Q;
            this.c = data.c;
            this.A = data.A;
            this.b = data.b;

            this.Initialise();
            this.Update(iterate);
        }
Example #16
0
        static Script()
        {
            if (Vars == null)
                Vars = new Variables();

            if (Environment.OSVersion.Platform == PlatformID.Unix)
                Environment.SetEnvironmentVariable("MONO_VISUAL_STYLES", "gtkplus");

            Application.EnableVisualStyles();
        }
Example #17
0
        private ISolver<double> Factorize(Variables currentIterate)
        {
            Vector<double> z = currentIterate.z;
            Vector<double> s = currentIterate.s;

            Matrix<double> sOverZ = this.matBuilder.SparseOfDiagonalVector(z.Count, z.Count, z.PointwiseDivide(s));
            Matrix<double> Q_bar = this.Q + this.A.Multiply(sOverZ).TransposeAndMultiply(A);

            return Q_bar.Cholesky();
        }
Example #18
0
            public override string Process(TemplateList list, Variables variables)
            {
                string processedText = text;
                int offset = 0;

                foreach(TemplateToken token in tokens){
                    offset = token.ReplaceToken(offset, list, variables, ref processedText);
                }

                return processedText;
            }
Example #19
0
        public string ProcessTemplate(string templateName, Variables variables)
        {
            Template template;

            if (templates.TryGetValue(templateName, out template)){
                return template.Process(this, variables);
            }
            else{
                throw new TemplateException(Lang.Get["TemplateErrorNotFound", templateName]);
            }
        }
Example #20
0
        public Variables GenerateInitialPoint(QpProblem problem, Vector<double> x)
        {
            Vector<double> z = Vector<double>.Build.Dense(problem.A.ColumnCount, 1);
            Vector<double> s = Vector<double>.Build.Dense(problem.A.ColumnCount, 1);

            Variables initialPoint = new Variables(x, z, s);

            this.startingResiduals = new Residuals(problem, initialPoint);
            this.startingEquations = new NewtonSystem(problem, initialPoint);

            return initialPoint;
        }
Example #21
0
        public Frame (Goal [] goals, Goal parent, BoundVariableSet boundVariables, Dictionary <string, Variable> variables)
        {
            this.goals = goals;
            this.boundVariables = boundVariables;
            this.HeadGoal = parent;

            this.variables = new Variables(variables);

            foreach (var goal in goals)
            {
                goal.Frame = this;
            }
        }
Example #22
0
        public bool Edit(IWin32Window parentWindow, Variables variables, Connections connections)
        {
            DialogResult dialogResult;

            try
            {
                MessageBox.Show(parentWindow, "The custom user interface is under construction in the release." + Environment.NewLine + "Please use the advanced editor for now.", NopConstants.COMPONENT_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(parentWindow, ex.ToString(), NopConstants.COMPONENT_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return false;
        }
Example #23
0
        public void Update(Variables newIterate)
        {
            Vector<double> x = newIterate.x;
            Vector<double> z = newIterate.z;
            Vector<double> s = newIterate.s;

            this.Q.Multiply(x, this.rd);
            this.rd.Add(this.c, this.rd);
            this.DualityGap = this.rd.DotProduct(x) - this.b.DotProduct(z);
            this.rd.Subtract(this.A * z, this.rd);

            s.Add(this.b, this.rp);
            this.rp.Subtract(A.TransposeThisAndMultiply(x), this.rp);
            s.PointwiseMultiply(z, this.rs);
        }
Example #24
0
 private TestHostContext CreateTestContext([CallerMemberName] String testName = "")
 {
     var hc = new TestHostContext(this, testName);
     List<string> warnings;
     _variables = new Variables(
         hostContext: hc,
         copy: new Dictionary<string, string>(),
         maskHints: new List<MaskHint>(),
         warnings: out warnings);
     _ec = new Mock<IExecutionContext>();
     _ec.SetupAllProperties();
     _ec.Setup(x => x.Variables).Returns(_variables);
     _stepsRunner = new StepsRunner();
     _stepsRunner.Initialize(hc);
     return hc;
 }
Example #25
0
        public Variables ComputeStep(Variables currentIterate, Residuals residuals, ISolver<double> CholeskyFactor)
        {
            // Define shorter names
            Vector<double> z = currentIterate.z;
            Vector<double> s = currentIterate.s;
            Vector<double> rp = residuals.rp;
            Vector<double> rd = residuals.rd;
            Vector<double> rs = residuals.rs;

            Vector<double> r_bar = A * (rs - z.PointwiseMultiply(rp)).PointwiseDivide(s);
            Vector<double> c_bar = rd + r_bar;

            c_bar.Negate(c_bar);

            Vector<double> stepX = CholeskyFactor.Solve(c_bar);
            Vector<double> stepS = A.TransposeThisAndMultiply(stepX) - rp;
            Vector<double> stepZ = -(rs + z.PointwiseMultiply(stepS)).PointwiseDivide(s);

            return new Variables(stepX, stepZ, stepS);
        }
Example #26
0
 public bool Edit(IWin32Window parentWindow, Variables variables, Connections connections)
 {
     try
     {
         // Create UI form and display
         ReverseStringUIForm ui = new ReverseStringUIForm(_dtsComponentMetaData, _serviceProvider, connections);
         DialogResult result = ui.ShowDialog(parentWindow);
         // Set return value to represent DialogResult. This tells the
         // managed wrapper to persist any changes made
         // on the component input and/or output, or properties.
         if (result == DialogResult.OK)
         {
             return true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     return false;
 }
        public bool Edit(IWin32Window parentWindow, Variables variables, Connections connections)
        {
            DialogResult dialogResult;

            try
            {
                MessageBox.Show(parentWindow, "The custom user interface is under construction in the release." + Environment.NewLine + "Please use the advanced editor for now.", Constants.COMPONENT_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);

                /*using (ObfuConfMainForm form = new ObfuConfMainForm())
                {
                    form.ObfuscationConfiguration = this.ComponentMetadataWrapper.GetTableConfiguration().Parent as ObfuscationConfiguration;
                    dialogResult = form.ShowDialog(parentWindow);

                    if (dialogResult == DialogResult.OK)
                        return true;
                }*/
            }
            catch (Exception ex)
            {
                MessageBox.Show(parentWindow, ex.ToString(), Constants.COMPONENT_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return false;
        }
Example #28
0
        public TestHostContext Setup([CallerMemberName] string name = "")
        {
            // Setup the host context.
            TestHostContext hc = new TestHostContext(this, name);

            // Create a random work path.
            var configStore = new Mock<IConfigurationStore>();
            _workFolder = Path.Combine(
                Path.GetDirectoryName(Assembly.GetEntryAssembly().Location),
                $"_work_{Path.GetRandomFileName()}");
            var settings = new AgentSettings()
            {
                WorkFolder = _workFolder,
            };
            configStore.Setup(x => x.GetSettings()).Returns(settings);
            hc.SetSingleton<IConfigurationStore>(configStore.Object);

            // Setup the execution context.
            _ec = new Mock<IExecutionContext>();
            List<string> warnings;
            _variables = new Variables(hc, new Dictionary<string, string>(), new List<MaskHint>(), out warnings);
            _variables.Set(Constants.Variables.System.CollectionId, CollectionId);
            _variables.Set(WellKnownDistributedTaskVariables.TFCollectionUrl, CollectionUrl);
            _variables.Set(Constants.Variables.System.DefinitionId, DefinitionId);
            _variables.Set(Constants.Variables.Build.DefinitionName, DefinitionName);
            _ec.Setup(x => x.Variables).Returns(_variables);

            // Setup the endpoint.
            _endpoint = new ServiceEndpoint() { Url = new Uri(EndpointUrl) };

            // Setup the tracking manager.
            _trackingManager = new TrackingManager();
            _trackingManager.Initialize(hc);

            return hc;
        }
Example #29
0
        public object CoerceValue(ISchema schema, GraphType type, object input, Variables variables = null)
        {
            if (type is NonNullGraphType)
            {
                var nonNull = type as NonNullGraphType;
                return CoerceValue(schema, schema.FindType(nonNull.Type), input, variables);
            }

            if (input == null)
            {
                return null;
            }

            var variable = input as Variable;
            if (variable != null)
            {
                return variables != null
                    ? variables.ValueFor(variable.Name)
                    : null;
            }

            if (type is ListGraphType)
            {
                var listType = type as ListGraphType;
                var listItemType = schema.FindType(listType.Type);
                var list = input as IEnumerable;
                return list != null && !(input is string)
                    ? list.Map(item => CoerceValue(schema, listItemType, item, variables)).ToArray()
                    : new[] { CoerceValue(schema, listItemType, input, variables) };
            }

            if (type is ObjectGraphType || type is InputObjectGraphType)
            {
                var obj = new Dictionary<string, object>();

                if (input is KeyValuePair<string, object>)
                {
                    var kvp = (KeyValuePair<string, object>)input;
                    input = new Dictionary<string, object> { { kvp.Key, kvp.Value } };
                }

                var kvps = input as IEnumerable<KeyValuePair<string, object>>;
                if (kvps != null)
                {
                    input = kvps.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
                }

                var dict = input as Dictionary<string, object>;
                if (dict == null)
                {
                    return null;
                }

                type.Fields.Apply(field =>
                {
                    object inputValue;
                    if (dict.TryGetValue(field.Name, out inputValue))
                    {
                        var fieldValue = CoerceValue(schema, schema.FindType(field.Type), inputValue, variables);
                        obj[field.Name] = fieldValue ?? field.DefaultValue;
                    }
                });

                return obj;
            }

            if (type is ScalarGraphType)
            {
                var scalarType = type as ScalarGraphType;
                return scalarType.Coerce(input);
            }

            return input;
        }
Example #30
0
        public async Task <WorkflowExecutionContext> InvokeAsync(Workflow workflow, IActivity startActivity = default, Variables arguments = default, CancellationToken cancellationToken = default)
        {
            workflow.Arguments = arguments ?? new Variables();
            var workflowExecutionContext = new WorkflowExecutionContext(workflow);
            var isResuming = workflowExecutionContext.Workflow.Status == WorkflowStatus.Resuming;

            // If a start activity was provided, remove it from the blocking activities list. If not start activity was provided, pick the first one that has no inbound connections.
            if (startActivity != null)
            {
                workflow.BlockingActivities.Remove(startActivity);
            }
            else
            {
                startActivity = workflow.GetStartActivities().FirstOrDefault();
            }

            if (!isResuming)
            {
                workflow.StartedAt = clock.GetCurrentInstant();
            }

            workflowExecutionContext.Workflow.Status = WorkflowStatus.Executing;

            if (startActivity != null)
            {
                workflowExecutionContext.ScheduleActivity(startActivity);
            }

            // Keep executing activities as long as there are any scheduled.
            while (workflowExecutionContext.HasScheduledActivities)
            {
                var currentActivity = workflowExecutionContext.PopScheduledActivity();
                var result          = await ExecuteActivityAsync(workflowExecutionContext, currentActivity, isResuming, cancellationToken);

                if (result == null)
                {
                    break;
                }

                await result.ExecuteAsync(this, workflowExecutionContext, cancellationToken);

                workflowExecutionContext.IsFirstPass = false;
                isResuming = false;
            }

            // Any other status than Halted means the workflow has ended (either because it reached the final activity, was aborted or has faulted).
            if (workflowExecutionContext.Workflow.Status != WorkflowStatus.Halted)
            {
                workflowExecutionContext.Finish(clock.GetCurrentInstant());
            }
            else
            {
                // Persist workflow before executing the halted activities.
                await workflowStore.SaveAsync(workflow, cancellationToken);

                // Invoke Halted event on activity drivers that halted the workflow.
                while (workflowExecutionContext.HasScheduledHaltingActivities)
                {
                    var currentActivity = workflowExecutionContext.PopScheduledHaltingActivity();
                    var result          = await ExecuteActivityHaltedAsync(workflowExecutionContext, currentActivity, cancellationToken);

                    await result.ExecuteAsync(this, workflowExecutionContext, cancellationToken);
                }
            }

            await workflowStore.SaveAsync(workflow, cancellationToken);

            return(workflowExecutionContext);
        }
Example #31
0
 /// <summary>
 /// Evaluates the function on a scalar argument.
 /// </summary>
 /// <param name="Argument">Function argument.</param>
 /// <param name="Variables">Variables collection.</param>
 /// <returns>Function result.</returns>
 public override IElement EvaluateScalar(string Argument, Variables Variables)
 {
     return(new StringValue(System.Net.WebUtility.UrlEncode(Argument)));
 }
Example #32
0
        private void CalcMomentary(List <Field> Fields, DateTime Now, ushort Raw)
        {
            Fields.Add(new Int32Field(this, Now, "Raw", Raw, FieldType.Momentary, FieldQoS.AutomaticReadout, typeof(Module).Namespace, 26));

            if (this.exp is null && !string.IsNullOrEmpty(this.expression))
            {
                this.exp = new Expression(this.expression);
            }

            if (this.exp != null)
            {
                Variables v = new Variables()
                {
                    { "Raw", (double)Raw }
                };

                object Value = this.exp.Evaluate(v);
                Field  F;

                if (Value is double dbl)
                {
                    F = new QuantityField(this, Now, this.fieldName, dbl, this.nrDecimals, this.unit, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is PhysicalQuantity qty)
                {
                    F = new QuantityField(this, Now, this.fieldName, qty.Magnitude, this.nrDecimals, qty.Unit.ToString(), FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is bool b)
                {
                    F = new BooleanField(this, Now, this.fieldName, b, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is DateTime DT)
                {
                    F = new DateTimeField(this, Now, this.fieldName, DT, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is Duration D)
                {
                    F = new DurationField(this, Now, this.fieldName, D, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is Enum E)
                {
                    F = new EnumField(this, Now, this.fieldName, E, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is int i32)
                {
                    if (string.IsNullOrEmpty(this.unit))
                    {
                        F = new Int32Field(this, Now, this.fieldName, i32, FieldType.Momentary, FieldQoS.AutomaticReadout);
                    }
                    else
                    {
                        F = new QuantityField(this, Now, this.fieldName, i32, 0, this.unit, FieldType.Momentary, FieldQoS.AutomaticReadout);
                    }
                }
                else if (Value is long i64)
                {
                    if (string.IsNullOrEmpty(this.unit))
                    {
                        F = new Int64Field(this, Now, this.fieldName, i64, FieldType.Momentary, FieldQoS.AutomaticReadout);
                    }
                    else
                    {
                        F = new QuantityField(this, Now, this.fieldName, i64, 0, this.unit, FieldType.Momentary, FieldQoS.AutomaticReadout);
                    }
                }
                else if (Value is string s)
                {
                    F = new StringField(this, Now, this.fieldName, s, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else if (Value is TimeSpan TS)
                {
                    F = new TimeField(this, Now, this.fieldName, TS, FieldType.Momentary, FieldQoS.AutomaticReadout);
                }
                else
                {
                    F = new StringField(this, Now, this.fieldName, Value.ToString(), FieldType.Momentary, FieldQoS.AutomaticReadout);
                }

                if (this.fieldName == "Value")
                {
                    F.Module        = typeof(Module).Namespace;
                    F.StringIdSteps = new LocalizationStep[] { new LocalizationStep(13) };
                }

                Fields.Add(F);
            }
        }
Example #33
0
        public static List<LogInfo> Set(EngineState s, CodeCommand cmd)
        {
            CodeInfo_Set info = cmd.Info.Cast<CodeInfo_Set>();

            Variables.VarKeyType varType = Variables.DetectType(info.VarKey);
            if (varType == Variables.VarKeyType.None)
            {
                // Check Macro
                if (Regex.Match(info.VarKey, Macro.MacroNameRegex,
                    RegexOptions.Compiled | RegexOptions.CultureInvariant).Success) // Macro Name Validation
                {
                    string macroCommand = StringEscaper.Preprocess(s, info.VarValue);

                    if (macroCommand.Equals("NIL", StringComparison.OrdinalIgnoreCase))
                        macroCommand = null;

                    LogInfo log = s.Macro.SetMacro(info.VarKey, macroCommand, cmd.Section, info.Permanent, false);
                    return new List<LogInfo>(1) { log };
                }
            }

            // [WB082 Behavior] -> Enabled if s.CompatAllowSetModifyInterface == true
            // If PERMANENT was used but the key exists in interface command, the value will not be written to script.project but in interface.
            // Need to investigate where the logs are saved in this case.
            switch (info.Permanent)
            {
                case true:
                    {
                        // Check if interface contains VarKey
                        List<LogInfo> logs = new List<LogInfo>();

                        if (Variables.DetectType(info.VarKey) != Variables.VarKeyType.Variable)
                            goto case false;

                        #region Set interface control's value (Compat)
                        if (s.CompatAllowSetModifyInterface)
                        {
                            string varKey = Variables.TrimPercentMark(info.VarKey);
                            string finalValue = StringEscaper.Preprocess(s, info.VarValue);

                            Script sc = cmd.Section.Script;
                            ScriptSection iface = sc.GetInterfaceSection(out _);
                            if (iface == null)
                                goto case false;

                            (List<UIControl> uiCtrls, _) = UIParser.ParseStatements(iface.Lines, iface);
                            UIControl uiCtrl = uiCtrls.Find(x => x.Key.Equals(varKey, StringComparison.OrdinalIgnoreCase));
                            if (uiCtrl == null)
                                goto case false;

                            bool valid = uiCtrl.SetValue(finalValue, false, out List<LogInfo> varLogs);
                            logs.AddRange(varLogs);

                            if (valid)
                            {
                                // Update uiCtrl into file
                                uiCtrl.Update();

                                // Also update local variables
                                logs.AddRange(Variables.SetVariable(s, info.VarKey, info.VarValue, false, false));
                                return logs;
                            }
                        }

                        goto case false;
                        #endregion
                    }

                case false:
                default:
                    return Variables.SetVariable(s, info.VarKey, info.VarValue, info.Global, info.Permanent);
            }
        }
Example #34
0
 /// <summary>
 /// Evaluates the function on a scalar argument.
 /// </summary>
 /// <param name="Argument">Function argument.</param>
 /// <param name="Variables">Variables collection.</param>
 /// <returns>Function result.</returns>
 public override IElement EvaluateScalar(Complex Argument, Variables Variables)
 {
     return(new ComplexNumber(Complex.Reciprocal(Complex.Tan(Argument))));
 }
Example #35
0
    // Use this for initialization

    void Awake()
    {
        Variables = GameObject.FindGameObjectWithTag("UI").GetComponent <Variables>(); //This pulls the variables from the variables script. It's a handy way to call variables from objects without manualy telling unity where to look for the corisponding script every time a new scene loads.
    }
Example #36
0
        private void ExecuteDrawableFillRule(XmlElement element, Collection <IDrawable> drawables)
        {
            FillRule fillRule_ = Variables.GetValue <FillRule>(element, "fillRule");

            drawables.Add(new DrawableFillRule(fillRule_));
        }
Example #37
0
        private void ExecuteDrawableFontPointSize(XmlElement element, Collection <IDrawable> drawables)
        {
            double pointSize_ = Variables.GetValue <double>(element, "pointSize");

            drawables.Add(new DrawableFontPointSize(pointSize_));
        }
Example #38
0
        private void ExecuteDrawableFillOpacity(XmlElement element, Collection <IDrawable> drawables)
        {
            Percentage opacity_ = Variables.GetValue <Percentage>(element, "opacity");

            drawables.Add(new DrawableFillOpacity(opacity_));
        }
Example #39
0
        private void ExecuteDrawableFillPatternUrl(XmlElement element, Collection <IDrawable> drawables)
        {
            String url_ = Variables.GetValue <String>(element, "url");

            drawables.Add(new DrawableFillPatternUrl(url_));
        }
Example #40
0
        private void ExecuteDrawableClipUnits(XmlElement element, Collection <IDrawable> drawables)
        {
            ClipPathUnit units_ = Variables.GetValue <ClipPathUnit>(element, "units");

            drawables.Add(new DrawableClipUnits(units_));
        }
Example #41
0
        private void ExecuteDrawableTextKerning(XmlElement element, Collection <IDrawable> drawables)
        {
            double kerning_ = Variables.GetValue <double>(element, "kerning");

            drawables.Add(new DrawableTextKerning(kerning_));
        }
 /// <summary>
 /// Enumerator that reorders a sequence of items.
 /// </summary>
 /// <param name="ItemEnumerator">Item enumerator</param>
 /// <param name="Variables">Current set of variables.</param>
 /// <param name="Order">Custom order.</param>
 public CustomOrderEnumerator(IResultSetEnumerator ItemEnumerator, Variables Variables, KeyValuePair <ScriptNode, bool>[] Order)
 {
     this.order     = Order;
     this.items     = ItemEnumerator;
     this.variables = Variables;
 }
Example #43
0
        private void ExecuteDrawableTextEncoding(XmlElement element, Collection <IDrawable> drawables)
        {
            Encoding encoding_ = Variables.GetValue <Encoding>(element, "encoding");

            drawables.Add(new DrawableTextEncoding(encoding_));
        }
Example #44
0
        private void ExecuteDrawableGravity(XmlElement element, Collection <IDrawable> drawables)
        {
            Gravity gravity_ = Variables.GetValue <Gravity>(element, "gravity");

            drawables.Add(new DrawableGravity(gravity_));
        }
Example #45
0
 /// <summary>
 /// Add Variable to request.
 /// </summary>
 /// <param name="name">Name of variable.</param>
 /// <param name="value">Value of variable.</param>
 /// <returns></returns>
 public IGraphQLRequest AddVariable(string name, object value)
 {
     Variables.Add(name, value);
     return(this);
 }
Example #46
0
        private void ExecuteDrawablePushClipPath(XmlElement element, Collection <IDrawable> drawables)
        {
            String clipPath_ = Variables.GetValue <String>(element, "clipPath");

            drawables.Add(new DrawablePushClipPath(clipPath_));
        }
Example #47
0
 /// <summary>
 /// Evaluates the function on a scalar argument.
 /// </summary>
 /// <param name="Argument">Function argument.</param>
 /// <param name="Variables">Variables collection.</param>
 /// <returns>Function result.</returns>
 public override IElement EvaluateScalar(double Argument, Variables Variables)
 {
     return(new DoubleNumber(1.0 / Math.Tan(Argument)));
 }
Example #48
0
        private void ExecuteDrawableSkewY(XmlElement element, Collection <IDrawable> drawables)
        {
            double angle_ = Variables.GetValue <double>(element, "angle");

            drawables.Add(new DrawableSkewY(angle_));
        }
Example #49
0
 /// <summary>
 /// Enumerator that limits the return set to a maximum number of records.
 /// </summary>
 /// <param name="ItemEnumerator">Item enumerator</param>
 /// <param name="Columns">Column definitions. Might be null if objects are to be returned.</param>
 /// <param name="Variables">Current set of variables.</param>
 public RecordEnumerator(IResultSetEnumerator ItemEnumerator, ScriptNode[] Columns, Variables Variables)
 {
     this.e         = ItemEnumerator;
     this.columns   = Columns;
     this.variables = Variables;
     this.count     = this.columns?.Length ?? 0;
 }
Example #50
0
        private void ExecuteDrawableStrokeAntialias(XmlElement element, Collection <IDrawable> drawables)
        {
            Boolean isEnabled_ = Variables.GetValue <Boolean>(element, "isEnabled");

            drawables.Add(new DrawableStrokeAntialias(isEnabled_));
        }
Example #51
0
 /// <summary>
 /// Evaluates the function.
 /// </summary>
 /// <param name="Argument">Function argument.</param>
 /// <param name="Variables">Variables collection.</param>
 /// <returns>Function result.</returns>
 public override IElement Evaluate(IElement Argument, Variables Variables)
 {
     throw new LoopDetectedException(Argument.AssociatedObjectValue);
 }
Example #52
0
        private void ExecuteDrawableStrokeColor(XmlElement element, Collection <IDrawable> drawables)
        {
            MagickColor color_ = Variables.GetValue <MagickColor>(element, "color");

            drawables.Add(new DrawableStrokeColor(color_));
        }
Example #53
0
        public virtual void testStartAfterActivityListenerInvocation()
        {
            RecorderExecutionListener.clear();

            ProcessInstance instance = runtimeService.startProcessInstanceByKey("transitionListenerProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));

            Batch modificationBatch = runtimeService.createProcessInstanceModification(instance.Id).startTransition("flow2").executeAsync();

            assertNotNull(modificationBatch);
            executeSeedAndBatchJobs(modificationBatch);

            // transition listener should have been invoked
            IList <RecorderExecutionListener.RecordedEvent> events = RecorderExecutionListener.RecordedEvents;

            assertEquals(1, events.Count);

            RecorderExecutionListener.RecordedEvent @event = events[0];
            assertEquals("flow2", @event.TransitionId);

            RecorderExecutionListener.clear();

            ActivityInstance updatedTree = runtimeService.getActivityInstance(instance.Id);

            assertNotNull(updatedTree);
            assertEquals(instance.Id, updatedTree.ProcessInstanceId);

            assertThat(updatedTree).hasStructure(describeActivityInstanceTree(instance.ProcessDefinitionId).activity("task1").activity("task2").done());

            ExecutionTree executionTree = ExecutionTree.forExecution(instance.Id, processEngine);

            assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().done());

            completeTasksInOrder("task1", "task2", "task2");
            assertProcessEnded(instance.Id);
        }
Example #54
0
 private void ExecuteDrawableStrokeDashArray(XmlElement element, Collection <IDrawable> drawables)
 {
     Double[] dash_ = Variables.GetDoubleArray(element["dash"]);
     drawables.Add(new DrawableStrokeDashArray(dash_));
 }
Example #55
0
 public Task <WorkflowExecutionContext> ResumeAsync(Workflow workflow, IActivity startActivity = default, Variables arguments = default, CancellationToken cancellationToken = default)
 {
     workflow.Status = WorkflowStatus.Resuming;
     return(InvokeAsync(workflow, startActivity, arguments, cancellationToken));
 }
Example #56
0
        private void ExecuteDrawableStrokeDashOffset(XmlElement element, Collection <IDrawable> drawables)
        {
            double offset_ = Variables.GetValue <double>(element, "offset");

            drawables.Add(new DrawableStrokeDashOffset(offset_));
        }
Example #57
0
 public Variables GetVariableValues(ISchema schema, Variables variables, Inputs inputs)
 {
     variables.Apply(v =>
     {
         object variableValue;
         if (inputs != null && inputs.TryGetValue(v.Name, out variableValue))
         {
             v.Value = GetVariableValue(schema, v, variableValue);
         }
         else
         {
             v.Value = GetVariableValue(schema, v, v.DefaultValue);
         }
     });
     return variables;
 }
Example #58
0
 /// <summary>
 /// Evaluates the function.
 /// </summary>
 /// <param name="Argument">Function argument.</param>
 /// <param name="Variables">Variables collection.</param>
 /// <returns>Function result.</returns>
 public override IElement Evaluate(IElement Argument, Variables Variables)
 {
     throw new SeeOtherException(Expression.ToString(Argument.AssociatedObjectValue));
 }
Example #59
0
        private void ExecuteDrawableTextInterwordSpacing(XmlElement element, Collection <IDrawable> drawables)
        {
            double spacing_ = Variables.GetValue <double>(element, "spacing");

            drawables.Add(new DrawableTextInterwordSpacing(spacing_));
        }
Example #60
0
        private void ExecuteDrawableTextDirection(XmlElement element, Collection <IDrawable> drawables)
        {
            TextDirection direction_ = Variables.GetValue <TextDirection>(element, "direction");

            drawables.Add(new DrawableTextDirection(direction_));
        }