How Do I Implement ZApp Plugin |
[This is preliminary documentation and is subject to change.]
Both IZetApp and IZetProcessor require you to implement a common underlying interface, IPlugin, that is used to define all plugins for Zet Universe.
Define values for descriptional properties, such as Id (it should be a unique Guid), Publisher, Title, and Version.
Declare private member ZetHost and implement public IHost property:
Method invokation support is not currently required, thus implement Invoke() method as follows:
Implement OnConnection() method, retrieve IHost, cast it to IZetHost, retrieve IAppSettings, and use these values to continue initializing your plugin:
public bool OnConnection(ConnectMode mode) { if (this.Host == null) throw new NotImplementedException("Host is not available"); this.ZetHost = this.Host as IZetHost; if (this.ZetHost == null) throw new PlatformNotSupportedException("This build of Zet Universe platform is not supported. Host doesn't implement ZU.Plugins.IZetHost interface"); IAppSettings settings = this.ZetHost.AppManager.GetAppSettings(this).Result; // Continue plugin initialization using a separate Initialize() method this.Initialize(settings, this.ZetHost.SIM, this.ZetHost.AppManager); return true; }
Plugin disconnection is not currently supported; yet, this will be available in the future releases. For now, implement OnDisconnection() method:
Declare private member _settings, and implement GetCurrentAppSettings() method:
Decide if it needs support for more than one account, and define AreMultipleAccountsAllowed property accordingly.
Use the IAppSettings.Accounts list as the one used for your IZetApp.Accounts property: