<commit_before>﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace Weakly.MVVM
{
    /// <summary>
    /// Shared UI context
    /// </summary>
    public static class UIContext
    {
        private static Thread _thread;
        private static TaskScheduler _taskScheduler;

        static UIContext()
        {
            _thread = Thread.CurrentThread;
            _taskScheduler = TaskScheduler.Default;
        }

        /// <summary>
        /// Initializes the <see cref="UIContext"/>.
        /// </summary>
        public static void Initialize()
        {
            if (_thread != null)
                throw new InvalidOperationException("UIContext is already initialized.");

            _thread = Thread.CurrentThread;
            _taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
        }

        private static void CheckInitialized()
        {
            if (_thread == null)
                throw new InvalidOperationException("UIContext is not initialized.");
        }

        /// <summary>
        /// Determines whether the calling thread is the thread associated with the UI context. 
        /// </summary>
        /// <returns></returns>
        public static bool CheckAccess()
        {
            CheckInitialized();
            return _thread == Thread.CurrentThread;
        }

        /// <summary>
        /// The <see cref="TaskScheduler"/> associated with the UI context.
        /// </summary>
        public static TaskScheduler TaskScheduler
        {
            get
            {
                CheckInitialized();
                return _taskScheduler;
            }
        }
    }
}<commit_msg>add UIContext.IsInDesignTool<commit_after>﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace Weakly.MVVM
{
    /// <summary>
    /// Shared UI context
    /// </summary>
    public static class UIContext
    {
        private static Thread _thread;
        private static TaskScheduler _taskScheduler;
        private static bool _isInDesignTool;

        /// <summary>
        /// Initializes the <see cref="UIContext"/>.
        /// </summary>
        /// <param name="isInDesignTool">Whether or not the framework is running in the context of a designer.</param>
        public static void Initialize(bool isInDesignTool)
        {
            if (_thread != null)
                throw new InvalidOperationException("UIContext is already initialized.");

            _thread = Thread.CurrentThread;
            _taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            _isInDesignTool = isInDesignTool;
        }

        private static void VerifyInitialized()
        {
            if (_thread == null)
                throw new InvalidOperationException("UIContext is not initialized.");
        }

        /// <summary>
        /// Indicates whether or not the framework is running in the context of a designer.
        /// </summary>
        public static bool IsInDesignTool
        {
            get
            {
                VerifyInitialized();
                return _isInDesignTool;
            }
        }

        /// <summary>
        /// Determines whether the calling thread is the thread associated with the UI context. 
        /// </summary>
        /// <returns></returns>
        public static bool CheckAccess()
        {
            VerifyInitialized();
            return _thread == Thread.CurrentThread;
        }

        /// <summary>
        /// The <see cref="TaskScheduler"/> associated with the UI context.
        /// </summary>
        public static TaskScheduler TaskScheduler
        {
            get
            {
                VerifyInitialized();
                return _taskScheduler;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09217436974789917, 'fraction_numerical': 0.0, 'mean_word_length': 1.6214728148657949, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '3282106', 'n_tokens_mistral': 903, 'n_tokens_neox': 883, 'n_words': 258}