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 -->
set
{
throw new NotImplementedException();// do nothing
}
}
public const string NS_MY_PLUGIN = "System.MyPlugin;
public static readonly Guid PROPERTY_UID_MYPROPERTY = Guid.Parse("d90b50e0-17d9-40ac-b89d-18f4a01cd5cb");
public const string PROPERTY_NAME_MYPROPERTY = "LK_LOCATION";
set
{
throw new NotImplementedException();// do nothing
}
}
#endregion Version
// ...
#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
// ...
* [[HowTo:Create_UBIK_Module|Create your own module]]
[[Category:How-To]]
[[Category:Module]]
[[Category:How-To|Provide system definitions with a custom plugin]]
[[Category:Module|Provide system definitions with a custom plugin]]