public async void Initialize(IServiceProvider services)
            {
                var handlers = services.GetRequiredService <IMauiHandlersServiceProvider>();

                MauiHotReloadHelper.Init(handlers.GetCollection());

                Reloadify.Reload.Instance.ReplaceType = (d) =>
                {
                    MauiHotReloadHelper.RegisterReplacedView(d.ClassName, d.Type);
                };

                Reloadify.Reload.Instance.FinishedReload = () =>
                {
                    MauiHotReloadHelper.TriggerReload();
                };

                await Task.Run(async() =>
                {
                    try
                    {
                        var success = await Reloadify.Reload.Init(IdeIp, IdePort);

                        Console.WriteLine($"HotReload Initialize: {success}");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                });
            }
Exemplo n.º 2
0
        public void StateTransfersOnlyChangedValues()
        {
            ResetComet();
            const string textValue = "Hello";
            var          orgView   = new MyOrgView();

            var orgText = orgView.GetView() as Text;

            Assert.NotEqual(orgView.bindingObject.Title, textValue);
            orgView.bindingObject.Title = textValue;
            Assert.Equal(textValue, orgText.Value);
            //IsEnabled is defaulted to true.
            Assert.True(orgView.bindingObject.IsEnabled);

            MauiHotReloadHelper.RegisterReplacedView(typeof(MyOrgView).FullName, typeof(MyNewView));
            MauiHotReloadHelper.TriggerReload();

            var newText = orgView.GetView() as Text;

            Assert.NotNull(newText);
            var v       = orgView.GetReplacedView();
            var newView = v as MyNewView;

            Assert.IsType <MyNewView>(v);
            Assert.NotNull(newView);
            Assert.False(newView.bindingObject.IsEnabled);
            Assert.Equal(textValue, newView.bindingObject.Title);
        }
Exemplo n.º 3
0
        public static void ResetComet()
        {
            var v = new View();

            v.ResetGlobalEnvironment();
            //v.DisposeAllViews();
            UI.Init(true);
            MauiHotReloadHelper.Reset();
            v?.Dispose();
        }
Exemplo n.º 4
0
        public void HotReloadRegisterReplacedViewReplacesView()
        {
            var orgView = new MyOrgView();
            var orgText = orgView.GetView() as Text;

            Assert.Equal(MyOrgView.TextValue, orgText.Value.CurrentValue);

            MauiHotReloadHelper.RegisterReplacedView(typeof(MyOrgView).FullName, typeof(MyNewView));
            var newText = orgView.GetView() as Text;

            Assert.Equal(MyNewView.TextValue, newText.Value.CurrentValue);
        }
Exemplo n.º 5
0
        public void StateIsTransferedToReloadedView()
        {
            ResetComet();
            const string textValue = "Hello";
            var          orgView   = new MyOrgView();

            var orgText = orgView.GetView() as Text;

            Assert.NotEqual(orgView.bindingObject.Title, textValue);
            orgView.bindingObject.Title = textValue;
            Assert.Equal(textValue, orgText.Value);



            MauiHotReloadHelper.RegisterReplacedView(typeof(MyOrgView).FullName, typeof(MyNewView));
            var newText = orgView.GetView() as Text;

            Assert.Equal(textValue, newText.Value);
        }
Exemplo n.º 6
0
        public MainPage(List <MenuItem> additionalPage = null)
        {
            //This is only required since there is a parameter for the view
            MauiHotReloadHelper.Register(this, additionalPage);
            if (additionalPage != null)
            {
                pages.AddRange(additionalPage);
            }

            this.Title("UI Samples");

            Body = () => new NavigationView {
                new ListView <MenuItem>(pages)
                {
                    ViewFor = (page) => new HStack()
                    {
                        new Text(page.Title),
                        new Spacer()
                    }.Frame(height: 44).Margin(left: 10),
                    //ViewFor = (page) => new Text(page.Title).FillHorizontal().TextAlignment(TextAlignment.Left).Frame(height:44).Margin(left:10),
                }.OnSelectedNavigate(page => page.Page().Title(page.Title))
            };
        }
Exemplo n.º 7
0
            public async void Configure(HostBuilderContext context, IServiceProvider services)
            {
                var handlers = services.GetRequiredService <IMauiHandlersServiceProvider>();

                if (handlers is IHotReloadableHandlersServiceProvider hotReloadable)
                {
                    MauiHotReloadHelper.Init(hotReloadable.GetCollection());
                }
                else
                {
                    throw new NotSupportedException($"Hot Reload only works with a {nameof(IHotReloadableHandlersServiceProvider)}.");
                }

                Reloadify.Reload.Instance.ReplaceType = (d) =>
                {
                    MauiHotReloadHelper.RegisterReplacedView(d.ClassName, d.Type);
                };

                Reloadify.Reload.Instance.FinishedReload = () =>
                {
                    MauiHotReloadHelper.TriggerReload();
                };

                await Task.Run(async() =>
                {
                    try
                    {
                        var success = await Reloadify.Reload.Init(IdeIp, IdePort);

                        Console.WriteLine($"HotReload Initialize: {success}");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                });
            }
Exemplo n.º 8
0
 public MyNewView1(string text = TextValue)
 {
     MauiHotReloadHelper.Register(this, text);
     this.Body = () => new Text(text);
 }
Exemplo n.º 9
0
 public MyOrgView(string text)
 {
     MauiHotReloadHelper.Register(this, text);
     this.Body = () => new Text(text);
 }