示例#1
0
 public RootCommand(IApplicationLifecycle lifecycle, IConsole console)
 {
     //Add subcommands to root command
     AddCommand(new VersionCommand(console));
     AddCommand(new HelpCommand());
     AddCommand(new ExitCommand(lifecycle));
 }
示例#2
0
        public ExitCommand(IApplicationLifecycle lifecycle) : base("exit", "Exits mcsm")
        {
            _lifecycle = lifecycle;

            //Bind execution method
            Handler = CommandHandler.Create(Execute);
        }
示例#3
0
 /// <summary>
 /// Initializes the current management interface with a platform specific provider.
 /// </summary>
 public static void SetProvider(IApplicationLifecycle provider)
 {
     if (provider == null)
     {
         throw new ArgumentNullException("applicationLifecycleProvider");
     }
     ((ApplicationLifecycle)Service).Provider = provider;
 }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TopLevel"/> class.
        /// </summary>
        /// <param name="impl">The platform-specific window implementation.</param>
        /// <param name="dependencyResolver">
        /// The dependency resolver to use. If null the default dependency resolver will be used.
        /// </param>
        public TopLevel(ITopLevelImpl impl, IAvaloniaDependencyResolver dependencyResolver)
        {
            if (impl == null)
            {
                throw new InvalidOperationException(
                          "Could not create window implementation: maybe no windowing subsystem was initialized?");
            }

            PlatformImpl = impl;

            dependencyResolver = dependencyResolver ?? AvaloniaLocator.Current;
            var styler = TryGetService <IStyler>(dependencyResolver);

            _accessKeyHandler          = TryGetService <IAccessKeyHandler>(dependencyResolver);
            _inputManager              = TryGetService <IInputManager>(dependencyResolver);
            _keyboardNavigationHandler = TryGetService <IKeyboardNavigationHandler>(dependencyResolver);
            _applicationLifecycle      = TryGetService <IApplicationLifecycle>(dependencyResolver);
            _renderInterface           = TryGetService <IPlatformRenderInterface>(dependencyResolver);

            Renderer = impl.CreateRenderer(this);

            if (Renderer != null)
            {
                Renderer.SceneInvalidated += SceneInvalidated;
            }

            impl.SetInputRoot(this);

            impl.Closed         = HandleClosed;
            impl.Input          = HandleInput;
            impl.Paint          = HandlePaint;
            impl.Resized        = HandleResized;
            impl.ScalingChanged = HandleScalingChanged;

            _keyboardNavigationHandler?.SetOwner(this);
            _accessKeyHandler?.SetOwner(this);
            styler?.ApplyStyles(this);

            ClientSize = impl.ClientSize;

            this.GetObservable(PointerOverElementProperty)
            .Select(
                x => (x as InputElement)?.GetObservable(CursorProperty) ?? Observable.Empty <Cursor>())
            .Switch().Subscribe(cursor => PlatformImpl?.SetCursor(cursor?.PlatformCursor));

            if (_applicationLifecycle != null)
            {
                _applicationLifecycle.Exit += OnApplicationExiting;
            }

            if (((IStyleHost)this).StylingParent is IResourceProvider applicationResources)
            {
                WeakSubscriptionManager.Subscribe(
                    applicationResources,
                    nameof(IResourceProvider.ResourcesChanged),
                    this);
            }
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TopLevel"/> class.
        /// </summary>
        /// <param name="impl">The platform-specific window implementation.</param>
        /// <param name="dependencyResolver">
        /// The dependency resolver to use. If null the default dependency resolver will be used.
        /// </param>
        public TopLevel(ITopLevelImpl impl, IAvaloniaDependencyResolver dependencyResolver)
        {
            if (impl == null)
            {
                throw new InvalidOperationException(
                          "Could not create window implementation: maybe no windowing subsystem was initialized?");
            }

            PlatformImpl       = impl;
            dependencyResolver = dependencyResolver ?? AvaloniaLocator.Current;
            var styler = TryGetService <IStyler>(dependencyResolver);

            _accessKeyHandler          = TryGetService <IAccessKeyHandler>(dependencyResolver);
            _inputManager              = TryGetService <IInputManager>(dependencyResolver);
            _keyboardNavigationHandler = TryGetService <IKeyboardNavigationHandler>(dependencyResolver);
            _applicationLifecycle      = TryGetService <IApplicationLifecycle>(dependencyResolver);
            _renderInterface           = TryGetService <IPlatformRenderInterface>(dependencyResolver);

            var renderLoop      = TryGetService <IRenderLoop>(dependencyResolver);
            var rendererFactory = TryGetService <IRendererFactory>(dependencyResolver);

            Renderer = rendererFactory?.CreateRenderer(this, renderLoop);

            PlatformImpl.SetInputRoot(this);
            PlatformImpl.Activated       = HandleActivated;
            PlatformImpl.Deactivated     = HandleDeactivated;
            PlatformImpl.Closed          = HandleClosed;
            PlatformImpl.Input           = HandleInput;
            PlatformImpl.Paint           = Renderer != null ? (Action <Rect>)Renderer.Render : null;
            PlatformImpl.Resized         = HandleResized;
            PlatformImpl.ScalingChanged  = HandleScalingChanged;
            PlatformImpl.PositionChanged = HandlePositionChanged;

            _keyboardNavigationHandler?.SetOwner(this);
            _accessKeyHandler?.SetOwner(this);
            styler?.ApplyStyles(this);

            ClientSize = PlatformImpl.ClientSize;
            this.GetObservable(ClientSizeProperty).Skip(1).Subscribe(x => PlatformImpl.ClientSize = x);
            this.GetObservable(PointerOverElementProperty)
            .Select(
                x => (x as InputElement)?.GetObservable(CursorProperty) ?? Observable.Empty <Cursor>())
            .Switch().Subscribe(cursor => PlatformImpl.SetCursor(cursor?.PlatformCursor));

            if (_applicationLifecycle != null)
            {
                _applicationLifecycle.OnExit += OnApplicationExiting;
            }
        }
        public TelemetryBuffer(TelemetrySerializer serializer, IApplicationLifecycle applicationLifecycle)
            : this()
        {
            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

            if (applicationLifecycle == null)
            {
                throw new ArgumentNullException("applicationLifecycle");
            }

            this.serializer = serializer;

            applicationLifecycle.Stopping += this.HandleApplicationStoppingEvent;
        }
示例#7
0
        internal ServerTelemetryChannel(INetwork network, IApplicationLifecycle applicationLifecycle)
        {
            var policies = new TransmissionPolicy[]
            {
                new ApplicationLifecycleTransmissionPolicy(applicationLifecycle),
                new ErrorHandlingTransmissionPolicy(),
                new NetworkAvailabilityTransmissionPolicy(network),
                new ThrottlingTransmissionPolicy()
            };

            this.Transmitter = new Transmitter(policies: policies);

            this.TelemetrySerializer     = new TelemetrySerializer(this.Transmitter);
            this.TelemetryBuffer         = new Implementation.TelemetryBuffer(this.TelemetrySerializer, applicationLifecycle);
            this.telemetryBufferCapacity = this.TelemetryBuffer.Capacity;

            this.TelemetryProcessor = this.TelemetryBuffer;
        }
        internal ServerTelemetryChannel(INetwork network, IApplicationLifecycle applicationLifecycle)
        {
            var policies = new TransmissionPolicy[] 
            { 
                new ApplicationLifecycleTransmissionPolicy(applicationLifecycle),
                new ErrorHandlingTransmissionPolicy(),
                new NetworkAvailabilityTransmissionPolicy(network),
                new ThrottlingTransmissionPolicy()
            };

            this.Transmitter = new Transmitter(policies: policies);

            this.TelemetrySerializer = new TelemetrySerializer(this.Transmitter);
            this.TelemetryBuffer = new Implementation.TelemetryBuffer(this.TelemetrySerializer, applicationLifecycle);
            this.telemetryBufferCapacity = this.TelemetryBuffer.Capacity;

            this.TelemetryProcessor = this.TelemetryBuffer;
        }
示例#9
0
        internal ServerTelemetryChannel(INetwork network, IApplicationLifecycle applicationLifecycle)
        {
            var policies = new TransmissionPolicy[]
            {
#if !NETSTANDARD
                // We don't have implementation for IApplicationLifecycle for .NET Core
                new ApplicationLifecycleTransmissionPolicy(applicationLifecycle),
#endif
                new ThrottlingTransmissionPolicy(),
                new ErrorHandlingTransmissionPolicy(),
                new PartialSuccessTransmissionPolicy(),
                new NetworkAvailabilityTransmissionPolicy(network),
            };

            this.Transmitter = new Transmitter(policies: policies);

            this.TelemetrySerializer     = new TelemetrySerializer(this.Transmitter);
            this.TelemetryBuffer         = new TelemetryBuffer(this.TelemetrySerializer, applicationLifecycle);
            this.telemetryBufferCapacity = this.TelemetryBuffer.Capacity;

            this.TelemetryProcessor = this.TelemetryBuffer;
            this.isInitialized      = false;
        }
        public TelemetryBuffer(TelemetrySerializer serializer, IApplicationLifecycle applicationLifecycle)
            : this()
        {
            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

#if !NETSTANDARD
            // We don't have implementation for IApplicationLifecycle for .NET Core
            if (applicationLifecycle == null)
            {
                throw new ArgumentNullException("applicationLifecycle");
            }
#endif

            if (applicationLifecycle != null)
            {
                applicationLifecycle.Stopping += this.HandleApplicationStoppingEvent;
            }

            this.serializer = serializer;
        }
示例#11
0
        public void Participate(IApplicationLifecycle lifecycle)
        {
            var name = GetType().FullName;

            lifecycle.Subscribe(name, ApplicationLifecycleStages.AUTHORIZATION + SecondaryStage, OnStart, OnStop);
        }
示例#12
0
 public ApplicationLifecycleTransmissionPolicy(IApplicationLifecycle applicationLifecycle)
 {
     this.applicationLifecycle = applicationLifecycle;
 }
 public void Participate(IApplicationLifecycle lifecycle)
 {
     lifecycle.Subscribe <ComponentsTemplateLoader>(PresentLifetimeStages.COMPONENTS_TEMPLATE, OnStart);
 }
 public TelemetryBufferWhichDoesNothingOnFlush(TelemetrySerializer serializer, IApplicationLifecycle applicationLifecycle) : base(serializer, applicationLifecycle)
 {
 }
 public TestableApplicationLifecycleTransmissionPolicy(IApplicationLifecycle applicationLifecycle) 
     : base(applicationLifecycle)
 {
 }
 public TestableApplicationLifecycleTransmissionPolicy(IApplicationLifecycle applicationLifecycle)
     : base(applicationLifecycle)
 {
 }
        public void Participate(IApplicationLifecycle lifecycle)
        {
            var name = GetType().FullName;

            lifecycle.Subscribe(name, ApplicationLifecycleStages.LOCAL_STORAGE + SecondaryStage, OnStart, OnStop);
        }