Ejemplo n.º 1
0
        public static MongoCollectionManager <TData> Create(XElement xe)
        {
            MongoCollectionManager <TData> mongoCollectionManager = new MongoCollectionManager <TData>(xe.zXPathExplicitValue("MongoServer"), xe.zXPathExplicitValue("MongoDatabase"),
                                                                                                       xe.zXPathExplicitValue("MongoCollection"), xe.zXPathValue("MongoDocumentItemName"));

            mongoCollectionManager.DefaultSort = xe.zXPathValue("MongoDefaultSort");
            //MongoGenerateId
            if (xe.zXPathValue("MongoGenerateId").zTryParseAs(false))
            {
                string type = xe.zXPathValue("MongoGenerateId/@type").ToLowerInvariant();
                if (type == "int")
                {
                    mongoCollectionManager._idGenerator = new MongoIdGeneratorInt(mongoCollectionManager.GetCollection());
                    mongoCollectionManager._generateId  = true;
                }
                else
                {
                    throw new PBException("unknow id type generator \"{0}\"", type);
                }
            }
            return(mongoCollectionManager);
        }
Ejemplo n.º 2
0
 public static MongoDocumentStore <TData> Create(XElement xe)
 {
     if (xe.zXPathValue("UseMongo").zTryParseAs(false))
     {
         //MongoDocumentStore<TKey, TData> documentStore = new MongoDocumentStore<TKey, TData>(xe.zXPathValue("MongoServer"), xe.zXPathValue("MongoDatabase"), xe.zXPathValue("MongoCollection"), xe.zXPathValue("MongoDocumentItemName"));
         //documentStore.DefaultSort = xe.zXPathValue("MongoDefaultSort");
         //return documentStore;
         MongoDocumentStore <TData> mongoDocumentStore = new MongoDocumentStore <TData>(MongoCollectionManager <TData> .Create(xe));
         mongoDocumentStore.KeyElementName = xe.zXPathValue("MongoKeyElementName", mongoDocumentStore.KeyElementName);
         return(mongoDocumentStore);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
        //protected string _defaultSort = null;

        public MongoDocumentStore(MongoCollectionManager <TData> collectionManager)
        {
            _collectionManager = collectionManager;
        }