/// <summary> /// Get the declaring type of the specified property object. /// </summary> /// <param name="propertyObj">The property object (a <see cref="PropertyDeclBase"/> or <see cref="PropertyInfo"/>).</param> /// <returns>The <see cref="TypeRef"/> of the declaring type, or null if it can't be determined.</returns> public static TypeRefBase GetDeclaringType(object propertyObj) { TypeRefBase declaringTypeRef = null; if (propertyObj is PropertyDeclBase) { TypeDecl declaringTypeDecl = ((PropertyDeclBase)propertyObj).DeclaringType; declaringTypeRef = (declaringTypeDecl != null ? declaringTypeDecl.CreateRef() : null); } else if (propertyObj is PropertyInfo) { declaringTypeRef = TypeRef.Create(((PropertyInfo)propertyObj).DeclaringType); } return(declaringTypeRef); }
/// <summary> /// Get the declaring type of the specified enum member object. /// </summary> /// <param name="enumMemberObj">The enum member object (a <see cref="EnumMemberDecl"/> or <see cref="FieldInfo"/>).</param> /// <returns>The <see cref="TypeRef"/> of the declaring type, or null if it can't be determined.</returns> public static TypeRefBase GetDeclaringType(object enumMemberObj) { TypeRefBase declaringTypeRef = null; if (enumMemberObj is EnumMemberDecl) { TypeDecl declaringTypeDecl = ((EnumMemberDecl)enumMemberObj).ParentEnumDecl; declaringTypeRef = (declaringTypeDecl != null ? declaringTypeDecl.CreateRef() : null); } else if (enumMemberObj is FieldInfo) { declaringTypeRef = TypeRef.Create(((FieldInfo)enumMemberObj).DeclaringType); } return(declaringTypeRef); }
/// <summary> /// Get the declaring type of the specified field object. /// </summary> /// <param name="fieldObj">The field object (a <see cref="FieldDecl"/> or <see cref="FieldInfo"/>).</param> /// <returns>The <see cref="TypeRef"/> of the declaring type, or null if it can't be determined.</returns> public static TypeRefBase GetDeclaringType(object fieldObj) { TypeRefBase declaringTypeRef; if (fieldObj is FieldDecl) { TypeDecl declaringTypeDecl = ((FieldDecl)fieldObj).DeclaringType; declaringTypeRef = (declaringTypeDecl != null ? declaringTypeDecl.CreateRef() : null); } else //if (fieldObj is FieldInfo) { declaringTypeRef = TypeRef.Create(((FieldInfo)fieldObj).DeclaringType); } return(declaringTypeRef); }
/// <summary> /// Get the declaring type of the specified event object. /// </summary> /// <param name="eventObj">The event object (an <see cref="EventDecl"/> or <see cref="EventInfo"/>).</param> /// <returns>The <see cref="TypeRef"/> of the declaring type, or null if it can't be determined.</returns> public static TypeRefBase GetDeclaringType(object eventObj) { TypeRefBase declaringTypeRef; if (eventObj is EventDecl) { TypeDecl declaringTypeDecl = ((EventDecl)eventObj).DeclaringType; declaringTypeRef = (declaringTypeDecl != null ? declaringTypeDecl.CreateRef() : null); } else //if (eventObj is EventInfo) { declaringTypeRef = TypeRef.Create(((EventInfo)eventObj).DeclaringType); } return(declaringTypeRef); }
/// <summary> /// Create a <see cref="NewObject"/>. /// </summary> /// <param name="typeDecl">The TypeDecl of the object being created.</param> /// <param name="parameters">The constructor parameters (if any).</param> public NewObject(TypeDecl typeDecl, params Expression[] parameters) : base(typeDecl.CreateRef(), parameters) { }