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


C# DbItem类代码示例

本文整理汇总了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)));
        }
开发者ID:SorenHK,项目名称:sdb,代码行数:7,代码来源:MySQLDataService.cs

示例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);
    }
开发者ID:sergeyshushlyapin,项目名称:Sitecore.FakeDb,代码行数:25,代码来源:MoveItemCommandTest.cs

示例3: Delete

        public override void Delete(DbItem item)
        {
            if (!IsAuthenticated)
                throw AuthException.NotLoggedIn();

            _dataService.Delete(item);
        }
开发者ID:SorenHK,项目名称:sdb,代码行数:7,代码来源:AuthDataService.cs

示例4: Copy

 public DbItem Copy(bool includeId = false)
 {
     var item = new DbItem(Value, RefId);
     if (includeId)
         item.Id = Id;
     return item;
 }
开发者ID:SorenHK,项目名称:sdb,代码行数:7,代码来源:DbItem.cs

示例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);
    }
开发者ID:dharnitski,项目名称:Sitecore.FakeDb,代码行数:7,代码来源:AddFromTemplateCommand.cs

示例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;
    }
开发者ID:udalovas,项目名称:Sitecore.FakeDb,代码行数:31,代码来源:ItemCreator.cs

示例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);
    }
开发者ID:maxshell,项目名称:Sitecore.FakeDb,代码行数:35,代码来源:MoveItemCommandTest.cs

示例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;
    }
开发者ID:maxshell,项目名称:Sitecore.FakeDb,代码行数:26,代码来源:CopyItemCommand.cs

示例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);
    }
开发者ID:maxshell,项目名称:Sitecore.FakeDb,代码行数:27,代码来源:DeleteItemCommandTest.cs

示例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);
    }
开发者ID:maxshell,项目名称:Sitecore.FakeDb,代码行数:26,代码来源:GetChildrenCommandTest.cs

示例11: ShouldCreateNewItemAccess

    public void ShouldCreateNewItemAccess()
    {
      // arrange
      var item = new DbItem("home");

      // act
      item.Access.Should().BeOfType<DbItemAccess>();
    }
开发者ID:udalovas,项目名称:Sitecore.FakeDb,代码行数:8,代码来源:DbItemTest.cs

示例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!");
    }
开发者ID:udalovas,项目名称:Sitecore.FakeDb,代码行数:8,代码来源:DbItemTest.cs

示例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 });
 }
开发者ID:sergeyshushlyapin,项目名称:Sitecore.FakeDb,代码行数:8,代码来源:SetStatistics.cs

示例14: ShouldCheckIfDoesNotContain

    public void ShouldCheckIfDoesNotContain(DbItem item, DbItemChildCollection sut)
    {
      // act
      var result = sut.Contains(item);

      // assert
      result.Should().BeFalse();
    }
开发者ID:maxshell,项目名称:Sitecore.FakeDb,代码行数:8,代码来源:DbItemChildCollectionTest.cs

示例15: ShouldAdd

    public void ShouldAdd(DbItem item, DbItemChildCollection sut)
    {
      // act
      sut.Add(item);

      // assert
      sut.Count.Should().Be(1);
    }
开发者ID:maxshell,项目名称:Sitecore.FakeDb,代码行数:8,代码来源:DbItemChildCollectionTest.cs


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