ExportInitializerAttribute
PlatformExtensionAttributeAttribute[AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)]
public sealed class ExportInitializerAttribute : PlatformExtensionAttribute
Attribute to apply to 3rd party assemblies to load additional controls or functionality.
Remarks: This can be used by both by the cross platform control library, and in each of the platform-specific libraries.
Example:For example, say you want to create a new control, called
MyControl, you would have a shared assembly, plus implementation assemblies for each platform. MyControls.dll: using Eto;
using Eto.Forms;
namespace MyControls
{
[Handler(typeof(IHandler))]
public class MyControl : Control
{
new IHandler Handler => base.Handler as IHandler;
public bool SomeProperty
{
get { return Handler.SomeProperty; }
set { Handler.SomeProperty = value; }
}
public new interface IHandler : IHandler
{
bool SomeProperty { get; set; }
}
}
} MyControls.Wpf.dll: using Eto;
using Eto.Forms;
using Eto.Wpf.Forms;
[assembly:ExportInitializer(typeof(MyControls.Wpf.MyPlatform))]
namespace MyControls.Wpf
{
class MyPlatform : IPlatformExtension
{
public Initialize(Platform platform)
{
platform.Add<MyControl.IHandler>(() => new MyControlHandler());
}
}
public class MyControlHandler : WpfFrameworkElement<SomeWpfControl, MyControl, MyControl.ICallback>, MyControl.IHandler
{
public MyControlHandler()
{
Control = new SomeWpfControl();
}
// TODO:
public bool SomeProperty
{
get { return false; }
set { }
}
}
}Constructors
Properties
InitializerType
#Type of the extension class to instantiate when the assembly this attribute is supplied on is loaded by the platform.
Remarks: This type should usually implement IPlatformInitializer so that it can know what platform it is being loaded on.
Value: The type of the extension.
PlatformID
Gets or sets the platform identifier this extension should be loaded on, or null to load for all platforms.
Value: The platform identifier.
Methods
Register
#Registers the extension with the specified platform
Parameters:
| platform (Platform) | Platform to register this extension with. |
Returns:
true, if the extension was applied, false otherwise.Overrides: PlatformExtensionAttribute.Register
Supports
Gets a value indicating that this extension supports the specified platform.
Remarks: PlatformExtensionAttribute.Register(Platform) will only be called if this returns
true.Parameters:
| platform (Platform) | Platform to determine if this extension applies. |
Returns:
true, if this extension supports the specified platform, false otherwise.