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; }