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


C# Item.GetProviderPath方法代码示例

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


在下文中一共展示了Item.GetProviderPath方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: EditItem

 protected override void EditItem(Item item)
 {
     if (ShouldProcess(item.GetProviderPath(), "Protect item"))
     {
         item.Appearance.ReadOnly = true;
     }
 }
开发者ID:GuitarRich,项目名称:Console,代码行数:7,代码来源:ProtectItemCommand.cs

示例3: ProcessItemLanguages

 protected override void ProcessItemLanguages(Item item)
 {
     if (ShouldProcess(item.GetProviderPath(),
         string.Format("{0} versions for language(s) '{1}' {2}", (Recurse ? "Recursively remove" : "Remove"),
             Language.Aggregate((seed, curr) => seed + ", " + curr),
             (ExcludeLanguage == null || ExcludeLanguage.Length == 0)
                 ? ""
                 : string.Format("excluding {0} language(s)",
                     ExcludeLanguage.Aggregate((seed, curr) => seed + ", " + curr)))))
     {
         foreach (var langItem in item.Versions.GetVersions(true))
         {
             if (LanguageWildcardPatterns.Any(wildcard => wildcard.IsMatch(langItem.Language.Name)))
             {
                 if (!ExcludeLanguageWildcardPatterns.Any(wildcard => wildcard.IsMatch(langItem.Language.Name)))
                 {
                     langItem.Versions.RemoveAll(false);
                 }
             }
         }
         if (Recurse)
         {
             foreach (Item child in item.Children)
             {
                 ProcessItemLanguages(child);
             }
         }
     }
 }
开发者ID:sobek85,项目名称:Console,代码行数:29,代码来源:RemoveItemLanguageCommand.cs

示例4: EditItem

 protected override void EditItem(Item item)
 {
     if (ShouldProcess(item.GetProviderPath(), "Unlock Item"))
     {
         item.Locking.Unlock();
     }
 }
开发者ID:sobek85,项目名称:Console,代码行数:7,代码来源:UnlockItemCommand.cs

