本文整理汇总了C#中DbItem类的典型用法代码示例。如果您正苦于以下问题:C# DbItem类的具体用法?C# DbItem怎么用?C# DbItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbItem类属于命名空间,在下文中一共展示了DbItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public override void Delete(DbItem item)
{
if (item.Id <= 0)
return;
Execute(string.Format("DELETE FROM " + _itemsTable + " WHERE id = {0}", AsValueNullable(item.Id)));
}
示例2: ShouldMoveItemToNewDestination
public void ShouldMoveItemToNewDestination(MoveItemCommand sut, GetParentCommandPrototype getParentCommand, Item item, Item destination, ID parentId, DataStorageSwitcher switcher)
{
// arrange
sut.Database.Engines.DataEngine.Commands.GetParentPrototype = getParentCommand;
var fakeItem = new DbItem("item", item.ID) { ParentID = parentId };
var fakeParent = new DbItem("parent", parentId) { Children = { fakeItem } };
var fakeDestination = new DbItem("destination", destination.ID) { FullPath = "/new destination path" };
sut.DataStorage.GetFakeItem(item.ID).Returns(fakeItem);
sut.DataStorage.GetFakeItem(parentId).Returns(fakeParent);
sut.DataStorage.GetFakeItem(destination.ID).Returns(fakeDestination);
sut.Initialize(item, destination);
// act
var result = (bool)ReflectionUtil.CallMethod(sut, "DoExecute");
// assert
result.Should().BeTrue();
fakeItem.ParentID.Should().Be(destination.ID);
fakeItem.FullPath.Should().Be("/new destination path/item");
fakeParent.Children.Should().NotContain(fakeItem);
fakeDestination.Children.Should().Contain(fakeItem);
}
示例3: Delete
public override void Delete(DbItem item)
{
if (!IsAuthenticated)
throw AuthException.NotLoggedIn();
_dataService.Delete(item);
}
示例4: Copy
public DbItem Copy(bool includeId = false)
{
var item = new DbItem(Value, RefId);
if (includeId)
item.Id = Id;
return item;
}
示例5: DoExecute
protected override Item DoExecute()
{
var item = new DbItem(this.ItemName, this.NewId, this.TemplateId) { ParentID = this.Destination.ID };
this.dataStorage.AddFakeItem(item);
return this.dataStorage.GetSitecoreItem(this.NewId);
}
示例6: Create
public virtual Item Create(string itemName, ID itemId, ID templateId, Database database, Item destination)
{
var language = Language.Current;
if (this.DataStorage.GetFakeItem(itemId) != null)
{
return this.DataStorage.GetSitecoreItem(itemId, language);
}
var fieldList = this.DataStorage.GetFieldList(templateId, itemName);
var item = ItemHelper.CreateInstance(itemName, itemId, templateId, fieldList, database, language);
var parentItem = this.DataStorage.GetFakeItem(destination.ID);
var fullPath = parentItem.FullPath + "/" + itemName;
var dbitem = new DbItem(itemName, itemId, templateId) { ParentID = destination.ID, FullPath = fullPath };
if (this.dataStorage.GetFakeTemplate(templateId) != null)
{
foreach (var field in this.dataStorage.GetFakeTemplate(templateId).Fields)
{
// TODO: Introduce field clonning.
dbitem.Fields.Add(new DbField(field.Name) { ID = field.ID });
}
}
this.DataStorage.FakeItems.Add(itemId, dbitem);
this.DataStorage.GetFakeItem(destination.ID).Children.Add(dbitem);
return item;
}
示例7: ShouldMoveItemToNewDestination
public void ShouldMoveItemToNewDestination()
{
// arrange
var itemId = ID.NewID;
var parentId = ID.NewID;
var destinationId = ID.Null;
var item = ItemHelper.CreateInstance(this.database, "item", itemId);
var destination = ItemHelper.CreateInstance(this.database, destinationId);
var getParentCommand = new FakeGetParentCommand();
this.database.Engines.DataEngine.Commands.GetParentPrototype = getParentCommand;
var fakeItem = new DbItem("item", itemId) { ParentID = parentId };
var fakeParent = new DbItem("parent", parentId) { Children = { fakeItem } };
var fakeDestination = new DbItem("destination", destinationId) { FullPath = "/new destination path" };
this.dataStorage.GetFakeItem(itemId).Returns(fakeItem);
this.dataStorage.GetFakeItem(parentId).Returns(fakeParent);
this.dataStorage.GetFakeItem(destinationId).Returns(fakeDestination);
var command = new OpenMoveItemCommand();
command.Initialize(item, destination);
command.Initialize(this.dataStorage);
// act
var result = command.DoExecute();
// assert
result.Should().BeTrue();
fakeItem.ParentID.Should().Be(destinationId);
fakeItem.FullPath.Should().Be("/new destination path/item");
fakeParent.Children.Should().NotContain(fakeItem);
fakeDestination.Children.Should().Contain(fakeItem);
}
示例8: DoExecute
protected override Item DoExecute()
{
var dataStorage = this.innerCommand.DataStorage;
var item = new DbItem(this.CopyName, this.CopyId, this.Source.TemplateID) { ParentID = this.Destination.ID };
dataStorage.AddFakeItem(item);
var fakeItem = dataStorage.GetFakeItem(this.Source.ID);
var fakeCopy = dataStorage.GetFakeItem(this.CopyId);
this.CopyFields(fakeItem, fakeCopy);
var copy = dataStorage.GetSitecoreItem(this.CopyId, this.Source.Language);
if (!this.Deep)
{
return copy;
}
foreach (Item child in this.Source.Children)
{
ItemManager.CopyItem(child, copy, this.Deep, child.Name, ID.NewID);
}
return copy;
}
示例9: ShouldDeleteItemDescendants
public void ShouldDeleteItemDescendants()
{
// arrange
var itemId = ID.NewID;
var desc1Id = ID.NewID;
var desc2Id = ID.NewID;
var item = new DbItem("item", itemId);
var desc1 = new DbItem("descendant1", desc1Id);
var desc2 = new DbItem("descendant2", desc2Id);
item.Children.Add(desc1);
desc1.Children.Add(desc2);
this.dataStorage.FakeItems.Add(itemId, item);
this.dataStorage.FakeItems.Add(desc1Id, desc1);
this.dataStorage.FakeItems.Add(desc2Id, desc2);
this.command.Initialize(ItemHelper.CreateInstance(this.database, itemId), ID.NewID);
// act
this.command.DoExecute();
// assert
this.dataStorage.FakeItems.Should().NotContainKey(desc1Id);
this.dataStorage.FakeItems.Should().NotContainKey(desc2Id);
}
示例10: ShouldReturnItemChildren
public void ShouldReturnItemChildren()
{
// arrange
var dbchild1 = new DbItem("child1");
var dbchild2 = new DbItem("child2");
var dbitem = new DbItem("item") { dbchild1, dbchild2 };
var child1 = ItemHelper.CreateInstance(this.database);
var child2 = ItemHelper.CreateInstance(this.database);
var item = ItemHelper.CreateInstance(this.database, dbitem.ID);
this.dataStorage.GetFakeItem(dbitem.ID).Returns(dbitem);
this.dataStorage.GetSitecoreItem(dbchild1.ID, item.Language).Returns(child1);
this.dataStorage.GetSitecoreItem(dbchild2.ID, item.Language).Returns(child2);
var command = new OpenGetChildrenCommand { Engine = new DataEngine(this.database) };
command.Initialize(item);
command.Initialize(this.dataStorage);
// act
var children = command.DoExecute();
// assert
children[0].Should().Be(child1);
children[1].Should().Be(child2);
}
示例11: ShouldCreateNewItemAccess
public void ShouldCreateNewItemAccess()
{
// arrange
var item = new DbItem("home");
// act
item.Access.Should().BeOfType<DbItemAccess>();
}
示例12: ShouldAddFields
public void ShouldAddFields()
{
// arrange
var item = new DbItem("home") { { "Title", "Welcome!" } };
// act & assert
item.Fields.Should().ContainSingle(f => f.Name == "Title" && f.Value == "Welcome!");
}
示例13: AddStatisticsFields
private static void AddStatisticsFields(DbItem item, string date, string user)
{
item.Fields.Add(new DbField("__Created", FieldIDs.Created) { Value = date });
item.Fields.Add(new DbField("__Created by", FieldIDs.CreatedBy) { Value = user });
item.Fields.Add(new DbField("__Revision", FieldIDs.Revision) { Value = ID.NewID.ToString() });
item.Fields.Add(new DbField("__Updated", FieldIDs.Updated) { Value = date });
item.Fields.Add(new DbField("__Updated by", FieldIDs.UpdatedBy) { Value = user });
}
示例14: ShouldCheckIfDoesNotContain
public void ShouldCheckIfDoesNotContain(DbItem item, DbItemChildCollection sut)
{
// act
var result = sut.Contains(item);
// assert
result.Should().BeFalse();
}
示例15: ShouldAdd
public void ShouldAdd(DbItem item, DbItemChildCollection sut)
{
// act
sut.Add(item);
// assert
sut.Count.Should().Be(1);
}