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.
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

ExportInitializerAttribute

#
public ExportInitializerAttribute(Type initializerType)
Initializes a new instance of the PlatformInitializerAttribute class

Properties

InitializerType

#
public Type InitializerType { get; }
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.
The type of the extension.

PlatformID

public string PlatformID { get; set; }
Gets or sets the platform identifier this extension should be loaded on, or null to load for all platforms.
inherited fromPlatformExtensionAttribute

Methods

Register

#
public override void Register(Platform platform)
Registers the extension with the specified platform
platform (Platform)Platform to register this extension with.
true, if the extension was applied, false otherwise.

Supports

public virtual bool Supports(Platform platform)
Gets a value indicating that this extension supports the specified platform.
inherited fromPlatformExtensionAttribute
Remarks: PlatformExtensionAttribute.Register(Platform) will only be called if this returns true.
platform (Platform)Platform to determine if this extension applies.
true, if this extension supports the specified platform, false otherwise.