Пример #1
0
    public void AddType(TypeDefinition typeDefinition)
    {
      if (typeDefinition.IsValueType && !typeDefinition.IsEnum)
      {
        MyStructureInfo myStructureInfo = new MyStructureInfo(typeDefinition, assemblyName);
        Dictionary<string, MetaClass> membersGroup;
        NamespaceMembersGroups namespaceMembersGroupType;

        if (myStructureInfo.IsPublic)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.PublicStructures;
        }
        else if (myStructureInfo.IsProtectedInternal)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInternalStructures;
        }
        else if (myStructureInfo.IsProtected)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.ProtectedStructures;
        }
        else if (myStructureInfo.IsInternal)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.InternalStructures;
        }
        else if (myStructureInfo.IsPrivate)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.PrivateStructures;
        }
        else
        {
          Debug.Assert(false, "Impossible! Visibility of a type is not supported.");
          return;
        }

        membersGroup = GetMembersGroup(namespaceMembersGroupType);

        if (!membersGroup.ContainsKey(myStructureInfo.Name))
        {
          membersGroup.Add(myStructureInfo.Name, myStructureInfo);

          AddGenericNameMappingIfNeeded(myStructureInfo, namespaceMembersGroupType);
        }
        else
        {
          Logger.Warning("Structure named '{0}' has already been added to namespace {1}.", myStructureInfo.Name, name);
        }
      }
      else if (typeDefinition.IsInterface)
      {
        MyInterfaceInfo myInterfaceInfo = new MyInterfaceInfo(typeDefinition, assemblyName);
        Dictionary<string, MetaClass> membersGroup;
        NamespaceMembersGroups namespaceMembersGroupType;

        if (myInterfaceInfo.IsPublic)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.PublicInterfaces;
        }
        else if (myInterfaceInfo.IsProtectedInternal)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInternalInterfaces;
        }
        else if (myInterfaceInfo.IsProtected)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInterfaces;
        }
        else if (myInterfaceInfo.IsInternal)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.InternalInterfaces;
        }
        else if (myInterfaceInfo.IsPrivate)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.PrivateInterfaces;
        }
        else
        {
          Debug.Assert(false, "Impossible! Visibility of a type is not supported.");
          return;
        }

        membersGroup = GetMembersGroup(namespaceMembersGroupType);

        if (!membersGroup.ContainsKey(myInterfaceInfo.Name))
        {
          membersGroup.Add(myInterfaceInfo.Name, myInterfaceInfo);

          AddGenericNameMappingIfNeeded(myInterfaceInfo, namespaceMembersGroupType);
        }
        else
        {
          Logger.Warning("Interface named '{0}' has already been added to namespace {1}.", myInterfaceInfo.Name, name);
        }
      }
      else if (typeDefinition.IsEnum)
      {
        MyEnumerationInfo myEnumerationInfo = new MyEnumerationInfo(typeDefinition, assemblyName);
        Dictionary<string, MetaClass> membersGroup;
        NamespaceMembersGroups namespaceMembersGroupType;

        if (myEnumerationInfo.IsPublic)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.PublicEnumerations;
        }
        else if (myEnumerationInfo.IsProtectedInternal)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInternalEnumerations;
        }
        else if (myEnumerationInfo.IsProtected)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.ProtectedEnumerations;
        }
        else if (myEnumerationInfo.IsInternal)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.InternalEnumerations;
        }
        else if (myEnumerationInfo.IsPrivate)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.PrivateEnumerations;
        }
        else
        {
          Debug.Assert(false, "Impossible! Visibility of a type is not supported.");
          return;
        }

        membersGroup = GetMembersGroup(namespaceMembersGroupType);

        if (!membersGroup.ContainsKey(myEnumerationInfo.Name))
        {
          membersGroup.Add(myEnumerationInfo.Name, myEnumerationInfo);

          AddGenericNameMappingIfNeeded(myEnumerationInfo, namespaceMembersGroupType);
        }
        else
        {
          Logger.Warning("Enumeration named '{0}' has already been added to namespace {1}.", myEnumerationInfo.Name, name);
        }
      }
      else if (typeDefinition.IsClass && !Utils.IsDelegate(typeDefinition))
      {
        MyClassInfo myClassInfo = new MyClassInfo(typeDefinition, assemblyName);
        Dictionary<string, MetaClass> membersGroup;
        NamespaceMembersGroups namespaceMembersGroupType;

        if (myClassInfo.IsPublic)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.PublicClasses;
        }
        else if (myClassInfo.IsProtectedInternal)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInternalClasses;
        }
        else if (myClassInfo.IsProtected)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.ProtectedClasses;
        }
        else if (myClassInfo.IsInternal)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.InternalClasses;
        }
        else if (myClassInfo.IsPrivate)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.PrivateClasses;
        }
        else
        {
          Debug.Assert(false, "Impossible! Visibility of a type is not supported.");
          return;
        }

        membersGroup = GetMembersGroup(namespaceMembersGroupType);

        if (!membersGroup.ContainsKey(myClassInfo.Name))
        {
          membersGroup.Add(myClassInfo.Name, myClassInfo);

          AddGenericNameMappingIfNeeded(myClassInfo, namespaceMembersGroupType);
        }
        else
        {
          Logger.Warning("Class named '{0}' has already been added to namespace {1}.", myClassInfo.Name, name);
        }
      }
      else if (Utils.IsDelegate(typeDefinition))
      {
        MyDelegateInfo myDelegateInfo = new MyDelegateInfo(typeDefinition, assemblyName);
        Dictionary<string, MetaClass> membersGroup;
        NamespaceMembersGroups namespaceMembersGroupType;

        if (myDelegateInfo.IsPublic)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.PublicDelegates;
        }
        else if (myDelegateInfo.IsProtectedInternal)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInternalDelegates;
        }
        else if (myDelegateInfo.IsProtected)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.ProtectedDelegates;
        }
        else if (myDelegateInfo.IsInternal)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.InternalDelegates;
        }
        else if (myDelegateInfo.IsPrivate)
        {
          namespaceMembersGroupType = NamespaceMembersGroups.PrivateDelegates;
        }
        else
        {
          Debug.Assert(false, "Impossible! Visibility of a type is not supported.");
          return;
        }

        membersGroup = GetMembersGroup(namespaceMembersGroupType);

        if (!membersGroup.ContainsKey(myDelegateInfo.Name))
        {
          membersGroup.Add(myDelegateInfo.Name, myDelegateInfo);

          AddGenericNameMappingIfNeeded(myDelegateInfo, namespaceMembersGroupType);
        }
        else
        {
          Logger.Warning("Delegate named '{0}' has already been added to namespace {1}.", myDelegateInfo.Name, name);
        }
      }
      else
      {
        Logger.Warning("Unrecognized type: {0}.", typeDefinition.FullName);
      }
    }
