Raven.Database.Storage.IndexDefinitionStorage.ReadIndexesFromCatalog C# (CSharp) Method

ReadIndexesFromCatalog() private method

private ReadIndexesFromCatalog ( IEnumerable compiledGenerators, ITransactionalStorage transactionalStorage ) : void
compiledGenerators IEnumerable
transactionalStorage ITransactionalStorage
return void
        private void ReadIndexesFromCatalog(IEnumerable<AbstractViewGenerator> compiledGenerators, ITransactionalStorage transactionalStorage)
        {
            foreach (var generator in compiledGenerators)
            {
                var copy = generator;
                var displayNameAtt = TypeDescriptor.GetAttributes(copy)
                    .OfType<DisplayNameAttribute>()
                    .FirstOrDefault();

                var name = displayNameAtt != null ? displayNameAtt.DisplayName : copy.GetType().Name;

	            name = FixupIndexName(name, path);

                transactionalStorage.Batch(actions =>
                {
                    if (actions.Indexing.GetIndexesStats().Any(x => x.Name == name))
                        return;

                    actions.Indexing.AddIndex(name, copy.ReduceDefinition != null);
                });

                var indexDefinition = new IndexDefinition
                {
                    Name = name,
                    Map = "Compiled map function: " + generator.GetType().AssemblyQualifiedName,
                    // need to supply this so the index storage will create map/reduce index
                    Reduce = generator.ReduceDefinition == null ? null : "Compiled reduce function: " + generator.GetType().AssemblyQualifiedName,
                    Indexes = generator.Indexes,
                    Stores = generator.Stores,
                    TermVectors = generator.TermVectors,
                    SpatialIndexes = generator.SpatialIndexes,
                    IsCompiled = true
                };
                indexCache.AddOrUpdate(name, copy, (s, viewGenerator) => copy);
                indexDefinitions.AddOrUpdate(name, indexDefinition, (s1, definition) => indexDefinition);
            }
        }