Exemple #1
0
        private static string GetTypeNameForType(Type type)
        {
            var typeName = type.Name;
            var att      = PropertyNameResolver.GetElasticPropertyFor(type);

            if (att != null && !att.Name.IsNullOrEmpty())
            {
                typeName = att.Name;
            }
            else
            {
                typeName = Inflector.MakePlural(type.Name).ToLower();
            }

            return(typeName);
        }
Exemple #2
0
        public static string GetTypeNameFor <T>() where T : class
        {
            var type     = typeof(T);
            var typeName = type.Name;
            var att      = PropertyNameResolver.GetElasticPropertyFor <T>();

            if (att != null && !att.Name.IsNullOrEmpty())
            {
                typeName = att.Name;
            }
            else
            {
                typeName = Inflector.MakePlural(type.Name).ToLower();
            }

            return(typeName);
        }
Exemple #3
0
        private string InferTypeName <T>() where T : class
        {
            var type     = typeof(T);
            var typeName = type.Name;
            var att      = PropertyNameResolver.GetElasticPropertyFor <T>();

            if (att != null && !att.Name.IsNullOrEmpty())
            {
                typeName = att.Name;
            }
            else
            {
                if (this.Settings.TypeNameInferrer != null)
                {
                    typeName = this.Settings.TypeNameInferrer(typeName);
                }
                if (this.Settings.TypeNameInferrer == null || string.IsNullOrEmpty(typeName))
                {
                    typeName = Inflector.MakePlural(type.Name).ToLower();
                }
            }
            return(typeName);
        }