/// <summary> /// Gets the metadata associated with a specific contract method /// </summary> public List <object> GetMetadata(MethodInfo method) { // consider the various possible sources of distinct metadata object[] contractType = ContractType.GetCustomAttributes(inherit: true), contractMethod = method.GetCustomAttributes(inherit: true), serviceType = Array.Empty <object>(), serviceMethod = Array.Empty <object>(); if (ContractType != ServiceType & ContractType.IsInterface & ServiceType.IsClass) { serviceType = ServiceType.GetCustomAttributes(inherit: true); serviceMethod = GetImplementation(method)?.GetCustomAttributes(inherit: true) ?? Array.Empty <object>(); } // note: later is higher priority in the code that consumes this, but // GetAttributes() is "most derived to least derived", so: add everything // backwards, then reverse var metadata = new List <object>( contractType.Length + contractMethod.Length + serviceType.Length + serviceMethod.Length); metadata.AddRange(serviceMethod); metadata.AddRange(serviceType); metadata.AddRange(contractMethod); metadata.AddRange(contractType); metadata.Reverse(); return(metadata); }