コード例 #1
0
ファイル: HTMLDocumenter.cs プロジェクト: Q42/ImmDoc.NET
    private void CreateNamespaceMemberMembersIndex(MetaClass namespaceMember, NamespaceMembersGroups namespaceMembersGroupType)
    {
      if (namespaceMembersGroupType == NamespaceMembersGroups.PublicEnumerations || namespaceMembersGroupType == NamespaceMembersGroups.PublicDelegates
       || namespaceMembersGroupType == NamespaceMembersGroups.ProtectedInternalEnumerations || namespaceMembersGroupType == NamespaceMembersGroups.ProtectedInternalDelegates
       || namespaceMembersGroupType == NamespaceMembersGroups.ProtectedEnumerations || namespaceMembersGroupType == NamespaceMembersGroups.ProtectedDelegates
       || namespaceMembersGroupType == NamespaceMembersGroups.InternalEnumerations || namespaceMembersGroupType == NamespaceMembersGroups.InternalDelegates
       || namespaceMembersGroupType == NamespaceMembersGroups.PrivateEnumerations || namespaceMembersGroupType == NamespaceMembersGroups.PrivateDelegates)
      {
        Debug.Assert(false, String.Format("Impossible! We don't want to create member's index of type '{0}'.", namespaceMember.GetType()));
        return;
      }

      MyClassInfo myClassInfo = (MyClassInfo)namespaceMember;

      string namespaceDirName = GetNamespaceDirName(myClassInfo.Namespace);
      string indexFileName = Utils.CombineMultiplePaths(myClassInfo.AssemblyName + "_" + myClassInfo.AssemblyName.GetHashCode(),
                                                        namespaceDirName,
                                                        "MS_" + myClassInfo.Name + "_" + myClassInfo.Name.GetHashCode() + ".html");

	  string filename = Utils.CombineMultiplePaths(outputDirectory, CONTENTS_DIRECTORY, GetAliasName(indexFileName));			
			
      FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write);
      StreamWriter sw = new StreamWriter(fs);

      string memberTypeName = "";
      switch (namespaceMembersGroupType)
      {
        case NamespaceMembersGroups.PublicClasses: memberTypeName = "Class"; break;
        case NamespaceMembersGroups.PublicInterfaces: memberTypeName = "Interface"; break;
        case NamespaceMembersGroups.PublicStructures: memberTypeName = "Structure"; break;
        case NamespaceMembersGroups.ProtectedInternalClasses: memberTypeName = "Class"; break;
        case NamespaceMembersGroups.ProtectedInternalInterfaces: memberTypeName = "Interface"; break;
        case NamespaceMembersGroups.ProtectedInternalStructures: memberTypeName = "Structure"; break;
        case NamespaceMembersGroups.ProtectedClasses: memberTypeName = "Class"; break;
        case NamespaceMembersGroups.ProtectedInterfaces: memberTypeName = "Interface"; break;
        case NamespaceMembersGroups.ProtectedStructures: memberTypeName = "Structure"; break;
        case NamespaceMembersGroups.InternalClasses: memberTypeName = "Class"; break;
        case NamespaceMembersGroups.InternalInterfaces: memberTypeName = "Interface"; break;
        case NamespaceMembersGroups.InternalStructures: memberTypeName = "Structure"; break;
        case NamespaceMembersGroups.PrivateClasses: memberTypeName = "Class"; break;
        case NamespaceMembersGroups.PrivateInterfaces: memberTypeName = "Interface"; break;
        case NamespaceMembersGroups.PrivateStructures: memberTypeName = "Structure"; break;

        default: Debug.Assert(false, "Impossible! Couldn't obtain member's type name."); break;
      }
      string pageTitle = String.Format("{0} {1} Members", Utils.HTMLEncode(myClassInfo.Name.Replace('/', '.')), memberTypeName);

      string[] sectionsShortcutsNamesAndIndices = ObtainListOfMembersSectionsShortcutsNamesAndIndices(myClassInfo);
      string[] sectionsNames = ObtainListOfMembersSectionsNames(myClassInfo);

      WriteIndexHeader(sw, pageTitle, sectionsShortcutsNamesAndIndices);

      WriteIndexSummary(sw, myClassInfo.Summary);

      WriteIndexItemLocation(sw,
                             myClassInfo.DisplayableName,
                             myClassInfo.Namespace,
                             myClassInfo.AssemblyName,
                             ResolveNamespaceMemberLink(myClassInfo.AssemblyName, myClassInfo.Namespace, myClassInfo.Name),
                             ResolveNamespaceLink(myClassInfo.AssemblyName, myClassInfo.Namespace),
                             ResolveAssemblyLink(myClassInfo.AssemblyName));

      int sectionIndex = 0;
      int sectionNameIndex = 0;
      int classMembersGroupTypeIndex = 0;

      while (Enum.IsDefined(typeof(ClassMembersGroups), classMembersGroupTypeIndex))
      {
        ClassMembersGroups classMembersGroupType = (ClassMembersGroups)classMembersGroupTypeIndex;

        if (myClassInfo.GetMembersCount(classMembersGroupType) > 0)
        {
          WriteMembersIndex(sw, sectionsNames[sectionNameIndex++], sectionIndex,
                            myClassInfo.GetEnumerator(classMembersGroupType),
                            DEFAULT_MEMBERS_COLUMNS_NAMES,
                            TYPE_MEMBERS_COLUMNS_WIDTHS,
                            0, classMembersGroupType);
        }

        classMembersGroupTypeIndex++;
        sectionIndex++;
      }

      WriteIndexFooter(sw);

      sw.Close();
      fs.Close();
    }
