Beispiel #1
0
    private void ProcessPropertiesOverloads(MyPropertiesOverloadsInfo myPropertiesOverloadsInfo, MyClassInfo declaringType, string dirName)
    {
      if (myPropertiesOverloadsInfo.Count > 1)
      {
        CreatePropertiesOverloadsIndex(myPropertiesOverloadsInfo, declaringType, dirName);
      }

      string prefix = "P_";

      int index = -1;
      foreach (MyPropertyInfo myPropertyInfo in myPropertiesOverloadsInfo)
      {
        index++;
        string fileName = Utils.CombineMultiplePaths(dirName, prefix + GetMyPropertyInfoVisibilitModifiersCodeString(myPropertyInfo) + "_" + myPropertyInfo.Name + "_" + index + "_" + myPropertyInfo.Name.GetHashCode() + ".html");

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

        string paramsString = "(";
        bool first = true;
        foreach (string paramName in myPropertyInfo.ParametersNames)
        {
          MyParameterInfo myParameterInfo = myPropertyInfo.Parameters[paramName];

          if (!first)
          {
            paramsString += ", ";
          }

          paramsString += ProcessType(myParameterInfo.TypeFullName);

          first = false;
        }
        paramsString += ")";

        if (paramsString == "()") { paramsString = ""; }

        string pageTitle = Utils.HTMLEncode(declaringType.DisplayableName) + "." + Utils.HTMLEncode(myPropertyInfo.DisplayableName) + " Property " + paramsString;

        List<string> sectionsNames = new List<string>();

        sectionsNames.Add("Syntax");

        if (myPropertyInfo.ExceptionsDescrs.Count > 0)
        {
          sectionsNames.Add("Exceptions");
        }

        if (myPropertyInfo.Remarks != "")
        {
          sectionsNames.Add("Remarks");
        }

        if (myPropertyInfo.Example != "")
        {
          sectionsNames.Add("Example");
        }

        string[] sectionsNamesAndIndices = new string[sectionsNames.Count];
        for (int i = 0; i < sectionsNamesAndIndices.Length; i++)
        {
          sectionsNamesAndIndices[i] = sectionsNames[i] + ":" + i;
        }

        WriteIndexHeader(sw, pageTitle, sectionsNamesAndIndices);

        WriteIndexSummary(sw, myPropertyInfo.Summary);

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

        int sectionIndex = 0;

        WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex);

        string syntax = CreatePropertySyntaxString(myPropertyInfo);
        WriteIndexCodeBlockTable(sw, DEFAULT_LANGUAGE, syntax);

        WriteParametersAndReturnValueDescriptions(sw, myPropertyInfo.ParametersNames, myPropertyInfo.Parameters,
                                                  ((MyPropertyInfo)myPropertyInfo).TypeFullName,
                                                  ((MyPropertyInfo)myPropertyInfo).ReturnValueSummary,
                                                  true);

        WriteIndexSectionEnd(sw);

        sectionIndex++;

        if (myPropertyInfo.ExceptionsDescrs.Count > 0)
        {
          Debug.Assert(sectionsNames[sectionIndex] == "Exceptions", "Exceptions section was expected.");

          WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex);
          WriteIndexExceptionsTable(sw, myPropertyInfo.ExceptionsDescrs);
          WriteIndexSectionEnd(sw);

          sectionIndex++;
        }

        if (myPropertyInfo.Remarks != "")
        {
          Debug.Assert(sectionsNames[sectionIndex] == "Remarks", "Remarks section was expected.");

          WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex);
          WriteIndexRemarks(sw, myPropertyInfo.Remarks);
          WriteIndexSectionEnd(sw);

          sectionIndex++;
        }

        if (myPropertyInfo.Example != "")
        {
          Debug.Assert(sectionsNames[sectionIndex] == "Example", "There should be 'Example' section now.");

          WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex);
          WriteIndexExample(sw, myPropertyInfo.Example);
          WriteIndexSectionEnd(sw);

          sectionIndex++;
        }

        WriteIndexFooter(sw);

        sw.Close();
        fs.Close();
      }
    }
