Esempio n. 1
0
        public string GetInstallDataToNsi()
        {
            if (!Variables.Any())
            {
                return(string.Empty);
            }

            var sb = new StringBuilder();

            sb.Append(";variables" + Environment.NewLine);

            foreach (var item in Variables.OrderBy(x => !x.UserDefined))
            {
                sb.Append("!define ");
                if (item.UserDefined)
                {
                    sb.Append(item.VariableName);
                    sb.Append(" \"");
                    sb.Append(item.VariableValue);
                    sb.Append("\" ");
                }
                else
                {
                    sb.Append(item.VariableName);
                }
                sb.Append(Environment.NewLine);
            }

            return(sb.ToString());
        }
Esempio n. 2
0
        public override string ToString()
        {
            string signString        = string.Empty;
            string coefficientString = string.Empty;
            string variableString    = string.Empty;
            string multiplyString    = string.Empty;

            if (Variables.Any())
            {
                variableString = string.Join("*", Variables.Select(v => v.ToString()));
            }
            else if (Complex.Abs(CoEfficient) == 1)
            {
                coefficientString = Complex.Abs(CoEfficient).ToString();
            }

            if (Complex.Abs(CoEfficient) != 1)
            {
                if (Variables.Any())
                {
                    multiplyString = "*";
                }
                coefficientString = Complex.Abs(CoEfficient).ToString();
            }

            return($"{coefficientString}{multiplyString}{variableString}");
        }
Esempio n. 3
0
        private void SaveOrUpdateVariables()
        {
            foreach (var stepVariable in _stepVariables)
            {
                string value = null;

                if (stepVariable.Source == (int)VariableSource.Content)
                {
                    value = GetContentVariable(stepVariable);
                }

                if (stepVariable.Source == (int)VariableSource.Headers)
                {
                    value = GetHeaderVariable(stepVariable);
                }

                if (stepVariable.Source == (int)VariableSource.Cookies)
                {
                    value = GetCookiesVariable(stepVariable);
                }

                if (Variables.Any(v => v.Key.Equals(stepVariable.Name)))
                {
                    Variables.FirstOrDefault(v => v.Key.Equals(stepVariable.Name)).Value = value;
                }
                else
                {
                    Variables.Add(new KeyValueParameter {
                        Key = stepVariable.Name, Value = value
                    });
                }
            }
        }
Esempio n. 4
0
        public void RemoveVariable(string variableID)
        {
            NodeEditor.Assertions.IsTrue(Variables.Any(x => x.ID == variableID));
            var variable = Variables.Find(x => x.ID == variableID);

            RemoveVariable(variable);
        }
Esempio n. 5
0
        public string ToString(bool alwaysWithSign)
        {
            if (Math.Abs(K) < Extensions.Epsilon)
            {
                return("0");
            }

            var result = new StringBuilder();

            if (Positive)
            {
                if (alwaysWithSign)
                {
                    result.Append("+");
                }
            }
            else if (IsOne)
            {
                result.Append("-");
            }

            if (!IsOne || !Variables.Any())
            {
                result.Append(K);
            }

            result.Append(Variables.Format());

            return(result.ToString());
        }
Esempio n. 6
0
 public NodeTreeVar GetVariable(string variableId)
 {
     if (Variables == null || !Variables.Any())
     {
         return(null);
     }
     return(Variables.FirstOrDefault(v => v.ID == variableId));
 }
Esempio n. 7
0
        protected string FormatProperties()
        {
            if (Variables == null || !Variables.Any())
            {
                return(String.Empty);
            }

            string output = String.Empty;

            // Only for pure UStructs because UClass handles this on its own
            if (IsPureStruct())
            {
                output += FormatConstants() + FormatEnums() + FormatStructs();
            }

            // Don't use foreach, screws up order.
            foreach (var property in Variables)
            {
                try
                {
                    // Fix for properties within structs
                    output += "\r\n" + property.PreDecompile() + UDecompilingState.Tabs + "var";
                    try
                    {
                        if (property.CategoryIndex > -1 &&
                            String.Compare(property.CategoryName, "None",
                                           StringComparison.OrdinalIgnoreCase) != 0)
                        {
                            if (property.CategoryName != Name)
                            {
                                output += "(" + property.CategoryName + ")";
                            }
                            else
                            {
                                output += "()";
                            }
                        }
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        output += String.Format("/* INDEX:{0} */", property.CategoryIndex);
                    }

                    output += " " + property.Decompile() + ";";
                }
                catch (Exception e)
                {
                    output += String.Format
                              (
                        " /* Property:{0} threw the following exception:{1} */",
                        property.Name, e.Message
                              );
                }
            }
            return(output + "\r\n");
        }