コード例 #2
0
ファイル: HTMLDocumenter.cs プロジェクト: Q42/ImmDoc.NET
    private string ResolveTypeMemberLink(MetaClass metaClass)
    {
      if (metaClass == null)
      {
        return null;
      }

      string namespaceDirName;

      Debug.Assert(!(metaClass is MyInvokableMemberInfo), "Can't resolve link of invokableMember without knowing its number in overloadsList.");
      Debug.Assert(!(metaClass is MyPropertyInfo), "Can't resolve link of property without knowing its number in overloadsList.");

      MyClassInfo declaringType = metaClass.DeclaringType;

      Debug.Assert(declaringType != null, String.Format("Impossible! In order to resolve type member link this member has to contain reference to the declaring type ({0}).", metaClass.Name + " : " + metaClass.GetType()));

      if (metaClass is MyNestedTypeInfo)
      {
        namespaceDirName = GetNamespaceDirName(declaringType.Namespace);

        string fullName = ((MyNestedTypeInfo)metaClass).FullName;

        return GetAliasName(declaringType.AssemblyName + "_" + declaringType.AssemblyName.GetHashCode()
                          + Path.DirectorySeparatorChar + namespaceDirName
                          + Path.DirectorySeparatorChar + "SM_" + fullName
                          + "_" + fullName.GetHashCode() + ".html",
                          true, true);
      }

      string prefix = "";
      string suffix = "";

      if (metaClass is MyEventInfo) { prefix = "E_"; }
      else if (metaClass is MyFieldInfo) { prefix = "F_"; }
      else if (metaClass is MyInvokableMembersOverloadsInfo)
      {
        MyInvokableMembersOverloadsInfo overloads = (MyInvokableMembersOverloadsInfo)metaClass;

        if (overloads[0] is MyMethodInfo)
        {
          if (overloads.Count > 1) { prefix = "MO_" + GetMyInvokableMemberVisibilitModifiersCodeString(overloads[0]) + "_"; }
          else { prefix = "M_" + GetMyInvokableMemberVisibilitModifiersCodeString(overloads[0]) + "_"; suffix = "_0"; }
        }
        else // overloads[0] is MyConstructorInfo
        {
          Debug.Assert(overloads[0] is MyConstructorInfo, "Impossible! There should MyConstructorInfo object.");

          if (overloads.Count > 1) { prefix = "CO_" + GetMyInvokableMemberVisibilitModifiersCodeString(overloads[0]) + "_"; }
          else { prefix = "C_" + GetMyInvokableMemberVisibilitModifiersCodeString(overloads[0]) + "_"; suffix = "_0"; }
        }
      }
      else if (metaClass is MyPropertiesOverloadsInfo)
      {
        MyPropertiesOverloadsInfo overloads = (MyPropertiesOverloadsInfo)metaClass;

        if (overloads.Count > 1) { prefix = "PO_" + GetMyPropertyInfoVisibilitModifiersCodeString(overloads[0]) + "_"; }
        else { prefix = "P_" + GetMyPropertyInfoVisibilitModifiersCodeString(overloads[0]) + "_"; suffix = "_0"; }
      }

      namespaceDirName = GetNamespaceDirName(declaringType.Namespace);

      return GetAliasName(declaringType.AssemblyName + "_" + declaringType.AssemblyName.GetHashCode()
                        + Path.DirectorySeparatorChar + namespaceDirName
                        + Path.DirectorySeparatorChar + CLASS_MEMBERS_DIRECTORY
                        + Path.DirectorySeparatorChar + declaringType.Name + "_" + declaringType.Name.GetHashCode()
                        + Path.DirectorySeparatorChar + prefix + metaClass.Name + suffix + "_" + metaClass.Name.GetHashCode() + ".html",
                          true, true);
    }
