BindKey(Key: String; [CanCreate: Boolean = false]): ISysSettingsKey;
BindKey(Key: String; CanCreate: Boolean): Prognoz.Platform.Interop.ForeSystem.ISysSettingsKey;
Key. Element key in the settings file.
CanCreate. It indicates whether the element is created if it is missing in the current settings file. Available values:
True. Create an element.
False. Do not create an element (default value).
The BindKey method returns parameters of the specified element with settings.
Key of the Key element is formed from the names of all its parent elements separated with the \\ character. If the @ character is situated before the first value in the key, the value itself is taken as value of the Name attribute for the Key element.
If the CanCreate parameter is set to True, and the element with the Key key is missing, an exception is thrown.
Executing the example requires the Settings.xml file. This file contains all sections with BI server settings filled. Add a link to the Xml system assembly.
Sub UserProc;
Var
Settings: ISysSettings;
Node: ISysSettingsKey;
XmlNode: IXmlDomElement;
Lock: Object;
Begin
Settings := New SysSettings.Create;
Node := Settings.Root;
XmlNode := Node.Element As IXmlDomElement;
//Get parameters of the <Root> element/<Key Name="PP">/<BIS>/<Key Name="System">/<Pool>
Node := Node.BindKey("@PP\\BIS\\Key\\Pool", True);
XmlNode := Node.Element As IXmlDomElement;
//Change value of the MaxConnections attribute
XmlNode.setAttribute("MaxConnections", "10");
//Lock before saving
Lock := Settings.CriticalLock;
Try
Settings.Commit;
Finally
Dispose Lock;
End Try;
End Sub UserProc;
After executing the example, value of the MaxConnections parameter is changed in the file with BI server settings. If the parameter is missing, it is created.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports System.Xml;
Imports Prognoz.Platform.Interop.ForeSystem;
Public Shared Sub UserProc();
Var
Settings: SysSettings = New SysSettingsClass();
Node: ISysSettingsKey;
XmlNode: XmlElement;
Lock: Object;
Begin
Node := Settings.Root;
XmlNode := Node.Element As XmlElement;
//Get parameters of the <Root> element/<Key Name="PP">/<BIS>/<Key Name="System">/<Pool>
Node := Node.BindKey("@PP\\BIS\\Key\\Pool", True);
XmlNode := Node.Element As XmlElement;
//Change value of the MaxConnections attribute
XmlNode.setAttribute("MaxConnections", "10");
//Lock before saving
Lock := Settings.CriticalLock;
Try
Settings.Commit();
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(Lock);
End Try;
End Sub;
See also: