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


C# Item.Edit方法代码示例

本文整理汇总了C#中Item.Edit方法的典型用法代码示例。如果您正苦于以下问题:C# Item.Edit方法的具体用法?C# Item.Edit怎么用?C# Item.Edit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Item的用法示例。


在下文中一共展示了Item.Edit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessRenderings

        protected override void ProcessRenderings(Item item, LayoutDefinition layout, DeviceDefinition device,
            IEnumerable<RenderingDefinition> renderings)
        {
            if (renderings.Any())
            {
                if (!ShouldProcess(item.GetProviderPath(),
                    $"Remove rendering(s) '{renderings.Select(r => r.ItemID.ToString()).Aggregate((seed, curr) => seed + ", " + curr)}' from device {Device.Name}"))
                    return;

                foreach (
                    var instanceRendering in
                        renderings.Select(rendering => device.Renderings.Cast<RenderingDefinition>()
                            .FirstOrDefault(r => r.UniqueId == rendering.UniqueId))
                            .Where(instanceRendering => instanceRendering != null)
                            .Reverse())
                {
                    device.Renderings.Remove(instanceRendering);
                }

                item.Edit(p =>
                {
                    var outputXml = layout.ToXml();
                    Item[LayoutFieldId] = outputXml;
                });
            }
            else
            {
                WriteError(typeof(ObjectNotFoundException), "Cannot find a rendering to remove",
                    ErrorIds.RenderingNotFound, ErrorCategory.ObjectNotFound, null);
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:31,代码来源:RemoveRenderingCommand.cs

示例2: ProcessRenderings

        protected override void ProcessRenderings(Item item, LayoutDefinition layout, DeviceDefinition device,
            IEnumerable<RenderingDefinition> renderings)
        {
            if (ShouldProcess(item.GetProviderPath(),
                string.Format("Remove rendering(s) '{0}' from device {1}",
                    renderings.Select(r => r.ItemID.ToString()).Aggregate((seed, curr) => seed + ", " + curr),
                    Device.Name)))
            {
                foreach (
                    var instanceRendering in
                        renderings.Select(rendering => device.Renderings.Cast<RenderingDefinition>()
                            .FirstOrDefault(r => r.UniqueId == rendering.UniqueId))
                            .Where(instanceRendering => instanceRendering != null))
                {
                    device.Renderings.Remove(instanceRendering);
                }

                item.Edit(p =>
                {
                    var outputXml = layout.ToXml();
                    Item["__Renderings"] = outputXml;
                });
            }
        }
开发者ID:ostat,项目名称:Console,代码行数:24,代码来源:RemoveRenderingCommand.cs

示例3: ProcessItem

        protected override void ProcessItem(Item item)
        {
            if (ShouldProcess(item.GetProviderPath(),
                string.Format("Set '{0}' rendering parameters. Rendering is of type: {1}", Instance.UniqueId,
                    Instance.ItemID)))
            {
                LayoutField layoutField = item.Fields[FieldIDs.LayoutField];
                if (layoutField == null || string.IsNullOrEmpty(layoutField.Value))
                {
                    return;
                }

                var layout = LayoutDefinition.Parse(layoutField.Value);

                DeviceDefinition device;
                RenderingDefinition rendering;

                foreach (DeviceDefinition aDevice in layout.Devices)
                {
                    foreach (
                        RenderingDefinition aRendering in
                            aDevice.Renderings.Cast<RenderingDefinition>()
                                .Where(aRendering => aRendering.UniqueId == Instance.UniqueId))
                    {
                        device = aDevice;
                        rendering = aRendering;
                        goto Renderingfound;
                    }
                }

                return;

                Renderingfound: //goto label
                rendering.ItemID = Instance.ItemID;
                rendering.Placeholder = MyInvocation.BoundParameters.ContainsKey("PlaceHolder")
                    ? PlaceHolder
                    : Instance.Placeholder ?? rendering.Placeholder;
                rendering.Datasource =
                    !string.IsNullOrEmpty(DataSource)
                        ? DataSource
                        : Instance.Datasource;
                rendering.Cachable = Instance.Cachable;
                rendering.VaryByData = Instance.VaryByData;
                rendering.VaryByDevice = Instance.VaryByDevice;
                rendering.VaryByLogin = Instance.VaryByLogin;
                rendering.VaryByParameters = Instance.VaryByParameters;
                rendering.VaryByQueryString = Instance.VaryByQueryString;
                rendering.VaryByUser = Instance.VaryByUser;
                rendering.Parameters = Instance.Parameters;
                rendering.MultiVariateTest = Instance.MultiVariateTest;
                rendering.Rules = Instance.Rules;
                rendering.Conditions = Instance.Conditions;

                if (Parameter != null)
                {
                    var parameters = new UrlString(rendering.Parameters ?? string.Empty);
                    foreach (string name in Parameter.Keys)
                        if (parameters.Parameters.AllKeys.Contains(name))
                        {
                            parameters.Parameters[name] = Parameter[name].ToString();
                        }
                        else
                        {
                            parameters.Add(name, Parameter[name].ToString());
                        }
                    rendering.Parameters = parameters.ToString();
                }

                if (Index > -1)
                {
                    device.Renderings.Remove(rendering);
                    device.Insert(index, rendering);
                }

                item.Edit(p =>
                {
                    var outputXml = layout.ToXml();
                    Item["__Renderings"] = outputXml;
                });
            }
        }
开发者ID:sobek85,项目名称:Console,代码行数:81,代码来源:SetRenderingCommand.cs

示例4: ProcessLayout

        protected override void ProcessLayout(Item item, LayoutDefinition layout, DeviceDefinition device)
        {
            if (!ShouldProcess(item.GetProviderPath(), "Add rendering " + Instance.ItemID))
            {
                return;
            }
            var rendering = new RenderingDefinition
            {
                ItemID = Instance.ItemID,
                Placeholder = PlaceHolder ?? Instance.Placeholder,
                Datasource = DataSource ?? Instance.Datasource,
                Cachable = Instance.Cachable,
                VaryByData = Instance.VaryByData,
                VaryByDevice = Instance.VaryByDevice,
                VaryByLogin = Instance.VaryByLogin,
                VaryByParameters = Instance.VaryByParameters,
                VaryByQueryString = Instance.VaryByQueryString,
                VaryByUser = Instance.VaryByUser
            };

            if (Parameter != null)
            {
                var parameters = new UrlString(rendering.Parameters ?? string.Empty);
                foreach (string name in Parameter.Keys)
                    if (parameters.Parameters.AllKeys.Contains(name))
                    {
                        parameters.Parameters[name] = Parameter[name].ToString();
                    }
                    else
                    {
                        parameters.Add(name, Parameter[name].ToString());
                    }
                rendering.Parameters = parameters.ToString();
            }

            //todo: add support for conditions
            //renderingDefinition.Conditions
            //todo: add support for multivariate tests
            //rendering.MultiVariateTest

            if (Index > -1)
            {
                device.Insert(index, rendering);
            }
            else
            {
                device.AddRendering(rendering);
            }

            item.Edit(p =>
            {
                var outputXml = layout.ToXml();
                Item["__Renderings"] = outputXml;
            });
        }
开发者ID:sobek85,项目名称:Console,代码行数:55,代码来源:AddRenderingCommand.cs


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