本文整理汇总了C#中SitecoreService.Map方法的典型用法代码示例。如果您正苦于以下问题:C# SitecoreService.Map方法的具体用法?C# SitecoreService.Map怎么用?C# SitecoreService.Map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SitecoreService
的用法示例。
在下文中一共展示了SitecoreService.Map方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Map_ClassWithId_MapsFieldValues
public void Map_ClassWithId_MapsFieldValues()
{
//Assign
var db = Sitecore.Configuration.Factory.GetDatabase("master");
string text = "test text 1";
Guid id = new Guid("{346D7364-ECBA-4E7A-9580-58DB4785C20A}");
DateTime date = new DateTime(2013, 04, 03, 12, 15, 10);
var item = db.GetItem(id.ToString());
using (new ItemEditing(item, true))
{
item["StringField"] = text;
item["DateField"] = date.ToString("yyyyMMddThhmmss");
}
var context = Context.Create(Utilities.CreateStandardResolver());
context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration"));
var service = new SitecoreService(db, context);
var model = new MapStub();
model.Id = id;
//Act
service.Map(model);
//Assert
Assert.AreEqual(text, model.StringField);
Assert.AreEqual(date, model.DateField);
}
示例2: Map_ClassWithItemUri_MapsFieldValues
public void Map_ClassWithItemUri_MapsFieldValues()
{
//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());
var service = new SitecoreService(database.Database);
string text = "test text 1";
DateTime date = new DateTime(2013, 04, 03, 12, 15, 10);
var item = database.GetItem(id.ToString());
using (new ItemEditing(item, true))
{
item["StringField"] = text;
item["DateField"] = date.ToString("yyyyMMddThhmmss");
}
var model = new MapItemUriStub();;
model.Uri =new ItemUri(new ID(id), Language.Parse("en"), database.Database);
//Act
service.Map(model);
//Assert
Assert.AreEqual(text, model.StringField);
Assert.AreEqual(date, model.DateField);
}
}