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();
 }
 public CustomAuthorizationHandler(string customAuthzAssembly, string customAuthzTypeName, CustomAuthorizationHandler.ICustomContextStore customContextStore)
 {
     try
     {
         if (customContextStore != null)
         {
             this.customContextStore = customContextStore;
         }
         else
         {
             this.customContextStore = new CustomAuthorizationHandler.OperationContextBasedContextStore();
         }
         Type type = TypeLoader.LoadType(customAuthzAssembly, customAuthzTypeName);
         if (type != null)
         {
             this.customAuthorization = type.Assembly.CreateInstance(type.FullName) as CustomAuthorization;
             ExceptionHelpers.ThrowArgumentExceptionIf("customAuthzTypeName", this.customAuthorization == null, Resources.CustomAuthorizationPluginCreationFailed, new object[0]);
         }
         else
         {
             object[] objArray = new object[2];
             objArray[0] = customAuthzTypeName;
             objArray[1] = customAuthzAssembly;
             throw new ArgumentException(ExceptionHelpers.GetExceptionMessage(Resources.TypeLoadFromAssebmlyFailed, objArray), "customAuthzTypeName");
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         TraceHelper.Current.CustomAuthorizationLoadingFailed(customAuthzAssembly, exception.ToTraceMessage("Exception"));
         if (!exception.IsSevereException())
         {
             throw new TypeLoadException(customAuthzTypeName, customAuthzAssembly, Utils.GetBaseBinDirectory(customAuthzAssembly), exception);
         }
         else
         {
             throw;
         }
     }
     TraceHelper.Current.CustomAuthorizationLoadedSuccessfully(customAuthzTypeName);
 }
        public static void CreateDataServiceController(DSConfiguration settings, CustomAuthorizationHandler.ICustomContextStore customContextStore, ISchemaBuilder testSchemaBuilder)
        {
            string filePath;

            lock (DataServiceController.syncObject)
            {
                Configuration configuration = null;
                if (settings == null)
                {
                    try
                    {
                        settings = DSConfiguration.GetSection(configuration);
                    }
                    catch (Exception exception1)
                    {
                        Exception exception = exception1;
                        Microsoft.Management.Odata.Tracing.Tracer current = TraceHelper.Current;
                        string str = "config file is ";
                        if (configuration == null)
                        {
                            filePath = "(not available)";
                        }
                        else
                        {
                            filePath = configuration.FilePath;
                        }
                        current.DebugMessage(string.Concat(str, filePath));
                        if (TraceHelper.IsEnabled(5))
                        {
                            TraceHelper.Current.DebugMessage(exception.ToTraceMessage("DataServiceController failed to create"));
                        }
                        TraceHelper.Current.DataServiceControllerCreationFailedOperational(exception.Message);
                        throw;
                    }
                }
                DataServiceController.current = new DataServiceController(settings, customContextStore, testSchemaBuilder);
            }
        }
 public void SetCustomStateStore(CustomAuthorizationHandler.ICustomContextStore context)
 {
     this.customContextStore = context;
 }
 public static void CreateDataServiceController(DSConfiguration settings, CustomAuthorizationHandler.ICustomContextStore customContextStore)
 {
     DataServiceController.CreateDataServiceController(settings, customContextStore, null);
 }