Ejemplo n.º 1
0
        public string Resolve(IConnectionSettings connectionSettings)
        {
            connectionSettings.ThrowIfNull("connectionSettings");

            string typeName = this.Name;

            if (this.Type == null)
            {
                return(this.Name);
            }
            if (connectionSettings.DefaultTypeNames.TryGetValue(this.Type, out typeName))
            {
                return(typeName);
            }

            if (this.Type != null)
            {
                var att = new PropertyNameResolver().GetElasticPropertyFor(this.Type);
                if (att != null && !att.TypeNameMarker.IsNullOrEmpty())
                {
                    typeName = att.TypeNameMarker.Name;
                }
                else if (att != null && !string.IsNullOrEmpty(att.Name))
                {
                    typeName = att.Name;
                }
                else
                {
                    typeName = connectionSettings.DefaultTypeNameInferrer(this.Type);
                }
                return(typeName);
            }
            return(this.Name);
        }
Ejemplo n.º 2
0
        public string GetTypeNameFor(Type type)
        {
            if (type == null)
            {
                return(null);
            }
            string typeName;

            if (_connectionSettings.DefaultTypeNames.TryGetValue(type, out typeName))
            {
                return(typeName);
            }

            var att = ElasticAttributes.Type(type);

            if (att != null && !att.Name.IsNullOrEmpty())
            {
                typeName = att.Name;
            }
            else
            {
                typeName = _connectionSettings.DefaultTypeNameInferrer(type);
            }
            return(typeName);
        }