void PrepareAttributes() { // Match up the snapin with the snapin abouts. foreach (SnapinRegistrationInfo info in m_infos) { SnapinAboutRegistrationInfo aboutInfo = m_aboutInfos[info.SnapinType.ToString()] as SnapinAboutRegistrationInfo; if (aboutInfo == null) { throw new ApplicationException("Failed to locate a Snapin About object for the snapin: " + info.SnapinType.ToString()); } info.AboutRegistrationInfo = aboutInfo; } }
void FindAttributes(System.Type type) { // Get Guid and ProgId. string clsid = "{" + Marshal.GenerateGuidForType(type).ToString().ToUpper() + "}"; // Look for a Snapin. object [] attributes = type.GetCustomAttributes(typeof(SnapinInfoAttribute), true); if (attributes.Length != 0) { SnapinInfoAttribute attribute = attributes[0] as SnapinInfoAttribute; if (attribute != null) { SnapinRegistrationInfo info = new SnapinRegistrationInfo(); info.Attribute = attribute; info.Guid = clsid.ToUpper(); info.SnapinType = type; m_infos.Add(info); } } // Look for a Snapin About. attributes = type.GetCustomAttributes(typeof(AboutSnapinAttribute), true); if (attributes.Length != 0) { AboutSnapinAttribute attribute = attributes[0] as AboutSnapinAttribute; if (attribute != null) { SnapinAboutRegistrationInfo info = new SnapinAboutRegistrationInfo(); info.Attribute = attribute; info.Guid = clsid.ToUpper(); m_aboutInfos.Add(attribute.SnapinType.ToString(), info); } } }