コード例 #1
0
        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);
        }