async Task <string> INamingService.GetNameForAttributeAsync(EntityMetadata entityMetadata, AttributeMetadata attributeMetadata, IServiceProvider services) { await CrmSvcUtil.CrmSvcUtilLogger.TraceMethodStartAsync("Entering {0}", MethodBase.GetCurrentMethod().Name); if (attributeMetadata.MetadataId != null && (entityMetadata.MetadataId != null && this._knowNames.ContainsKey(entityMetadata.MetadataId.Value.ToString() + attributeMetadata.MetadataId.Value))) { await CrmSvcUtil.CrmSvcUtilLogger.TraceMethodStopAsync("Exiting {0}", MethodBase.GetCurrentMethod().Name); return(this._knowNames[entityMetadata.MetadataId.Value.ToString() + attributeMetadata.MetadataId.Value]); } var text = StaticNamingService.GetNameForAttribute(attributeMetadata) ?? attributeMetadata.SchemaName; text = NamingService.CreateValidName(text); var namingService = (INamingService)services?.GetService(typeof(INamingService)); if (this._reservedAttributeNames.Contains(text) || text == await namingService.GetNameForEntityAsync(entityMetadata, services)) { text += "1"; } if (entityMetadata.MetadataId != null) { if (attributeMetadata.MetadataId != null) { this._knowNames.Add(entityMetadata.MetadataId.Value.ToString() + attributeMetadata.MetadataId.Value, text); } } await CrmSvcUtil.CrmSvcUtilLogger.TraceMethodStopAsync("Exiting {0}", MethodBase.GetCurrentMethod().Name); return(text); }
async Task <string> INamingService.GetNameForEntityAsync(EntityMetadata entityMetadata, IServiceProvider services) { await CrmSvcUtil.CrmSvcUtilLogger.TraceMethodStartAsync("Entering {0}", MethodBase.GetCurrentMethod().Name); if (entityMetadata.MetadataId != null && this._knowNames.ContainsKey(entityMetadata.MetadataId.Value.ToString())) { await CrmSvcUtil.CrmSvcUtilLogger.TraceMethodStopAsync("Exiting {0}", MethodBase.GetCurrentMethod().Name); return(this._knowNames[entityMetadata.MetadataId.Value.ToString()]); } var name = string.IsNullOrEmpty(StaticNamingService.GetNameForEntity(entityMetadata)) ? entityMetadata.SchemaName : StaticNamingService.GetNameForEntity(entityMetadata); var text = this.CreateValidTypeName(name); if (entityMetadata.MetadataId != null) { this._knowNames.Add(entityMetadata.MetadataId.Value.ToString(), text); } await CrmSvcUtil.CrmSvcUtilLogger.TraceMethodStopAsync("Exiting {0}", MethodBase.GetCurrentMethod().Name); return(text); }
/// <summary> /// Static constructor. /// </summary> static StaticNamingService() { StaticNamingService.InitializeAttributeNames(); }