Skip to content

Commit

Permalink
Updated provider to finish the Dynamic Parameter support for issue #181.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellwest committed Apr 29, 2014
1 parent f667bb4 commit 6f90deb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Cognifide.PowerShell.PowerShellIntegrations.Provider
{
public partial class PsSitecoreItemProvider
public partial class PsSitecoreItemProvider : IDynamicParameters
{
private const string FailSilentlyParam = "FailSilently";
private const string QueryParam = "Query";
Expand Down Expand Up @@ -184,5 +184,10 @@ protected override object NewItemDynamicParameters(string path, string itemTypeN
paramAdded |= AddDynamicParameter(typeof (Item), ParentParam, ref dic, true);
return paramAdded ? dic : null;
}

public object GetDynamicParameters()
{
return null;
}
}
}
16 changes: 10 additions & 6 deletions PowerShellIntegrations/Provider/PsSitecoreItemProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ protected override void GetItem(string path)
{
string Id = dic[IdParam].Value.ToString();
Item itemById = Factory.GetDatabase(PSDriveInfo.Name).GetItem(new ID(Id));
WriteMatchingItem(language, version, itemById);
if (itemById != null)
{
WriteMatchingItem(language, version, itemById);
}
return;
}

Expand Down Expand Up @@ -333,7 +336,7 @@ protected override void CopyItem(string path, string destination, bool recurse)
}
}

if (ShouldProcess(sourceItem.Paths.Path, "Copy to '" + destinationItem.Paths.Path + "/" + leafName+"'"))
if (ShouldProcess(sourceItem.Paths.Path, "Copy to '" + destinationItem.Paths.Path + "/" + leafName + "'"))
{
var id = new ID(Guid.NewGuid());
Item itemCopy = sourceItem.CopyTo(destinationItem, leafName, id, recurse);
Expand Down Expand Up @@ -382,7 +385,7 @@ protected override void MoveItem(string path, string destination)
}
}

if (ShouldProcess(sourceItem.Paths.Path, "Move to '" + destinationItem.Paths.Path + "/"+leafName))
if (ShouldProcess(sourceItem.Paths.Path, "Move to '" + destinationItem.Paths.Path + "/" + leafName))
{
sourceItem.MoveTo(destinationItem);

Expand Down Expand Up @@ -412,7 +415,7 @@ protected override void RenameItem(string path, string newName)
if (item != null)
{
CheckOperationAllowed("rename", item.Access.CanRename(), item.Uri.ToString());
if (ShouldProcess(item.Paths.Path, "Rename to '" +newName + "'"))
if (ShouldProcess(item.Paths.Path, "Rename to '" + newName + "'"))
{
item.Edit(
args => { item.Name = newName; });
Expand Down Expand Up @@ -449,7 +452,7 @@ protected override void NewItem(string path, string itemTypeName, object newItem

Item srcItem = GetItemForPath("/" + itemTypeName);

if(srcItem == null)
if (srcItem == null)
{
throw new ObjectNotFoundException(
string.Format("Template '{0}' does not exist or wrong path provided.",
Expand All @@ -463,7 +466,8 @@ protected override void NewItem(string path, string itemTypeName, object newItem
parentItem = dic[ParentParam].Value as Item;
}

if (ShouldProcess(GetParentFromPath(path), "Create item '" + GetLeafFromPath(path) + "' of type '" + itemTypeName + "'"))
if (ShouldProcess(GetParentFromPath(path),
"Create item '" + GetLeafFromPath(path) + "' of type '" + itemTypeName + "'"))
{
Item createdItem = null;
if (srcItem.TemplateName == "Template")
Expand Down

0 comments on commit 6f90deb

Please sign in to comment.