Difference between revisions of "HowTo:Provide system definitions with a custom plugin"
m |
|||
| Line 1: | Line 1: | ||
| + | |||
| + | |||
This tutorial explains how to provide any kind of preconfigured {{UBIK}} data (system definitions) using a custom plugin. | This tutorial explains how to provide any kind of preconfigured {{UBIK}} data (system definitions) using a custom plugin. | ||
| + | |||
<!-- DO NOT REMOVE THIS -->{{Template:HowTo/Begin}}<!-- DO NOT REMOVE THIS --> | <!-- DO NOT REMOVE THIS -->{{Template:HowTo/Begin}}<!-- DO NOT REMOVE THIS --> | ||
| Line 249: | Line 252: | ||
set | set | ||
{ | { | ||
| − | + | // do nothing | |
} | } | ||
} | } | ||
| Line 280: | Line 283: | ||
public const string NS_MY_PLUGIN = "System.MyPlugin; | public const string NS_MY_PLUGIN = "System.MyPlugin; | ||
| − | public static Guid PROPERTY_UID_MYPROPERTY = Guid.Parse("d90b50e0-17d9-40ac-b89d-18f4a01cd5cb"); | + | public static readonly Guid PROPERTY_UID_MYPROPERTY = Guid.Parse("d90b50e0-17d9-40ac-b89d-18f4a01cd5cb"); |
public const string PROPERTY_NAME_MYPROPERTY = "LK_LOCATION"; | public const string PROPERTY_NAME_MYPROPERTY = "LK_LOCATION"; | ||
| Line 384: | Line 387: | ||
set | set | ||
{ | { | ||
| − | + | // do nothing | |
} | } | ||
} | } | ||
| Line 536: | Line 539: | ||
#endregion Version | #endregion Version | ||
| − | + | ||
// ... | // ... | ||
| Line 550: | Line 553: | ||
#endregion System Meta Classes | #endregion System Meta Classes | ||
| + | |||
| + | // ... | ||
| + | } | ||
| + | } | ||
| + | </syntaxhighlight> | ||
| + | </div></div> | ||
| + | |||
| + | = Create a new MetaProxy = | ||
| + | |||
| + | <div class="toccolours mw-collapsible mw-collapsed" style="width:100%; overflow:auto;"> | ||
| + | <div style="font-weight:bold;line-height:1.6;">SystemDesignMetaProxy template code</div> | ||
| + | <div class="mw-collapsible-content"> | ||
| + | <syntaxhighlight lang="csharp"> | ||
| + | namespace UBIK.MyPlugin | ||
| + | { | ||
| + | public class MyProxyMetaClass : SystemDesignMetaProxy | ||
| + | { | ||
| + | public static Guid UID = GuidUtility.MY_PROXY; | ||
| + | private const string NAME = "MYPROXY"; | ||
| + | private const string NAMESPACE = "System.MyPlugin"; | ||
| + | private const string DESCRIPTION = "My meta proxy"; | ||
| + | |||
| + | public MyProxyMetaClass(UBIKEnvironment environment) | ||
| + | { | ||
| + | InitUidAndEnvironment(UID, environment); | ||
| + | InitStrings(NAME, NAMESPACE, DESCRIPTION); | ||
| + | |||
| + | SetModuleId(MyPlugin.ID); | ||
| + | |||
| + | List<Guid> metaProperties = new List<Guid>(); | ||
| + | // regular meta properties | ||
| + | DefineMetaProperties(metaProperties); | ||
| + | |||
| + | List<MetaProxyPropertyInfo> metaProxyPropertyInfos = new List<MetaProxyPropertyInfo>(); | ||
| + | metaProxyPropertyInfos.Add(new MetaProxyPropertyInfo(environment, MyProxyMetaProperties.PROXY_PROPERTY_UID_MYPROPERTY, true, -1, ProxyUpdateModes.BiDirectional, MyMetaProperties.PROPERTY_UID_MYPROPERTY, "My property")); | ||
| + | |||
| + | DefineMetaProxyProperties(metaProxyPropertyInfos); | ||
| + | } | ||
| + | |||
| + | public override MetaClass MetaClass | ||
| + | { | ||
| + | get | ||
| + | { | ||
| + | return this.Environment.GetSystemMetaClass(SystemObjects.METAPROXY); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | public override MetaClass Inheritance | ||
| + | { | ||
| + | get | ||
| + | { | ||
| + | return this.Environment.GetSystemMetaClass(SystemObjects.PROXY_ROOT); | ||
| + | } | ||
| + | set | ||
| + | { | ||
| + | // do nothing | ||
| + | } | ||
| + | } | ||
| + | |||
| + | public override MetaClassTypes ClassType | ||
| + | { | ||
| + | get | ||
| + | { | ||
| + | return MetaClassTypes.Proxy; | ||
| + | } | ||
| + | set | ||
| + | { | ||
| + | // do nothing | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </syntaxhighlight> | ||
| + | </div></div> | ||
| + | |||
| + | <div class="toccolours mw-collapsible mw-collapsed" style="width:100%; overflow:auto;"> | ||
| + | <div style="font-weight:bold;line-height:1.6;">SystemDesignMetaProxyProperty template code</div> | ||
| + | <div class="mw-collapsible-content"> | ||
| + | <syntaxhighlight lang="csharp"> | ||
| + | namespace UBIK.MyPlugin | ||
| + | { | ||
| + | public class MyMetaProxyProperties | ||
| + | { | ||
| + | public const string NS_MY_PLUGIN = "System.MyPlugin; | ||
| + | public const int STR_LEN_MED = 255; | ||
| + | |||
| + | public static UBIKClassList<MetaProperty> DefineSystemMetaProperties(UBIKEnvironment environment) | ||
| + | { | ||
| + | UBIKClassList<MetaProperty> metaProperties = new UBIKClassList<MetaProperty>(); | ||
| + | |||
| + | SystemDesignMetaProxyProperty myMetaProxyProperty = new SystemDesignMetaProxyProperty(environment, | ||
| + | GuidUtility.MPP_MYPROPERTY, // assuming the ids are documented in a class GuidUtility | ||
| + | MyMetaProperties.PROPERTY_NAME_MYPROPERTY, | ||
| + | NAMESPACE, | ||
| + | PropertyTypes.String, | ||
| + | GuidUtility.MPP_MYPROPERTY_VIRTUAL_PROPERTIES[0], | ||
| + | GuidUtility.MPP_MYPROPERTY_VIRTUAL_PROPERTIES[1]); | ||
| + | myMetaProxyProperty.MetaAttribute = environment.GetSystemMetaClass(SystemObjects.PROXYATTRIBUTE); | ||
| + | myMetaProxyProperty.SetStringLen(STR_LEN_MED); | ||
| + | proxyProperties.Add(myMetaProxyProperty); | ||
| + | |||
| + | return metaProperties; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </syntaxhighlight> | ||
| + | </div></div> | ||
| + | |||
| + | <div class="toccolours mw-collapsible mw-collapsed" style="width:100%; overflow:auto;"> | ||
| + | <div style="font-weight:bold;line-height:1.6;">SystemDefinitions adaptations</div> | ||
| + | <div class="mw-collapsible-content"> | ||
| + | <syntaxhighlight lang="csharp"> | ||
| + | namespace UBIK.MyPlugin | ||
| + | { | ||
| + | public class MySystemDefinitions_V100 : SystemDefinitionsBase | ||
| + | { | ||
| + | // ... | ||
| + | |||
| + | #region System Meta Classes | ||
| + | |||
| + | public override UBIKClassList<MetaClass> DefineSystemMetaClasses(UBIKEnvironment environment) | ||
| + | { | ||
| + | UBIKClassList<MetaClass> metaClasses = new UBIKClassList<MetaClass>(); | ||
| + | |||
| + | MyProxyMetaClass myBaseClass = new MyProxyMetaClass(environment); | ||
| + | metaClasses.Add(myBaseClass); | ||
| + | |||
| + | return metaClasses; | ||
| + | } | ||
| + | |||
| + | #endregion System Meta Classes | ||
| + | |||
| + | #region System Meta Properties | ||
| + | |||
| + | public override UBIKClassList<MetaProperty> DefineSystemMetaProperties(UBIKEnvironment environment) | ||
| + | { | ||
| + | UBIKClassList<MetaProperty> result = new UBIKClassList<MetaProperty>(); | ||
| + | result.AddRangeUnique(MyMetaProxyProperties.DefineSystemMetaProperties(environment)); | ||
| + | return result; | ||
| + | } | ||
| + | |||
| + | #endregion System Meta Properties | ||
// ... | // ... | ||
| Line 562: | Line 707: | ||
* [[HowTo:Create_UBIK_Module|Create your own module]] | * [[HowTo:Create_UBIK_Module|Create your own module]] | ||
| + | |||
| + | [[Category:How-To]] | ||
| + | [[Category:Module]] | ||
[[Category:How-To|Provide system definitions with a custom plugin]] | [[Category:How-To|Provide system definitions with a custom plugin]] | ||
[[Category:Module|Provide system definitions with a custom plugin]] | [[Category:Module|Provide system definitions with a custom plugin]] | ||
Revision as of 12:11, 25 November 2024
This tutorial explains how to provide any kind of preconfigured UBIK® data (system definitions) using a custom plugin.

