Exemple #1
0
        /// <summary>
        /// Registers documents by scanning specified assembly for types that decorated with [Document] attribute.
        /// You can optionaly specify fullNamePrefix parameter to register types only with this prefix.
        /// Name of database and collection for particular document will be discovered by looking to [Document] attribute
        /// of TDocument type.
        /// </summary>
        public static DatabaseConfiguration RegisterDocuments(this DatabaseConfiguration configuration, Assembly assembly, String fullNamePrefix = null)
        {
            var result = GetTypesWithAttribute <DocumentAttribute>(new[] { assembly });

            if (fullNamePrefix != null)
            {
                result = result.Where(t => t.Item1.FullName != null && t.Item1.FullName.StartsWith(fullNamePrefix));
            }

            foreach (var tuple in result)
            {
                foreach (var documentAttribute in tuple.Item2)
                {
                    configuration.RegisterDocument(tuple.Item1);
                }
            }

            return(configuration);
        }
Exemple #2
0
 /// <summary>
 /// Registers single document that belong to specified database and collection
 /// </summary>
 public static DatabaseConfiguration RegisterDocument <TDocument>(this DatabaseConfiguration configuration)
 {
     configuration.RegisterDocument(typeof(TDocument));
     return(configuration);
 }