本文整理汇总了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);
}
}
示例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);
}
}
}