コード例 #3
0
ファイル: HTMLDocumenter.cs プロジェクト: Q42/ImmDoc.NET
    private string ResolveLink(MetaClass metaClass)
    {
      if (metaClass is MyAssemblyInfo)
      {
        return ResolveAssemblyLink(((MyAssemblyInfo)metaClass).Name);
      }
      else if (metaClass is MyNamespaceInfo)
      {
        MyNamespaceInfo myNamespaceInfo = (MyNamespaceInfo)metaClass;

        return ResolveNamespaceLink(myNamespaceInfo.AssemblyName, myNamespaceInfo.Name);
      }
      else if (metaClass is MyClassInfo)
      {
        MyClassInfo namespaceMemberInfo = (MyClassInfo)metaClass;

        return ResolveNamespaceMemberLink(namespaceMemberInfo.AssemblyName, namespaceMemberInfo.Namespace, namespaceMemberInfo.Name);
      }
      else if ((metaClass is MyFieldInfo) || (metaClass is MyInvokableMembersOverloadsInfo) || (metaClass is MyPropertiesOverloadsInfo) || (metaClass is MyNestedTypeInfo) || (metaClass is MyEventInfo))
      {
        return ResolveTypeMemberLink(metaClass);
      }
      else if (metaClass is MyPropertyInfo)
      {
        MyPropertyInfo myPropertyInfo = (MyPropertyInfo)metaClass;

        Debug.Assert(myPropertyInfo.DeclaringType != null, "Impossible! No declaring type.");
        Debug.Assert(myPropertyInfo.IndexInOverloadsList != -1, "Impossible! Unknown index in overloads list.");

        return ResolvePropertyLink(myPropertyInfo, myPropertyInfo.DeclaringType, myPropertyInfo.IndexInOverloadsList);
      }
      else if (metaClass is MyInvokableMemberInfo)
      {
        MyInvokableMemberInfo myInvokableMemberInfo = (MyInvokableMemberInfo)metaClass;

        Debug.Assert(myInvokableMemberInfo.DeclaringType != null, "Impossible! No declaring type.");
        Debug.Assert(myInvokableMemberInfo.IndexInOverloadsList != -1, "Impossible! Unknown index in overloads list.");

        return ResolveInvokableMemberLink(myInvokableMemberInfo, myInvokableMemberInfo.DeclaringType, myInvokableMemberInfo.IndexInOverloadsList);
      }
      else
      {
        Debug.Assert(false, String.Format("Impossible! Couldn't recognize the type of member for which a link should be resolved ('{0}').", metaClass.Name + " : " + metaClass.GetType()));

        return null;
      }
    }
