Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Add] QueryReferencedThings() and QueryReferencedThingsDeep() methods to the abstract Thing class #143

Merged
merged 5 commits into from
Oct 23, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions CDP4Common/Poco/Thing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ protected Thing(Guid iid, ConcurrentDictionary<CacheKey, Lazy<CommonData.Thing>>
[CDPVersion("1.1.0")]
[UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)]
[DataMember]
public virtual List<DomainOfExpertise> ExcludedDomain { get; set; }
public virtual List<DomainOfExpertise> ExcludedDomain { get; set; }
/// <summary>
/// Gets or sets a list of <see cref="Person"/> that are excluded for this instance.
/// </summary>
Expand Down Expand Up @@ -236,8 +236,8 @@ public CacheKey CacheKey
if (this.cacheKey.Thing != Guid.Empty)
{
return this.cacheKey;
}
}
var iterationContainer = this.GetContainerOfType<Iteration>();
Guid? iterationId = null;
if (iterationContainer != null && this.ClassKind != ClassKind.Iteration)
Expand Down Expand Up @@ -273,8 +273,8 @@ public string Route
get
{
var currentType = this.GetType();
var typeName = currentType.Name;
var typeName = currentType.Name;
if (this is TopContainer)
{
if (typeName == "SiteDirectory" && this.Iid == Guid.Empty)
Expand All @@ -288,8 +288,8 @@ public string Route
if (this is NotThing)
{
return "no thing, no route";
}
}
var container = this.Container;

if (container == null)
Expand Down Expand Up @@ -339,6 +339,39 @@ public IEnumerable<Thing> QueryContainedThingsDeep()
return temp;
}

/// <summary>
/// Queries the referenced <see cref="Thing"/>s of the current <see cref="Thing"/>
/// </summary>
/// <remarks>
/// this does not include the contained <see cref="Thing"/>s, the contained <see cref="Thing"/>s
/// are exposed via the <see cref="ContainerLists"/> method
/// </remarks>
/// <returns></returns>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing doc

public virtual IEnumerable<Thing> QueryReferencedThings()
{
return Enumerable.Empty<Thing>();
}

/// <summary>
/// Queries all the referenced <see cref="Thing"/>s of the current <see cref="Thing"/>, along the complete
/// referenced <see cref="Thing"/> chain and returns them as a flat list
/// </summary>
/// <returns>
/// An <see cref="IEnumerable{Thing}"/>
/// </returns>
public IEnumerable<Thing> QueryReferencedThingsDeep()
{
var temp = new List<Thing>();

foreach (var thing in this.QueryReferencedThings())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For QueryReferencedThingsDeep, I was thinking of returning the list of objects referenced from the full containment [sub]tree, not a tree of referenced things: so iterating through this.ContainerList, not the referenced things.

For the full tree of things "connected" to the current thing, we would indeed interate through both contained and referenced things.

{
temp.Add(thing);
temp.AddRange(thing.QueryReferencedThings());
}

return temp;
}

/// <summary>
/// Gets or sets the Change status of this <see cref="Thing"/>.
/// </summary>
Expand Down