Пример #2
0
    private void ProcessEnumerationMembers(MyEnumerationInfo myEnumerationInfo)
    {
      string namespaceDirName = GetNamespaceDirName(myEnumerationInfo.Namespace);
      string dirName = Utils.CombineMultiplePaths(myEnumerationInfo.AssemblyName + "_" + myEnumerationInfo.AssemblyName.GetHashCode(),
                                                  namespaceDirName,
                                                  CLASS_MEMBERS_DIRECTORY,
                                                  myEnumerationInfo.Name + "_" + myEnumerationInfo.Name.GetHashCode());

      List<MetaClass> fields = myEnumerationInfo.GetMembers(ClassMembersGroups.PublicFields);

      fields.AddRange(myEnumerationInfo.GetMembers(ClassMembersGroups.ProtectedFields));
      fields.AddRange(myEnumerationInfo.GetMembers(ClassMembersGroups.ProtectedInternalFields));

      if ((options & DocumentationGenerationOptions.IncludeInternalMembers) != 0)
      {
        fields.AddRange(myEnumerationInfo.GetMembers(ClassMembersGroups.InternalFields));
      }

      if ((options & DocumentationGenerationOptions.IncludePrivateMembers) != 0)
      {
        fields.AddRange(myEnumerationInfo.GetMembers(ClassMembersGroups.PrivateFields));
      }

      foreach (MyFieldInfo myFieldInfo in fields)
      {
        ProcessField(myFieldInfo, myEnumerationInfo, dirName);
      }
    }
