Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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 !);
        }
Exemplo n.º 3
0
        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());
        }