public void ThrowIfDisposed_Disposed() { _disposeToken.TryMarkDisposed(); Action a = () => _disposeToken.ThrowIfDisposed(); a.ShouldThrow <ObjectDisposedException>(); }
/// <summary> /// Add service to the service manager container /// </summary> /// <typeparam name="T">Service type</typeparam> /// <param name="service">Service instance</param> /// <param name="type"> /// Optional type to register the instance for. In Visual Studio /// some global services are registered as 'SVsService` while /// actual interface type is IVsService. /// </param> public virtual IServiceManager AddService <T>(T service, Type type = null) where T : class { _disposeToken.ThrowIfDisposed(); type = type ?? typeof(T); Check.ArgumentNull(nameof(service), service); Check.InvalidOperation(() => _s.TryAdd(type, service), $"Service of type {type} already exists"); return(this); }
/// <summary> /// Add service to the service manager container /// </summary> /// <param name="service">Service instance</param> /// <param name="type"> /// Optional type to register the instance for. In Visual Studio /// some global services are registered as 'SVsService` while /// actual interface type is IVsService. /// </param> public virtual IServiceManager AddService(object service, Type type = null) { _disposeToken.ThrowIfDisposed(); type = type ?? service.GetType(); Check.ArgumentNull(nameof(service), service); Check.InvalidOperation(() => _s.GetOrAdd(type, service) == service, Invariant($"Another instance of service of type {type} already added")); return(this); }
/// <summary> /// Add service to the service manager container /// </summary> /// <typeparam name="T">Service type</typeparam> /// <param name="service">Service instance</param> /// <param name="type"> /// Optional type to register the instance for. In Visual Studio /// some global services are registered as 'SVsService` while /// actual interface type is IVsService. /// </param> public virtual IServiceManager AddService <T>(T service, Type type = null) where T : class { _disposeToken.ThrowIfDisposed(); type = type ?? typeof(T); Check.ArgumentNull(nameof(service), service); Check.InvalidOperation(() => _s.TryAdd(type, service), "Service already exists"); ServiceAdded?.Invoke(this, new ServiceContainerEventArgs(type)); return(this); }
/// <summary> /// Add service to the service manager container /// </summary> /// <typeparam name="T">Service type</typeparam> /// <param name="service">Service instance</param> public virtual IServiceManager AddService <T>(T service) where T : class { _disposeToken.ThrowIfDisposed(); var type = typeof(T); Check.ArgumentNull(nameof(service), service); Check.Operation(() => _s.TryAdd(type, service)); ServiceAdded?.Invoke(this, new ServiceContainerEventArgs(type)); return(this); }
public Task <IRSessionInteraction> BeginInteractionAsync(bool isVisible = true, CancellationToken cancellationToken = default(CancellationToken)) { _disposeToken.ThrowIfDisposed(); if (!_isHostRunning) { return(CanceledBeginInteractionTask); } RSessionRequestSource requestSource = new RSessionRequestSource(isVisible, cancellationToken); _pendingRequestSources.Post(requestSource); return(_isHostRunning ? requestSource.CreateRequestTask : CanceledBeginInteractionTask); }
public IRSession GetOrCreate(string sessionId) { _disposeToken.ThrowIfDisposed(); return(_sessions.GetOrAdd(sessionId, CreateRSession)); }
public IRSession GetOrCreate(Guid guid) { _disposeToken.ThrowIfDisposed(); return(_sessions.GetOrAdd(guid, id => new RSession(Interlocked.Increment(ref _sessionCounter), () => DisposeSession(guid)))); }