Пример #1
0
        /// <summary>
        /// Initializes any factory methods exposed by the registered view provider.
        /// </summary>
        /// <param name="configuration">The Ultraviolet Framework configuration settings for this context.</param>
        private void InitializeFactoryMethodsInViewProvider(UltravioletConfiguration configuration)
        {
            if (String.IsNullOrEmpty(configuration.ViewProviderAssembly))
            {
                return;
            }

            Assembly asm;

            try
            {
                asm = Assembly.Load(configuration.ViewProviderAssembly);
                InitializeFactoryMethodsInAssembly(asm);

                viewProviderAssembly = asm;
            }
            catch (Exception e)
            {
                if (e is FileNotFoundException ||
                    e is FileLoadException ||
                    e is BadImageFormatException)
                {
                    throw new InvalidOperationException(UltravioletStrings.InvalidViewProviderAssembly, e);
                }
                throw;
            }
        }
 /// <summary>
 /// Populates the Ultraviolet configuration from the application settings.
 /// </summary>
 partial void PopulateConfigurationFromSettings(UltravioletConfiguration configuration)
 {
     if (this.settings?.Window != null)
     {
         configuration.InitialWindowPosition = this.settings.Window.WindowedPosition;
     }
 }
Пример #3
0
 /// <summary>
 /// Initializes the context's plugins.
 /// </summary>
 /// <param name="configuration">The Ultraviolet Framework configuration settings for this context.</param>
 protected void InitializePlugins(UltravioletConfiguration configuration)
 {
     foreach (var plugin in configuration.Plugins)
     {
         plugin.Initialize(this, Factory);
         plugin.Initialized = true;
     }
 }
Пример #4
0
        /// <summary>
        /// Initializes the context's view provider.
        /// </summary>
        /// <param name="configuration">The Ultraviolet Framework configuration settings for this context.</param>
        protected void InitializeViewProvider(UltravioletConfiguration configuration)
        {
            var initializerFactory = TryGetFactoryMethod <UIViewProviderInitializerFactory>();

            if (initializerFactory != null)
            {
                var initializer = initializerFactory();
                initializer.Initialize(this, configuration.ViewProviderConfiguration);
            }
        }
Пример #5
0
        /// <summary>
        /// Initializes the context's object factory.
        /// </summary>
        /// <param name="configuration">The Ultraviolet Framework configuration settings for this context.</param>
        private void InitializeFactory(UltravioletConfiguration configuration)
        {
            var asmCore = typeof(UltravioletContext).Assembly;
            var asmImpl = GetType().Assembly;

            InitializeFactoryMethodsInAssembly(asmCore);
            InitializeFactoryMethodsInAssembly(asmImpl);
            InitializeFactoryMethodsInCompatibilityShim();
            InitializeFactoryMethodsInViewProvider(configuration);

            var asmEntry = Assembly.GetEntryAssembly();

            if (asmEntry != null)
            {
                InitializeFactoryMethodsInAssembly(asmEntry);
            }
        }
Пример #6
0
        /// <summary>
        /// Configures the context's plugins.
        /// </summary>
        private void ConfigurePlugins(UltravioletConfiguration configuration)
        {
            while (configuration.Plugins.Any(x => !x.Configured))
            {
                var plugins = configuration.Plugins.ToList();
                foreach (var plugin in plugins)
                {
                    if (plugin.Configured)
                    {
                        continue;
                    }

                    plugin.Configure(configuration);
                    plugin.Configured = true;
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UltravioletContext"/> class.
        /// </summary>
        /// <param name="host">The object that is hosting the Ultraviolet context.</param>
        /// <param name="configuration">The Ultraviolet Framework configuration settings for this context.</param>
        public UltravioletContext(IUltravioletHost host, UltravioletConfiguration configuration)
        {
            Contract.Require(host, nameof(host));
            Contract.Require(configuration, nameof(configuration));

            if (configuration.GraphicsConfiguration == null)
            {
                throw new InvalidOperationException(UltravioletStrings.MissingGraphicsConfiguration);
            }

            AcquireContext();

            this.IsRunningInServiceMode  = configuration.EnableServiceMode;
            this.IsHardwareInputDisabled = configuration.IsHardwareInputDisabled;

            this.Properties = new UltravioletContextProperties();
            this.Properties.SupportsHighDensityDisplayModes = configuration.SupportsHighDensityDisplayModes;
            this.Properties.SrgbDefaultForSurface2D         = configuration.GraphicsConfiguration.SrgbDefaultForSurface2D;
            this.Properties.SrgbDefaultForSurface3D         = configuration.GraphicsConfiguration.SrgbDefaultForSurface3D;
            this.Properties.SrgbDefaultForTexture2D         = configuration.GraphicsConfiguration.SrgbDefaultForTexture2D;
            this.Properties.SrgbDefaultForTexture3D         = configuration.GraphicsConfiguration.SrgbDefaultForTexture3D;
            this.Properties.SrgbDefaultForRenderBuffer2D    = configuration.GraphicsConfiguration.SrgbDefaultForRenderBuffer2D;

            if (UltravioletPlatformInfo.CurrentRuntime == UltravioletRuntime.CoreCLR)
            {
                this.Properties.SupportsHighDensityDisplayModes = false;
            }

            this.host = host;

            this.thread = Thread.CurrentThread;

            this.messages = new LocalMessageQueue <UltravioletMessageID>();
            this.messages.Subscribe(this, UltravioletMessages.Quit);

            this.syncContext = new UltravioletSynchronizationContext(this);
            ChangeSynchronizationContext(syncContext);

            this.taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            this.taskFactory   = new TaskFactory(taskScheduler);

            InitializeFactory(configuration);
        }
Пример #8
0
 /// <summary>
 /// Populates the Ultraviolet configuration from the application settings.
 /// </summary>
 partial void PopulateConfigurationFromSettings(UltravioletConfiguration configuration);
Пример #9
0
        /// <summary>
        /// Populates the specified Ultraviolet configuration with the application's initial values.
        /// </summary>
        /// <param name="configuration">The <see cref="UltravioletConfiguration"/> to populate.</param>
        protected void PopulateConfiguration(UltravioletConfiguration configuration)
        {
            Contract.Require(configuration, nameof(configuration));

            PopulateConfigurationFromSettings(configuration);
        }
 /// <summary>
 /// Configures the Ultraviolet context in preparation for use of this plugin.
 /// </summary>
 /// <param name="configuration">The Ultraviolet configuration.</param>
 public virtual void Configure(UltravioletConfiguration configuration)
 {
 }
 /// <inheritdoc/>
 public void InitializePrimaryWindow(UltravioletConfiguration configuration)
 {
 }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UltravioletPluginCollection"/> class.
        /// </summary>
        /// <param name="owner">The configuration object which owns this collection.</param>
        public UltravioletPluginCollection(UltravioletConfiguration owner)
        {
            Contract.Require(owner, nameof(owner));

            this.owner = owner;
        }
Пример #13
0
 /// <summary>
 /// Registers the plugin and allows it to modify the Ultraviolet configuration prior to context creation.
 /// </summary>
 /// <param name="configuration">The Ultraviolet configuration.</param>
 public virtual void Register(UltravioletConfiguration configuration)
 {
 }