Ejemplo n.º 1
0
 /// <summary>
 /// Find a field on the specified type <see cref="Alias"/> with the specified name.
 /// </summary>
 /// <returns>A <see cref="FieldRef"/> to the field, or an <see cref="UnresolvedRef"/> if no match was found.</returns>
 public static SymbolicRef Find(Alias typeAlias, string name, bool isFirstOnLine)
 {
     if (typeAlias != null)
     {
         FieldRef fieldRef = typeAlias.GetField(name);
         if (fieldRef != null)
         {
             fieldRef.IsFirstOnLine = isFirstOnLine;
             return(fieldRef);
         }
     }
     return(new UnresolvedRef(name, isFirstOnLine));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Find a field on the specified <see cref="TypeRefBase"/> with the specified name.
 /// </summary>
 /// <returns>A <see cref="FieldRef"/> to the field, or an <see cref="UnresolvedRef"/> if no match was found.</returns>
 public static SymbolicRef Find(TypeRefBase typeRefBase, string name, bool isFirstOnLine)
 {
     if (typeRefBase is TypeRef)
     {
         FieldRef fieldRef = ((TypeRef)typeRefBase).GetField(name);
         if (fieldRef != null)
         {
             fieldRef.IsFirstOnLine = isFirstOnLine;
             return(fieldRef);
         }
     }
     return(new UnresolvedRef(name, isFirstOnLine));
 }
        protected static void AsTextDescription(CodeWriter writer, MemberInfo memberInfo)
        {
            const RenderFlags flags = RenderFlags.ShowParentTypes | RenderFlags.NoPreAnnotations;

            switch (memberInfo.MemberType)
            {
            case MemberTypes.TypeInfo:
            case MemberTypes.NestedType:
                TypeRefBase.AsTextType(writer, (Type)memberInfo, flags | RenderFlags.Description);
                break;

            case MemberTypes.Constructor:
                ConstructorRef.AsTextConstructorInfo(writer, (ConstructorInfo)memberInfo, flags);
                break;

            case MemberTypes.Method:
                MethodRef.AsTextMethodInfo(writer, (MethodInfo)memberInfo, flags);
                break;

            case MemberTypes.Property:
                PropertyRef.AsTextPropertyInfo(writer, (PropertyInfo)memberInfo, flags);
                break;

            case MemberTypes.Field:
                FieldRef.AsTextFieldInfo(writer, (FieldInfo)memberInfo, flags);
                break;

            case MemberTypes.Event:
                EventRef.AsTextEventInfo(writer, (EventInfo)memberInfo, flags);
                break;

            default:
                writer.Write(memberInfo.ToString());
                break;
            }
        }