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


C# GlassHtml.Editable方法代码示例

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


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

示例1: InterfaceIssueInPageEditorWhenInterfaceInheritsFromAnInterfaceWithSimilarName

        public void InterfaceIssueInPageEditorWhenInterfaceInheritsFromAnInterfaceWithSimilarName()
        {
            /*
             * This test is in response to issue 53 raised on the Glass.Sitecore.Mapper
             * project. When two interfaces have similar names are created as proxies
             * the method GetTypeConfiguration returns the wrong config.
             */
             
            
            //Assign
            var context = Context.Create(Utilities.CreateStandardResolver());
            context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration"));

            var db = Sitecore.Configuration.Factory.GetDatabase("master");
            var scContext = new SitecoreContext(db);

            var glassHtml = new GlassHtml(scContext);
            var instance = scContext.GetItem<IBasePage>("/sitecore");

            //Act
            glassHtml.Editable(instance, x => x.Title);

            //This method should execute without error


        }
开发者ID:bplasmeijer,项目名称:Glass.Mapper,代码行数:26,代码来源:MiscFixture.cs

示例2: Editable_InEditMode_StringFieldWithEditReturned

        public void Editable_InEditMode_StringFieldWithEditReturned()
        {
            //Assign
            string targetPath = "/sitecore/content/Tests/GlassHtml/MakeEditable/Target";

            var db = Sitecore.Configuration.Factory.GetDatabase("master");
            var context = Context.Create(Utilities.CreateStandardResolver());
            context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration"));
            var service = new SitecoreContext(db);

            var html = new GlassHtml(service);
            
            var model = service.GetItem<StubClass>(targetPath);

            var fieldValue = "test content field";

            model.StringField = fieldValue ;

            using (new SecurityDisabler())
            {
                service.Save(model);
            }

            var doc = new XmlDocument();
            doc.LoadXml("<site name='GetHomeItem' virtualFolder='/' physicalFolder='/' rootPath='/sitecore/content/Tests/SitecoreContext/GetHomeItem' startItem='/Target1' database='master' domain='extranet' allowDebug='true' cacheHtml='true' htmlCacheSize='10MB' registryCacheSize='0' viewStateCacheSize='0' xslCacheSize='5MB' filteredItemsCacheSize='2MB' enablePreview='true' enableWebEdit='true' enableDebugger='true' disableClientData='false' />");

            var siteContext = new SiteContextStub(
                new SiteInfo(
                    doc.FirstChild
                    )
                );

            siteContext.SetDisplayMode(DisplayMode.Edit);

            Sitecore.Context.Site = siteContext;

            //Act
            string result;

            using (new SecurityDisabler())
            {
                result = html.Editable(model, x => x.StringField);
            }

            //Assert
            Assert.IsTrue(result.Contains(fieldValue));
            //this is the webedit class
            Assert.IsTrue(result.Contains("scWebEditInput"));
            Console.WriteLine("result "+result);
        }
开发者ID:JamesHay,项目名称:Glass.Mapper,代码行数:50,代码来源:GlassHtmlFixture.cs

