public override void InitializeVariables() { base.InitializeVariables(); bool value; if (Variables.TryGetVariableValue(Key, out value)) { Value = value; } else { Variables.AddVariable(Key, _control.Default); } foreach (var option in CheckedOptions) { option.InitializeVariables(); } foreach (var option in UncheckedOptions) { option.InitializeVariables(); } }
/// <summary> /// Adds the (non-input) variable of given <paramref name="name"/> and <paramref name="variableType">type</paramref> into the definition /// </summary> /// <param name="name">Name of the variable to add</param> /// <param name="variableType">Type of the variable to add</param> /// <param name="variableRef">Reference to the variable added</param> /// <returns>The current <see cref="DmnDefinitionBuilder"/></returns> /// <exception cref="DmnBuilderException">Throws <see cref="DmnBuilderException"/> when the definition has already been built</exception> public DmnDefinitionBuilder WithVariable(string name, Type variableType, out Variable.Ref variableRef) { if (IsBuilt) { throw Logger.Error <DmnBuilderException>("Definition is already built"); } if (name == null) { throw new ArgumentNullException(nameof(name)); } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Missing variable name", nameof(name)); } var variableName = DmnVariableDefinition.NormalizeVariableName(name); if (Variables.Variables.ContainsKey(variableName)) { throw Logger.Error <DmnBuilderException>($"Duplicate variable name {variableName} (normalized from {name})"); } var variable = new Variable(Variables, Decisions, variableName, variableType); variableRef = variable.Reference; Variables.AddVariable(variable); return(this); }
public override void InitializeVariables() { base.InitializeVariables(); View = CollectionViewSource.GetDefaultView(_items); View.Filter = OnFilter; string value; if (Variables.TryGetVariableValue(Key, out value)) { Value = value; } else { Variables.AddVariable(Key, _items.Select(item => item.Value).FirstOrDefault()); } }
public override void InitializeVariables() { string value; if (!string.IsNullOrEmpty(_control.Value)) { Variables.AddVariable(Key, _control.Value); } else if (Variables.TryGetVariableValue(Key, out value)) { Value = value; } else { Variables.AddVariable(Key, string.Empty); } _allowValidation = true; }
public bool ImportStateCADFile(byte[] data) { for (int i = 0; i < data.Length; i++) { data[i] ^= 0x80; } StateCadImporter importer = new StateCadImporter(Encoding.Default.GetString(data), MainSheet.Sketch, 4f); Dictionary <int, DrawableObject> list = new Dictionary <int, DrawableObject>(); Rectangle sheet = importer.DrawArea; sheet.Inflate(400, 400); MainSheet.Size = Util.ScaleSize(sheet.Size, 4f); DrawableObject select = null; foreach (Instruction inst in importer.Instructions) { switch (inst.Head) { case "variable add": if (inst.Parameter[10] == 1) //Input { Variables.AddVariable(new BooleanInput(inst.Name)); } else if (inst.Parameter[10] == 2) //Output { Variables.AddVariable(new BooleanOutput(inst.Name)); } else if (inst.Parameter[10] == 6) //Flag { Variables.AddVariable(new BooleanFlag(inst.Name)); } break; case "state add": if (inst.Parameter[11] == 0) //Origin { list.Add(inst.StateId, inst.GetOrigin()); } else if (inst.Parameter[11] == 224) //State { list.Add(inst.StateId, inst.GetState()); } else if (inst.Parameter[11] == 176) //Alias { list.Add(inst.StateId, inst.GetAlias()); } break; case "state select": select = list[inst.StateId]; break; case "transition add": int idx = importer.Instructions.IndexOf(inst); inst.GetTransition(importer.Instructions.GetRange(idx, 5), select, list); break; case "text add": if (inst.Text[3] == "") { inst.GetText(); } else { inst.GetEcuation(); } break; } } foreach (Instruction inst in importer.Instructions) { switch (inst.Head) { case "state add": if (inst.Parameter[11] == 176) //Alias { var salias = list[inst.StateId] as StateAlias; salias.PointingTo = inst.Text[1]; } break; } } return(true); }
private void ExtractVariable(Variable variable) { Variables.AddVariable(variable); }
public override void InitializeVariables() { var dt = new DataTable(); if (!string.IsNullOrWhiteSpace(_control.Data)) { try { // strip out empty lines var lines = _control.Data.Split('\n'); var data = lines.Where(l => !string.IsNullOrWhiteSpace(l)).Aggregate((l1, l2) => $"{l1}\n{l2}"); using (var parser = new TextFieldParser(new StringReader(data))) { parser.HasFieldsEnclosedInQuotes = true; parser.SetDelimiters(","); var isFirstRow = true; while (!parser.EndOfData) { var fields = parser.ReadFields(); if (fields == null) { continue; } if (isFirstRow) { foreach (var field in fields) { dt.Columns.Add(new DataColumn(field)); } isFirstRow = false; } else { dt.Rows.Add(fields.Take(dt.Columns.Count).Cast <object>().ToArray()); } } } //foreach (var line in lines.Where(l => !string.IsNullOrWhiteSpace(l))) //{ // var fields = line.Trim().Split(','); // if (isFirstRow) // { // foreach (var field in fields) // { // dt.Columns.Add(new DataColumn(field)); // } // isFirstRow = false; // } // else // { // dt.Rows.Add(fields.Take(dt.Columns.Count).Cast<object>().ToArray()); // } //} } catch (Exception ex) { Logger.Log(ex); } } Variables.AddVariable(Key, dt); Items = dt.AsDataView(); }