Esempio n. 1
0
 public static SnapInRegistrationInfo LoadFromStore(string id)
 {
     using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MMC\SnapIns\" + id))
     {
         if (key == null)
         {
             return null;
         }
         SnapInRegistrationInfo info = new SnapInRegistrationInfo();
         info._id = id;
         for (int i = 0; i < info._dWordProperties.Length; i++)
         {
             info._dWordProperties[i].SetValue(GetRegistryDWordValue(key, info._dWordProperties[i].Name));
         }
         for (int j = 0; j < info._stringProperties.Length; j++)
         {
             info._stringProperties[j].Value = GetRegistryStringValue(key, info._stringProperties[j].Name);
         }
         info._snapInType = GetRegistrySnapInType(key);
         if (info._snapInType == Microsoft.ManagementConsole.Internal.SnapInType.Unknown)
         {
             return null;
         }
         using (RegistryKey key2 = key.OpenSubKey("NodeTypes"))
         {
             if (key2 != null)
             {
                 foreach (string str in key2.GetSubKeyNames())
                 {
                     NodeType item = new NodeType();
                     try
                     {
                         item.Guid = new Guid(str);
                     }
                     catch (FormatException)
                     {
                         TraceSources.ExecutiveSource.TraceEvent(TraceEventType.Warning, 10, "Snap-in guid string is an invalid format");
                         goto Label_015D;
                     }
                     using (RegistryKey key3 = key2.OpenSubKey(str))
                     {
                         item.Description = GetRegistryStringValue(key3, "");
                         info.NodeTypes.Add(item);
                     }
                 Label_015D:;
                 }
             }
         }
         return info;
     }
 }
Esempio n. 2
0
 private static void LoadNodeTypes(SnapInRegistrationInfo info, Type type)
 {
     ExtendsNodeTypeAttribute[] customAttributes = (ExtendsNodeTypeAttribute[]) type.GetCustomAttributes(typeof(ExtendsNodeTypeAttribute), true);
     PublishesNodeTypeAttribute[] attributeArray2 = (PublishesNodeTypeAttribute[]) type.GetCustomAttributes(typeof(PublishesNodeTypeAttribute), true);
     if (((customAttributes.Length > 0) && !type.IsSubclassOf(typeof(NamespaceExtension))) && !type.IsSubclassOf(typeof(PropertySheetExtension)))
     {
         throw new Exception(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.SnapInRegistrationLoadNodeTypesWrongType));
     }
     foreach (PublishesNodeTypeAttribute attribute in attributeArray2)
     {
         NodeType item = new NodeType();
         item.Description = attribute.Description;
         item.Guid = attribute.Guid;
         info.NodeTypes.Add(item);
     }
     foreach (ExtendsNodeTypeAttribute attribute2 in customAttributes)
     {
         info.ExtendedNodeTypes.Add(attribute2.NodeType);
     }
 }