/// <summary> /// 获取特性声明的AttributeCtorUsageAtribute是否声明了指定目标 /// </summary> /// <param name="attributeData"></param> /// <param name="targets">指定目标</param> /// <returns></returns> private bool CtorAttribueIsDefind(AttributeData attributeData, AttributeCtorTargets targets) { var ctorAttributes = attributeData.AttributeConstructor?.GetAttributes(); if (ctorAttributes.HasValue == false) { return(true); } var ctorUsageAttribute = ctorAttributes.Value .FirstOrDefault(item => item.AttributeClass.Equals(this.webApiClientContext.AttributeCtorUsageAtributeType)); if (ctorUsageAttribute == null) { return(true); } var arg = ctorUsageAttribute.ConstructorArguments.FirstOrDefault(); if (arg.IsNull == true) { return(true); } var ctorTargets = (AttributeCtorTargets)arg.Value; return(ctorTargets.HasFlag(targets)); }
/// <summary> /// 特性的构造函数使用范围 /// </summary> /// <param name="targets">使用范围</param> public AttributeCtorUsageAttribute(AttributeCtorTargets targets) { this.Targets = targets; }