Exemplo n.º 1
0
        public static void RegisterClass(Type t)
        {
            Type attributeType = typeof(GuidAttribute);

            object[] attributes = t.GetCustomAttributes(attributeType, /* inherit */ true);
            if (attributes.Length == 0)
            {
                throw new Exception(
                          String.Format("Class '{0}' does not provide a '{1}' attribute.",
                                        t.FullName, attributeType.FullName));
            }
            GuidAttribute       guidAttribute       = (GuidAttribute)((Attribute)attributes[0]);
            CustomToolAttribute customToolAttribute = getCustomToolAttribute(t);

            using (RegistryKey key = Registry.LocalMachine.CreateSubKey(
                       GetKeyName(CSharpCategoryGuid, customToolAttribute.Name)))
            {
                key.SetValue("", customToolAttribute.Description);
                key.SetValue("CLSID", "{" + guidAttribute.Value + "}");
                key.SetValue("GeneratesDesignTimeSource", 1);
            }
        }
 public CodeAttributeDeclaration Convert(GuidAttribute attribute)
 {
     return new CodeAttributeDeclaration(new CodeTypeReference(attribute.GetType()), new CodeAttributeArgument(new CodePrimitiveExpression(attribute.Value)));
 }