当前位置: 首页>>代码示例>>C#>>正文


C# Embedded.EmbeddableDocumentStore类代码示例

本文整理汇总了C#中Raven.Client.Embedded.EmbeddableDocumentStore的典型用法代码示例。如果您正苦于以下问题:C# EmbeddableDocumentStore类的具体用法?C# EmbeddableDocumentStore怎么用?C# EmbeddableDocumentStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EmbeddableDocumentStore类属于Raven.Client.Embedded命名空间,在下文中一共展示了EmbeddableDocumentStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

 /// <summary>
 /// Configures StructureMap to look for registries.
 /// </summary>
 /// <returns></returns>
 public static IContainer Initialize()
 {
     ObjectFactory.Initialize(x => {
         var documentStore = new EmbeddableDocumentStore { ConnectionStringName = "RavenDB" };
         documentStore.Conventions.FindTypeTagName = type => typeof(IPageModel).IsAssignableFrom(type) ? "Pages" : null;
         documentStore.RegisterListener(new StoreListener());
         documentStore.Initialize();
         IndexCreation.CreateIndexes(typeof(Documents_ByParent).Assembly, documentStore);
         x.For<IDocumentStore>().Use(documentStore);
         x.For<IDocumentSession>()
             .HybridHttpOrThreadLocalScoped()
             .Use(y =>
             {
                 var store = y.GetInstance<IDocumentStore>();
                 return store.OpenSession();
             });
         x.For<IVirtualPathResolver>().Use<VirtualPathResolver>();
         x.For<IPathResolver>().Use<PathResolver>();
         x.For<IPathData>().Use<PathData>();
         x.For<IControllerMapper>().Use<ControllerMapper>();
         x.For<ISettings>().Use<Settings>();
         x.Scan(scanner =>
         {
             scanner.AssembliesFromApplicationBaseDirectory();
             scanner.Convention<PageTypeRegistrationConvetion>();
         });
         x.For<IPageModel>().UseSpecial(y => y.ConstructedBy( r => ((MvcHandler) HttpContext.Current.Handler).RequestContext.RouteData.GetCurrentPage<IPageModel>()));
         x.For<IStructureInfo>().UseSpecial(y => y.ConstructedBy(r => ((MvcHandler)HttpContext.Current.Handler).RequestContext.RouteData.Values["StructureInfo"] as IStructureInfo));
     });
     return ObjectFactory.Container;
 }
开发者ID:stemyers,项目名称:BrickPile,代码行数:35,代码来源:Bootstrapper.cs

