internal static (string TypeName, string?AttributeNamespace, string?AttributeName) GetServiceNonGenericName(Type serviceType, Attribute serviceContractAttribute) { var attributeType = serviceContractAttribute.GetType(); var @namespace = (string?)attributeType.TryInstanceProperty("Namespace")?.GetValue(serviceContractAttribute); var name = (string?)attributeType.TryInstanceProperty("Name")?.GetValue(serviceContractAttribute); return(ReflectionTools.GetNonGenericName(serviceType), @namespace, name); }
private static string GetDataContainerName(Type type) { var attribute = ReflectionTools.GetCustomAttribute(type, "System.Runtime.Serialization.DataContractAttribute"); string?attributeName = null; if (attribute != null) { attributeName = (string?)attribute.GetType().TryInstanceProperty("Name")?.GetValue(attribute); } return(string.IsNullOrWhiteSpace(attributeName) ? ReflectionTools.GetNonGenericName(type) : attributeName !); }
private static string GetClassName(Type serviceType, string?suffix = null) { var result = new StringBuilder() .Append(serviceType.Assembly.GetName().Name) .Append('.') .Append(ReflectionTools.GetNamespace(serviceType)) .Append('.') .Append(ReflectionTools.GetNonGenericName(serviceType)); var serviceGenericEnding = ServiceContract.GetServiceGenericEnding(serviceType); for (var i = 0; i < serviceGenericEnding.Count; i++) { result .Append('-') .Append(serviceGenericEnding[i]); } result.Append(suffix); return(result.ToString()); }