public static VariableSettings CreateVariableModel(this VariableSettings variableSettings) { VariableSettings newVariableSettings = null; var @switch = new Dictionary<string, Action> { {VariableSettings.Textbox, () => newVariableSettings = new TextboxSettings()}, {VariableSettings.Dropdown, () => newVariableSettings = new DropdownSettings()}, {VariableSettings.Numeric, () => newVariableSettings = new NumericSettings()}, {VariableSettings.YesNo, () => newVariableSettings = new BooleanSettings()} }; @switch[variableSettings.SelectedEditor](); newVariableSettings.UpdateFrom(variableSettings); return newVariableSettings; }
public static VariableSettings CreateVariableModel(this FormField formField, Dictionary<string, Resource> variableSets) { VariableSettings variableSettings = null; var @switch = new Dictionary<Type, Action> { {typeof (FormField_Textbox), () => variableSettings = new TextboxSettings()}, {typeof (FormField_Dropdown), () => variableSettings = new DropdownSettings()}, {typeof (FormField_Numeric), () => variableSettings = new NumericSettings()}, {typeof (FormField_YesNo), () => variableSettings = new BooleanSettings()} }; @switch[formField.GetType().BaseType](); variableSettings.DisplayName = formField.DisplayName; variableSettings.IsReadonly = formField.IsReadonly; variableSettings.VariableName = formField.VariableName; variableSettings.UpdateFrom(formField, variableSets); return variableSettings; }
public static TextboxSettings CreateVariableModel(this VariableItem variableItem, Dictionary<string, Resource> variableSets) { var textboxModel = new TextboxSettings(); textboxModel.DisplayName = variableItem.Name.AddSpacesToSentence(true); textboxModel.IsReadonly = false; textboxModel.VariableName = variableItem.Name; foreach (KeyValuePair<string, Resource> variableSetKvp in variableSets) { string name = (variableSetKvp.Value as ProjectResource)?.Name ?? (variableSetKvp.Value as LibraryVariableSetResource)?.Name; textboxModel.VariableSets.Add(new DropdownItemModel { DisplayName = name, Value = variableSetKvp.Key }); } textboxModel.VariableSetId = textboxModel.VariableSets.First().Value; return textboxModel; }