Esempio n. 1
0
 protected ElasticReadOnlyRepositoryBase(IIndexType <T> indexType)
 {
     ElasticType = indexType;
     _client     = indexType.Configuration.Client;
     SetCache(indexType.Configuration.Cache);
     _logger = indexType.Configuration.LoggerFactory.CreateLogger(GetType());
 }
Esempio n. 2
0
        public override void AddType(IIndexType type)
        {
            if (!(type is ITimeSeriesIndexType))
            {
                throw new ArgumentException($"Type must implement {nameof(ITimeSeriesIndexType)}", nameof(type));
            }

            base.AddType(type);
        }
        public virtual void AddType(IIndexType type)
        {
            if (_frozenTypes.IsValueCreated)
            {
                throw new InvalidOperationException("Can't add index types after the list has been frozen.");
            }

            _types.Add(type);
        }
        public static bool CanAggregateByField(this IIndexType indexType, string field)
        {
            // allow all fields if an allowed list isn't specified
            if (indexType.AllowedAggregationFields == null || indexType.AllowedAggregationFields.Count == 0)
            {
                return(true);
            }

            return(indexType.AllowedAggregationFields.Contains(field, StringComparer.OrdinalIgnoreCase));
        }
 protected ElasticReadOnlyRepositoryBase(IIndexType <T> indexType)
 {
     ElasticType = indexType;
     if (HasIdentity)
     {
         _idField = indexType.GetFieldName((T doc) => ((IIdentity)doc).Id) ?? "id";
     }
     _client = indexType.Configuration.Client;
     SetCache(indexType.Configuration.Cache);
     _logger = indexType.Configuration.LoggerFactory.CreateLogger(GetType());
 }
 public ElasticQueryOptions(IIndexType indexType) {
     IndexType = indexType;
     Index = indexType.Index;
     ChildType = indexType as IChildIndexType;
     TimeSeriesType = indexType as ITimeSeriesIndexType;
     HasParent = ChildType != null;
     HasMultipleIndexes = TimeSeriesType != null;
     AllowedAggregationFields = indexType.AllowedAggregationFields;
     SupportsSoftDeletes = typeof(ISupportSoftDeletes).IsAssignableFrom(indexType.Type);
     HasIdentity = typeof(IIdentity).IsAssignableFrom(indexType.Type);
     ParentSupportsSoftDeletes = ChildType != null && typeof(ISupportSoftDeletes).IsAssignableFrom(ChildType.GetParentIndexType().Type);
 }
        public EmployeeRepository(IIndexType <Employee> employeeType) : base(employeeType)
        {
            DocumentsChanged.AddHandler((o, args) => {
                DocumentsChangedCount += args.Documents.Count;
                return(Task.CompletedTask);
            });

            BeforeQuery.AddHandler((o, args) => {
                QueryCount++;
                return(Task.CompletedTask);
            });
        }
        protected ElasticReadOnlyRepositoryBase(IIndexType <T> indexType)
        {
            ElasticType = indexType;
            if (HasIdentity)
            {
                _idField = new Lazy <string>(() => indexType.GetFieldName(doc => ((IIdentity)doc).Id) ?? "id");
            }
            _lazyClient = new Lazy <IElasticClient>(() => indexType.Configuration.Client);

            SetCache(indexType.Configuration.Cache);
            _logger = indexType.Configuration.LoggerFactory.CreateLogger(GetType());
        }
 public ElasticTypeSettings(IIndexType indexType)
 {
     IndexType                 = indexType;
     Index                     = indexType.Index;
     ChildType                 = indexType as IChildIndexType;
     TimeSeriesType            = indexType as ITimeSeriesIndexType;
     HasParent                 = ChildType != null;
     HasMultipleIndexes        = TimeSeriesType != null;
     SupportsSoftDeletes       = typeof(ISupportSoftDeletes).IsAssignableFrom(indexType.Type);
     HasIdentity               = typeof(IIdentity).IsAssignableFrom(indexType.Type);
     ParentSupportsSoftDeletes = ChildType != null && typeof(ISupportSoftDeletes).IsAssignableFrom(ChildType.GetParentIndexType().Type);
 }
        protected ElasticRepositoryBase(IIndexType <T> indexType, IValidator <T> validator = null) : base(indexType)
        {
            _validator           = validator;
            _messagePublisher    = indexType.Configuration.MessageBus;
            NotificationsEnabled = _messagePublisher != null;

            if (HasCreatedDate)
            {
                var propertyName = _client.Infer.PropertyName(typeof(T).GetMember(nameof(IHaveCreatedDate.CreatedUtc)).Single());
                FieldsRequiredForRemove.Add(propertyName);
            }
        }