示例2: SuccessTest1

		public void SuccessTest1()
		{
			using (IDocumentStore documentStore = new EmbeddableDocumentStore
			{
				RunInMemory = true
			}.Initialize())
			{
				dynamic expando = new ExpandoObject();

				using (IDocumentSession session = documentStore.OpenSession())
				{
					session.Store(expando);

					RavenJObject metadata =
						session.Advanced.GetMetadataFor((ExpandoObject)expando);

					metadata[PropertyName] = RavenJToken.FromObject(true);

					session.SaveChanges();
				}

				using (IDocumentSession session = documentStore.OpenSession())
				{
					var loaded =
						session.Load<dynamic>((string)expando.Id);

					RavenJObject metadata =
						session.Advanced.GetMetadataFor((DynamicJsonObject)loaded);
					RavenJToken token = metadata[PropertyName];

					Assert.NotNull(token);
					Assert.True(token.Value<bool>());
				}
			}
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:35,代码来源:LuceneQueryCustomMetadata.cs

示例3: Should_give_documents_where_ExpirationDate_is_null_or_expirationdate_greater_than_today

        public void Should_give_documents_where_ExpirationDate_is_null_or_expirationdate_greater_than_today()
        {
            using (var documentStore = new EmbeddableDocumentStore
                                           {
                                               RunInMemory = true,
                                               Conventions =
                                                   {
                                                       DefaultQueryingConsistency =
                                                           ConsistencyOptions.QueryYourWrites
                                                   }
                                           })
            {
                documentStore.Initialize();

                using (var session = documentStore.OpenSession())
                {
                    session.Store(new Foo());
                    session.Store(new Foo());
                    session.SaveChanges();
                }
                using (var session = documentStore.OpenSession())
                {
                    var bar =
                        session.Query<Foo>()
                               .Where(foo => foo.ExpirationTime == null || foo.ExpirationTime > DateTime.Now)
                               .ToList();
                    Assert.That(bar.Count, Is.EqualTo(2));
                }
            }
        }
开发者ID:nilsml,项目名称:RavenDbEmbeddedDebug,代码行数:30,代码来源:RavenTests.cs

示例4: Main

        static void Main(string[] args)
        {
            var cfg = new HttpSelfHostConfiguration("http://localhost:1337");

            cfg.MaxReceivedMessageSize = 16L * 1024 * 1024 * 1024;
            cfg.TransferMode = TransferMode.StreamedRequest;
            cfg.ReceiveTimeout = TimeSpan.FromMinutes(20);

            cfg.Routes.MapHttpRoute(
                "API Default", "api/{controller}/{id}",
                new { id = RouteParameter.Optional });

            cfg.Routes.MapHttpRoute(
                "Default", "{*res}",
                new { controller = "StaticFile", res = RouteParameter.Optional });

            var db = new EmbeddableDocumentStore { DataDirectory = new FileInfo("db/").DirectoryName };
            db.Initialize();
            cfg.Filters.Add(new RavenDbApiAttribute(db));

            using (HttpSelfHostServer server = new HttpSelfHostServer(cfg))
            {
                Console.WriteLine("Initializing server.");
                server.OpenAsync().Wait();
                Console.WriteLine("Server ready at: " + cfg.BaseAddress);
                Console.WriteLine("Press Enter to quit.");
                Console.ReadLine();
            }
        }
开发者ID:Lords-Von-Handschreiber,项目名称:Juke-Mobile-Prototype,代码行数:29,代码来源:Program.cs

示例5: ReturnsBooksByPriceLimit

        public void ReturnsBooksByPriceLimit()
        {
            using (var docStore = new EmbeddableDocumentStore { RunInMemory = true }
                .Initialize()
                )
            {
                using (var session = docStore.OpenSession())
                {
                    // Store test data
                    session.Store(new Book { Title = "Test book", YearPublished = 2013, Price = 12.99 });
                    session.SaveChanges();
                }

                var controller = new BooksController { RavenSession = docStore.OpenSession() };

                var viewResult = (ViewResult)controller.ListByPriceLimit(15);
                var result = viewResult.ViewData.Model as List<Book>;
                Assert.IsNotNull(result);
                Assert.AreEqual(1, result.Count);

                viewResult = (ViewResult)controller.ListByPriceLimit(10);
                result = viewResult.ViewData.Model as List<Book>;
                Assert.IsNotNull(result);
                Assert.AreEqual(0, result.Count);

                controller.RavenSession.Dispose();
            }
        }
开发者ID:synhershko,项目名称:RavenDB-in-Action,代码行数:28,代码来源:BooksControllerTests.cs

示例6: AuthenticationTest

		protected AuthenticationTest()
		{
			database::Raven.Database.Extensions.IOExtensions.DeleteDirectory("Data");
			embeddedStore = new EmbeddableDocumentStore()
			{
				Configuration = 
					{
						AnonymousUserAccessMode = database::Raven.Database.Server.AnonymousUserAccessMode.Get,
						Catalog = {Catalogs = {new AssemblyCatalog(typeof (AuthenticationUser).Assembly)}},
						DataDirectory = "Data",
						RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
						AuthenticationMode = "oauth",
						Port = 8079,
						OAuthTokenCertificate = database::Raven.Database.Config.CertGenerator.GenerateNewCertificate("RavenDB.Test")
					},
				UseEmbeddedHttpServer = true,
			};

			embeddedStore.Configuration.Initialize();
			embeddedStore.Initialize();
			store = new DocumentStore
			{
				Url = embeddedStore.Configuration.ServerUrl,
			};
			store.Initialize();
			store.JsonRequestFactory.
				EnableBasicAuthenticationOverUnsecureHttpEvenThoughPasswordsWouldBeSentOverTheWireInClearTextToBeStolenByHackers =
				true;
			foreach (DictionaryEntry de in HttpRuntime.Cache)
			{
				HttpRuntime.Cache.Remove((string)de.Key);
			}
		}
开发者ID:alwin,项目名称:ravendb,代码行数:33,代码来源:AuthorizationTest.cs

示例7: when_querying_cases_by_name_using_danish_collation

        public when_querying_cases_by_name_using_danish_collation()
        {
            var culture = new CultureInfo("da");
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;

            store = new EmbeddableDocumentStore
            {
                RunInMemory = true
            };
            store.Initialize();

            using (var session = store.OpenSession())
            {
                session.Store(new Case { Name = "bcda" });
                session.Store(new Case { Name = "dacb" });
                session.Store(new Case { Name = "daab" });
                session.Store(new Case { Name = "dacb" });
                session.Store(new Case { Name = "aacb" });
                session.Store(new Case { Name = "aaac" });
                session.Store(new Case { Name = "bcbb" });
                session.Store(new Case { Name = "acba" });
                session.Store(new Case { Name = "aaaa" });
                session.Store(new Case { Name = "dada" });
                session.SaveChanges();
            }
        }
开发者ID:larsudengaard,项目名称:ravendb,代码行数:27,代码来源:when_querying_cases_by_name.cs

示例8: AddTest

        public void AddTest()
        {
            var cacheKey = new CacheKey("/api/Cars", new[] { "1234", "abcdef" });
            var documentStore = new EmbeddableDocumentStore()
            {
                RunInMemory = true
            }.Initialize();

            new RavenDocumentsByEntityName().Execute(documentStore);

            var store = new RavenDbEntityTagStore(documentStore);
            var value = new TimedEntityTagHeaderValue("\"abcdef1234\"") { LastModified = DateTime.Now };

            // first remove them
            store.RemoveAllByRoutePattern(cacheKey.RoutePattern);

            // add
            store.AddOrUpdate(cacheKey, value);

            // get
            TimedEntityTagHeaderValue dbValue;
            store.TryGetValue(cacheKey, out dbValue);

            Assert.AreEqual(value.Tag, dbValue.Tag);
            Assert.AreEqual(value.LastModified.ToString(), dbValue.LastModified.ToString());
        }
开发者ID:taliesins,项目名称:CacheCow,代码行数:26,代码来源:IntegrationTests.cs

示例9: WhenAnEventIsWrittenToTheSinkItIsRetrievableFromTheDocumentStore

        public void WhenAnEventIsWrittenToTheSinkItIsRetrievableFromTheDocumentStore()
        {
            using (var documentStore = new EmbeddableDocumentStore {RunInMemory = true}.Initialize())
            {
                var timestamp = new DateTimeOffset(2013, 05, 28, 22, 10, 20, 666, TimeSpan.FromHours(10));
                var exception = new ArgumentException("Mládek");
                const LogEventLevel level = LogEventLevel.Information;
                const string messageTemplate = "{Song}++";
                var properties = new List<LogEventProperty> { new LogEventProperty("Song", new ScalarValue("New Macabre")) };

                using (var ravenSink = new RavenDBSink(documentStore, 2, TinyWait, null))
                {
                    var template = new MessageTemplateParser().Parse(messageTemplate);
                    var logEvent = new Events.LogEvent(timestamp, level, exception, template, properties);
                    ravenSink.Emit(logEvent);
                }

                using (var session = documentStore.OpenSession())
                {
                    var events = session.Query<LogEvent>().Customize(x => x.WaitForNonStaleResults()).ToList();
                    Assert.AreEqual(1, events.Count);
                    var single = events.Single();
                    Assert.AreEqual(messageTemplate, single.MessageTemplate);
                    Assert.AreEqual("\"New Macabre\"++", single.RenderedMessage);
                    Assert.AreEqual(timestamp, single.Timestamp);
                    Assert.AreEqual(level, single.Level);
                    Assert.AreEqual(1, single.Properties.Count);
                    Assert.AreEqual("New Macabre", single.Properties["Song"]);
                    Assert.AreEqual(exception.Message, single.Exception.Message);
                }
            }
        }
开发者ID:BugBusted,项目名称:serilog,代码行数:32,代码来源:RavenDBSinkTests.cs

示例10: GetRavenDBStore

        public IDocumentStore GetRavenDBStore()
        {
            var hasRavenConnectionString = ConfigurationManager.ConnectionStrings["RavenDB"] != null;
            IDocumentStore docStore;
            if (hasRavenConnectionString)
            {
                docStore = new DocumentStore
                    {
                        ConnectionStringName = "RavenDB",
                        DefaultDatabase = "BusRouteLondonDB"
                    };
            }
            else
            {
                //NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);
                docStore = new EmbeddableDocumentStore
                    {
                        //RunInMemory = true,
                        DataDirectory = "~/App_Data/Raven",
                        //UseEmbeddedHttpServer = true
                    };
            }

            docStore.Initialize();

            docStore.Conventions.RegisterIdConvention<BusRoute>(
                (dbName, command, route) =>
                string.Format("busroutes/{0}-{1}-{2}", route.Route, route.Run, route.Sequence));

            return docStore;
        }
开发者ID:yogiramchandani,项目名称:BusRouteLondon,代码行数:31,代码来源:RavenDBConfig.cs

示例11: DocumentStoreWorksWhenAddingItemThenDeletingItAndThenGrabbingNonExistingItemAndStoringNewOne

		public void DocumentStoreWorksWhenAddingItemThenDeletingItAndThenGrabbingNonExistingItemAndStoringNewOne()
		{
			using (var documentStore = new EmbeddableDocumentStore { RunInMemory = true }.Initialize())
			{
				documentStore.Conventions.AllowQueriesOnId = true;
				using (var session = documentStore.OpenSession())
				{
					var deletedModel = new TestModel { Id = 1 };
					session.Store(deletedModel);
					session.SaveChanges();

					session.Delete(deletedModel);
					session.SaveChanges();

					TestModel testModelItem = session.Query<TestModel>().SingleOrDefault(t => t.Id == 2) ??
												  new TestModel { Id = 2 };
					Assert.NotNull(testModelItem);
					session.Store(testModelItem);
					session.SaveChanges();

					var list = session.Query<TestModel>()
						.Customize(x => x.WaitForNonStaleResults())
						.ToList();
					Assert.Equal(1, list.Count());
				}
			}
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:27,代码来源:BuildStarted.cs

示例12: InMemoryStartup

        public static IContainer InMemoryStartup()
        {
            var presentationdocumentStore = new EmbeddableDocumentStore
            {
                RunInMemory = true,
            };

            presentationdocumentStore.Initialize();

            ObjectFactory.Initialize(config =>
            {
                config.Scan(scan =>
                {
                    scan.TheCallingAssembly();
                    scan.WithDefaultConventions();

                });
                config.AddRegistry(new CoreRegistry(presentationdocumentStore));

            });

            ObjectFactory.AssertConfigurationIsValid();
            ObjectFactory.WhatDoIHave();
            WaitForIndexes(presentationdocumentStore);
            IndexCreation.CreateIndexes(typeof(Users_ByUsername).Assembly, presentationdocumentStore);
            WaitForIndexes(presentationdocumentStore);

            return ObjectFactory.Container;
        }
开发者ID:DanHibbert,项目名称:PresentationGenerator,代码行数:29,代码来源:Bootstrapper.cs

示例13: CanQueryMetadata

        public void CanQueryMetadata()
        {
            using (var store = new EmbeddableDocumentStore { RunInMemory = true })
            {
                store.Initialize();
                using (var s = store.OpenSession())
                {
                    s.Store(new User
                    {
                        Metadata =
                        {
                            IsActive = true
                        }
                    });
                    s.SaveChanges();
                }

                using (var s = store.OpenSession())
                {
                    var actual = s.Query<User>()
                        .Customize(x=>x.WaitForNonStaleResultsAsOfLastWrite())
                        .Where(x => x.Metadata.IsActive == true)
                        .Count();
                    Assert.Equal(1, actual);
                }
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:27,代码来源:Marcus.cs

示例14: ShouldWork

        public void ShouldWork()
        {
            using (var _documentStore = new EmbeddableDocumentStore
                                           {
                                               RunInMemory = true,
                                               Conventions =
                                                   {
                                                       DefaultQueryingConsistency =
                                                           ConsistencyOptions.QueryYourWrites
                                                   }
                                           })
            {
                _documentStore.Initialize();

                using (var session = _documentStore.OpenSession())
                {
                    session.Store(new Foo());
                    session.Store(new Foo());
                    session.SaveChanges();
                }

                using (var session = _documentStore.OpenSession())
                {
                    var bar = session.Query<Foo>().Where(foo => foo.ExpirationTime == null || foo.ExpirationTime > DateTime.Now).ToList();
                    Assert.Equal(2, bar.Count);
                }
            }
        }
开发者ID:nilsml,项目名称:RavenDbEmbeddedDebug,代码行数:28,代码来源:QueryingUsingOr.cs

示例15: Class1

        public Class1()
        {
            Person myObject = new Person()
                                   {
                                       Date = DateTime.Now,
                                       Name = "Jack"
                                   };

            var documentStore = new EmbeddableDocumentStore()
                                    {
                                        DataDirectory = "Data"
                                    };
            documentStore.Initialize();
            Console.WriteLine("inited");
            var session = documentStore.OpenSession();
            Console.WriteLine("session open");
            session.Store(myObject);
            session.SaveChanges();
            Console.WriteLine("changes saved");
            Thread.Sleep(1000);
            foreach (Person queryResponse in session.Query<Person>().Where(o => o.Name == "Jack"))
            {
                Console.WriteLine(queryResponse.Name + ".");
            }
            Console.WriteLine("done");
            Console.ReadLine();
        }
开发者ID:uatec,项目名称:CodeNexus,代码行数:27,代码来源:Class1.cs


注:本文中的Raven.Client.Embedded.EmbeddableDocumentStore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。