private DataServiceController(DSConfiguration settings, CustomAuthorizationHandler.ICustomContextStore customContextStore, ISchemaBuilder testSchemaBuilder) { TraceHelper.Current.CorrelateWithActivity(EtwActivity.GetActivityId()); try { this.Configuration = settings; this.cmdManagers = new Dictionary <ManagementSystemType, ICommandManager>(); this.PerfCounters = new PerfCounters(CurrentRequestHelper.EndPointAddress); this.UserDataCache = new UserDataCache(this.Configuration.Invocation.Lifetime); this.QuotaSystem = new QuotaSystem(); InitialSessionStateManager initialSessionStateManager = new InitialSessionStateManager(this.Configuration.PowerShell.SessionConfig.Assembly, this.Configuration.PowerShell.SessionConfig.Type); this.intialSessionStateStore = new SharedItemStore <InitialSessionState, UserContext>(initialSessionStateManager, this.Configuration.Quotas.UserSchemaTimeout, this.Configuration.Quotas.MaxUserSchemas); PSRunspaceFactory pSRunspaceFactory = new PSRunspaceFactory(this.intialSessionStateStore, true); int runspaceTimeout = this.Configuration.PowerShell.Quotas.RunspaceTimeout; ExclusiveItemStore <PSRunspace, UserContext> exclusiveItemStore = new ExclusiveItemStore <PSRunspace, UserContext>(pSRunspaceFactory, runspaceTimeout, this.Configuration.PowerShell.Quotas.MaxRunspaces); PSCommandManager pSCommandManager = new PSCommandManager(exclusiveItemStore); this.cmdManagers.Add(ManagementSystemType.PowerShell, pSCommandManager); PSRunspaceFactory pSRunspaceFactory1 = new PSRunspaceFactory(this.intialSessionStateStore, false); ExclusiveItemStore <PSRunspace, UserContext> exclusiveItemStore1 = new ExclusiveItemStore <PSRunspace, UserContext>(pSRunspaceFactory1, runspaceTimeout, this.Configuration.PowerShell.Quotas.MaxRunspaces); this.cmdManagers.Add(ManagementSystemType.GenericInvoke, new GICommandManager(exclusiveItemStore1)); List <ISchemaBuilder> schemaBuilders = new List <ISchemaBuilder>(); if (testSchemaBuilder != null) { schemaBuilders.Add(testSchemaBuilder); } schemaBuilders.Add(new PSSchemaBuilder(exclusiveItemStore)); schemaBuilders.Add(new GISchemaBuilder()); SchemaFactory schemaFactory = new SchemaFactory(this.Configuration.SchemaFileName, this.Configuration.ResourceMappingFileName, schemaBuilders, settings); this.schemaStore = new SharedItemStore <Microsoft.Management.Odata.Schema.Schema, UserContext>(schemaFactory, this.Configuration.Quotas.UserSchemaTimeout, this.Configuration.Quotas.MaxUserSchemas); this.customAuthorizationHandler = new CustomAuthorizationHandler(this.Configuration.CustomAuthorization.Assembly, this.Configuration.CustomAuthorization.Type, customContextStore); } catch (Exception exception1) { Exception exception = exception1; TraceHelper.Current.DataServiceControllerCreationFailedOperational(exception.Message); if (TraceHelper.IsEnabled(5)) { TraceHelper.Current.DebugMessage(exception.ToTraceMessage("DataServiceController failed to create")); } if (this.PerfCounters != null) { this.PerfCounters.Dispose(); } throw; } TraceHelper.Current.DataServiceControllerCreationSucceeded(); }
private DataServiceController(DSConfiguration settings, CustomAuthorizationHandler.ICustomContextStore customContextStore, ISchemaBuilder testSchemaBuilder) { TraceHelper.Current.CorrelateWithActivity(EtwActivity.GetActivityId()); try { this.Configuration = settings; this.cmdManagers = new Dictionary<ManagementSystemType, ICommandManager>(); this.PerfCounters = new PerfCounters(CurrentRequestHelper.EndPointAddress); this.UserDataCache = new UserDataCache(this.Configuration.Invocation.Lifetime); this.QuotaSystem = new QuotaSystem(); InitialSessionStateManager initialSessionStateManager = new InitialSessionStateManager(this.Configuration.PowerShell.SessionConfig.Assembly, this.Configuration.PowerShell.SessionConfig.Type); this.intialSessionStateStore = new SharedItemStore<InitialSessionState, UserContext>(initialSessionStateManager, this.Configuration.Quotas.UserSchemaTimeout, this.Configuration.Quotas.MaxUserSchemas); PSRunspaceFactory pSRunspaceFactory = new PSRunspaceFactory(this.intialSessionStateStore, true); int runspaceTimeout = this.Configuration.PowerShell.Quotas.RunspaceTimeout; ExclusiveItemStore<PSRunspace, UserContext> exclusiveItemStore = new ExclusiveItemStore<PSRunspace, UserContext>(pSRunspaceFactory, runspaceTimeout, this.Configuration.PowerShell.Quotas.MaxRunspaces); PSCommandManager pSCommandManager = new PSCommandManager(exclusiveItemStore); this.cmdManagers.Add(ManagementSystemType.PowerShell, pSCommandManager); PSRunspaceFactory pSRunspaceFactory1 = new PSRunspaceFactory(this.intialSessionStateStore, false); ExclusiveItemStore<PSRunspace, UserContext> exclusiveItemStore1 = new ExclusiveItemStore<PSRunspace, UserContext>(pSRunspaceFactory1, runspaceTimeout, this.Configuration.PowerShell.Quotas.MaxRunspaces); this.cmdManagers.Add(ManagementSystemType.GenericInvoke, new GICommandManager(exclusiveItemStore1)); List<ISchemaBuilder> schemaBuilders = new List<ISchemaBuilder>(); if (testSchemaBuilder != null) { schemaBuilders.Add(testSchemaBuilder); } schemaBuilders.Add(new PSSchemaBuilder(exclusiveItemStore)); schemaBuilders.Add(new GISchemaBuilder()); SchemaFactory schemaFactory = new SchemaFactory(this.Configuration.SchemaFileName, this.Configuration.ResourceMappingFileName, schemaBuilders, settings); this.schemaStore = new SharedItemStore<Microsoft.Management.Odata.Schema.Schema, UserContext>(schemaFactory, this.Configuration.Quotas.UserSchemaTimeout, this.Configuration.Quotas.MaxUserSchemas); this.customAuthorizationHandler = new CustomAuthorizationHandler(this.Configuration.CustomAuthorization.Assembly, this.Configuration.CustomAuthorization.Type, customContextStore); } catch (Exception exception1) { Exception exception = exception1; TraceHelper.Current.DataServiceControllerCreationFailedOperational(exception.Message); if (TraceHelper.IsEnabled(5)) { TraceHelper.Current.DebugMessage(exception.ToTraceMessage("DataServiceController failed to create")); } if (this.PerfCounters != null) { this.PerfCounters.Dispose(); } throw; } TraceHelper.Current.DataServiceControllerCreationSucceeded(); }