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


C# SitecoreService.GetItemWithInterfaces方法代码示例

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


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

示例1: GetItemWithInterfaces_UsingPath2Types_ReturnsProxy

        public void GetItemWithInterfaces_UsingPath2Types_ReturnsProxy()
        {
            //Assign
            var context = Context.Create(Utilities.CreateStandardResolver());
            string id = "{0D5534BA-12E8-4C0C-AB17-587392906BBB}";
            string expectedString = "some test string";
            DateTime expectedDate = new DateTime(2015, 05, 15, 15, 45, 48);
            string path = "/sitecore/content/Tests/SitecoreService/GetItemWithInterfaces/Target";

            var db = Sitecore.Configuration.Factory.GetDatabase("master");
            var service = new SitecoreService(db);

            var item = db.GetItem(path);

            using (new ItemEditing(item, true))
            {
                item["StringField"] = expectedString;
                item["DateField"] = Sitecore.DateUtil.ToIsoDate(expectedDate);
            }

            Guid guidId = new Guid(id);

            //Act
            using (new SecurityDisabler())
            {
                var result = service.GetItemWithInterfaces<IOne, ITwo, IThree>(path);

                //Assert
                Assert.IsNotNull(result);
                Assert.IsTrue(result is IOne);
                Assert.AreEqual(expectedString, result.StringField);
                var objTwo = (ITwo)result;
                Assert.AreEqual(expectedDate, objTwo.DateField);
            }
        }
开发者ID:JamesHay,项目名称:Glass.Mapper,代码行数:35,代码来源:SitecoreServiceFixture.cs

示例2: GetItemWithInterfaces_UsingPath2Types_ReturnsProxy

        public void GetItemWithInterfaces_UsingPath2Types_ReturnsProxy()
        {
            //Assign
            var id = Guid.NewGuid();

            using (Db database = new Db
            {
                new Sitecore.FakeDb.DbItem("Target", new ID(id))
                {
                    {"StringField", ""},
                    {"DateField", ""}
                },
            })
            {
                var context = Context.Create(Utilities.CreateStandardResolver());
                context.Load(new OnDemandLoader<SitecoreTypeConfiguration>(typeof(StubClass)));
                var service = new SitecoreService(database.Database);

                string expectedString = "some test string";
                DateTime expectedDate = new DateTime(2015, 05, 15, 15, 45, 48);
                string path = "/sitecore/content/Target";


                var item = database.GetItem(path);

                using (new ItemEditing(item, true))
                {
                    item["StringField"] = expectedString;
                    item["DateField"] = DateUtil.ToIsoDate(expectedDate);
                }


                //Act
                using (new SecurityDisabler())
                {
                    var result = service.GetItemWithInterfaces<IOne, ITwo, IThree>(path);

                    //Assert
                    Assert.IsNotNull(result);
                    Assert.IsTrue(result is IOne);
                    Assert.AreEqual(expectedString, result.StringField);
                    var objTwo = (ITwo) result;
                    Assert.AreEqual(expectedDate, objTwo.DateField);
                }
            }
        }
开发者ID:mikeedwards83,项目名称:Glass.Mapper,代码行数:46,代码来源:SitecoreServiceFixture.cs


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