CreateDocStore() public méthode

public CreateDocStore ( ) : DocumentStore
Résultat Raven.Client.Document.DocumentStore
Exemple #1
0
        private void InitDocStore(RavenConnectionDialogViewModel conn)
        {
            if (conn == null)
            {
                throw new ArgumentNullException("conn", "conn is null.");
            }



            var assemblies = conn.GetAssemblyPaths().Select(Path.GetFileNameWithoutExtension).Select(Assembly.Load);

            var docStoreCreatorType = (from a in assemblies
                                       from t in a.TypesImplementing <ICreateDocumentStore>()
                                       select t).FirstOrDefault();

            if (docStoreCreatorType != null)
            {
                var docStoreCreator = (ICreateDocumentStore)docStoreCreatorType.CreateInstance();
                _docStore = docStoreCreator.CreateDocumentStore(new ConnectionInfo
                {
                    Url             = conn.Url,
                    DefaultDatabase = conn.DefaultDatabase,
                    Credentials     = new NetworkCredential
                    {
                        UserName = conn.Username,
                        Password = conn.Password
                    },
                    ResourceManagerId = conn.ResourceManagerId,
                    ApiKey            = conn.ApiKey
                });
            }
            else
            {
                _docStore = conn.CreateDocStore();
            }

            _docStore.Initialize();
        }
Exemple #2
0
        private static IDocumentStore CreateDocStore(RavenConnectionDialogViewModel conn)
        {
            if (conn == null)
            {
                throw new ArgumentNullException("conn", "conn is null.");
            }

            var assemblies = conn.AssemblyPaths.Select(Path.GetFileNameWithoutExtension).Select(Assembly.Load);

            var docStoreCreatorType = (from a in assemblies
                                       from t in a.TypesImplementing <ICreateDocumentStore>()
                                       let hasDefaultCtor = t.GetConstructor(Type.EmptyTypes) != null
                                                            where !t.IsAbstract && hasDefaultCtor
                                                            select t).FirstOrDefault();

            if (docStoreCreatorType == null)
            {
                return(conn.CreateDocStore());
            }

            var docStoreCreator = (ICreateDocumentStore)Activator.CreateInstance(docStoreCreatorType);

            var connectionInfo = new ConnectionInfo
            {
                Url             = conn.Url,
                DefaultDatabase = conn.DefaultDatabase,
                Credentials     = new NetworkCredential
                {
                    UserName = conn.Username,
                    Password = conn.Password
                },
                ResourceManagerId = conn.ResourceManagerId,
                ApiKey            = conn.ApiKey
            };

            return(docStoreCreator.CreateDocumentStore(connectionInfo));
        }