Exemplo n.º 1
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         EvaluationContextManager.Dispose();
         Stop();
     }
 }
Exemplo n.º 2
0
        public void IntegrateWith(EvaluationContextManager evaluationContextManager)
        {
            realAgent = evaluationContextManager.Context as AndroidAgent;

            if (realAgent == null)
            {
                return;
            }

            if (realAgent.ViewHierarchyHandlerManager == null)
            {
                return;
            }

            try {
                realAgent.ViewHierarchyHandlerManager.AddViewHierarchyHandler(HierarchyKind,
                                                                              new AndroidFormsViewHierarchyHandler(realAgent));

                evaluationContextManager.RepresentationManager.AddProvider <FormsRepresentationProvider> ();

                if (realAgent.ClientSessionUri.SessionKind == ClientSessionKind.Workbook)
                {
                    evaluationContextManager.RegisterResetStateHandler(ResetStateHandler);

                    // Set up launching the Forms activity.
                    Log.Debug(TAG, "Setting up activity type and grabbing current activity...");
                    var activityType = Type.GetType(FormsActivityTypeName);

                    if (activityType == null)
                    {
                        Log.Warning(TAG, "Could not fully initialize Xamarin.Forms integration, missing Forms launch activity.");
                        return;
                    }

                    var intent = new Intent(Application.Context, activityType);
                    intent.AddFlags(ActivityFlags.NewTask);

                    var currentActivity = realAgent.GetTopActivity();

                    // Launch the Forms activity.
                    Log.Debug(TAG, "Launching Forms activity via intent.");
                    Application.Context.StartActivity(intent);

                    // Wrap the previous activity up to reduce confusion.
                    Log.Debug(TAG, "Finishing existing activity.");
                    currentActivity.Finish();
                }

                Log.Info(TAG, "Registered Xamarin.Forms agent integration!");
            } catch (Exception e) {
                Log.Error(TAG, "Could not register Xamarin.Forms agent integration.", e);
            }
        }
Exemplo n.º 3
0
        public async Task TwoPlusTwo()
        {
            var evaluationContextManager = new EvaluationContextManager(
                new RepresentationManager(RepresentationManagerOptions.YieldOriginal)
                );

            var workspaceConfiguration = await WorkspaceConfiguration
                                         .CreateAsync(evaluationContextManager);

            var workspaceService = await WorkspaceServiceFactory
                                   .CreateWorkspaceServiceAsync("csharp", workspaceConfiguration);

            var evaluationService = new EvaluationService(
                workspaceService,
        public void IntegrateWith(EvaluationContextManager evaluationContextManager)
        {
            var realAgent = evaluationContextManager.Context as iOSAgent;

            if (realAgent == null)
            {
                return;
            }

            if (realAgent.ViewHierarchyHandlerManager == null)
            {
                return;
            }

            try {
                realAgent.ViewHierarchyHandlerManager.AddViewHierarchyHandler(HierarchyKind,
                                                                              new iOSFormsViewHierarchyHandler(realAgent));

                evaluationContextManager.RepresentationManager.AddProvider <FormsRepresentationProvider> ();

                if (realAgent.ClientSessionUri.SessionKind == ClientSessionKind.Workbook)
                {
                    evaluationContextManager.RegisterResetStateHandler(ResetStateHandler);

                    Log.Debug(TAG, "Initializing Xamarin.Forms.");
                    Xamarin.Forms.Forms.Init();

                    Log.Debug(TAG, "Creating base Xamarin.Forms application.");
                    var app = new WorkbookApplication {
                        MainPage = new ContentPage()
                    };

                    Log.Debug(TAG, "Creating view controller for main page and setting it as root.");
                    UIApplication.SharedApplication.KeyWindow.RootViewController =
                        app.MainPage.CreateViewController();
                }

                Log.Info(TAG, "Registered Xamarin.Forms agent integration!");
            } catch (Exception e) {
                Log.Error(TAG, "Could not register Xamarin.Forms agent integration.", e);
            }
        }