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


C# UnityContainer.ConfigureCms方法代码示例

本文整理汇总了C#中Microsoft.Practices.Unity.UnityContainer.ConfigureCms方法的典型用法代码示例。如果您正苦于以下问题:C# UnityContainer.ConfigureCms方法的具体用法?C# UnityContainer.ConfigureCms怎么用?C# UnityContainer.ConfigureCms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Practices.Unity.UnityContainer的用法示例。


在下文中一共展示了UnityContainer.ConfigureCms方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateContext

 protected override CmsContext CreateContext(Action<ICmsConfigurator> configure = null)
 {
     var unity = new UnityContainer();
     var configurator = unity.ConfigureCms();
     SharedConfiguration(configurator);
     if (configure != null)
         configure(configurator);
     return new TestCmsContext(new CmsContainerProvider(() => new UnityCmsContainer(unity)));
 }
开发者ID:Steinerd,项目名称:MicroCms,代码行数:9,代码来源:UnityCmsContainerTests.cs

示例2: WebApiFixture

        public WebApiFixture()
        {
            var unity = new UnityContainer();
            unity.ConfigureCms()
                .UseMemoryStorage()
                .UseLuceneSearch(new RAMDirectory())
                .UseTextRenderer()
                .UseHtmlRenderer()
                .UseMarkdownRenderer()
                .UseSourceCodeRenderer();
            Cms.Configure(() => new UnityCmsContainer(unity.CreateChildContainer()));
            using (var context = Cms.CreateContext())
            {
                ExampleDocument = new CmsDocument("Example");
                context.Documents.Save(ExampleDocument);
                ExampleView = new CmsView("Example");
                context.Views.Save(ExampleView);
            }

            //CmsTesting.Initialize(() => new UnityCmsContainer(unity.CreateChildContainer()));
            _WebApp = WebApp.Start<Startup>(WebUrl.ToString());
        }
开发者ID:Steinerd,项目名称:MicroCms,代码行数:22,代码来源:WebApiFixture.cs

示例3: ConfigureCms

        private void ConfigureCms()
        {
            var rootFolder = Server.MapPath("~/");
            var cmsDirectory = new DirectoryInfo(Path.Combine(rootFolder, @"App_Data\Cms"));

            if (cmsDirectory.Exists && !UseSql)
            {
                cmsDirectory.Delete(true);
            }

            var unity = new UnityContainer();
            var configuration = unity.ConfigureCms()
                .UseHtmlRenderer()
                .UseTextRenderer()
                .UseMarkdownRenderer()
                .UseSourceCodeRenderer();

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (UseAzure)
            {
                var azureStorageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
                configuration
                    .UseAzureStorage(azureStorageAccount.CreateCloudBlobClient(), "cms")
                    .UseLuceneSearch(new AzureDirectory(azureStorageAccount, "cms-index", new RAMDirectory()));
            }
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            else if (UseRedis)
            {
                configuration
                    .UseRedisStorage()
                    .UseLuceneSearch(new SimpleFSDirectory(new DirectoryInfo(Path.Combine(cmsDirectory.FullName, "Index"))));
            }
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            else if (UseSql)
            {
                // To configure db via web.config, uncomment entityFramework section and connection string and pass in connection string
                // name to ICmsConfigurator; e.g. .UseSqlStorage("DefaultConnection")
                if (!cmsDirectory.Exists)
                    cmsDirectory.Create();
                string connectionString =
                    string.Format(
                        @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename={0}\{1}.mdf;Initial Catalog={1};Integrated Security=True;MultipleActiveResultSets=true",
                        cmsDirectory.FullName, "MicroCmsSqlDb");
                configuration
                    .UseSqlStorage(connectionString)
                    .UseSqlSearch(connectionString);
            }
            else
            {
                configuration
                    .UseFileSystemStorage(cmsDirectory)
                    .UseLuceneSearch(new SimpleFSDirectory(new DirectoryInfo(Path.Combine(cmsDirectory.FullName, "Index"))));
            }

            Cms.Configure(() => new UnityCmsContainer(unity.CreateChildContainer()));
            using (var context = Cms.CreateContext())
            {
                if (!context.Documents.GetAll().Any())
                {
                    var rowView = new CmsView("RowView", "<div class=\"row\">{0}</div>");
                    var sidebarView = new CmsView("SidebarView", "<div>{0}</div>");
                    context.Views.Save(rowView);
                    context.Views.Save(sidebarView);
                    var document = new CmsDocument("Example Rows",
                        CreateMarkdown("#MD4", 4),
                        CreateMarkdown("#MD8", 8),
                        CreateMarkdown("#MD3", 3),
                        CreateMarkdown("#MD3", 3),
                        CreateMarkdown("#MD3", 3),
                        CreateMarkdown("#MD3", 3),
                        CreateMarkdown("#MD12", 12));
                    document.Tags.Add("documents");
                    context.Documents.Save(document);
                    context.Documents.Save(new CmsDocument("Source Code Example", CreateMarkdown(@"#CODE
            {{CSharp}}
            public class Thing
            {
            public string Name { get; set; }
            }
            ", 12)));
                    var sidebar = new CmsDocument("TableOfContents", new CmsPart(CmsTypes.Markdown, @"[Home](/)

            [Docs](/docs/)"));
                    sidebar.Tags.Add("TableOfContents");
                    context.Documents.Save(sidebar);

                    var readmeText = File.ReadAllText(Path.Combine(rootFolder, @"..\..\README.md"));

                    var homeDocument = new CmsDocument("Readme", CreateMarkdown(readmeText, 12));
                    homeDocument.Tags.Add("home");
                    Cms.CreateContext().Documents.Save(homeDocument);
                }
            }
        }
开发者ID:Steinerd,项目名称:MicroCms,代码行数:94,代码来源:Global.asax.cs


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