public string GetTypeNameFor(Type type) { if (type == null) { return(null); } string typeName; if (_connectionSettings.DefaultTypeNames.TryGetValue(type, out typeName)) { return(typeName); } var att = ElasticsearchTypeAttribute.From(type); if (att != null && !att.Name.IsNullOrEmpty()) { typeName = att.Name; } else { typeName = _connectionSettings.DefaultTypeNameInferrer(type); } return(typeName); }
private PropertyInfo GetInferredId(Type type) { // if the type specifies through ElasticAttribute what the id prop is // use that no matter what string propertyName; this._connectionSettings.IdProperties.TryGetValue(type, out propertyName); if (!propertyName.IsNullOrEmpty()) { return(GetPropertyCaseInsensitive(type, propertyName)); } var esTypeAtt = ElasticsearchTypeAttribute.From(type); propertyName = (esTypeAtt?.IdProperty.IsNullOrEmpty() ?? true) ? "Id" : esTypeAtt?.IdProperty; return(GetPropertyCaseInsensitive(type, propertyName)); }