private void EnsureRole(Hashtable cache) { ICatalogCollection appColl = null; ICatalogObject app = null; ICatalogCollection roleColl = null; // Check to see if we've cached the existence of the role: Hashtable appRoleCache = (Hashtable)(cache[RoleCacheString]); if (appRoleCache == null) { appRoleCache = new Hashtable(); cache[RoleCacheString] = appRoleCache; } if (appRoleCache[_role] != null) { return; } appColl = (ICatalogCollection)(cache["ApplicationCollection"]); app = (ICatalogObject)(cache["Application"]); DBG.Info(DBG.Registration, "Getting roles for app: " + app.Key()); roleColl = (ICatalogCollection)(appColl.GetCollection(CollectionName.Roles, app.Key())); roleColl.Populate(); ICatalogObject newRole = Search(roleColl, "Name", _role); if (newRole == null) { // We didn't find it, we need to try to add a new role: newRole = (ICatalogObject)(roleColl.Add()); newRole.SetValue("Name", _role); if (_description != null) { newRole.SetValue("Description", _description); } roleColl.SaveChanges(); if (_setEveryoneAccess) { DBG.Info(DBG.Registration, "\tAdding everyone to the role!"); ICatalogCollection userColl = (ICatalogCollection)(roleColl.GetCollection(CollectionName.UsersInRole, newRole.Key())); userColl.Populate(); // Add the Everyone user to this guy, so that activation will // subsequently succeed: ICatalogObject newUser = (ICatalogObject)(userColl.Add()); newUser.SetValue("User", EveryoneAccount); userColl.SaveChanges(); } } // Mark this guy in the cache. appRoleCache[_role] = (Object)true; }
public InterfaceConfigCallback(ICatalogCollection coll, Type t, Hashtable cache, RegistrationDriver driver) { _type = t; _coll = coll; _cache = cache; _driver = driver; // TODO: Populate w/ QueryByKey // TODO: Build cache for FindObject() _ifcs = GetInteropInterfaces(_type); // Check to see if one of the interfaces is IProcessInitializer foreach (Type ifc in _ifcs) { if (Marshal.GenerateGuidForType(ifc) == IID_IProcessInitializer) { DBG.Info(DBG.Registration, "Setting component " + cache["ComponentType"] + " up as process initializer"); try { ICatalogObject comp = cache["Component"] as ICatalogObject; ICatalogCollection compColl = cache["ComponentCollection"] as ICatalogCollection; comp.SetValue("InitializesServerApplication", 1); compColl.SaveChanges(); } catch (Exception e) { throw new RegistrationException(Resource.FormatString("Reg_FailPIT", _type), e); } } } RegistrationDriver.Populate(_coll); }
static bool FindListener(Guid appid, out Guid clsid, out string progid) { clsid = Guid.Empty; progid = null; ICatalogObject appObj = null; ICatalogCollection appColl = null; if (!FindApplication(appid.ToString("B"), out appObj, out appColl)) { throw Tool.CreateException(SR.GetString(SR.ApplicationNotFound, appid.ToString("B")), null); } ICatalogCollection comps = (ICatalogCollection)appColl.GetCollection(CollectionName.Components, appObj.Key()); comps.Populate(); for (int i = 0; i < comps.Count(); i++) { ICatalogObject compObj = (ICatalogObject)comps.Item(i); if (IsListenerComponent(compObj)) { clsid = new Guid((string)compObj.Key()); progid = (string)compObj.Name(); return(true); } } return(false); }
public void ConfigureDefaults(Object a, Object key) { ICatalogObject obj = (ICatalogObject)a; if (Platform.IsLessThan(Platform.W2K)) { obj.SetValue("Transaction", "Not Supported"); obj.SetValue("SecurityEnabled", "N"); } else { obj.SetValue("AllowInprocSubscribers", true); obj.SetValue("ComponentAccessChecksEnabled", false); obj.SetValue("COMTIIntrinsics", false); obj.SetValue("ConstructionEnabled", false); obj.SetValue("EventTrackingEnabled", false); obj.SetValue("FireInParallel", false); obj.SetValue("IISIntrinsics", false); obj.SetValue("JustInTimeActivation", false); obj.SetValue("LoadBalancingSupported", false); obj.SetValue("MustRunInClientContext", false); obj.SetValue("ObjectPoolingEnabled", false); obj.SetValue("Synchronization", SynchronizationOption.Disabled); obj.SetValue("Transaction", TransactionOption.Disabled); obj.SetValue("ComponentTransactionTimeoutEnabled", false); } if (!Platform.IsLessThan(Platform.Whistler)) { obj.SetValue("TxIsolationLevel", TransactionIsolationLevel.Serializable); } }
public void ConfigureSubCollections(ICatalogCollection coll) { if ((_installFlags & InstallationFlags.ConfigureComponentsOnly) == 0) { foreach (Type t in _spec.ConfigurableTypes) { ICatalogObject obj = (ICatalogObject)FindObject(coll, t); ICatalogCollection ifcColl = (ICatalogCollection)(coll.GetCollection(CollectionName.Interfaces, obj.Key())); // Poke the cache so it's up to date... _cache["Component"] = obj; _cache["ComponentType"] = t; InterfaceConfigCallback cb = new InterfaceConfigCallback(ifcColl, t, _cache, _driver); _driver.ConfigureCollection(ifcColl, cb); if (_cache["SecurityOnMethods"] != null || ServicedComponentInfo.AreMethodsSecure(t)) { DBG.Info(DBG.Registration, "Found security on methods for: " + t); FixupMethodSecurity(ifcColl); _cache["SecurityOnMethods"] = null; } } } }
private ICatalogObject CreateApplication(ApplicationSpec spec, bool checkExistence) { if (checkExistence && (this.FindApplication(this._appColl, spec) != null)) { throw new RegistrationException(Resource.FormatString("Reg_AppExistsErr", spec)); } ICatalogObject obj3 = (ICatalogObject)this._appColl.Add(); this.CheckForAppSecurityAttribute(spec.Assembly); this.ApplicationDefaults(obj3, this._appColl); obj3.SetValue("Name", spec.Name); if (spec.ID != null) { obj3.SetValue("ID", spec.ID); } if (spec.AppRootDir != null) { obj3.SetValue("ApplicationDirectory", spec.AppRootDir); } SaveChanges(this._appColl); this.ConfigureObject(spec.Assembly, obj3, this._appColl, "Application", this._cache); spec.Name = (string)obj3.GetValue("Name"); SaveChanges(this._appColl); return(obj3); }
internal bool ConfigureObject(ICustomAttributeProvider t, ICatalogObject obj, ICatalogCollection coll, string prefix, Hashtable cache) { bool flag = false; object[] customAttributes = t.GetCustomAttributes(true); cache[prefix] = obj; cache[prefix + "Type"] = t; cache[prefix + "Collection"] = coll; cache["CurrentTarget"] = prefix; foreach (object obj2 in customAttributes) { if (obj2 is IConfigurationAttribute) { try { IConfigurationAttribute attribute = (IConfigurationAttribute)obj2; if (attribute.IsValidTarget(prefix) && attribute.Apply(cache)) { flag = true; } } catch (Exception exception) { if ((exception is NullReferenceException) || (exception is SEHException)) { throw; } throw new RegistrationException(Resource.FormatString("Reg_ComponentAttrErr", obj.Name(), obj2), exception); } } } return(flag); }
private static void ConfigureComponent(ICatalogCollection coll, ICatalogObject obj) { obj.SetValue("Transaction", TransactionOption.RequiresNew); obj.SetValue("ComponentTransactionTimeoutEnabled", true); obj.SetValue("ComponentTransactionTimeout", 0); coll.SaveChanges(); }
static bool SetComponentProperty(string appIdOrName, string compIdOrName, string property, object value) { ICatalogObject appObj = null; ICatalogCollection appColl = null; if (!FindApplication(appIdOrName, out appObj, out appColl)) { throw Tool.CreateException(SR.GetString(SR.ApplicationNotFound, appIdOrName), null); } ICatalogCollection comps = (ICatalogCollection)appColl.GetCollection(CollectionName.Components, appObj.Key()); comps.Populate(); compIdOrName = compIdOrName.ToLowerInvariant(); //make compName lowercase for (int i = 0; i < comps.Count(); i++) { ICatalogObject compObj = (ICatalogObject)comps.Item(i); string name = ((string)compObj.Name()).ToLowerInvariant(); //make name lowercase string id = ((string)compObj.Key()).ToLowerInvariant(); //make key lowercase if (name == compIdOrName || id == compIdOrName) { compObj.SetValue(property, value); comps.SaveChanges(); return(true); } } return(false); }
public static bool GetApplicationBitness(ICatalog2 catalog, string partitionID, string applicationID) { ICatalogCollection partitions = (ICatalogCollection)(catalog.GetCollection(CollectionName.Partitions)); ICatalogCollection applications = (ICatalogCollection)(partitions.GetCollection(CollectionName.Applications, partitionID)); applications.Populate(); ICatalogCollection components = (ICatalogCollection)applications.GetCollection(CollectionName.Components, applicationID); try { components.Populate(); } catch (Exception ex) { if (ex is NullReferenceException || ex is SEHException) { throw ex; } throw Tool.CreateException(SR.GetString(SR.FailedToDetermineTheBitnessOfApplication, applicationID), ex); } ICatalogObject component = (ICatalogObject)(components.Item(0)); return(IsBitness64bit(component)); }
private void ConfigureComponents(ApplicationSpec spec) { ICatalogCollection coll = null; try { ICatalogObject obj2 = this.FindApplication(this._appColl, spec); if (obj2 == null) { throw new RegistrationException(Resource.FormatString("Reg_AppNotFoundErr", spec)); } this._cache["Application"] = obj2; this._cache["ApplicationType"] = spec.Assembly; this._cache["ApplicationCollection"] = this._appColl; coll = (ICatalogCollection)this._appColl.GetCollection(CollectionName.Components, obj2.Key()); this.ConfigureCollection(coll, new ComponentConfigCallback(coll, spec, this._cache, this, this._installFlags)); } catch (RegistrationException) { throw; } catch (COMException exception) { throw this.WrapCOMException(coll, exception, Resource.FormatString("Reg_ConfigErr")); } catch (Exception exception2) { if ((exception2 is NullReferenceException) || (exception2 is SEHException)) { throw; } throw new RegistrationException(Resource.FormatString("Reg_ConfigUnkErr"), exception2); } }
//these method comes almost unmodified from the msdn example: //http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/concreatingcomperfmoncounters.asp public void RegisterComTransactionEventsListener() { ICatalogObject pISub, pIProp; ICatalogCollection pISubs, pIProps; long lret = 0; ICOMAdminCatalog pICat = new COMAdminCatalog(); pISubs = (ICatalogCollection)pICat.GetCollection("TransientSubscriptions"); pISubs.Populate(); pISub = (ICatalogObject)pISubs.Add(); pISub.set_Value("Name", "Method"); pISub.set_Value("EventCLSID", "{ECABB0C3-7F19-11D2-978E-0000F8757E2A}"); pISub.set_Value("InterfaceID", "{683130A8-2E50-11D2-98A5-00C04F8EE1C4}"); IntPtr thisRef = Marshal.GetIUnknownForObject(this); pISub.set_Value("SubscriberInterface", thisRef); lret = pISubs.SaveChanges(); subID = (string)pISub.get_Value("ID"); string strKey = (pISub.Key).ToString(); pIProps = (ICatalogCollection)pISubs.GetCollection("TransientPublisherProperties", strKey); pIProps.Populate(); ICatalogObject pITPP = (ICatalogObject)pIProps.Add(); pITPP.set_Value("Name", "AppID"); pITPP.set_Value("Value", "{071FB34B-9465-40B8-99B7-B68B66813E8D}"); lret = pIProps.SaveChanges(); }
public object FindObject(ICatalogCollection coll, object key) { ICatalogObject obj2 = (ICatalogObject)key; int slot = (int)obj2.GetValue("Index"); ComMemberType method = ComMemberType.Method; MemberInfo setMethod = Marshal.GetMethodInfoForComSlot(this._type, slot, ref method); if (setMethod is PropertyInfo) { switch (method) { case ComMemberType.PropSet: setMethod = ((PropertyInfo)setMethod).GetSetMethod(); break; case ComMemberType.PropGet: setMethod = ((PropertyInfo)setMethod).GetGetMethod(); break; } } if (this._map.InterfaceMethods != null) { for (int i = 0; i < this._map.InterfaceMethods.Length; i++) { MethodInfo info2 = setMethod as MethodInfo; if (this._map.InterfaceMethods[i] == info2) { return(this._map.TargetMethods[i]); } } } return(setMethod); }
public void ConfigureDefaults(Object a, Object key) { DBG.Assert(!(Platform.IsLessThan(Platform.W2K)), "Configuring interfaces on non-w2k platform!"); if (!Platform.IsLessThan(Platform.W2K)) { bool setQdefault = true; ICatalogObject obj = (ICatalogObject)key; // If this type (a) has been touched by the parent component, // we don't want to set this value... if (_cache[_type] != null) { Object co = _cache[_type]; if (co is Hashtable && ((Hashtable)co)[a] != null) { DBG.Info(DBG.Registration, "*** not setting queue defaults!"); setQdefault = false; } } if (setQdefault) { obj.SetValue("QueuingEnabled", false); } } }
bool IConfigurationAttribute.Apply(Hashtable cache) { Platform.Assert(Platform.MTS, "ApplicationAccessControlAttribute"); ICatalogObject obj = (ICatalogObject)(cache["Application"]); // MTS-speak if (Platform.IsLessThan(Platform.W2K)) { bool en = (bool)_val; obj.SetValue("SecurityEnabled", en?"Y":"N"); } else { obj.SetValue("ApplicationAccessChecksEnabled", _val); obj.SetValue("AccessChecksLevel", _checkLevel); } if (_authLevel != (AuthenticationOption)(-1)) { obj.SetValue("Authentication", _authLevel); } if (_impLevel != (ImpersonationLevelOption)(-1)) { obj.SetValue("ImpersonationLevel", _impLevel); } return(true); }
static void Main(string[] args) { string packageName = "TRICOLOR"; ICOMAdminCatalog catalog = (ICOMAdminCatalog)Interaction.CreateObject("COMAdmin.COMAdminCatalog", string.Empty); ICatalogCollection packages = (ICatalogCollection)catalog.GetCollection("Applications"); packages.Populate(); foreach (ICatalogObject package in packages) { if (package.Name.ToString().Equals(packageName)) { ICatalogCollection roles = (ICatalogCollection)packages.GetCollection("Roles", package.Key); roles.Populate(); ICatalogObject role = (ICatalogObject)roles.Add(); role.set_Value("Name", "MyRoleName"); roles.SaveChanges(); ICatalogCollection users = (ICatalogCollection)roles.GetCollection("UsersInRole", role.Key); users.Populate(); ICatalogObject user = (ICatalogObject)users.Add(); user.set_Value("User", "MV0266\\IUSR_MV0266"); users.SaveChanges(); break; } } }
public InterfaceConfigCallback(ICatalogCollection coll, Type t, Hashtable cache, RegistrationDriver driver) { this._type = t; this._coll = coll; this._cache = cache; this._driver = driver; this._ifcs = this.GetInteropInterfaces(this._type); foreach (Type type in this._ifcs) { if (Marshal.GenerateGuidForType(type) == IID_IProcessInitializer) { try { ICatalogObject obj2 = cache["Component"] as ICatalogObject; ICatalogCollection catalogs = cache["ComponentCollection"] as ICatalogCollection; obj2.SetValue("InitializesServerApplication", 1); catalogs.SaveChanges(); } catch (Exception exception) { if ((exception is NullReferenceException) || (exception is SEHException)) { throw; } throw new RegistrationException(Resource.FormatString("Reg_FailPIT", this._type), exception); } } } RegistrationDriver.Populate(this._coll); }
public void AddObj(ref Archives archive, Func <User, bool> func, ICatalogObject obj) { var user = ListUsers.Find(m => func(m)); archive.Add(new Archive(user, obj, 15)); ListUsers[ListUsers.FindIndex(m => m.NumTicket == user.NumTicket)] = user; }
static void MarkComponentAsPrivate(ICatalog2 catalog, string partitionID, string applicationID, string progid) { ICatalogCollection partitions = (ICatalogCollection)(catalog.GetCollection(CollectionName.Partitions)); ICatalogCollection applications = (ICatalogCollection)(partitions.GetCollection(CollectionName.Applications, partitionID)); applications.Populate(); ICatalogCollection components = (ICatalogCollection)applications.GetCollection(CollectionName.Components, applicationID); try { components.Populate(); for (int j = 0; j < components.Count(); j++) { ICatalogObject component = (ICatalogObject)(components.Item(j)); if ((string)component.Name() == progid) { component.SetValue(PropertyName.IsPrivateComponent, true); components.SaveChanges(); break; } } } catch (Exception ex) { if (ex is NullReferenceException || ex is SEHException) { throw ex; } ToolConsole.WriteWarning(SR.GetString(SR.FailedToMarkListenerComponentAsPrivateForApplication, progid, applicationID)); } }
private Type FindInterfaceByName(ICatalogObject ifcObj, Type t, Type[] interfaces) { String name = (String)(ifcObj.GetValue("Name")); foreach (Type ifc in interfaces) { if (ifc.IsInterface) { DBG.Info(DBG.Registration, "Matching " + ifc.Name + " against " + name + " on " + ifc); if (ifc.Name == name) { return(ifc); } } else { DBG.Info(DBG.Registration, "Matching _" + ifc.Name + " against " + name + " on " + ifc); if ("_" + ifc.Name == name) { return(ifc); } } } return(null); }
public ComAdminClassInfo(ICatalogObject compObj, ICatalogCollection compColl) { this.clsid = new Guid((string)compObj.Key()); this.progid = (string)compObj.Name(); this.isPrivate = (bool)compObj.GetValue(PropertyName.IsPrivateComponent); this.transactionOption = (TransactionOption)compObj.GetValue(PropertyName.TransactionOption); this.BuildInterfaces(compObj, compColl); }
internal static ComCatalogObject FindApplication(Guid applicationId) { ICatalog2 catalog = (ICatalog2)(new xCatalog()); ICatalogObject appObject = null; ICatalogCollection partitionCollection = null; try { partitionCollection = (ICatalogCollection)catalog.GetCollection( "Partitions"); partitionCollection.Populate(); } catch (COMException comException) { if (comException.ErrorCode != HR.COMADMIN_E_PARTITIONS_DISABLED) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(comException); } } if (partitionCollection != null) { for (int i = 0; i < partitionCollection.Count(); i++) { ICatalogObject partition; partition = (ICatalogObject)partitionCollection.Item(i); ICatalogCollection appCollection; appCollection = (ICatalogCollection)partitionCollection.GetCollection( "Applications", partition.Key()); appCollection.Populate(); appObject = FindApplication(appCollection, applicationId); if (appObject != null) { return(new ComCatalogObject(appObject, appCollection)); } } } else { ICatalogCollection appCollection; appCollection = (ICatalogCollection)catalog.GetCollection( "Applications"); appCollection.Populate(); appObject = FindApplication(appCollection, applicationId); if (appObject != null) { return(new ComCatalogObject(appObject, appCollection)); } } return(null); }
bool IConfigurationAttribute.Apply(Hashtable info) { Platform.Assert(Platform.W2K, "CrmEnabledAttribute"); ICatalogObject obj = (ICatalogObject)(info["Application"]); obj.SetValue("CRMEnabled", _value); return(true); }
bool IConfigurationAttribute.Apply(Hashtable info) { if (this._interface == null) { ICatalogObject obj2 = (ICatalogObject)info["Interface"]; this.ConfigureInterface(obj2); } return(true); }
public void ConfigureDefaults(Object a, Object key) { DBG.Assert(!(Platform.IsLessThan(Platform.W2K)), "Configuring methods on non-w2k platform!"); if (!Platform.IsLessThan(Platform.W2K)) { ICatalogObject obj = (ICatalogObject)key; obj.SetValue("AutoComplete", false); } }
internal static bool IsListenerComponent(ICatalogObject compObj) { string compName = (string)compObj.Name(); if (compName.ToUpperInvariant() == ListenerWSUName.ToUpperInvariant()) { return(true); } return(false); }
bool IConfigurationAttribute.Apply(Hashtable info) { ICatalogObject obj2 = (ICatalogObject)info["Component"]; obj2.SetValue("JustInTimeActivation", this._enabled); if (this._enabled && (((int)obj2.GetValue("Synchronization")) == 0)) { obj2.SetValue("Synchronization", SynchronizationOption.Required); } return(true); }
bool IConfigurationAttribute.Apply(Hashtable info) { ICatalogObject obj2 = (ICatalogObject)info["Component"]; obj2.SetValue("ConstructionEnabled", this._enabled); if ((this._default != null) && (this._default != "")) { obj2.SetValue("ConstructorString", this._default); } return(true); }
private ICatalogObject FindApplication(ICatalogCollection apps, ApplicationSpec spec) { for (int i = 0; i < apps.Count(); i++) { ICatalogObject obj2 = (ICatalogObject)apps.Item(i); if (spec.Matches(obj2)) { return(obj2); } } return(null); }
bool IConfigurationAttribute.Apply(Hashtable info) { ICatalogObject obj2 = (ICatalogObject)info["Component"]; obj2.SetValue("FireInParallel", this._fireInParallel); obj2.SetValue("AllowInprocSubscribers", this._allowInprocSubscribers); if (this._filter != null) { obj2.SetValue("MultiInterfacePublisherFilterCLSID", this._filter); } return(true); }
private void ApplicationDefaults(ICatalogObject obj, ICatalogCollection coll) { obj.SetValue("Activation", ActivationOption.Library); obj.SetValue("AccessChecksLevel", AccessChecksLevelOption.Application); obj.SetValue("ApplicationAccessChecksEnabled", true); obj.SetValue("Authentication", AuthenticationOption.Packet); obj.SetValue("CRMEnabled", false); obj.SetValue("EventsEnabled", true); obj.SetValue("ImpersonationLevel", ImpersonationLevelOption.Impersonate); obj.SetValue("QueuingEnabled", false); obj.SetValue("QueueListenerEnabled", false); obj.SetValue("SoapActivated", false); obj.SetValue("QCListenerMaxThreads", 0); }
private void FindInterfaceByKey(string key, ICatalogCollection coll, Type comp, out ICatalogObject ifcObj, out Type ifcType) { ifcType = FindInterfaceByName(key, comp); if (ifcType == null) { throw new RegistrationException(Resource.FormatString("Reg_TypeFindError", key, comp.ToString())); } Guid guid = Marshal.GenerateGuidForType(ifcType); object[] aKeys = new object[] { "{" + guid + "}" }; coll.PopulateByKey(aKeys); if (coll.Count() != 1) { throw new RegistrationException(Resource.FormatString("Reg_TypeFindError", key, comp.ToString())); } ifcObj = (ICatalogObject) coll.Item(0); }
protected void ApplyProperties(ArrayList properties, ICatalogObject catalogObject) { foreach (PropertyTask propertyTask in properties) { string value; if (!propertyTask.Dynamic) { value = Project.ExpandProperties(propertyTask.Value, Location); } else { value = propertyTask.Value; } ApplyProperty(propertyTask.PropertyName, value, catalogObject); } }
private bool ConfigureInterface(ICatalogObject obj) { bool flag = (bool) obj.GetValue("QueuingSupported"); if (this._enabled && flag) { obj.SetValue("QueuingEnabled", this._enabled); } else { if (this._enabled) { throw new RegistrationException(Resource.FormatString("Reg_QueueingNotSupported", (string) obj.Name())); } obj.SetValue("QueuingEnabled", this._enabled); } return true; }
protected void ApplyProperty(string name, string value, ICatalogObject catalogObject) { Log(Level.Info, Resources.BaseCOMTaskApplyProperty, name, value); if (SpecificProperties.ContainsKey(name)) { TypeConverter converter = TypeDescriptor.GetConverter(SpecificProperties[name]); try { object convertedValue = converter.ConvertFromString(value); catalogObject.set_Value(name, convertedValue); } catch (FormatException) { StringBuilder sbMessage = new StringBuilder(); sbMessage.AppendFormat(Resources.BaseCOMTaskFormatPossibleValues, value, name); sbMessage.AppendLine(); if (converter is EnumConverter) { foreach (string possibleValue in Enum.GetNames(SpecificProperties[name])) { sbMessage.AppendLine(possibleValue); } } if (converter is Int32Converter) { sbMessage.AppendLine("any number"); } throw new BuildException(sbMessage.ToString()); } } else { // Hack asserting that if the property ends with Enabled, then it's a boolean. if (name.EndsWith("Enabled", StringComparison.InvariantCulture)) { catalogObject.set_Value(name, Convert.ToBoolean(value)); } else { catalogObject.set_Value(name, value); } } }
static bool FindApplication(string appidOrName, out ICatalogObject targetAppObj, out ICatalogCollection appColl) { targetAppObj = null; appColl = null; bool found = false; ICatalog2 catalog = GetCatalog(); string partitionId = null; partitionId = GetPartitionIdForApplication(catalog, appidOrName, true); if (!string.IsNullOrEmpty(partitionId)) { SetCurrentPartition(catalog, partitionId); } appColl = (ICatalogCollection)(catalog.GetCollection(CollectionName.Applications)); appColl.Populate(); for (int i = 0; i < appColl.Count(); i++) { ICatalogObject appObj = (ICatalogObject)(appColl.Item(i)); string id = ((string)appObj.Key()).ToLowerInvariant(); string name = ((string)appObj.Name()).ToLowerInvariant(); appidOrName = appidOrName.ToLowerInvariant(); if (!found) { if ((appidOrName == id) || (appidOrName == name)) { found = true; targetAppObj = appObj; } } else { if ((appidOrName == id) || (appidOrName == name)) { throw Tool.CreateException(SR.GetString(SR.AmbiguousApplicationName, appidOrName), null); } } } return found; }
internal bool AfterSaveChanges(ICustomAttributeProvider t, ICatalogObject obj, ICatalogCollection coll, string prefix, Hashtable cache) { bool flag = false; object[] customAttributes = t.GetCustomAttributes(true); cache[prefix] = obj; cache[prefix + "Type"] = t; cache[prefix + "Collection"] = coll; cache["CurrentTarget"] = prefix; foreach (object obj2 in customAttributes) { if (obj2 is IConfigurationAttribute) { IConfigurationAttribute attribute = (IConfigurationAttribute) obj2; if (attribute.IsValidTarget(prefix) && attribute.AfterSaveChanges(cache)) { flag = true; } } } return flag; }
public bool Matches(ICatalogObject obj) { if (this.ID != null) { Guid guid = new Guid(this.ID); Guid guid2 = new Guid((string) obj.GetValue("ID")); if (guid == guid2) { return true; } } else { string str = ((string) obj.GetValue("Name")).ToLower(CultureInfo.InvariantCulture); if (this.Name.ToLower(CultureInfo.InvariantCulture) == str) { return true; } } return false; }
private Type FindInterfaceByID(ICatalogObject ifcObj, Type t, Type[] interfaces) { Guid guid = new Guid((string) ifcObj.GetValue("IID")); foreach (Type type in interfaces) { if (Marshal.GenerateGuidForType(type) == guid) { return type; } } return null; }
private void AddRoles(ICatalogCollection catalogCollection, ICatalogObject application) { ICatalogCollection rolesCatalog = (ICatalogCollection)catalogCollection.GetCollection(COMConstants.ROLES_CATALOG_NAME, application.Key); rolesCatalog.Populate(); foreach (COMRoleElement comRole in Roles) { Log(Level.Info, Resources.COMCreateApplicationAddRole, comRole.RoleName, application.Name); ICatalogObject newRole = (ICatalogObject)rolesCatalog.Add(); newRole.set_Value("Name", comRole.RoleName); rolesCatalog.SaveChanges(); ICatalogCollection usersInRolesCatalog = (ICatalogCollection)rolesCatalog.GetCollection(COMConstants.USERS_IN_ROLES_CATALOG_NAME, newRole.Key); foreach (COMRoleUserElement comRoleUserElement in comRole.Users) { ICatalogObject newUser = (ICatalogObject)usersInRolesCatalog.Add(); newUser.set_Value("User", comRoleUserElement.UserName); usersInRolesCatalog.SaveChanges(); } } rolesCatalog.SaveChanges(); }
private void ExtractApplicationProperties(StringBuilder result, ICOMAdminCatalog catalog, ICatalogObject application) { ICatalogCollection appCatalog = (ICatalogCollection)catalog.GetCollection(COMConstants.APPLICATIONS_CATALOG_NAME); appCatalog.Populate(); foreach (COMAdminCatalogObject app in appCatalog) { if (app.Key.Equals(application.Key)) { foreach (ComponentProperties property in appProperties) { try { object propertyValue = app.get_Value(property.Name); if (propertyValue.GetType() != property.Type) { TypeConverter converter = TypeDescriptor.GetConverter(property.Type); if (converter is EnumConverter) { foreach (int value in Enum.GetValues(property.Type)) { if (value == (int)propertyValue) { propertyValue = Enum.ToObject(property.Type, (int) propertyValue); } } } else { propertyValue = converter.ConvertFrom(propertyValue); } } if (!propertyValue.Equals(property.DefaultValue)) { result.AppendFormat("\t<property name=\"{0}\" value=\"{1}\" />", property.Name, propertyValue); result.AppendLine(); } } catch { } } } } }
public ComCatalogObject(ICatalogObject catalogObject, ICatalogCollection catalogCollection) { this.catalogObject = catalogObject; this.catalogCollection = catalogCollection; }
private void PostProcessApplication(ICatalogObject app, ApplicationSpec spec) { try { if (this.AfterSaveChanges(spec.Assembly, app, this._appColl, "Application", this._cache)) { SaveChanges(this._appColl); } } catch (Exception exception) { if ((exception is NullReferenceException) || (exception is SEHException)) { throw; } throw new RegistrationException(Resource.FormatString("Reg_ConfigUnkErr"), exception); } }
void BuildInterfaces(ICatalogObject compObj, ICatalogCollection compColl) { this.interfaces = new List<ComAdminInterfaceInfo>(); ICatalogCollection interfaceColl = (ICatalogCollection)compColl.GetCollection(CollectionName.InterfacesForComponent, compObj.Key()); interfaceColl.Populate(); for (int i = 0; i < interfaceColl.Count(); i++) { ICatalogObject itf = (ICatalogObject)interfaceColl.Item(i); Guid interfaceID = new Guid((string)itf.Key()); ComAdminInterfaceInfo interfaceInfo = new ComAdminInterfaceInfo(interfaceID, (string)itf.Name()); this.interfaces.Add(interfaceInfo); } }
public COMSearchResult(ICatalogCollection catalogCollection, ICatalogObject catalogObject, int index) { this.catalogCollection = catalogCollection; this.index = index; this.catalogObject = catalogObject; }
void BuildClasses(ICatalogObject appObj, ICatalogCollection appColl) { int versionStrSize = 256; StringBuilder version = new StringBuilder(256); bool isFrameworkVersionSet = false; bool isRuntimeVersionSet = false; bool isRuntimeVersionInstalled = true; int length = 0; Version appClrVersion = null; this.classes = new List<ComAdminClassInfo>(); ICatalogCollection comps = (ICatalogCollection)appColl.GetCollection(CollectionName.Components, appObj.Key()); comps.Populate(); for (int i = 0; i < comps.Count(); i++) { ICatalogObject comp = (ICatalogObject)comps.Item(i); ComAdminClassInfo classInfo = new ComAdminClassInfo(comp, comps); isFrameworkVersionSet = false; if (!isRuntimeVersionSet) { isFrameworkVersionSet = (SafeNativeMethods.ERROR_SUCCESS == SafeNativeMethods.GetRequestedRuntimeVersionForCLSID(classInfo.Clsid, version, versionStrSize, ref length, 0)); if (isFrameworkVersionSet && TryGetVersionFromString(version, out appClrVersion)) { if (IsCLRVersionInstalled(appClrVersion)) { isRuntimeVersionSet = true; } else if (ValidateCLRVersion(appClrVersion)) { // We've found an valid CLR version in the app but that runtime version is not installed isRuntimeVersionSet = true; isRuntimeVersionInstalled = false; } } } if (ComAdminWrapper.IsListenerComponent(comp)) { this.listenerExists = true; } else { this.classes.Add(classInfo); } } //Parse the version number we get // If the version is V4.0* we are going to register the 4.0 version of ServiceMonikerSupport.dll // Anything else we are going to register the 3.0 version of ServiceMonikerSupport.dll if (isRuntimeVersionSet && isRuntimeVersionInstalled) { if (appClrVersion.Major == 4 && appClrVersion.Minor == 0) { this.runtimeVersion = RuntimeVersions.V40; } else if (appClrVersion.Major == 2 && appClrVersion.Minor == 0) { this.runtimeVersion = RuntimeVersions.V20; } else { // It is non of the CLR version this tool recognize throw Tool.CreateException(SR.GetString(SR.FailedToGetRuntime, appClrVersion.ToString()), null); } } else if (!isRuntimeVersionInstalled) { // When we can't find the matching runtime for the user application, throw an application exception throw Tool.CreateException(SR.GetString(SR.FailedToGetRuntime, appClrVersion.ToString()), null); } else { this.runtimeVersion = RuntimeVersions.V40; } }
public ComAdminAppInfo(ICatalogObject appObj, ICatalogCollection appColl) { this.appid = new Guid((string)appObj.Key()); this.appname = (string)appObj.Name(); this.appdir = (string)appObj.GetValue(PropertyName.ApplicationDirectory); // Note that casting to long would throw an InvalidCastException this.serverActivated = ((int)appObj.GetValue(PropertyName.Activation)) == 1; this.systemApplication = (bool)appObj.GetValue(PropertyName.IsSystem); this.processPooled = ((int)appObj.GetValue(PropertyName.ConcurrentApps)) > 1; this.automaticRecycling = (((int)appObj.GetValue(PropertyName.RecycleActivationLimit) > 0) || ((int)appObj.GetValue(PropertyName.RecycleCallLimit) > 0) || ((int)appObj.GetValue(PropertyName.RecycleLifetimeLimit) > 0) || ((int)appObj.GetValue(PropertyName.RecycleMemoryLimit) > 0)); this.BuildClasses(appObj, appColl); }
internal bool ConfigureObject(ICustomAttributeProvider t, ICatalogObject obj, ICatalogCollection coll, string prefix, Hashtable cache) { bool flag = false; object[] customAttributes = t.GetCustomAttributes(true); cache[prefix] = obj; cache[prefix + "Type"] = t; cache[prefix + "Collection"] = coll; cache["CurrentTarget"] = prefix; foreach (object obj2 in customAttributes) { if (obj2 is IConfigurationAttribute) { try { IConfigurationAttribute attribute = (IConfigurationAttribute) obj2; if (attribute.IsValidTarget(prefix) && attribute.Apply(cache)) { flag = true; } } catch (Exception exception) { if ((exception is NullReferenceException) || (exception is SEHException)) { throw; } throw new RegistrationException(Resource.FormatString("Reg_ComponentAttrErr", obj.Name(), obj2), exception); } } } return flag; }
internal static bool IsListenerComponent(ICatalogObject compObj) { string compName = (string)compObj.Name(); if (compName.ToUpperInvariant() == ListenerWSUName.ToUpperInvariant()) return true; return false; }
static bool IsBitness64bit(ICatalogObject component) { int bitness = (int)component.GetValue(PropertyName.Bitness); if (bitness == 1) { return false; } else { return true; } }
private Type FindInterfaceByName(ICatalogObject ifcObj, Type t, Type[] interfaces) { string str = (string) ifcObj.GetValue("Name"); foreach (Type type in interfaces) { if (type.IsInterface) { if (type.Name == str) { return type; } } else if (("_" + type.Name) == str) { return type; } } return null; }