• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DbItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DbItem的典型用法代码示例。如果您正苦于以下问题:C# DbItem类的具体用法?C# DbItem怎么用?C# DbItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DbItem类属于命名空间,在下文中一共展示了DbItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: ShouldResolvePath

    public void ShouldResolvePath(string path, ResolvePathCommand sut, DbItem item)
    {
      item.FullPath = "/sitecore/content/home";
      sut.DataStorage.GetFakeItems().Returns(new[] { item });
      sut.Initialize(path);

      ReflectionUtil.CallMethod(sut, "DoExecute").Should().Be(item.ID);
    }
开发者ID:dharnitski,项目名称:Sitecore.FakeDb,代码行数:8,代码来源:ResolvePathCommandTest.cs


示例17: ShouldSetItemAccess

    public void ShouldSetItemAccess()
    {
      // arrange
      var item = new DbItem("home") { Access = new DbItemAccess { CanRead = false } };

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


示例18: ShouldCopyTo

    public void ShouldCopyTo([Frozen]DbItem item, [Greedy]DbItemChildCollection sut)
    {
      var array = new DbItem[3];

      sut.CopyTo(array, 0);

      array.Should().Contain(item);
    }
开发者ID:dharnitski,项目名称:Sitecore.FakeDb,代码行数:8,代码来源:DbItemChildCollectionTest.cs


示例19: UpdateFields

 protected virtual void UpdateFields(DbItem fakeItem)
 {
   foreach (Field field in this.Item.Fields)
   {
     Assert.IsTrue(fakeItem.Fields.InnerFields.ContainsKey(field.ID), "Item field not found. Item: '{0}', '{1}'; field: '{2}'.", Item.Name, Item.ID, field.ID);
     fakeItem.Fields[field.ID].Value = field.Value;
   }
 }
开发者ID:udalovas,项目名称:Sitecore.FakeDb,代码行数:8,代码来源:SaveItemCommand.cs


示例20: AddDbItemArgs

    public AddDbItemArgs(DbItem item, DataStorage dataStorage)
    {
      Assert.ArgumentNotNull(item, "item");
      Assert.ArgumentNotNull(dataStorage, "dataStorage");

      this.item = item;
      this.dataStorage = dataStorage;
    }
开发者ID:maxshell,项目名称:Sitecore.FakeDb,代码行数:8,代码来源:AddDbItemArgs.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DbManager类代码示例发布时间:2022-05-24
下一篇:
C# DbHelper类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap