/// <summary> /// Gets the type T specified in [typeOfAttribute(typeof(T))] if specified. /// </summary> /// <param name="type">Type possibly having the attribute named "typeofAttribute".</param> /// <param name="typeOfAttribute">The type of the attribute that has the type T as its argument.</param> /// <returns>TypeNode for the type specified in the attribute, or null if the attribute is not present.</returns> internal static TypeNode/*?*/ GetTypeFromAttribute(TypeNode type, TypeNode typeOfAttribute) { if (type == null) return null; AttributeNode contractClass = type.GetAttribute(typeOfAttribute); if (contractClass == null) return null; Expression typeExpr = contractClass.GetPositionalArgument(0); if (typeExpr == null) return null; Literal typeLiteral = typeExpr as Literal; if (typeLiteral == null) return null; TypeNode typeNode = typeLiteral.Value as TypeNode; if (typeNode == null) return null; return typeNode; }