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


C# Item.GetProviderPath方法代码示例

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


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

示例1: EditItem

        protected override void EditItem(Item item)
        {
            if (!ShouldProcess(item.GetProviderPath(), "Lock Item")) return;

            var itemLock = item.Locking;
            if (itemLock.GetOwner().Is(Identity.Name))
            {
                return;
            }
            if (itemLock.IsLocked())
            {
                if (Force)
                {
                    itemLock.Unlock();
                }
                else
                {
                    WriteError(typeof(SecurityException), $"Cannot modify item '{item.Name}' because it is locked by '{item.Locking.GetOwner()}' - Use the -Force parameter to transfet lock to the new user.",
                        ErrorIds.InsufficientSecurityRights, ErrorCategory.InvalidData,item);
                    return;
                }
            }

            item.Locking.Lock();
        }
开发者ID:sobek85,项目名称:Console,代码行数:25,代码来源:LockItemCommand.cs

示例2: ProcessItem

        protected override void ProcessItem(Item item)
        {
            if (ShouldProcess(item.GetProviderPath(), string.Format("Set layout '{0}'", Layout.GetProviderPath())))
            {
                LayoutField layoutField = item.Fields[LayoutFieldId];
                if (layoutField == null)
                {
                    return;
                }

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

                var device = layout.GetDevice(Device.ID.ToString());

                if (string.Equals(device.Layout, Layout.ID.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    //same layout as already set - no point in setting it again
                    return;
                }

                device.Layout = Layout.ID.ToString();

                item.Edit(p =>
                {
                    var outputXml = layout.ToXml();
                    layoutField.Value = outputXml;
                });
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:29,代码来源:SetLayoutCommand.cs

示例3: ProcessItem

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

示例4: ProcessItem

        protected override void ProcessItem(Item item)
        {
            if (ShouldProcess(item.GetProviderPath(), "Reset layout"))
            {
                Field layoutField = item.Fields[LayoutFieldId];

                if (layoutField == null)
                {
                    return;
                }

                item.Edit(p =>
                {
                    layoutField.Reset();
                });
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:17,代码来源:ResetLayoutCommand.cs

示例5: ProcessItem

        protected override void ProcessItem(Item item)
        {
            if (ShouldProcess(item.GetProviderPath(), "Expand tokens"))
            {
                Item.Editing.BeginEdit();
                try
                {
                    tokenReplacer.ReplaceItem(Item);
                    Item.Editing.EndEdit();
                }
                catch (Exception ex)
                {
                    Item.Editing.CancelEdit();
                    WriteError(new ErrorRecord(ex, "sitecore_token_expander_error", ErrorCategory.NotSpecified, Item));
                }

                WriteItem(Item);
            }
        }
开发者ID:sobek85,项目名称:Console,代码行数:19,代码来源:ExpandTokensCommand.cs

示例6: PublishToTarget

        private void PublishToTarget(Item item, Database source, Database target)
        {
            if (PublishMode == PublishMode.Unknown)
            {
                PublishMode = PublishMode.Smart;
            }

            var language = item.Language;

            if (ShouldProcess(item.GetProviderPath(),
                string.Format("{3}ublishing language '{0}', version '{1}' to target '{2}'.", language, item.Version,
                    target.Name, Recurse.IsPresent ? "Recursively p" : "P")))
            {
                WriteVerbose(
                    String.Format(
                        "Publishing item '{0}' in language '{1}', version '{2}' to target '{3}'.  (Recurse={4}).",
                        item.Name, language, item.Version, target.Name, Recurse.IsPresent));

                var options = new PublishOptions(source, target, PublishMode, language, DateTime.Now)
                {
                    Deep = Recurse.IsPresent,
                    RootItem = item
                };

                var optionsArgs = new PublishOptions[1];
                optionsArgs[0] = options;

                var handle = PublishManager.Publish(optionsArgs);

                if (handle != null)
                {
                    var publishStatus = PublishManager.GetStatus(handle) ?? new PublishStatus();

                    WriteVerbose(String.Format("Publish Job submitted, current state={0}.",
                        publishStatus.State));
                }
            }
        }
开发者ID:ostat,项目名称:Console,代码行数:38,代码来源:PublishItemCommand.cs

示例7: ProcessItem

 protected override void ProcessItem(Item item)
 {
     if (ShouldProcess(item.GetProviderPath(),
         string.Format("Add language '{0}' version(s){1}",
             TargetLanguage.Aggregate((seed, curr) => seed + ", " + curr), (Recurse ? " recursively" : ""))))
     {
         foreach (var targetLanguage in TargetLanguage)
         {
             var lang = LanguageManager.GetLanguage(targetLanguage);
             if (lang == null)
             {
                 var error = String.Format("Cannot find target language '{0}' or it is not enabled.",
                     targetLanguage);
                 WriteError(new ErrorRecord(new ObjectNotFoundException(error), error,
                     ErrorCategory.ObjectNotFound,
                     item));
             }
             else
             {
                 var latestVersion = item.Versions.GetLatestVersion(lang);
                 if (IfExist != ActionIfExists.Skip || (latestVersion.Versions.Count == 0))
                 {
                     CopyFields(item, latestVersion, false);
                 }
                 if (Recurse)
                 {
                     foreach (Item childItem in item.Children)
                     {
                         ProcessItem(childItem);
                     }
                 }
             }
         }
     }
 }
开发者ID:ostat,项目名称:Console,代码行数:35,代码来源:AddItemLanguageCommand.cs

示例8: ProcessItem

        protected override void ProcessItem(Item item)
        {
            if (!ShouldProcess(item.GetProviderPath(),
                $"Add language '{TargetLanguage.Aggregate((seed, curr) => seed + ", " + curr)}' version(s){(Recurse ? " recursively" : "")}"))
                return;

            foreach (var targetLanguage in TargetLanguage)
            {
                var lang = LanguageManager.GetLanguage(targetLanguage);
                if (lang == null)
                {
                    WriteError(typeof(ObjectNotFoundException), $"Cannot find target language '{targetLanguage}' or it is not enabled.",
                        ErrorIds.LanguageNotFound, ErrorCategory.ObjectNotFound, item);
                }
                else
                {
                    var latestVersion = item.Versions.GetLatestVersion(lang);
                    if (IfExist != ActionIfExists.Skip || (latestVersion.Versions.Count == 0))
                    {
                        CopyFields(item, latestVersion, false);
                    }
                    if (Recurse)
                    {
                        foreach (Item childItem in item.Children)
                        {
                            ProcessItem(childItem);
                        }
                    }
                }
            }
        }
开发者ID:sobek85,项目名称:Console,代码行数:31,代码来源:AddItemLanguageCommand.cs

示例9: SetExecutedScript

 public void SetExecutedScript(Item scriptItem)
 {
     if (scriptItem != null)
     {
         SetVariable("PSScriptRoot", scriptItem.Parent.GetProviderPath());
         SetVariable("PSCommandPath", scriptItem.GetProviderPath());
         SetVariable("PSScript", scriptItem);
     }
 }
开发者ID:sobek85,项目名称:Console,代码行数:9,代码来源:ScriptSession.cs


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