コード例 #4
0
ファイル: HTMLDocumenter.cs プロジェクト: Q42/ImmDoc.NET
    private void CreateTOCTreeViewAux(MetaClass metaClass, string treePath, StringBuilder sb)
    {
      Debug.Assert(metaClass != null, "ArgumentNullException(metaClass)");
      Debug.Assert(sb != null, "ArgumentNullException(sb)");
      Debug.Assert(metaClass is ISummarisableMember, "Meta class must implement ISummarisableMember interface.");

      bool hasChildren = HasChildren(metaClass);

      string label = Utils.HTMLEncode(metaClass.Name.Replace('/', '.')) + " " + metaClass.GetMetaName();
      string href = ResolveLink(metaClass);
      string link = String.Format("<a href=\"{0}\" class=\"TV_NodeLink\" target=\"ContentsFrame\" onclick=\"TV_NodeLink_Clicked(this, '{2}');\">{1}</a>", string.IsNullOrEmpty(href) ? "javascript: void(0);" : href, label, treePath);

      string id = "";
      string imgSrc = "../../" + GRAPHICS_DIRECTORY + "/TV_Null.gif";
      string onclick = "";
      string alt = "";

      if (hasChildren)
      {
        id = " id=\"TV_NodeExpansionIcon_" + treePath + "\"";
        onclick = " onclick=\"TV_Node_Clicked('" + treePath + "');\"";
        imgSrc = "../../" + GRAPHICS_DIRECTORY + "/TV_Plus.gif";
        alt = "Expand/Collapse";
      }

      sb.Append("<div class=\"TV_NodeContainer\">\n");
      sb.Append(String.Format("<img{0} class=\"TV_NodeExpansionIcon\" src=\"{1}\"{2} alt=\"{3}\" />\n", id, imgSrc, onclick, alt));
      sb.Append(String.Format("<span class=\"TV_NodeLabel\">{0}</span>\n", link));
      sb.Append("</div>\n");

      if (hasChildren)
      {
        sb.Append(String.Format("<div class=\"TV_SubtreeContainer\" id=\"TV_Subtree_{0}\">\n", treePath));

        if (metaClass is MyAssemblyInfo)
        {
          MyAssemblyInfo myAssemblyInfo = (MyAssemblyInfo)metaClass;
          int number = 1;

          foreach (MyNamespaceInfo myNamespaceInfo in myAssemblyInfo.Namespaces.OrderBy(s => s.DisplayableName))
          {
            CreateTOCTreeViewAux(myNamespaceInfo, treePath + "_" + number, sb);
            number++;
          }
        }
        else if (metaClass is MyNamespaceInfo)
        {
          MyNamespaceInfo myNamespaceInfo = (MyNamespaceInfo)metaClass;
          int number1 = 1;

          IEnumerable<MetaClass> members = myNamespaceInfo.GetEnumerator();

          foreach (MetaClass member in members)
          {
            string newTreePath = treePath + "_" + number1;

            CreateTOCTreeViewAux(member, newTreePath + "_" + number1, sb);

            number1++;
          }
        }
        else if (metaClass is MyClassInfo)
        {
          if (!(metaClass is MyDelegateInfo) && !(metaClass is MyEnumerationInfo))
          {
            MyClassInfo myClassInfo = (MyClassInfo)metaClass;

            id = " id=\"TV_NodeExpansionIcon_" + treePath + "_1" + "\"";
            onclick = " onclick=\"TV_Node_Clicked('" + treePath + "_1" + "');\"";

            string namespaceDirName = GetNamespaceDirName(myClassInfo.Namespace);
            href = GetAliasName(myClassInfo.AssemblyName + "_" + myClassInfo.AssemblyName.GetHashCode()
                              + Path.DirectorySeparatorChar + namespaceDirName + Path.DirectorySeparatorChar
                              + "MS_" + myClassInfo.Name + "_" + myClassInfo.Name.GetHashCode() + ".html",
                                true, true);

            sb.Append("<div class=\"TV_NodeContainer\">\n");
            sb.Append("<img class=\"TV_NodeExpansionIcon\" src=\"../../" + GRAPHICS_DIRECTORY + "/TV_Null.gif\" alt=\"\" />\n");
            sb.Append(String.Format("<span class=\"TV_NodeLabel\"><a href=\"{0}\" class=\"TV_NodeLink\" target=\"ContentsFrame\" onclick=\"TV_NodeLink_Clicked(this, null);\">Members</a></span>\n", href));
            sb.Append("</div>\n");
          }
        }
        else
        {
          Debug.Assert(false, "Impossible! Couldn't recognize type of a metaclass (" + metaClass.GetType() + ").");
        }

        sb.Append("</div>\n");
      }
    }
