示例#1
0
        public SnapinAbout()
        {
            // Take the provider and version information from the
            // snapin attribute on the associated snapin class.

            object[] attributes = GetType().GetCustomAttributes(typeof(AboutSnapinAttribute), true);
            if (attributes.Length > 0)
            {
                AboutSnapinAttribute aboutAttribute = (AboutSnapinAttribute)attributes[0];
                attributes = aboutAttribute.SnapinType.GetCustomAttributes(typeof(SnapinInfoAttribute), true);
                if (attributes.Length != 0)
                {
                    SnapinInfoAttribute attribute = (SnapinInfoAttribute)attributes[0];

                    m_provider = attribute.Provider;
                    if (attribute.Version != null)
                    {
                        m_version = attribute.Version;
                    }
                    else
                    {
                        m_version = GetType().Module.Assembly.GetName().Version.ToString();
                    }
                }
            }

            m_mask = Color.Black;
            m_folderIcons.InsertResource(m_mainIconIndex, string.Empty);
            m_folderIcons.InsertResource(m_smallOpenImageIndex, string.Empty);
            m_folderIcons.InsertResource(m_smallClosedImageIndex, string.Empty);
            m_folderIcons.InsertResource(m_largeImageIndex, string.Empty);
        }
示例#2
0
        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);
                }
            }
        }