Esempio n. 8
0
        public void InitializeArrayVariable(DataType dataType, string name, int length)
        {
            if (!(dataType is RefType type))
            {
                throw new ArgumentException($"{nameof(dataType)} needs to be a reference type");
            }

            if (!DataTypes.Types[DataTypes.arrayTypes].Any(x => x.Name == dataType.Name))
            {
                throw new InvalidOperationException($"{dataType.Name} is in an array type.");
            }

            if (!Types.Any(x => x.Name == type.Name))
            {
                throw new InvalidOperationException($"{dataType.Name} is not in the list of available types.");
            }

            if (Variables.Any(x => x.Name == name))
            {
                throw new InvalidOperationException($"Variable with name {name} already exists");
            }

            var variable = new Variable
            {
                Name  = name,
                Type  = dataType,
                Value = NextAvailableHeap.ToString()
            };

            var valueType = GetValueTypeFromArray(dataType.Name);

            for (int i = 0; i < length; i++)
            {
                var variableOnHeap = new Variable
                {
                    Name   = $"{name}[{i}]",
                    Type   = valueType,
                    Value  = valueType.Defaultvalue,
                    Parent = variable
                };

                variable.Variables.Add(variableOnHeap);

                Ram.SetVariable(NextAvailableHeap, variableOnHeap);
                NextAvailableHeap++;
            }

            Ram.SetVariable(NextAvailableStack, variable);

            Variables.Add(variable);

            NextAvailableStack++;

            SourceCode.Add($"{dataType.Name} {name} = new {valueType.Name}[{length}];");
        }
Esempio n. 9
0
 public Complex Evaluate()
 {
     if (Variables.Any())
     {
         return(Complex.Multiply(CoEfficient, Variables.Select(indt => indt.Evaluate()).Aggregate(Complex.Multiply)));
     }
     else
     {
         return(CoEfficient.Clone());;
     }
 }
