public ContractInfo(Guid iid, ServiceEndpointElement endpoint, ComCatalogObject interfaceObject, ComCatalogObject application) { this.name = endpoint.Contract; this.iid = iid; // Interface Roles // ComCatalogCollection roles; roles = interfaceObject.GetCollection("RolesForInterface"); this.interfaceRoleMembers = CatalogUtil.GetRoleMembers(application, roles); // Operations // this.operations = new List <OperationInfo>(); ComCatalogCollection methods; methods = interfaceObject.GetCollection("MethodsForInterface"); foreach (ComCatalogObject method in methods) { this.operations.Add(new OperationInfo(method, application)); } }
public OperationInfo(ComCatalogObject methodObject, ComCatalogObject application) { this.name = (string)methodObject.GetValue("Name"); ComCatalogCollection collection = methodObject.GetCollection("RolesForMethod"); this.methodRoleMembers = CatalogUtil.GetRoleMembers(application, collection); }
public ContractInfo(Guid iid, ServiceEndpointElement endpoint, ComCatalogObject interfaceObject, ComCatalogObject application) { this.name = endpoint.Contract; this.iid = iid; ComCatalogCollection collection = interfaceObject.GetCollection("RolesForInterface"); this.interfaceRoleMembers = CatalogUtil.GetRoleMembers(application, collection); this.operations = new List <OperationInfo>(); ComCatalogCollection.Enumerator enumerator = interfaceObject.GetCollection("MethodsForInterface").GetEnumerator(); while (enumerator.MoveNext()) { ComCatalogObject current = enumerator.Current; this.operations.Add(new OperationInfo(current, application)); } }
// NOTE: Construction of this thing is quite inefficient-- it // has several nested loops that could probably be // improved. Such optimizations have been left for when // it turns out to be a performance problem, for the // sake of simplicity. // public ServiceInfo(Guid clsid, ServiceElement service, ComCatalogObject application, ComCatalogObject classObject, HostingMode hostingMode) { // Simple things... // this.service = service; this.clsid = clsid; this.appid = Fx.CreateGuid((string)application.GetValue("ID")); this.partitionId = Fx.CreateGuid((string)application.GetValue("AppPartitionID")); this.bitness = (Bitness)classObject.GetValue("Bitness"); this.transactionOption = (TransactionOption)classObject.GetValue("Transaction"); this.hostingMode = hostingMode; this.managedType = TypeCacheManager.ResolveClsidToType(clsid); this.serviceName = application.Name + "." + classObject.Name; this.udts = new Dictionary <Guid, List <Type> >(); // Isolation Level COMAdminIsolationLevel adminIsolationLevel; adminIsolationLevel = (COMAdminIsolationLevel)classObject.GetValue("TxIsolationLevel"); switch (adminIsolationLevel) { case COMAdminIsolationLevel.Any: this.isolationLevel = IsolationLevel.Unspecified; break; case COMAdminIsolationLevel.ReadUncommitted: this.isolationLevel = IsolationLevel.ReadUncommitted; break; case COMAdminIsolationLevel.ReadCommitted: this.isolationLevel = IsolationLevel.ReadCommitted; break; case COMAdminIsolationLevel.RepeatableRead: this.isolationLevel = IsolationLevel.RepeatableRead; break; case COMAdminIsolationLevel.Serializable: this.isolationLevel = IsolationLevel.Serializable; break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed( SR.GetString(SR.InvalidIsolationLevelValue, this.clsid, adminIsolationLevel))); } // Threading Model // COMAdminThreadingModel adminThreadingModel; adminThreadingModel = (COMAdminThreadingModel)classObject.GetValue("ThreadingModel"); switch (adminThreadingModel) { case COMAdminThreadingModel.Apartment: case COMAdminThreadingModel.Main: this.threadingModel = ThreadingModel.STA; objectPoolingEnabled = false; break; default: this.threadingModel = ThreadingModel.MTA; objectPoolingEnabled = (bool)classObject.GetValue("ObjectPoolingEnabled"); break; } // Object Pool settings // if (objectPoolingEnabled) { maxPoolSize = (int)classObject.GetValue("MaxPoolSize"); } else { maxPoolSize = 0; } // Security Settings // bool appSecurityEnabled; appSecurityEnabled = (bool)application.GetValue( "ApplicationAccessChecksEnabled"); if (appSecurityEnabled) { bool classSecurityEnabled; classSecurityEnabled = (bool)classObject.GetValue( "ComponentAccessChecksEnabled"); if (classSecurityEnabled) { this.checkRoles = true; } } // Component Roles // ComCatalogCollection roles; roles = classObject.GetCollection("RolesForComponent"); this.componentRoleMembers = CatalogUtil.GetRoleMembers(application, roles); // Contracts // One ContractInfo per unique IID exposed, so we need to // filter duplicates. // this.contracts = new List <ContractInfo>(); ComCatalogCollection interfaces; interfaces = classObject.GetCollection("InterfacesForComponent"); foreach (ServiceEndpointElement endpoint in service.Endpoints) { ContractInfo contract = null; if (endpoint.Contract == ServiceMetadataBehavior.MexContractName) { continue; } Guid iid; if (DiagnosticUtility.Utility.TryCreateGuid(endpoint.Contract, out iid)) { // (Filter duplicates.) bool duplicate = false; foreach (ContractInfo otherContract in this.contracts) { if (iid == otherContract.IID) { duplicate = true; break; } } if (duplicate) { continue; } foreach (ComCatalogObject interfaceObject in interfaces) { Guid otherInterfaceID; if (DiagnosticUtility.Utility.TryCreateGuid((string)interfaceObject.GetValue("IID"), out otherInterfaceID)) { if (otherInterfaceID == iid) { contract = new ContractInfo(iid, endpoint, interfaceObject, application); break; } } } } if (contract == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed( SR.GetString(SR.EndpointNotAnIID, clsid.ToString("B").ToUpperInvariant(), endpoint.Contract))); } this.contracts.Add(contract); } }
public ServiceInfo(Guid clsid, System.ServiceModel.Configuration.ServiceElement service, ComCatalogObject application, ComCatalogObject classObject, System.ServiceModel.ComIntegration.HostingMode hostingMode) { this.service = service; this.clsid = clsid; this.appid = Fx.CreateGuid((string) application.GetValue("ID")); this.partitionId = Fx.CreateGuid((string) application.GetValue("AppPartitionID")); this.bitness = (System.ServiceModel.ComIntegration.Bitness) classObject.GetValue("Bitness"); this.transactionOption = (System.EnterpriseServices.TransactionOption) classObject.GetValue("Transaction"); this.hostingMode = hostingMode; this.managedType = TypeCacheManager.ResolveClsidToType(clsid); this.serviceName = application.Name + "." + classObject.Name; this.udts = new Dictionary<Guid, List<Type>>(); COMAdminIsolationLevel level = (COMAdminIsolationLevel) classObject.GetValue("TxIsolationLevel"); switch (level) { case COMAdminIsolationLevel.Any: this.isolationLevel = System.Transactions.IsolationLevel.Unspecified; break; case COMAdminIsolationLevel.ReadUncommitted: this.isolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; break; case COMAdminIsolationLevel.ReadCommitted: this.isolationLevel = System.Transactions.IsolationLevel.ReadCommitted; break; case COMAdminIsolationLevel.RepeatableRead: this.isolationLevel = System.Transactions.IsolationLevel.RepeatableRead; break; case COMAdminIsolationLevel.Serializable: this.isolationLevel = System.Transactions.IsolationLevel.Serializable; break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("InvalidIsolationLevelValue", new object[] { this.clsid, level }))); } switch (((COMAdminThreadingModel) classObject.GetValue("ThreadingModel"))) { case COMAdminThreadingModel.Apartment: case COMAdminThreadingModel.Main: this.threadingModel = System.ServiceModel.ComIntegration.ThreadingModel.STA; this.objectPoolingEnabled = false; break; default: this.threadingModel = System.ServiceModel.ComIntegration.ThreadingModel.MTA; this.objectPoolingEnabled = (bool) classObject.GetValue("ObjectPoolingEnabled"); break; } if (this.objectPoolingEnabled) { this.maxPoolSize = (int) classObject.GetValue("MaxPoolSize"); } else { this.maxPoolSize = 0; } if (((bool) application.GetValue("ApplicationAccessChecksEnabled")) && ((bool) classObject.GetValue("ComponentAccessChecksEnabled"))) { this.checkRoles = true; } ComCatalogCollection collection = classObject.GetCollection("RolesForComponent"); this.componentRoleMembers = CatalogUtil.GetRoleMembers(application, collection); this.contracts = new List<ContractInfo>(); ComCatalogCollection catalogs2 = classObject.GetCollection("InterfacesForComponent"); foreach (ServiceEndpointElement element in service.Endpoints) { ContractInfo item = null; if (element.Contract != "IMetadataExchange") { Guid guid; if (DiagnosticUtility.Utility.TryCreateGuid(element.Contract, out guid)) { bool flag3 = false; foreach (ContractInfo info2 in this.contracts) { if (guid == info2.IID) { flag3 = true; break; } } if (flag3) { continue; } ComCatalogCollection.Enumerator enumerator = catalogs2.GetEnumerator(); while (enumerator.MoveNext()) { Guid guid2; ComCatalogObject current = enumerator.Current; if (DiagnosticUtility.Utility.TryCreateGuid((string) current.GetValue("IID"), out guid2) && (guid2 == guid)) { item = new ContractInfo(guid, element, current, application); break; } } } if (item == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("EndpointNotAnIID", new object[] { clsid.ToString("B").ToUpperInvariant(), element.Contract }))); } this.contracts.Add(item); } } }