| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.Reflection; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.Description |
| | | 9 | | { |
| | | 10 | | // goal of this class to move logic from TypeLoader to build message contract |
| | | 11 | | internal static class MessageContractHelper |
| | | 12 | | { |
| | | 13 | | internal static bool IsMessageContract(Type type) |
| | | 14 | | { |
| | 41836 | 15 | | foreach (Attribute attr in type.GetCustomAttributes(inherit: false)) |
| | | 16 | | { |
| | 16832 | 17 | | if (attr.GetType() == typeof(MessageContractAttribute) |
| | 16832 | 18 | | || (string.Compare(attr.GetType().FullName, ServiceReflector.SMMessageContractAttributeFullName, true) = |
| | | 19 | | { |
| | 332 | 20 | | return true; |
| | | 21 | | } |
| | | 22 | | } |
| | 3920 | 23 | | return false; |
| | | 24 | | } |
| | | 25 | | |
| | 4 | 26 | | private static HashSet<string> s_eligibleMessageList = new HashSet<string>() |
| | 4 | 27 | | { |
| | 4 | 28 | | ServiceReflector.CWCFMessageHeaderAttribute, |
| | 4 | 29 | | ServiceReflector.CWCFMessageHeaderArrayAttribute, |
| | 4 | 30 | | ServiceReflector.CWCFMessageBodyMemberAttribute, |
| | 4 | 31 | | ServiceReflector.CWCFMessagePropertyAttribute, |
| | 4 | 32 | | ServiceReflector.SMMessageHeaderAttributeFullName, |
| | 4 | 33 | | ServiceReflector.SMMessageHeaderArrayAttributeFullName, |
| | 4 | 34 | | ServiceReflector.SMMessageBodyMemberAttributeFullName, |
| | 4 | 35 | | ServiceReflector.SMMessagePropertyAttributeFullName |
| | 4 | 36 | | }; |
| | | 37 | | |
| | | 38 | | internal static bool IsEligibleMember(MemberInfo memberInfo) |
| | | 39 | | { |
| | 1149 | 40 | | foreach (Attribute attr in memberInfo.GetCustomAttributes()) |
| | | 41 | | { |
| | 336 | 42 | | if (s_eligibleMessageList.Contains(attr.GetType().FullName)) |
| | | 43 | | { |
| | 195 | 44 | | return true; |
| | | 45 | | } |
| | | 46 | | } |
| | 141 | 47 | | return false; |
| | 195 | 48 | | } |
| | | 49 | | |
| | | 50 | | internal static bool IsMessageHeader(MemberInfo memberInfo) |
| | | 51 | | { |
| | 694 | 52 | | foreach (Attribute attr in memberInfo.GetCustomAttributes()) |
| | | 53 | | { |
| | 195 | 54 | | if ((attr.GetType() == typeof(MessageHeaderAttribute)) |
| | 195 | 55 | | || (attr.GetType() == typeof(MessageHeaderArrayAttribute)) |
| | 195 | 56 | | || (string.Compare(attr.GetType().FullName, ServiceReflector.SMMessageHeaderAttributeFullName, true) |
| | 195 | 57 | | || (string.Compare(attr.GetType().FullName, ServiceReflector.SMMessageHeaderArrayAttributeFullName, |
| | 195 | 58 | | ) |
| | | 59 | | { |
| | 86 | 60 | | return true; |
| | | 61 | | } |
| | | 62 | | } |
| | 109 | 63 | | return false; |
| | 86 | 64 | | } |
| | | 65 | | |
| | | 66 | | internal static bool IsMessageProperty(MemberInfo memberInfo) |
| | | 67 | | { |
| | 431 | 68 | | foreach (Attribute attr in memberInfo.GetCustomAttributes()) |
| | | 69 | | { |
| | 109 | 70 | | if (attr.GetType() == typeof(CoreWCF.MessagePropertyAttribute) |
| | 109 | 71 | | || attr.GetType() == typeof(MessagePropertyAttribute) |
| | 109 | 72 | | || string.Compare(attr.GetType().FullName, ServiceReflector.SMMessagePropertyAttributeFullName, true |
| | | 73 | | { |
| | 5 | 74 | | return true; |
| | | 75 | | } |
| | | 76 | | } |
| | 104 | 77 | | return false; |
| | 5 | 78 | | } |
| | | 79 | | } |
| | | 80 | | } |