Beispiel #2
0
    private void CreatePropertiesOverloadsIndex(MyPropertiesOverloadsInfo myPropertiessOverloadsInfo, MyClassInfo declaringType, string dirName)
    {
      Debug.Assert(myPropertiessOverloadsInfo.Count > 1, "Impossible! We don't create overloads index when there are no overloads.");

      string prefix = "PO_";

      string fileName = Utils.CombineMultiplePaths(dirName, prefix + GetMyPropertyInfoVisibilitModifiersCodeString(myPropertiessOverloadsInfo[0]) + "_" + myPropertiessOverloadsInfo.Name + "_" + myPropertiessOverloadsInfo.Name.GetHashCode() + ".html");

      FileStream fs = new FileStream(GetAliasName(fileName), FileMode.Create, FileAccess.Write);
      StreamWriter sw = new StreamWriter(fs);

      string pageTitle = String.Format("{0}.{1} Property", Utils.HTMLEncode(declaringType.DisplayableName), Utils.HTMLEncode(myPropertiessOverloadsInfo[0].DisplayableName));

      string[] sectionsNamesAndIndices = { "Overload List:0" };
      int sectionIndex = 0;

      WriteIndexHeader(sw, pageTitle, sectionsNamesAndIndices);

      WriteIndexSummary(sw, myPropertiessOverloadsInfo.SummaryWithoutPrefix);

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

      WriteIndexSectionBegin(sw,
                             sectionsNamesAndIndices[sectionIndex].Substring(0, sectionsNamesAndIndices[sectionIndex].LastIndexOf(':')),
                             sectionIndex);

      WriteIndexMembersTableBegin(sw,
                                  DEFAULT_MEMBERS_COLUMNS_NAMES,
                                  TYPE_MEMBERS_COLUMNS_WIDTHS);

      int index = -1;
      foreach (MyPropertyInfo myPropertyInfo in myPropertiessOverloadsInfo)
      {
        IconsTypes iconsTypes = GetIconsTypes(myPropertyInfo, 0, 0);

        index++;

        string link = ResolvePropertyLink(myPropertyInfo, declaringType, index);

        string displayableName = Utils.HTMLEncode(myPropertyInfo.DisplayableName);
        string name = Utils.HTMLEncode(declaringType.DisplayableName + "." + displayableName + " (");

        if (myPropertyInfo.Parameters.Count > 0)
        {
          bool first = true;
          foreach (string parameterName in myPropertyInfo.ParametersNames)
          {
            MyParameterInfo myParameterInfo = myPropertyInfo.Parameters[parameterName];
            string processedType = ProcessType(myParameterInfo.TypeFullName);

            if (!first)
            {
              name += ", ";
            }

            name += processedType;

            first = false;
          }
        }

        WriteIndexMembersTableRow(sw,
                                  name + ")",
                                  link,
                                  myPropertyInfo.Summary,
                                  Icons.GetFileNames(iconsTypes),
                                  Icons.GetAltLabels(iconsTypes));
      }

      WriteIndexMembersTableEnd(sw);

      WriteIndexSectionEnd(sw);

      WriteIndexFooter(sw);

      sw.Close();
      fs.Close();
    }
Beispiel #3
0
    protected virtual void AddProperty(PropertyDefinition propertyDefinition)
    {
      MyPropertyInfo myPropertyInfo = new MyPropertyInfo(propertyDefinition, this);
      Dictionary<string, MetaClass> membersGroup;

      if (myPropertyInfo.IsPublic)
      {
        membersGroup = CreateAndGetMembersGroup(ClassMembersGroups.PublicPropertiesOverloads);
      }
      else if (myPropertyInfo.IsProtectedInternal)
      {
        membersGroup = CreateAndGetMembersGroup(ClassMembersGroups.ProtectedInternalPropertiesOverloads);
      }
      else if (myPropertyInfo.IsProtected)
      {
        membersGroup = CreateAndGetMembersGroup(ClassMembersGroups.ProtectedPropertiesOverloads);
      }
      else if (myPropertyInfo.IsInternal)
      {
        membersGroup = CreateAndGetMembersGroup(ClassMembersGroups.InternalPropertiesOverloads);
      }
      else if (myPropertyInfo.IsPrivate)
      {
        membersGroup = CreateAndGetMembersGroup(ClassMembersGroups.PrivatePropertiesOverloads);
      }
      else
      {
        Debug.Assert(false, "Impossible! Visibility of a member is not supported.");
        return;
      }

      MyPropertiesOverloadsInfo propertiesOverloads;
      if (!membersGroup.ContainsKey(myPropertyInfo.Name))
      {
        propertiesOverloads = new MyPropertiesOverloadsInfo(myPropertyInfo.Name);
        membersGroup[myPropertyInfo.Name] = propertiesOverloads;
      }
      else
      {
        propertiesOverloads = (MyPropertiesOverloadsInfo)membersGroup[myPropertyInfo.Name];
      }

      propertiesOverloads.AddProperty(myPropertyInfo);
    }