UserMethodTemplates: IMsUserMethodTemplates;
The UserMethodTemplates property returns the collection of custom method templates used in modeling container.
Executing the example requires that the repository contains a database with the BD identifier, as well as the User_Method unit that contains a custom method template.
Sub UserProc;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Kont: IMsModelSpace;
Templates: IMsUserMethodTemplates;
Template: IMsUserMethodTemplate;
TemplateParams: IMsUserMethodTemplateParams;
TemplateParam: IMsUserMethodTemplateParam;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MODELSPACE;
CrInfo.Id := "Kont_Model";
CrInfo.Name := "New modeling container";
CrInfo.Parent := MB.Root;
MObj := MB.CreateObject(CrInfo).Edit;
Kont := MObj As IMsModelSpace;
//Set database
Kont.Database := MB.ItemById("BD").Bind As IDatabase;
//Set period
Kont.StartDate := DateTime.ComposeDay(2000, 1, 1);
Kont.EndDate := DateTime.AddYears(Kont.StartDate, 10);
//Custom method template
Templates := Kont.UserMethodTemplates;
Template := Templates.Add;
Template.Assembly := MB.ItemById("User_Method");
Template.ClassName := "My_Method";
//Template parameters
TemplateParams := Template.Params;
TemplateParam := TemplateParams.Add;
TemplateParam.Binding := """UI=""FloatEdit""";
TemplateParam.Name := "First parameter";
TemplateParam := TemplateParams.Add;
TemplateParam.Binding := """UI=""FloatEdit""";
TemplateParam.Name := "Second parameters";
MObj.Save;
End Sub UserProc;
After executing the example a modeling container is created in the root directory of repository. The calendar period for this container is set to 10 years, one template is created in the list of templates of the custom methods.
See also: