/// <summary>
 /// Create an <see cref="Attribute"/>.
 /// </summary>
 public Attribute(AttributeTarget target, params TypeRefBase[] typeRefBases)
 {
     _target = target;
     foreach (TypeRefBase typeRefBase in typeRefBases)
     {
         CreateAttributeExpressions().Add(ConstructorRef.Find(typeRefBase));
     }
 }
        /// <summary>
        /// Get all non-static constructors for this type.
        /// </summary>
        public override NamedCodeObjectGroup GetConstructors(bool currentPartOnly)
        {
            // Find the constructor (ignore 'currentPartOnly', since delegates have no bodies)
            TypeRef        delegateTypeRef = CreateRef();
            ConstructorRef constructorRef  = GetConstructor(delegateTypeRef);

            return(new NamedCodeObjectGroup(constructorRef != null ? constructorRef.Reference : null));
        }
 /// <summary>
 /// Find the constructor of the specified <see cref="TypeRefBase"/> with the specified signature.
 /// </summary>
 /// <returns>A <see cref="ConstructorRef"/> to the constructor, or an <see cref="UnresolvedRef"/> if no match was found.</returns>
 public static TypeRefBase Find(TypeRefBase typeRefBase, bool isFirstOnLine, params TypeRefBase[] parameterTypes)
 {
     if (typeRefBase is TypeRef)
     {
         ConstructorRef constructorRef = ((TypeRef)typeRefBase).GetConstructor(parameterTypes);
         if (constructorRef != null)
         {
             constructorRef.IsFirstOnLine = isFirstOnLine;
             return(constructorRef);
         }
         return(new UnresolvedRef(typeRefBase.Name, isFirstOnLine));
     }
     return(null);
 }
        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;
            }
        }
예제 #5
0
 /// <summary>
 /// Create a <see cref="BaseInitializer"/> operator.
 /// </summary>
 public BaseInitializer(ConstructorRef constructorRef, params Expression[] parameters)
     : base(constructorRef, parameters)
 {
 }
예제 #6
0
 protected ConstructorInitializer(ConstructorRef constructorRef, params Expression[] parameters)
     : base(constructorRef, parameters)
 {
 }