public UnitFactory()
 {
     if (factory == null || factory.Count == 0)
     {
         RepositoryConfiguration  configuration = RepositoryConfiguration.GetConfig();
         RepositoryCollection     col           = configuration.RepositoryCollection;
         IEnumerable <Repository> Repo          = col.Cast <Repository>();
         factory = new Dictionary <string, Type>();
         foreach (Repository item in Repo)
         {
             Type type = Type.GetType(item.DataBase);
             factory.Add(item.RepositoryName, type);
         }
     }
 }
Exemple #2
0
            //private DocumentStore _store;
            /// <summary>
            /// Constructor of the repository.
            /// The directory where the database will be located in the path indicated in the Configuration Field named <c>data_dir</c>. If
            /// no data directory is specified a temporary path will be used.
            /// </summary>
            /// <param name="config">Configuration used to initialize the Repository</param>
            public RavenRepository(RepositoryConfiguration config = null)
            {
                log.Info("Trying to load RavenRepository class...");
                this.RepositoryType = "Raven";
                string dataDir = System.IO.Path.GetTempPath() + "/p2p-player-db";

                if (config != null)
                {
                    string tdd = config.GetConfig("data_dir");
                    if (!tdd.Equals(""))
                    {
                        dataDir = tdd;
                    }
                }
                log.Debug("Start opening and initializing RavenDB");
                _store = new EmbeddableDocumentStore {
                    DataDirectory = dataDir
                };
                //_store = new DocumentStore { Url = "http://localhost:8080" };
                _store.Initialize();
                log.Info("RavenDB initialized at " + dataDir);
            }