<commit_before>// Copyright © <NAME> and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

using System;
using System.Linq;
using System.Reflection;
using TerraFX.ApplicationModel;
using TerraFX.Graphics;
using TerraFX.Graphics.Geometry2D;
using TerraFX.Numerics;
using TerraFX.UI;
using TerraFX.Utilities;

namespace TerraFX.Samples.Graphics
{
    public class HelloWindow : Sample
    {
        private GraphicsDevice _graphicsDevice = null!;
        private Window _window = null!;
        private TimeSpan _elapsedTime;

        public HelloWindow(string name, params Assembly[] compositionAssemblies)
            : base(name, compositionAssemblies)
        {
        }

        public GraphicsDevice GraphicsDevice => _graphicsDevice;

        public Window Window => _window;

        public override void Cleanup()
        {
            _graphicsDevice?.Dispose();
            _window?.Dispose();

            base.Cleanup();
        }

        /// <summary>Initializes the GUI for this sample.</summary>
        /// <param name="application">The hosting <see cref="Application" />.</param>
        /// <param name="timeout">The <see cref="TimeSpan" /> after which this sample should stop running.</param>
        public override void Initialize(Application application, TimeSpan timeout) => Initialize(application, timeout, null, null);

        /// <summary>Initializes the GUI for this sample.</summary>
        /// <param name="application">The hosting <see cref="Application" />.</param>
        /// <param name="timeout">The <see cref="TimeSpan" /> after which this sample should stop running.</param>
        /// <param name="windowLocation">The <see cref="Vector2" /> that defines the initial window location.</param>
        /// <param name="windowSize">The <see cref="Vector2" /> that defines the initial window client rectangle size.</param>
        public virtual void Initialize(Application application, TimeSpan timeout, Vector2? windowLocation, Vector2? windowSize)
        {
            ExceptionUtilities.ThrowIfNull(application, nameof(application));

            var windowProvider = application.GetService<WindowProvider>();

            _window = windowProvider.CreateWindow();
            _window.SetTitle(Name);
            if (windowLocation.HasValue)
            {
                _window.Relocate(windowLocation.Value);
            }
            if (windowSize.HasValue)
            {
                _window.ResizeClient(windowSize.Value);
            }
            _window.Show();<commit_msg>Apply suggestions from code review<commit_after>// Copyright © <NAME> and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

using System;
using System.Linq;
using System.Reflection;
using TerraFX.ApplicationModel;
using TerraFX.Graphics;
using TerraFX.Graphics.Geometry2D;
using TerraFX.Numerics;
using TerraFX.UI;
using TerraFX.Utilities;

namespace TerraFX.Samples.Graphics
{
    public class HelloWindow : Sample
    {
        private GraphicsDevice _graphicsDevice = null!;
        private Window _window = null!;
        private TimeSpan _elapsedTime;

        public HelloWindow(string name, params Assembly[] compositionAssemblies)
            : base(name, compositionAssemblies)
        {
        }

        public GraphicsDevice GraphicsDevice => _graphicsDevice;

        public Window Window => _window;

        public override void Cleanup()
        {
            _graphicsDevice?.Dispose();
            _window?.Dispose();

            base.Cleanup();
        }

        /// <summary>Initializes the GUI for this sample.</summary>
        /// <param name="application">The hosting <see cref="Application" />.</param>
        /// <param name="timeout">The <see cref="TimeSpan" /> after which this sample should stop running.</param>
        public override void Initialize(Application application, TimeSpan timeout) => Initialize(application, timeout, null, null);

        /// <summary>Initializes the GUI for this sample.</summary>
        /// <param name="application">The hosting <see cref="Application" />.</param>
        /// <param name="timeout">The <see cref="TimeSpan" /> after which this sample should stop running.</param>
        /// <param name="windowLocation">The <see cref="Vector2" /> that defines the initial window location.</param>
        /// <param name="windowSize">The <see cref="Vector2" /> that defines the initial window client rectangle size.</param>
        public virtual void Initialize(Application application, TimeSpan timeout, Vector2? windowLocation, Vector2? windowSize)
        {
            ExceptionUtilities.ThrowIfNull(application, nameof(application));

            var windowProvider = application.GetService<WindowProvider>();

            _window = windowProvider.CreateWindow();
            _window.SetTitle(Name);
            if (windowLocation.HasValue)
            {
                _window.Relocate(windowLocation.GetValueOrDefault());
            }
            if (windowSize.HasValue)
            {
                _window.ResizeClient(windowSize.GetValueOrDefault());
            }
            _window.Show();
{'fraction_non_alphanumeric': 0.10441767068273092, 'fraction_numerical': 0.0019124115509657677, 'mean_word_length': 2.727726300784034, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4809783', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1250, 'n_words': 371}