/// <summary> /// Initializes a new instance of the DomainServiceContext class /// </summary> /// <param name="serviceProvider">A service provider.</param> /// <param name="operationType">The type of operation that is being executed.</param> public WcfDomainServiceContext(IServiceProvider serviceProvider, DomainOperationType operationType) : base(serviceProvider, operationType) { _httpContext = HttpContext.Current; this.DisableStackTraces = _httpContext?.IsCustomErrorEnabled ?? true; }
private TDST_DomainService CreateDomainService(DomainOperationType operation) { TDST_DomainService domainService = new TDST_DomainService(); domainService.Initialize(new DomainServiceContext(new MockDataService(new MockUser("mock")), operation)); return(domainService); }
/// <summary> /// Copy constructor that creates a new context of the specified type copying /// the rest of the context from the provided instance. /// </summary> /// <param name="serviceContext">The service context to copy from.</param> /// <param name="operationType">The type of operation that is being executed.</param> internal DomainServiceContext(DomainServiceContext serviceContext, DomainOperationType operationType) { if (serviceContext == null) { throw new ArgumentNullException("serviceContext"); } this._serviceProvider = serviceContext._serviceProvider; this._operationType = operationType; }
/// <summary> /// Initializes a new instance of the DomainServiceContext class /// </summary> /// <param name="serviceProvider">A service provider.</param> /// <param name="operationType">The type of operation that is being executed.</param> public DomainServiceContext(IServiceProvider serviceProvider, DomainOperationType operationType) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } this._serviceProvider = serviceProvider; this._operationType = operationType; }
/// <summary> /// Copy constructor that creates a new context of the specified type copying /// the rest of the context from the provided instance. /// </summary> /// <param name="serviceContext">The service context to copy from.</param> /// <param name="operationType">The type of operation that is being executed.</param> internal DomainServiceContext(DomainServiceContext serviceContext, DomainOperationType operationType) { if (serviceContext == null) { throw new ArgumentNullException(nameof(serviceContext)); } this._serviceProvider = serviceContext._serviceProvider; this.OperationType = operationType; this.User = (IPrincipal)_serviceProvider.GetService(typeof(IPrincipal)); }
/// <summary> /// Initializes a new instance of the DomainServiceContext class /// </summary> /// <param name="serviceProvider">A service provider.</param> /// <param name="operationType">The type of operation that is being executed.</param> public DomainServiceContext(IServiceProvider serviceProvider, DomainOperationType operationType) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } this._serviceProvider = serviceProvider; this.OperationType = operationType; this.User = (IPrincipal)serviceProvider?.GetService(typeof(IPrincipal)); }
/// <summary> /// Creates an <see cref="OperationContext"/> for the specified <see cref="DomainOperationType"/> /// </summary> /// <param name="operationType">The type of operation context to create</param> /// <returns>An operation context for the specified type</returns> private OperationContext CreateOperationContext(DomainOperationType operationType) { // TODO: consider whether this implementation should call dispose // Maybe OperationContext would implement IDisposable... DomainServiceContext domainServiceContext = new DomainServiceContext(this.ServiceProvider, operationType); DomainService domainService = this.Factory.CreateDomainService(typeof(TDomainService), domainServiceContext); DomainServiceDescription domainServiceDescription = DomainServiceDescription.GetDescription(typeof(TDomainService)); return(new OperationContext(domainServiceContext, domainService, domainServiceDescription)); }
/// <summary> /// Initializes a new instance of the DomainServiceContext class /// </summary> /// <param name="serviceProvider">A service provider.</param> /// <param name="operationType">The type of operation that is being executed.</param> public WcfDomainServiceContext(IServiceProvider serviceProvider, DomainOperationType operationType) : base(serviceProvider, operationType) { _httpContext = HttpContext.Current; this.DisableStackTraces = _httpContext?.IsCustomErrorEnabled ?? true; // Wire up cancellation token // It might make sense in the future to also create a CancellationToken based on // OperationContext.Current.Channel.OperationTimeout and combine it with the // disconnation token using System.Threading.CancellationTokenSource.CreateLinkedTokenSource var httpResponse = _httpContext?.Response; if (httpResponse != null) { base.CancellationToken = httpResponse.ClientDisconnectedToken; } }
public ServiceMetadataQueryOperationMessageFormatter(IDispatchMessageFormatter innerFormatter, DomainOperationType operationType, Type entityType) { this.innerFormatter = innerFormatter; this.operationType = operationType; this.entityType = TypeUtility.GetElementType(entityType); }
public MockDomainServiceContext(DomainOperationType operationType) : base(new MockServiceProvider(), operationType) { }
public ServiceContext_CurrentOperation_DomainService(DomainOperationType type) { this.Initialize(new DomainServiceContext(this, type)); }
public DomainOperationInvoker(DomainOperationType operationType) { this.operationType = operationType; }
/// <summary> /// Creates an instance of the specified provider type, initialized with /// a mock operation context. /// </summary> /// <param name="providerType">The Type of provider to create and initialize</param> /// <param name="operationType">The operation type</param> /// <returns>The provider instance</returns> public static DomainService CreateInitializedDomainService(Type providerType, DomainOperationType operationType) { DomainService provider = (DomainService)Activator.CreateInstance(providerType); // create a fully functional, authenticated test context MockUser mockUser = new MockUser("test_user"); mockUser.IsAuthenticated = true; MockDataService dataService = new MockDataService(mockUser); DomainServiceContext operationContext = new DomainServiceContext(dataService, operationType); provider.Initialize(operationContext); return(provider); }
/// <summary> /// Creates an instance of the specified provider type, initialized with /// a mock operation context. /// </summary> /// <typeparam name="T">The Type of provider to create and initialize</typeparam> /// <param name="operationType">The operation type</param> /// <returns>The provider instance</returns> public static T CreateInitializedDomainService <T>(DomainOperationType operationType) where T : DomainService { return((T)CreateInitializedDomainService(typeof(T), operationType)); }
/// <summary>Constructs an invoker instance.</summary> /// <param name="operationType">Operation type.</param> internal DomainDataServiceOperationInvoker(DomainOperationType operationType) { this.operationType = operationType; }