Exemplo n.º 1
0
        public static string GetCommentIdForType(Type type)
        {
            StringBuilder stringBuilder = new StringBuilder("T:");

            XmlCommentsIdHelper.AppendFullTypeName(type, stringBuilder, false);
            return(stringBuilder.ToString());
        }
Exemplo n.º 2
0
        public static string GetCommentIdForProperty(PropertyInfo propertyInfo)
        {
            StringBuilder stringBuilder = new StringBuilder("P:");

            XmlCommentsIdHelper.AppendFullTypeName(propertyInfo.DeclaringType, stringBuilder, false);
            stringBuilder.Append(".");
            XmlCommentsIdHelper.AppendPropertyName(propertyInfo, stringBuilder);
            return(stringBuilder.ToString());
        }
Exemplo n.º 3
0
        public static string GetCommentIdForMethod(MethodInfo methodInfo)
        {
            StringBuilder stringBuilder = new StringBuilder("M:");

            XmlCommentsIdHelper.AppendFullTypeName(methodInfo.DeclaringType, stringBuilder, false);
            stringBuilder.Append(".");
            XmlCommentsIdHelper.AppendMethodName(methodInfo, stringBuilder);
            return(stringBuilder.ToString());
        }
Exemplo n.º 4
0
 private static void AppendTypeName(Type type, StringBuilder builder, bool expandGenericArgs)
 {
     if (type.IsNested)
     {
         XmlCommentsIdHelper.AppendTypeName(type.DeclaringType, builder, false);
         builder.Append(".");
     }
     builder.Append(type.Name);
     if (expandGenericArgs)
     {
         XmlCommentsIdHelper.ExpandGenericArgsIfAny(type, builder);
     }
 }
Exemplo n.º 5
0
 private static void AppendMethodName(MethodInfo methodInfo, StringBuilder builder)
 {
     builder.Append(methodInfo.Name);
     ParameterInfo[] parameters = methodInfo.GetParameters();
     if (parameters.Length == 0)
     {
         return;
     }
     builder.Append("(");
     ParameterInfo[] array = parameters;
     for (int i = 0; i < array.Length; i++)
     {
         ParameterInfo parameterInfo = array[i];
         XmlCommentsIdHelper.AppendFullTypeName(parameterInfo.ParameterType, builder, true);
         builder.Append(",");
     }
     builder.Replace(",", ")", builder.Length - 1, 1);
 }
Exemplo n.º 6
0
        private void ApplyPropertyComments(Schema propertySchema, PropertyInfo propertyInfo)
        {
            if (propertyInfo == null)
            {
                return;
            }
            string         commentIdForProperty = XmlCommentsIdHelper.GetCommentIdForProperty(propertyInfo);
            XPathNavigator xPathNavigator       = this._navigator.SelectSingleNode(string.Format("/doc/members/member[@name='{0}']", commentIdForProperty));

            if (xPathNavigator == null)
            {
                return;
            }
            XPathNavigator xPathNavigator2 = xPathNavigator.SelectSingleNode("summary");

            if (xPathNavigator2 != null)
            {
                propertySchema.description = xPathNavigator2.ExtractContent();
            }
        }
Exemplo n.º 7
0
        public void Apply(Schema model, ModelFilterContext context)
        {
            string         commentIdForType = XmlCommentsIdHelper.GetCommentIdForType(context.SystemType);
            XPathNavigator xPathNavigator   = this._navigator.SelectSingleNode(string.Format("/doc/members/member[@name='{0}']", commentIdForType));

            if (xPathNavigator != null)
            {
                XPathNavigator xPathNavigator2 = xPathNavigator.SelectSingleNode("summary");
                if (xPathNavigator2 != null)
                {
                    model.description = xPathNavigator2.ExtractContent();
                }
            }
            foreach (KeyValuePair <string, Schema> current in model.properties)
            {
                JsonProperty jsonProperty = context.JsonObjectContract.Properties[current.Key];
                if (jsonProperty != null)
                {
                    this.ApplyPropertyComments(current.Value, jsonProperty.PropertyInfo());
                }
            }
        }
Exemplo n.º 8
0
 public static void ExpandGenericArgsIfAny(Type type, StringBuilder builder)
 {
     if (type.IsGenericType)
     {
         StringBuilder stringBuilder    = new StringBuilder("{");
         Type[]        genericArguments = type.GetGenericArguments();
         Type[]        array            = genericArguments;
         for (int i = 0; i < array.Length; i++)
         {
             Type type2 = array[i];
             XmlCommentsIdHelper.AppendFullTypeName(type2, stringBuilder, true);
             stringBuilder.Append(",");
         }
         stringBuilder.Replace(",", "}", stringBuilder.Length - 1, 1);
         builder.Replace(string.Format("`{0}", genericArguments.Length), stringBuilder.ToString());
         return;
     }
     if (type.IsArray)
     {
         XmlCommentsIdHelper.ExpandGenericArgsIfAny(type.GetElementType(), builder);
     }
 }
Exemplo n.º 9
0
 private static void AppendFullTypeName(Type type, StringBuilder builder, bool expandGenericArgs = false)
 {
     builder.Append(type.Namespace);
     builder.Append(".");
     XmlCommentsIdHelper.AppendTypeName(type, builder, expandGenericArgs);
 }