示例5: ProcessItem

        protected override void ProcessItem(Item item)
        {
            ScheduleItem schedule = null;
            if (item != null)
            {
                if (!CheckItemTypeMatch(item))
                {
                    return;
                }
                schedule = new ScheduleItem(item);
            }

            if (Schedule != null)
            {
                schedule = Schedule;
            }

            if (schedule != null)
            {
                if (ShouldProcess(item.GetProviderPath(), "Start task defined in schedule"))
                {
                    schedule.Execute();
                    WriteObject(schedule);
                }
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:26,代码来源:StartTaskScheduleCommand.cs

示例6: 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

示例7: ProcessItem

 protected override void ProcessItem(Item item)
 {
     var name = string.IsNullOrEmpty(Name) ? item.Name : Name;
     if (ShouldProcess(Destination.GetProviderPath(),
         string.Format("Create clone of '{0}'  with name '{1}' {2} children", item.GetProviderPath(), name,
             (Recursive.IsPresent ? "with" : "without"))))
     {
         var clone = item.CloneTo(Destination, name, Recursive.IsPresent);
         WriteItem(clone);
     }
 }
开发者ID:GuitarRich,项目名称:Console,代码行数:11,代码来源:NewItemCloneCommand.cs

示例8: ProcessItem

        protected override void ProcessItem(Item item)
        {
            if (!this.CanAdmin(item)) { return; }

            if (ShouldProcess(item.GetProviderPath(), "Change access rights"))
            {
                item.Security.SetAccessRules(AccessRules);
            }

            if (PassThru)
            {
                WriteItem(item);
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:14,代码来源:SetItemAclCommand.cs

示例9: ProcessItem

 protected override void ProcessItem(Item item)
 {
     if (!item.IsItemClone)
     {
         WriteError
             (
                 new ErrorRecord
                     (
                     new PSArgumentException("The supplied Item is not a clone!"),
                     "supplied_item_is_not_a_clone",
                     ErrorCategory.InvalidArgument,
                     null
                     )
             );
         return;
     }
     if (ShouldProcess(item.GetProviderPath(), "Convert item clone to full item"))
     {
         var clone = new CloneItem(item);
         WriteItem(clone.Unclone());
     }
 }
开发者ID:sobek85,项目名称:Console,代码行数:22,代码来源:ConvertFromItemCloneCommand.cs

示例10: ProcessItem

        protected override void ProcessItem(Item item)
        {
            var accessRules = item.Security.GetAccessRules();

            if (AccessRules == null)
            {
                AccessRight accessRight;

                if (!this.TryParseAccessRight(AccessRight, out accessRight)) return;

                Account account = this.GetAccountFromIdentity(Identity);

                var accessRule = AccessRule.Create(account, accessRight, PropagationType, SecurityPermission);
                accessRules.Add(accessRule);

                if (ShouldProcess(item.GetProviderPath(),
                    string.Format(
                        "Add access right '{0}' with PropagationType '{1}', SecurityPermission '{2}' for '{3}'",
                        accessRight.Name, PropagationType, SecurityPermission, Identity.Name)))
                {
                    item.Security.SetAccessRules(accessRules);
                }
            }
            else
            {
                if (ShouldProcess(item.GetProviderPath(),"Add Acl list."))
                {
                    accessRules.AddRange(AccessRules);
                    item.Security.SetAccessRules(accessRules);
                }
            }

            if (PassThru)
            {
                WriteItem(item);
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:37,代码来源:AddItemAclCommand.cs

示例11: 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

示例12: ProcessItem

        protected override void ProcessItem(Item item)
        {
            var workflowProvider = item.Database.WorkflowProvider;
            if (workflowProvider == null)
            {
                WriteError(
                    new ErrorRecord(new WorkflowException("Workflow provider could not be obtained for database: " +
                                                          item.Database.Name),
                        "sitecore_workflow_provider_missing",
                        ErrorCategory.ObjectNotFound, null));
                return;
            }

            var workflow = workflowProvider.GetWorkflow(item);
            if (workflow == null)
            {
                WriteError(new ErrorRecord(
                    new WorkflowException("Workflow missing or item not in workflow: " + item.ID),
                    "sitecore_workflow_missing",
                    ErrorCategory.ObjectNotFound, null));
                return;
            }

            try
            {
                var command = workflow.GetCommands(item).FirstOrDefault(c => c.DisplayName == CommandName);
                if (command == null)
                {
                    WriteError(new ErrorRecord(
                        new WorkflowException("Command not present or no execution rights: " + CommandName),
                        "sitecore_workflow_command_missing",
                        ErrorCategory.ObjectNotFound, null));
                    return;
                }

                if (ShouldProcess(item.GetProviderPath(),
                    string.Format("Invoke command '{0}' in workflow '{1}'", command.DisplayName,
                        workflow.Appearance.DisplayName)))
                {
                    var workflowResult = workflow.Execute(command.CommandID, item, Comments, false);
                    if (!workflowResult.Succeeded)
                    {
                        var message = workflowResult.Message;
                        if (string.IsNullOrEmpty(message))
                        {
                            message = "IWorkflow.Execute() failed for unknown reason.";
                        }
                        WriteError(new ErrorRecord(
                            new WorkflowException(message),
                            "sitecore_workflow_execution_error",
                            ErrorCategory.OperationStopped, null));
                    }
                }
            }
            catch (WorkflowStateMissingException)
            {
                WriteError(new ErrorRecord(
                    new WorkflowStateMissingException("Item workflow state does not specify the next step."),
                    "sitecore_workflow_execution_error",
                    ErrorCategory.OperationStopped, null));
            }
        }
开发者ID:sobek85,项目名称:Console,代码行数:62,代码来源:InvokeWorkflowCommand.cs

示例13: 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

示例14: ProcessItem

        protected override void ProcessItem(Item item)
        {
            var matchingFields = GetMatchingFields(item).ToList();

            if (matchingFields.Any())
            {
                if (ShouldProcess(item.GetProviderPath(), string.Format("Reset field(s) '{0}'",
                    matchingFields.Select(r => r.DisplayName).Aggregate((seed, curr) => seed + ", " + curr))))
                {
                    item.Editing.BeginEdit();

                    foreach (var field in matchingFields)
                    {
                        field.Reset();
                    }

                    item.Editing.EndEdit();
                }
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:20,代码来源:ResetItemFieldCommand.cs


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