Пример #3
0
        public void AddType(TypeDefinition typeDefinition)
        {
            if (typeDefinition.IsClass && !Utils.IsDelegate(typeDefinition))
            {
                MyClassInfo myClassInfo = new MyClassInfo(typeDefinition, assemblyName);
                Dictionary <string, MetaClass> membersGroup;
                NamespaceMembersGroups         namespaceMembersGroupType;

                if (myClassInfo.IsPublic)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.PublicClasses;
                }
                else if (myClassInfo.IsProtectedInternal)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInternalClasses;
                }
                else if (myClassInfo.IsProtected)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.ProtectedClasses;
                }
                else if (myClassInfo.IsInternal)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.InternalClasses;
                }
                else if (myClassInfo.IsPrivate)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.PrivateClasses;
                }
                else
                {
                    Debug.Assert(false, "Impossible! Visibility of a type is not supported.");
                    return;
                }

                membersGroup = GetMembersGroup(namespaceMembersGroupType);

                if (!membersGroup.ContainsKey(myClassInfo.Name))
                {
                    membersGroup.Add(myClassInfo.Name, myClassInfo);

                    AddGenericNameMappingIfNeeded(myClassInfo, namespaceMembersGroupType);
                }
                else
                {
                    Logger.Warning("Class named '{0}' has already been added to namespace {1}.", myClassInfo.Name, name);
                }
            }
            else if (typeDefinition.IsValueType && !typeDefinition.IsEnum)
            {
                MyStructureInfo myStructureInfo = new MyStructureInfo(typeDefinition, assemblyName);
                Dictionary <string, MetaClass> membersGroup;
                NamespaceMembersGroups         namespaceMembersGroupType;

                if (myStructureInfo.IsPublic)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.PublicStructures;
                }
                else if (myStructureInfo.IsProtectedInternal)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInternalStructures;
                }
                else if (myStructureInfo.IsProtected)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.ProtectedStructures;
                }
                else if (myStructureInfo.IsInternal)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.InternalStructures;
                }
                else if (myStructureInfo.IsPrivate)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.PrivateStructures;
                }
                else
                {
                    Debug.Assert(false, "Impossible! Visibility of a type is not supported.");
                    return;
                }

                membersGroup = GetMembersGroup(namespaceMembersGroupType);

                if (!membersGroup.ContainsKey(myStructureInfo.Name))
                {
                    membersGroup.Add(myStructureInfo.Name, myStructureInfo);

                    AddGenericNameMappingIfNeeded(myStructureInfo, namespaceMembersGroupType);
                }
                else
                {
                    Logger.Warning("Structure named '{0}' has already been added to namespace {1}.", myStructureInfo.Name, name);
                }
            }
            else if (typeDefinition.IsInterface)
            {
                MyInterfaceInfo myInterfaceInfo = new MyInterfaceInfo(typeDefinition, assemblyName);
                Dictionary <string, MetaClass> membersGroup;
                NamespaceMembersGroups         namespaceMembersGroupType;

                if (myInterfaceInfo.IsPublic)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.PublicInterfaces;
                }
                else if (myInterfaceInfo.IsProtectedInternal)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInternalInterfaces;
                }
                else if (myInterfaceInfo.IsProtected)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInterfaces;
                }
                else if (myInterfaceInfo.IsInternal)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.InternalInterfaces;
                }
                else if (myInterfaceInfo.IsPrivate)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.PrivateInterfaces;
                }
                else
                {
                    Debug.Assert(false, "Impossible! Visibility of a type is not supported.");
                    return;
                }

                membersGroup = GetMembersGroup(namespaceMembersGroupType);

                if (!membersGroup.ContainsKey(myInterfaceInfo.Name))
                {
                    membersGroup.Add(myInterfaceInfo.Name, myInterfaceInfo);

                    AddGenericNameMappingIfNeeded(myInterfaceInfo, namespaceMembersGroupType);
                }
                else
                {
                    Logger.Warning("Interface named '{0}' has already been added to namespace {1}.", myInterfaceInfo.Name, name);
                }
            }
            else if (typeDefinition.IsEnum)
            {
                MyEnumerationInfo myEnumerationInfo = new MyEnumerationInfo(typeDefinition, assemblyName);
                Dictionary <string, MetaClass> membersGroup;
                NamespaceMembersGroups         namespaceMembersGroupType;

                if (myEnumerationInfo.IsPublic)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.PublicEnumerations;
                }
                else if (myEnumerationInfo.IsProtectedInternal)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInternalEnumerations;
                }
                else if (myEnumerationInfo.IsProtected)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.ProtectedEnumerations;
                }
                else if (myEnumerationInfo.IsInternal)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.InternalEnumerations;
                }
                else if (myEnumerationInfo.IsPrivate)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.PrivateEnumerations;
                }
                else
                {
                    Debug.Assert(false, "Impossible! Visibility of a type is not supported.");
                    return;
                }

                membersGroup = GetMembersGroup(namespaceMembersGroupType);

                if (!membersGroup.ContainsKey(myEnumerationInfo.Name))
                {
                    membersGroup.Add(myEnumerationInfo.Name, myEnumerationInfo);

                    AddGenericNameMappingIfNeeded(myEnumerationInfo, namespaceMembersGroupType);
                }
                else
                {
                    Logger.Warning("Enumeration named '{0}' has already been added to namespace {1}.", myEnumerationInfo.Name, name);
                }
            }
            else if (Utils.IsDelegate(typeDefinition))
            {
                MyDelegateInfo myDelegateInfo = new MyDelegateInfo(typeDefinition, assemblyName);
                Dictionary <string, MetaClass> membersGroup;
                NamespaceMembersGroups         namespaceMembersGroupType;

                if (myDelegateInfo.IsPublic)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.PublicDelegates;
                }
                else if (myDelegateInfo.IsProtectedInternal)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.ProtectedInternalDelegates;
                }
                else if (myDelegateInfo.IsProtected)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.ProtectedDelegates;
                }
                else if (myDelegateInfo.IsInternal)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.InternalDelegates;
                }
                else if (myDelegateInfo.IsPrivate)
                {
                    namespaceMembersGroupType = NamespaceMembersGroups.PrivateDelegates;
                }
                else
                {
                    Debug.Assert(false, "Impossible! Visibility of a type is not supported.");
                    return;
                }

                membersGroup = GetMembersGroup(namespaceMembersGroupType);

                if (!membersGroup.ContainsKey(myDelegateInfo.Name))
                {
                    membersGroup.Add(myDelegateInfo.Name, myDelegateInfo);

                    AddGenericNameMappingIfNeeded(myDelegateInfo, namespaceMembersGroupType);
                }
                else
                {
                    Logger.Warning("Delegate named '{0}' has already been added to namespace {1}.", myDelegateInfo.Name, name);
                }
            }
            else
            {
                Logger.Warning("Unrecognized type: {0}.", typeDefinition.FullName);
            }
        }