示例#1
0
        public async Task <DynamicEntityConfiguration> ConstructType(IPipeDriveClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            var service = new DealFieldEntityService <Field>(client);

            _logger?.Info("Loading deal fields...");
            var fields = await service.GetAllAsync();

            _logger?.Info("Constructing deals data type...");
            _customFields = fields
                            .Where(field => Regex.IsMatch(field.Key ?? "", "^[0-9A-Fa-f]{40}")); // custom field's Key starts with 40 hex chars

            _dealType = _entityTypeBuilder.Build(typeof(DbDeal), _customFields);

            return(new DynamicEntityConfiguration(typeof(DealEntityConfiguration <>), _dealType));
        }