public AddParameter ( |
||
parameter | Parameter object. | |
return | void |
public static void ImportProviderSettings(int moduleId, XmlNode settingsNode, string providerName) { if ((settingsNode != null)) { var pc = new ParameterController(providerName); foreach (var p in pc.GetParameters(moduleId)) { pc.DeleteParameter(p.Key); } foreach (XmlNode node in settingsNode.SelectNodes(Portable.ParamElement)) { if (node.Attributes == null) { continue; } var p = new ParameterInfo { ModuleId = moduleId, Name = node.Attributes["name"].Value, Type = node.Attributes[Portable.TypeAttribute].Value }; if (p.IsArgumentRequired()) { p.TypeArgument = node.Attributes[Portable.ArgAttribute].Value; } p.IsValueRequired = (node.Attributes[Portable.ValueRequiredAttribute] != null); pc.AddParameter(p); } } }
protected void GrdParams_UpdateCommand(object source, DataGridCommandEventArgs e) { try { // init vars var objParam = new ParameterInfo(); // set values if (e.Item.ItemIndex > -1) { objParam.Id = Convert.ToInt32(grdParams.DataKeys[e.Item.ItemIndex]); } objParam.ModuleId = ModuleId; objParam.Name = ((TextBox)e.Item.FindControl(ControlNames.ParameterName)).Text; objParam.Type = ((DropDownList)e.Item.FindControl(ControlNames.ParameterType)).SelectedValue; if (objParam.IsArgumentRequired() || (SupportsFallbackValues && objParam.SupportsFallbackValue())) { objParam.TypeArgument = ((TextBox)e.Item.FindControl(ControlNames.ParameterArgument)).Text; } objParam.IsValueRequired = ((CheckBox)e.Item.FindControl(ControlNames.ParameterIsValueRequired)).Checked; // add/update param if (objParam.IsValidDefinition) { var objController = new ParameterController(Purpose); if (objParam.IsNew) { objController.AddParameter(objParam); } else { objController.UpdateParameter(objParam); } // clear edit row grdParams.EditItemIndex = -1; // bind data BindParameters(); } else { ErrorMessagePlaceHolder.Controls.Add( UI.Skins.Skin.GetModuleMessageControl( Localization.GetString(LocaleKeys.ParameterInvalidHeader, LocalResourceFile), Localization.GetString(LocaleKeys.ParameterInvalid, LocalResourceFile), ModuleMessage.ModuleMessageType.RedError)); } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
protected void GrdParams_UpdateCommand(object source, DataGridCommandEventArgs e) { try { // init vars var objParam = new ParameterInfo(); // set values if (e.Item.ItemIndex > -1) objParam.Id = Convert.ToInt32(grdParams.DataKeys[e.Item.ItemIndex]); objParam.ModuleId = ModuleId; objParam.Name = ((TextBox) e.Item.FindControl(ControlNames.ParameterName)).Text; objParam.Type = ((DropDownList) e.Item.FindControl(ControlNames.ParameterType)).SelectedValue; if (objParam.IsArgumentRequired() || (SupportsFallbackValues && objParam.SupportsFallbackValue())) objParam.TypeArgument = ((TextBox) e.Item.FindControl(ControlNames.ParameterArgument)).Text; objParam.IsValueRequired = ((CheckBox) e.Item.FindControl(ControlNames.ParameterIsValueRequired)).Checked; // add/update param if (objParam.IsValidDefinition) { var objController = new ParameterController(Purpose); if (objParam.IsNew) { objController.AddParameter(objParam); } else { objController.UpdateParameter(objParam); } // clear edit row grdParams.EditItemIndex = -1; // bind data BindParameters(); } else { ErrorMessagePlaceHolder.Controls.Add( UI.Skins.Skin.GetModuleMessageControl( Localization.GetString(LocaleKeys.ParameterInvalidHeader, LocalResourceFile), Localization.GetString(LocaleKeys.ParameterInvalid, LocalResourceFile), ModuleMessage.ModuleMessageType.RedError)); } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
public static void ImportProviderSettings(int moduleId, XmlNode settingsNode, string providerName) { if ((settingsNode != null)) { var pc = new ParameterController(providerName); foreach (var p in pc.GetParameters(moduleId)) { pc.DeleteParameter(p.Key); } foreach (XmlNode node in settingsNode.SelectNodes(Portable.ParamElement)) { if (node.Attributes == null) continue; var p = new ParameterInfo { ModuleId = moduleId, Name = node.Attributes["name"].Value, Type = node.Attributes[Portable.TypeAttribute].Value }; if (p.IsArgumentRequired()) p.TypeArgument = node.Attributes[Portable.ArgAttribute].Value; p.IsValueRequired = (node.Attributes[Portable.ValueRequiredAttribute] != null); pc.AddParameter(p); } } }