コード例 #5
0
ファイル: HTMLDocumenter.cs プロジェクト: Q42/ImmDoc.NET
    private void CreateCHMTOCAux(MetaClass metaClass, StreamWriter sw)
    {
      Debug.Assert(metaClass != null, "ArgumentNullException(metaClass)");
      Debug.Assert(sw != null, "ArgumentNullException(sb)");
      Debug.Assert(metaClass is ISummarisableMember, "Meta class must implement ISummarisableMember interface.");

      bool hasChildren = HasChildren(metaClass);

      string label = Utils.HTMLEncode(metaClass.Name.Replace('/', '.')) + " " + metaClass.GetMetaName();
      string href = ResolveLink(metaClass);

      Debug.Assert(href.StartsWith("../../"), "Impossible (1)! href should start with '../../'!");
      href = href.Substring("../../".Length);

      sw.WriteLine("<LI> <OBJECT type=\"text/sitemap\">");
      sw.WriteLine("<param name=\"ImageNumber\" value=\"1\">");
      sw.WriteLine("<param name=\"Name\" value=\"{0}\">", label);
      sw.WriteLine("<param name=\"Local\" value=\"{0}\">", href);
      sw.WriteLine("</OBJECT>");

      if (hasChildren)
      {
        sw.Write("<UL>");

        if (metaClass is MyAssemblyInfo)
        {
          MyAssemblyInfo myAssemblyInfo = (MyAssemblyInfo)metaClass;
          int number = 1;

          foreach (MyNamespaceInfo myNamespaceInfo in myAssemblyInfo.Namespaces)
          {
            CreateCHMTOCAux(myNamespaceInfo, sw);
            number++;
          }
        }
        else if (metaClass is MyNamespaceInfo)
        {
          MyNamespaceInfo myNamespaceInfo = (MyNamespaceInfo)metaClass;
          IEnumerable<MetaClass> members = myNamespaceInfo.GetEnumerator();

          foreach (MetaClass member in members)
          {
            CreateCHMTOCAux(member, sw);
          }
        }
        else if (metaClass is MyClassInfo)
        {
          if (!(metaClass is MyDelegateInfo) && !(metaClass is MyEnumerationInfo))
          {
            MyClassInfo myClassInfo = (MyClassInfo)metaClass;
            string namespaceDirName = GetNamespaceDirName(myClassInfo.Namespace);

            href = GetAliasName(myClassInfo.AssemblyName + "_" + myClassInfo.AssemblyName.GetHashCode()
                              + Path.DirectorySeparatorChar + namespaceDirName + Path.DirectorySeparatorChar
                              + "MS_" + myClassInfo.Name + "_" + myClassInfo.Name.GetHashCode() + ".html",
                                true, true);

            Debug.Assert(href.StartsWith("../../"), "Impossible (2)! href should start with '../../'!");
            href = href.Substring("../../".Length);

            sw.WriteLine("<LI> <OBJECT type=\"text/sitemap\">");
            sw.WriteLine("<param name=\"Name\" value=\"Members\">");
            sw.WriteLine("<param name=\"Local\" value=\"{0}\">", href);
            sw.WriteLine("</OBJECT>");
          }
        }
        else
        {
          Debug.Assert(false, "Impossible! Couldn't recognize type of a metaclass (" + metaClass.GetType() + ").");
        }

        sw.Write("</UL>\n");
      }
    }