public void SetUp()
 {
     var configure = new MongoConfigurationBuilder();
     configure.ConnectionStringAppSettingKey("mongoserver");
     config = configure.BuildConfiguration();
     SessionStateItemCollection sessionItemsCollection = new SessionStateItemCollection();
     HttpStaticObjectsCollection staticObjectsCollection = new HttpStaticObjectsCollection();
     item = new SessionStateStoreData(sessionItemsCollection, staticObjectsCollection, 1);
 }
Exemplo n.º 2
0
        public MongoUnitOfWorkFactory(string connection)
        {
            var builder = new MongoConfigurationBuilder();

            builder.ConnectionString(connection);
            builder.Mapping(m => m.DefaultProfile(profile => profile
                .UseIdUnsavedValueConvention(new UnsavedIdConvention())));

            _mongo = new Mongo(builder.BuildConfiguration());
        }
Exemplo n.º 3
0
        private static MongoConfiguration BuildMongoConfiguration(ITypeCatalog domainEventTypeCatalog, string connectionString)
        {
            var configurationBuilder = new MongoConfigurationBuilder();
            configurationBuilder.ConnectionString(connectionString);
            configurationBuilder.Mapping(mapping =>
                                             {
                                                 mapping.DefaultProfile(profile => profile.SubClassesAre(t => t.IsSubclassOf(typeof(DomainEvent))));
                                                 domainEventTypeCatalog
                                                     .GetDerivedTypes(typeof(DomainEvent))
                                                     .ToList()
                                                     .ForEach(type => MapEventType(type, mapping));
                                             });

            return configurationBuilder.BuildConfiguration();
        }
Exemplo n.º 4
0
        public static MongoDB.Mongo GetDB()
        {
            var config = new MongoConfigurationBuilder();

            config.Mapping(mapping => {
                mapping.DefaultProfile(profile =>
                {
                    profile.SubClassesAre(x => x.IsSubclassOf(typeof(Module)));
                });

                mapping.Map<ContentModule>();
                mapping.Map<ListModule>();
            });

            config.ConnectionString("mongodb://localhost");

            MongoDB.Mongo mongo = new MongoDB.Mongo(config.BuildConfiguration());

            mongo.Connect();

            return mongo;
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            OptionSet options = new OptionSet(){
            {"i|inspect_sessions", i => InspectSessions()},
            {"fe|flush_expired", fe => FlushExpiredSession()},
            {"aix|add_indexes", aix => AddIndexes()},
            {"?|h|help", h => ShowHelp()}};

            try
            {
                var configure = new MongoConfigurationBuilder();
                configure.ConnectionStringAppSettingKey("mongoserver");
                var config = configure.BuildConfiguration();
                options.Parse(args);
            }
            catch (OptionException e)
            {
                Console.WriteLine(e.Message);
                return;
            }

        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            var config = new MongoConfigurationBuilder();

            // COMMENT OUT FROM HERE
            config.Mapping(mapping =>
            {
                mapping.DefaultProfile(profile =>
                {
                    profile.SubClassesAre(t => t.IsSubclassOf(typeof(MyClass)));
                });
                mapping.Map<MyClass>();
                mapping.Map<SubClass>();
            });
            // TO HERE

            config.ConnectionString("Server=127.0.0.1");

            using (Mongo mongo = new Mongo(config.BuildConfiguration()))
            {
                mongo.Connect();
                try
                {
                    var db = mongo.GetDatabase("TestDb");
                    var collection = db.GetCollection<MyClass>();

                    MyClass square = new MyClass()
                    {
                        Corners = 4,
                        Name = "Square"
                    };

                    MyClass circle = new MyClass()
                    {
                        Corners = 0,
                        Name = "Circle"
                    };

                    SubClass sub = new SubClass()
                    {
                        Name = "SubClass",
                        Corners = 6,
                        Ratio = 3.43
                    };

                    collection.Save(square);
                    collection.Save(circle);
                    collection.Save(sub);

                    var superclass = (from item in db.GetCollection<MyClass>("MyClass").Linq()
                                where item.Corners > 1
                                select item.Corners).ToList();

                    var subclass = (from item in db.GetCollection<SubClass>("MyClass").Linq()
                                    where item.Ratio > 1
                                    select item.Corners).ToList();

                    Console.WriteLine("Count by LINQ on typed collection: {0}", collection.Linq().Count(x => x.Corners > 1));
                    Console.WriteLine("Count by LINQ on typed collection2: {0}", db.GetCollection<SubClass>().Linq().Count(x => x.Corners > 1));
                    //Console.WriteLine("Count by LINQ on typed collection3: {0}", db.GetCollection<SubClass>().Count(new { Corners = Op.GreaterThan(1) }));
                    Console.WriteLine("Count on typed collection: {0}", collection.Count(new { Corners = Op.GreaterThan(1) }));

                    var coll = db.GetCollection("MyClass");
                    var count = coll.Count(new Document("Corners", Op.GreaterThan(1)));
                    Console.WriteLine("Count: {0}", count);
                    Console.ReadKey();
                }
                finally
                {
                    mongo.Disconnect();
                }
            }

            //var main = new MainClass();
            //main.Setup();
            //main.Run();
        }
 public void SetUp()
 {
     var configure = new MongoConfigurationBuilder();
     configure.ConnectionString("mongoserver");
     config = configure.BuildConfiguration();
 }
Exemplo n.º 8
0
 private SessionStore()
 {
     configure = new MongoConfigurationBuilder();
     configure.ConnectionStringAppSettingKey("mongoserver");
     config = configure.BuildConfiguration();
 }