示例3: Editable_SimpleLambdaInEditModeInterfaceWithInheritance_StringFieldWithEditReturned

        public void Editable_SimpleLambdaInEditModeInterfaceWithInheritance_StringFieldWithEditReturned()
        {
            //Assign
            string targetPath = "/sitecore/content/target";

            var templateId = ID.NewID;
            using (Db database = new Db
            {
                new DbTemplate(templateId)
                {
                    new DbField("StringField")
                    {
                        Type = "text"
                    }
                },
                new Sitecore.FakeDb.DbItem("Target", ID.NewID, templateId)
                {
                    {"StringField", ""}
                }
            })
            {
                var context = Context.Create(Utilities.CreateStandardResolver());
                context.Load(new OnDemandLoader<SitecoreTypeConfiguration>(typeof(StubClass)));

                var service = new SitecoreContext(database.Database);

                var html = new GlassHtml(service);

                var model = service.GetItem<IStubClassInherits>(targetPath);

                var fieldValue = "test content field";

                model.StringField = fieldValue;

                using (new SecurityDisabler())
                {
                    service.Save(model);
                }

                var doc = new XmlDocument();
                doc.LoadXml(
                    "<site name='GetHomeItem' virtualFolder='/' physicalFolder='/' rootPath='/sitecore/content/Tests/SitecoreContext/GetHomeItem' startItem='/Target1' database='master' domain='extranet' allowDebug='true' cacheHtml='true' htmlCacheSize='10MB' registryCacheSize='0' viewStateCacheSize='0' xslCacheSize='5MB' filteredItemsCacheSize='2MB' enablePreview='true' enableWebEdit='true' enableDebugger='true' disableClientData='false' />");

                var siteContext = new SiteContextStub(
                    new SiteInfo(
                        doc.FirstChild
                        )
                    );

                using (new EnableWebEditMode())
                {
                    using (new SiteContextSwitcher(siteContext))
                    {

                        //Act
                        string result;

                        using (new SecurityDisabler())
                        {
                            result = html.Editable(model, x => x.SubStub.StringField);
                        }
                        //Assert
                        Assert.IsTrue(result.Contains(fieldValue));
                        //this is the webedit class
                        Assert.IsTrue(result.Contains("scWebEditInput"));
                        Console.WriteLine("result " + result);
                    }
                }
            }
        }
开发者ID:mikeedwards83,项目名称:Glass.Mapper,代码行数:70,代码来源:GlassHtmlFixture.cs

示例4: Editable_RootInterface_NoExceptions

        public void Editable_RootInterface_NoExceptions()
        {
            //Assign
            IBase item = _service.GetItem<IBase>(_editablePath);
            GlassHtml html = new GlassHtml(_service);
            global::Sitecore.Context.Site = global::Sitecore.Configuration.Factory.GetSite("website");
                 

            //Act
            html.Editable(item, x => x.SingleLineText);
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:11,代码来源:GlassHtmlFixture.cs

示例5: Editable_ConcreteNoId_NoExceptions

        public void Editable_ConcreteNoId_NoExceptions()
        {
            //Assign
            global::Sitecore.Context.Site = global::Sitecore.Configuration.Factory.GetSite("website");

            Concrete3 item = _service.GetItem<Concrete3>(_editablePath);
            GlassHtml html = new GlassHtml(_service);


            //Act
            html.Editable(item, x => x.MissingField);
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:12,代码来源:GlassHtmlFixture.cs

示例6: Editable_ConcreteAccessingFirstChild_NoExceptions

        public void Editable_ConcreteAccessingFirstChild_NoExceptions()
        {
            //Assign
            global::Sitecore.Context.Site = global::Sitecore.Configuration.Factory.GetSite("website");

            Concrete1 item = _service.GetItem<Concrete1>(_editablePath);
            GlassHtml html = new GlassHtml(_service);


            //Act
            html.Editable(item, x => x.Children.First().SingleLineText);
            html.Editable(item, x => x.Children.First().Text);
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:13,代码来源:GlassHtmlFixture.cs

示例7: Editable_InterfaceWithSuperInterfaceWithSameName_NoExceptions

        public void Editable_InterfaceWithSuperInterfaceWithSameName_NoExceptions()
        {
            //Assign
            GlassHtmlFixtureNs.Inner.ISubType1 item = _service.GetItem<GlassHtmlFixtureNs.Inner.ISubType1>(_editablePath);
            GlassHtml html = new GlassHtml(_service);
            global::Sitecore.Context.Site = global::Sitecore.Configuration.Factory.GetSite("website");


            //Act
            html.Editable(item, x => x.SingleLineText);
            html.Editable(item, x => x.RichText);
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:12,代码来源:GlassHtmlFixture.cs


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