Click or drag to resize

ExportInitializerAttribute Class

Attribute to apply to 3rd party assemblies to load additional controls or functionality.
Inheritance Hierarchy

Namespace:  Eto
Assembly:  Eto (in Eto.dll) Version: 2.4.0
Syntax
[AttributeUsageAttribute(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)]
public sealed class ExportInitializerAttribute : PlatformExtensionAttribute

The ExportInitializerAttribute type exposes the following members.

Constructors
  NameDescription
Public methodExportInitializerAttribute
Initializes a new instance of the PlatformInitializerAttribute class
Top
Properties
  NameDescription
Public propertyInitializerType
Type of the extension class to instantiate when the assembly this attribute is supplied on is loaded by the platform.
Top
Methods
  NameDescription
Public methodRegister
Registers the extension with the specified platform
(Overrides PlatformExtensionAttributeRegister(Platform).)
Top
Remarks
This can be used by both by the cross platform control library, and in each of the platform-specific libraries.
Examples
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 { }
        }
    }
}
See Also

Reference