-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All ObjectPath elements displayed in action tree #36. Partially rewri…
- Loading branch information
1 parent
86da95d
commit 64ce01a
Showing
24 changed files
with
368 additions
and
415 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Xml.Linq; | ||
|
||
namespace CsomInspector.Core.Actions | ||
{ | ||
public abstract class ActionBase : IObjectTreeNode, INotifyPropertyChanged | ||
{ | ||
protected ActionBase() | ||
{ | ||
MergedActions = new List<ActionBase>(); | ||
} | ||
|
||
protected const String _elementNamespace = "http://schemas.microsoft.com/sharepoint/clientquery/2009"; | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
public virtual IEnumerable<IObjectTreeNode> Children => Enumerable.Empty<IObjectTreeNode>(); | ||
|
||
public Int32 Id { get; protected set; } | ||
|
||
public Boolean IsHighlighted { get; private set; } | ||
|
||
public Int32 ObjectPathId { get; protected set; } | ||
|
||
public List<ActionBase> MergedActions { get; } | ||
public List<Result> Results { get; internal set; } | ||
|
||
public static ActionBase FromXml(XElement actionElement) | ||
{ | ||
if (actionElement == null) | ||
{ | ||
throw new ArgumentNullException(nameof(actionElement)); | ||
} | ||
|
||
var name = actionElement.Name; | ||
if (actionElement.Name.NamespaceName != _elementNamespace) | ||
{ | ||
throw new ArgumentException("Specified element does not match CSOM request namespace.", nameof(actionElement)); | ||
} | ||
|
||
var idAttribute = actionElement.Attribute(XName.Get("Id")); | ||
var objectPathAttribute = actionElement.Attribute(XName.Get("ObjectPathId")); | ||
|
||
var action = CreateAction(actionElement); | ||
action.Id = Convert.ToInt32(idAttribute.Value); | ||
action.ObjectPathId = Convert.ToInt32(objectPathAttribute.Value); | ||
|
||
return action; | ||
} | ||
|
||
public void Highlight(Boolean isHighlighted) | ||
{ | ||
IsHighlighted = isHighlighted; | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsHighlighted))); | ||
} | ||
|
||
private static ActionBase CreateAction(XElement element) | ||
{ | ||
var name = element.Name.LocalName; | ||
|
||
switch (name) | ||
{ | ||
case "Query": | ||
return QueryAction.FromXml(element); | ||
case "Method": | ||
return MethodAction.FromXml(element); | ||
case "SetProperty": | ||
return SetPropertyAction.FromXml(element); | ||
default: | ||
return GenericAction.FromXml(element); | ||
} | ||
} | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
...mInspector.Core/Actions/ChildItemQuery.cs → ...ctor.Core/Actions/ChildItemQueryAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace CsomInspector.Core.Actions | ||
{ | ||
public class ChildItemQuery | ||
{ | ||
} | ||
namespace CsomInspector.Core.Actions | ||
{ | ||
public class ChildItemQueryAction | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 24 additions & 25 deletions
49
...ctor/CsomInspector.Core/Actions/Method.cs → ...somInspector.Core/Actions/MethodAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Xml.Linq; | ||
|
||
using System.Xml.Linq; | ||
|
||
namespace CsomInspector.Core.Actions | ||
{ | ||
public class Method : Action | ||
{ | ||
private Method(ObjectPaths.Method method) | ||
: base("Method") | ||
{ | ||
_method = method; | ||
} | ||
|
||
private ObjectPaths.Method _method; | ||
|
||
public override IEnumerable<IObjectTreeNode> Children => _method.Children; | ||
|
||
public override String ToString() => _method.ToString(); | ||
|
||
internal static Method FromXml(XElement actionElement) | ||
{ | ||
var nameAttribute = actionElement.Attribute(XName.Get("Name")); | ||
var parametersElement = actionElement.Element(XName.Get("Parameters")); | ||
var method = ObjectPaths.Method.FromXml(actionElement); | ||
|
||
return new Method(method); | ||
} | ||
{ | ||
public class MethodAction : ActionBase | ||
{ | ||
private MethodAction(ObjectPaths.Method method) | ||
{ | ||
_method = method; | ||
} | ||
|
||
private ObjectPaths.Method _method; | ||
|
||
public override IEnumerable<IObjectTreeNode> Children => _method.Children; | ||
|
||
public override String ToString() => _method.ToString(); | ||
|
||
internal static new MethodAction FromXml(XElement actionElement) | ||
{ | ||
var nameAttribute = actionElement.Attribute(XName.Get("Name")); | ||
var parametersElement = actionElement.Element(XName.Get("Parameters")); | ||
var method = ObjectPaths.Method.FromXml(actionElement); | ||
|
||
return new MethodAction(method); | ||
} | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
...ector.Core/Actions/ObjectIdentityQuery.cs → ...Core/Actions/ObjectIdentityQueryAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace CsomInspector.Core.Actions | ||
{ | ||
public class ObjectIdentityQuery | ||
{ | ||
} | ||
namespace CsomInspector.Core.Actions | ||
{ | ||
public class ObjectIdentityQueryAction | ||
{ | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
CsomInspector/CsomInspector.Core/Actions/ObjectPathAction.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.