Esempio n. 11
0
 public ElasticQueryOptions(IIndexType indexType)
 {
     IndexType                 = indexType;
     Index                     = indexType.Index;
     ChildType                 = indexType as IChildIndexType;
     TimeSeriesType            = indexType as ITimeSeriesIndexType;
     HasParent                 = ChildType != null;
     HasMultipleIndexes        = TimeSeriesType != null;
     AllowedSearchFields       = indexType.AllowedSearchFields;
     AllowedAggregationFields  = indexType.AllowedAggregationFields;
     AllowedSortFields         = indexType.AllowedSortFields;
     SupportsSoftDeletes       = typeof(ISupportSoftDeletes).IsAssignableFrom(indexType.Type);
     HasIdentity               = typeof(IIdentity).IsAssignableFrom(indexType.Type);
     ParentSupportsSoftDeletes = ChildType != null && typeof(ISupportSoftDeletes).IsAssignableFrom(ChildType.GetParentIndexType().Type);
 }
 public RepositoryBase(IIndexType <T> indexType, IValidator <T> validator, IOptions <AppOptions> options) : base(indexType, validator)
 {
     _options             = options;
     NotificationsEnabled = options.Value.EnableRepositoryNotifications;
 }
 public RepositoryOwnedByOrganization(IIndexType <T> indexType, IValidator <T> validator) : base(indexType, validator)
 {
     FieldsRequiredForRemove.Add("organization_id");
     DocumentsAdded.AddHandler(OnDocumentsAdded);
 }
Esempio n. 14
0
 public RepositoryOwnedByOrganization(IIndexType <T> indexType, IValidator <T> validator = null)
     : base(indexType)
 {
 }
 public static T ElasticType <T>(this T options, IIndexType indexType) where T : ICommandOptions
 {
     options.Values.Set(ElasticTypeSettingsKey, new ElasticTypeSettings(indexType));
     return(options);
 }
Esempio n. 16
0
 public DailyLogEventRepository(IIndexType <LogEvent> indexType) : base(indexType)
 {
 }
Esempio n. 17
0
 public RepositoryBase(IIndexType <T> indexType, IValidator <T> validator) : base(indexType, validator)
 {
     NotificationsEnabled = Settings.Current.EnableRepositoryNotifications;
 }
Esempio n. 18
0
 public EmployeeRepository(IIndexType <Employee> employeeType) : base(employeeType)
 {
 }
 public RepositoryOwnedByOrganization(IIndexType <T> indexType, IValidator <T> validator, IOptions <AppOptions> options) : base(indexType, validator, options)
 {
     DocumentsAdded.AddHandler(OnDocumentsAdded);
     AddPropertyRequiredForRemove(o => o.OrganizationId);
 }
Esempio n. 20
0
 public RepositoryBase(IIndexType <T> indexType, IValidator <T> validator) : base(indexType, validator)
 {
 }
Esempio n. 21
0
 public RepositoryOwnedByOrganizationAndProject(IIndexType <T> indexType, IValidator <T> validator, IOptions <AppOptions> options) : base(indexType, validator, options)
 {
     FieldsRequiredForRemove.Add("project_id");
 }
 public MigrationRepository(IIndexType <Migration> indexType) : base(indexType)
 {
 }
Esempio n. 23
0
 public RepositoryOwnedByOrganizationAndProject(IIndexType <T> indexType, IValidator <T> validator, IOptions <AppOptions> options) : base(indexType, validator, options)
 {
     AddPropertyRequiredForRemove(o => o.ProjectId);
 }