Skip to content

Commit

Permalink
Merge pull request #227 from SergeyNefyodov/dev-connectorManager-support
Browse files Browse the repository at this point in the history
Add ConnectorManager.Lookup support
  • Loading branch information
Nice3point authored May 1, 2024
2 parents f9ead94 + 943c554 commit e387c0b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/RevitLookup/Core/ComponentModel/DescriptorMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public static Descriptor FindDescriptor(object obj, Type type)
AssetProperty value when type is null || type == typeof(AssetProperty) => new AssetPropertyDescriptor(value),
BasePoint value when type == typeof(BasePoint) => new BasePointDescriptor(value),
InternalOrigin value when type == typeof(InternalOrigin) => new InternalOriginDescriptor(value),
ConnectorManager value when type == typeof(ConnectorManager) => new ConnectorManagerDescriptor(value),
ViewSchedule value when type == typeof(ViewSchedule) => new ViewScheduleDescriptor(value),
ScheduleDefinition value when type == typeof(ScheduleDefinition) => new ScheduleDefinitionDescriptor(value),
TableData value when type == typeof(TableData) => new TableDataDescriptor(value),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2003-2024 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.

using System.Reflection;
using RevitLookup.Core.Contracts;
using RevitLookup.Core.Objects;

namespace RevitLookup.Core.ComponentModel.Descriptors;

public class ConnectorManagerDescriptor(ConnectorManager connectorManager) : Descriptor, IDescriptorResolver
{
public ResolveSet Resolve(Document context, string target, ParameterInfo[] parameters)
{
return target switch
{
nameof(ConnectorManager.Lookup) => ResolveLookup(),
_ => null
};

ResolveSet ResolveLookup()
{
var connectorSet = connectorManager.Connectors;
var capacity = connectorSet.Size;
var resolveSummary = new ResolveSet(capacity);

for (var i = 0; i < capacity; i++)
{
resolveSummary.AppendVariant(connectorManager.Lookup(i));
}

return resolveSummary;
}
}
}

0 comments on commit e387c0b

Please sign in to comment.