public static string GetResourceTypeName(Type type)
        {
#if NET45
            AdfTypeNameAttribute typeNameAttribute = type.GetCustomAttribute <AdfTypeNameAttribute>(true);
#else
            AdfTypeNameAttribute typeNameAttribute =
                type.GetCustomAttributes(typeof(AdfTypeNameAttribute), true).FirstOrDefault() as AdfTypeNameAttribute;
#endif
            return(typeNameAttribute == null ? type.Name : typeNameAttribute.TypeName);
        }
        public static void TestCanGetRegisteredLinkedServiceCaseInsensitive(Type type, out string typeName)
        {
            AdfTypeNameAttribute att = type.GetCustomAttribute <AdfTypeNameAttribute>(true);

            if (att == null)
            {
                typeName = type.Name;
                return;
            }

            Assert.NotNull(att);

            // Get the type named used for de/ser
            typeName = att.TypeName;
            Assert.NotNull(typeName);
            Assert.NotEmpty(typeName);

            // Ensure that the type name is not already all lowercase
            string typeNameLower = typeName.ToLowerInvariant();

            Assert.NotEqual(typeName, typeNameLower, StringComparer.Ordinal);
        }
        protected void TestRegisteringTypeTwiceThrowsExceptionCaseInsensitive
        <TUserRegistered, TUserRegisteredDifferentCase>()
            where TUserRegistered : TRegistered
            where TUserRegisteredDifferentCase : TRegistered
        {
            AdfTypeNameAttribute attribute = typeof(TUserRegistered).GetCustomAttribute <AdfTypeNameAttribute>(true);

            Assert.NotNull(attribute);

            AdfTypeNameAttribute attribute2 =
                typeof(TUserRegisteredDifferentCase).GetCustomAttribute <AdfTypeNameAttribute>(true);

            Assert.NotNull(attribute);

            // Ensure the type names are the same when comparing case-insensitively
            Assert.Equal(attribute.TypeName, attribute2.TypeName, StringComparer.OrdinalIgnoreCase);
            Assert.NotEqual(attribute.TypeName, attribute2.TypeName, StringComparer.Ordinal);

            this.Client.RegisterType <TUserRegistered>(true);

            // Validate that trying to register a type with
            // the same name but different casing is not allowed
            Assert.Throws <InvalidOperationException>(() => this.Client.RegisterType <TUserRegisteredDifferentCase>());
        }