Esempio n. 10
0
        void AddIfOmitted(string variableName, bool isGlobal)
        {
            // Get the default index of the variable.
            int index = Array.IndexOf(DEFAULT_VARIABLES, variableName);

            // If the index was found and the variable was not added, add it.
            if (index != -1 && !Variables.Any(v => v.IsGlobal == isGlobal && v.Name == variableName))
            {
                Variables.Add(new WorkshopVariable(isGlobal, index, variableName));
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Check the name conflict between the two virtual tables
        /// </summary>
        public bool CheckNameConflict(MixinVirtualTable virtualTable, LoggerResult log)
        {
            var conflict = false;

            foreach (var variable in virtualTable.Variables.Where(variable => Variables.Any(x => x.Variable.Name.Text == variable.Variable.Name.Text)))
            {
                log.Error(XenkoMessageCode.ErrorVariableNameConflict, variable.Variable.Span, variable.Variable, "");
                conflict = true;
            }

            return(conflict);
        }
Esempio n. 12
0
        public void InitializeCustumTypeVariable(RefType customType, string name)
        {
            if (!(customType is RefType type))
            {
                throw new ArgumentException($"{nameof(customType)} needs to be a reference type");
            }

            if (!DataTypes.Types[DataTypes.customTypes].Any(x => x.Name == customType.Name))
            {
                throw new InvalidOperationException($"{customType.Name} is in an array type.");
            }

            if (!Types.Any(x => x.Name == type.Name))
            {
                throw new InvalidOperationException($"{customType.Name} is not in the list of available types.");
            }

            if (Variables.Any(x => x.Name == name))
            {
                throw new InvalidOperationException($"Variable with name {name} already exists");
            }

            var variable = new Variable
            {
                Name  = name,
                Type  = customType,
                Value = NextAvailableHeap.ToString()
            };

            foreach (var property in customType.Properties)
            {
                var variableOnHeap = new Variable
                {
                    Name   = $"{name}.{property.Name}",
                    Type   = property.Type,
                    Value  = property.Type.Defaultvalue,
                    Parent = variable
                };

                variable.Variables.Add(variableOnHeap);

                Ram.SetVariable(NextAvailableHeap, variableOnHeap);
                NextAvailableHeap++;
            }

            Ram.SetVariable(NextAvailableStack, variable);

            Variables.Add(variable);

            NextAvailableStack++;

            SourceCode.Add($"{customType.Name} {name} = new {customType.Name}();");
        }
Esempio n. 13
0
 public override bool HasVariable(string var)
 {
     if (Variables.Any(x => x.Name == var))
     {
         return(Variables.Any(x => x.Name == var));
     }
     else if (Parent != null)
     {
         return(Parent.HasVariable(var));
     }
     return(false);
 }
        // =======================================================================================
        // CLASS INITIALISATION
        // =======================================================================================
        public ReDimStatement(bool preseve, IEnumerable <DimVariable> variables) : base(variables)
        {
            // Ensure that all variables have at least one dimension (VBScript code will not compile if this is not the case and the assumption
            // is that we're dealing with valid code - it would be a compile time error, not a runtime error that could be masked with On Error
            // Resume Next)
            if (Variables.Any(v => (v == null) || !v.Dimensions.Any()))
            {
                throw new ArgumentException("There must be at least one argument for all variables specified in a ReDim statement");
            }

            Preserve = preseve;
        }
        /// <summary>
        /// Evaluates a filter in the given Evaluation Context
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        public override void Evaluate(SparqlEvaluationContext context)
        {
            if (context.InputMultiset is NullMultiset)
            {
                return;
            }

            if (context.InputMultiset is IdentityMultiset)
            {
                if (!Variables.Any())
                {
                    // If the Filter has no variables and is applied to an Identity Multiset then if the
                    // Filter Expression evaluates to False then the Null Multiset is returned
                    try
                    {
                        if (!_arg.Evaluate(context, 0).AsSafeBoolean())
                        {
                            context.InputMultiset = new NullMultiset();
                        }
                    }
                    catch
                    {
                        // Error is treated as false for Filters so Null Multiset is returned
                        context.InputMultiset = new NullMultiset();
                    }
                }
                else
                {
                    // As no variables are in scope the effect is that the Null Multiset is returned
                    context.InputMultiset = new NullMultiset();
                }
            }
            else
            {
#if NET40
                // Remember that not all expressions are safe to parallelise
                if (Options.UsePLinqEvaluation && this._arg.CanParallelise)
                {
                    context.InputMultiset.SetIDs.ToList().AsParallel().ForAll(i => EvalFilter(context, i));
                }
                else
                {
#endif
                foreach (int id in context.InputMultiset.SetIDs.ToList())
                {
                    EvalFilter(context, id);
                }
#if NET40
            }
#endif
            }
        }
Esempio n. 16
0
        public override int GetHashCode()
        {
            int hashCode = CoEfficient.GetHashCode();

            if (Variables.Any())
            {
                foreach (var variable in Variables)
                {
                    hashCode = CombineHashCodes(hashCode, variable.GetHashCode());
                }
            }
            return(hashCode);
        }
Esempio n. 17
0
        // =======================================================================================
        // CLASS INITIALISATION
        // =======================================================================================
        protected BaseDimStatement(IEnumerable <DimVariable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }

            Variables = variables.ToList().AsReadOnly();
            if (Variables.Any(v => v == null))
            {
                throw new ArgumentException("Null reference encountered in variables set");
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Convert command to a string that can be sent to FreeSWITCH
        /// </summary>
        /// <returns>FreeSWITCH command</returns>
        public string ToFreeSwitchString()
        {
            if (CallerId != null)
            {
                var name = CallerId.Name;
                if (name != null)
                {
                    AddVariable(Variable.Originator.CallerId.Name, "'" + name + "'");
                }
                if (CallerId.Number != null)
                {
                    AddVariable(Variable.Originator.CallerId.Number, CallerId.Number.ToString());
                }
            }
            if (Caller is ICallerIdProvider && !Variables.Any(x => x.Name == Variable.Originator.CallerId.Number))
            {
                var callerId = (ICallerIdProvider)Caller;
                if (callerId.CallerIdName != null)
                {
                    AddVariable(Variable.Originator.CallerId.Name, "'" + callerId.CallerIdName + "'");
                }
                if (callerId.CallerIdNumber != null)
                {
                    AddVariable(Variable.Originator.CallerId.Number, callerId.CallerIdNumber);
                }
            }

            if (AutoAnswer)
            {
                /*_variables.Add(new CallVariable("sip_invite_params", "intercom=true"));*/
                AddVariable(Variable.Sip.CallInfo, "answer-after=0");
                AddVariable(Variable.Sip.AutoAnswer, "true");
            }


            var variables = string.Empty;

            foreach (var variable in _variables)
            {
                variables += variable + ",";
            }

            if (variables.Length > 0)
            {
                variables = "{" + variables.Remove(variables.Length - 1, 1) + "}";
            }

            return(string.Format("originate {0}{1} {2}", variables, Caller.ToDialString(), Destination.ToDialString()));
        }
Esempio n. 19
0
        public override string ToString()
        {
            string sign = Math.Sign(Factor) < 0 ? "-" : "";

            float absFactor = Math.Abs(Factor);

            string factor = Variables.Any()
                ? absFactor == 1 ? "" : $"{absFactor}"
                : $"{absFactor}";

            string variables = string.Join(
                string.Empty, Variables.Select(v => v.ToString()));

            return($"{sign}{factor}{variables}");
        }
Esempio n. 20
0
        public void CreateCustomType(string name, List <Property> properties)
        {
            if (Variables.Any(x => x.Name == name))
            {
                throw new InvalidOperationException($"Variable with name {name} already exists");
            }

            var newCustomType = new RefType(name)
            {
                Properties = properties
            };

            DataTypes.Types[DataTypes.customTypes].Add(newCustomType);
            Types.Add(newCustomType);
        }
Esempio n. 21
0
        NodeGraphVariable AddVariable(NodeGraphVariableData graphVariableData)
        {
            NodeEditor.Assertions.IsFalse(Variables.Any(x => x.ID == graphVariableData.ID), "Tried to spawn a variable that has the same ID as an existing variable.");

            var variable = new NodeGraphVariable(graphVariableData);

            variable.NameChangeRequested += Variable_NameChangeRequested;
            Variables.Add(variable);

            NodeEditor.Logger.Log <NodeGraph>("Added variable '{0}' ({1})", variable.Name, variable.GetType());

            VariableAdded.InvokeSafe(variable);
            Edited.InvokeSafe(this);

            return(variable);
        }
        public static void Write(this Variables variables, CSideWriter writer)
        {
            if (!variables.Any())
            {
                return;
            }

            writer.WriteLine("VAR");
            writer.Indent();

            foreach (Variable variable in variables)
            {
                variable.Write(writer);
            }

            writer.Unindent();
        }
Esempio n. 23
0
        public void InitializeValueVariable(DataType dataType, string name, string value)
        {
            if (!(dataType is ValueType type))
            {
                throw new ArgumentException($"{nameof(dataType)} needs to be a value type");
            }

            if (!Types.Any(x => x.Name == type.Name))
            {
                throw new InvalidOperationException($"{dataType.Name} is not in the list of available types.");
            }

            if (Variables.Any(x => x.Name == name))
            {
                throw new InvalidOperationException($"Variable with name {name} already exists");
            }

            var variable = new Variable
            {
                Name  = name,
                Type  = dataType,
                Value = value == string.Empty ? dataType.Defaultvalue : value
            };

            Ram.SetVariable(NextAvailableStack, variable);

            Variables.Add(variable);

            NextAvailableStack++;

            if (dataType.Equals(DataTypes.String))
            {
                SourceCode.Add($"{dataType.Name} {name} = \"{value}\";");
            }
            else if (dataType.Equals(DataTypes.Bool))
            {
                SourceCode.Add($"{dataType.Name} {name} = {(value == "0" ? "false" : "true")};");
            }
            else
            {
                SourceCode.Add($"{dataType.Name} {name} = {value};");
            }
        }
Esempio n. 24
0
        internal void ValidateOptions()
        {
            if (!PromptForText)
            {
                ValidateOptionsWhenNotPromptedForText();
            }
            else
            {
                ValidateOptionsWhenPromptedForText();
            }

            if ((CycleInterval != null) && (Variables.Any() || AskForVariables))
            {
                Fail("You can't use the '-m' and '-v' / '-va' options at the same time.");
            }

            if ((SequenceValues?.Any() ?? false) && (CurrentConfig.Sequences?.Length ?? 0) == 0)
            {
                Fail($"There are no sequences declared in '{ConfigFile}' config file to override.");
            }
        }
Esempio n. 25
0
        public override string ToString()
        {
            if (Math.Abs(Multiplier) < float.Epsilon)
            {
                return("0");
            }

            var signStr       = Multiplier < 0 ? Symbols.Minus.ToString() : String.Empty;
            var absMultiplier = Math.Abs(Multiplier);

            var absMultiplierString = Math.Abs(absMultiplier - 1) < float.Epsilon
                ? Variables.Any() ? String.Empty : $"{absMultiplier.ToString("G", System.Globalization.CultureInfo.InvariantCulture)}"
                : $"{absMultiplier.ToString("G", System.Globalization.CultureInfo.InvariantCulture)}";

            var variablesString = Variables
                                  .OrderByDescending(x => x.Power)
                                  .ThenBy(x => x.Name)
                                  .CollectionToStringWithSeparator(String.Empty);

            return($"{signStr}{absMultiplierString}{variablesString}");
        }
        public string ToGraphQL()
        {
            var builder = new StringBuilder();

            var variablesText = "";

            if (Variables != null && Variables.Any())
            {
                variablesText = $"({string.Join(" ,", Variables.Select(v => $"${v.Name}: {v.ToString()}"))})";
            }

            builder.AppendLine($"query {variablesText} {{ ");

            foreach (var selection in Selections)
            {
                builder.Append(selection.ToGraphQL());
            }

            builder.AppendLine("}");
            return(builder.ToString());
        }
Esempio n. 27
0
        internal override void Write(System.CodeDom.Compiler.IndentedTextWriter writer, GmlFormatter formatter, bool semicolon)
        {
            writer.Write("globalvar");
            if (Variables.Any())
            {
                writer.Write(" ");
            }

            for (var i = 0; i < Variables.Length; i++)
            {
                if (i != 0)
                {
                    writer.Write("," + formatter.Padding);
                }

                writer.Write(Variables[i]);
            }
            if (semicolon)
            {
                writer.WriteLine(";");
            }
        }
Esempio n. 28
0
        public override string ToString()
        {
            if (CoEfficient == 0)
            {
                return("0");
            }

            string signString        = string.Empty;
            string coefficientString = string.Empty;
            string variableString    = string.Empty;
            string multiplyString    = string.Empty;

            if (Variables.Any())
            {
                variableString = string.Join("*", Variables.Select(v => v.ToString()));
            }
            else if (BigInteger.Abs(CoEfficient) == 1)
            {
                coefficientString = CoEfficient.ToString();
            }

            if (BigInteger.Abs(CoEfficient) != 1)
            {
                if (Variables.Any())
                {
                    multiplyString = "*";
                }
                coefficientString = CoEfficient.ToString();
            }
            else if (Variables.Any() && CoEfficient.Sign == -1)
            {
                coefficientString = "-";
            }

            return($"{coefficientString}{multiplyString}{variableString}");
        }
Esempio n. 29
0
        public string GetSql(Vendors vendor, string schemaName)
        {
            if (!IsSuitable(Query.Database, vendor))
            {
                return(null);
            }

            if (Variables == null || !Variables.Any())
            {
                return(Query.Text.Replace("{sc}", schemaName));
            }

            foreach (var v in Variables)
            {
                if (!IsSuitable(v.Database, vendor))
                {
                    continue;
                }

                Query.Text = Query.Text.Replace("{" + v.Name + "}", v.Value);
            }

            return(Query.Text.Replace("{sc}", schemaName));
        }
Esempio n. 30
0
 internal bool HasVariables()
 {
     return(Variables.Any());
 }