public Task Initialize(TaskScheduler scheduler)
        {
            if (this._initializationTask == null)
            {
                this._initializationTask = Task.Run(() => Core());

                if (this.AutoRestart && scheduler != null)
                {
                    this._initializationTask.ContinueWith(
                        _ => this.ComObjects.Listen(),
                        CancellationToken.None,
                        TaskContinuationOptions.OnlyOnRanToCompletion,
                        scheduler);
                }
            }

            return(this._initializationTask);

            void Core()
            {
                var assemblyProvider = new ComInterfaceAssemblyProvider(this.ComInterfaceAssemblyPath);
                var assembly         = new ComInterfaceAssembly(assemblyProvider.GetAssembly());

                this.ComObjects = new ComObjects(assembly);
            }
        }
    internal void Initialize(ComInterfaceAssembly assembly)
    {
        if (this.IsInitialized)
        {
            return;
        }

        this.InitializeCore(assembly);
        this.IsInitialized = true;
    }
 public static void Initialize(ComInterfaceAssembly assembly)
 {
     if (_cache == null)
     {
         var type = assembly.GetType("VirtualDesktopCacheImpl");
         _cache         = (IVirtualDesktopCache)Activator.CreateInstance(type);
         _cache.Factory = (id, comObject) => new VirtualDesktop(assembly, id, comObject);
     }
     else
     {
         _cache.Clear();
     }
 }
Example #4
0
    private protected override void InitializeCore(ComInterfaceAssembly assembly)
    {
        var type = Type.GetTypeFromCLSID(CLSID.VirtualDesktopManager)
                   ?? throw new Exception($"No type found for CLSID '{CLSID.VirtualDesktopManager}'.");

        this._virtualDesktopManager = Activator.CreateInstance(type) is IVirtualDesktopManager manager
            ? manager
            : throw new Exception($"Failed to create instance of Type '{typeof(IVirtualDesktopManager)}'.");

        this._applicationViewCollection = new ApplicationViewCollection(assembly);
        var factory = new ComWrapperFactory(
            x => new ApplicationView(assembly, x),
            x => this._applicationViewCollection.GetViewForHwnd(x),
            x => new VirtualDesktop(assembly, x));

        this._virtualDesktopManagerInternal     = new VirtualDesktopManagerInternal(assembly, factory);
        this._virtualDesktopPinnedApps          = new VirtualDesktopPinnedApps(assembly, factory);
        this._virtualDesktopNotificationService = new VirtualDesktopNotificationService(assembly, factory);
    }
Example #5
0
 internal VirtualDesktopNotificationService(ComInterfaceAssembly assembly, ComWrapperFactory factory)
     : base(assembly, CLSID.VirtualDesktopNotificationService)
 {
     this._factory = factory;
 }
 public VirtualDesktop(ComInterfaceAssembly assembly, object comObject)
     : base(assembly, comObject)
 {
 }
 public VirtualDesktopManagerInternal(ComInterfaceAssembly assembly, ComWrapperFactory factory)
     : base(assembly, CLSID.VirtualDesktopManagerInternal)
 {
     this._factory = factory;
 }
Example #8
0
 internal VirtualDesktop(ComInterfaceAssembly assembly, Guid id, object comObject)
     : base(assembly, comObject)
 {
     this.Id = id;
 }
 public ApplicationViewCollection(ComInterfaceAssembly assembly)
     : base(assembly)
 {
 }
 public ApplicationView(ComInterfaceAssembly assembly, object comObject)
     : base(assembly, comObject)
 {
 }
 public VirtualDesktopPinnedApps(ComInterfaceAssembly assembly, ComWrapperFactory factory)
     : base(assembly, CLSID.VirtualDesktopPinnedApps)
 {
     this._factory = factory;
 }
 private protected override void InitializeCore(ComInterfaceAssembly assembly)
 => throw new NotSupportedException();
 private protected abstract void InitializeCore(ComInterfaceAssembly assembly);