X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fdali-swig%2Fexamples%2Fcustom-control.cs;h=2da7ea4089f924c6236c34043a2c2662617fc200;hb=98a7a7f1acd1ccedc8c0e3157163201c2b2b473a;hp=20531a2256459f24a2568016bb92afce0efc9c30;hpb=2a7e2358bd82572eb9c4024655dc0050cc25d0b0;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/plugins/dali-swig/examples/custom-control.cs b/plugins/dali-swig/examples/custom-control.cs index 20531a2..2da7ea4 100644 --- a/plugins/dali-swig/examples/custom-control.cs +++ b/plugins/dali-swig/examples/custom-control.cs @@ -31,7 +31,21 @@ namespace MyCSharpExample private int _myRating; private bool _myDragEnabled; - public StarRating() : base(ViewWrapperImpl.CustomViewBehaviour.VIEW_BEHAVIOUR_DEFAULT) + // Called by DALi Builder if it finds a StarRating control in a JSON file + static CustomView CreateInstance() + { + return new StarRating(); + } + + // static constructor registers the control type (only runs once) + static StarRating() + { + // ViewRegistry registers control type with DALi type registery + // also uses introspection to find any properties that need to be registered with type registry + ViewRegistry.Instance.Register(CreateInstance, typeof(StarRating) ); + } + + public StarRating() : base(typeof(StarRating).Name, ViewWrapperImpl.CustomViewBehaviour.VIEW_BEHAVIOUR_DEFAULT) { } @@ -229,6 +243,8 @@ namespace MyCSharpExample [STAThread] static void Main(string[] args) { + System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (typeof(MyCSharpExample.StarRating).TypeHandle); + Example example = new Example(Application.NewApplication()); example.MainLoop (); }