Use new ProxyMap that is source gen (#14)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<PackageVersion Include="Glob" Version="1.1.9" />
|
||||
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||
<PackageVersion Include="SimpleExec" Version="12.0.0" />
|
||||
<PackageVersion Include="Speckle.ProxyGenerator" Version="0.1.6" />
|
||||
<PackageVersion Include="Speckle.ProxyGenerator" Version="0.1.7" />
|
||||
<PackageVersion Include="Mapster" Version="7.3.0" />
|
||||
<PackageVersion Include="MinVer" Version="5.0.0" />
|
||||
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
|
||||
@@ -15,4 +15,4 @@
|
||||
<PackageVersion Include="NUnit.Analyzers" Version="4.2.0" />
|
||||
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
},
|
||||
"Speckle.ProxyGenerator": {
|
||||
"type": "Direct",
|
||||
"requested": "[0.1.6, )",
|
||||
"resolved": "0.1.6",
|
||||
"contentHash": "SO9Udllol9Krpq+UFBr54Es79kmiIQmtSRXKFcvplnisdwmjo5CBlucuuvgZYmQUSvF/9KC4BcuVllZRTCBDHQ=="
|
||||
"requested": "[0.1.7, )",
|
||||
"resolved": "0.1.7",
|
||||
"contentHash": "CyMcXENu9e5qHPPbcSTMAtYt4AYHaFaeo/WL7Qhw4MiQyEk+j2ZFsDRY3YxWDmrp41gMcOmuXUPzFEWd0A6YYA=="
|
||||
},
|
||||
"Speckle.Revit.API": {
|
||||
"type": "Direct",
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
},
|
||||
"Speckle.ProxyGenerator": {
|
||||
"type": "Direct",
|
||||
"requested": "[0.1.6, )",
|
||||
"resolved": "0.1.6",
|
||||
"contentHash": "SO9Udllol9Krpq+UFBr54Es79kmiIQmtSRXKFcvplnisdwmjo5CBlucuuvgZYmQUSvF/9KC4BcuVllZRTCBDHQ=="
|
||||
"requested": "[0.1.7, )",
|
||||
"resolved": "0.1.7",
|
||||
"contentHash": "CyMcXENu9e5qHPPbcSTMAtYt4AYHaFaeo/WL7Qhw4MiQyEk+j2ZFsDRY3YxWDmrp41gMcOmuXUPzFEWd0A6YYA=="
|
||||
},
|
||||
"Speckle.Revit.API": {
|
||||
"type": "Direct",
|
||||
|
||||
@@ -98,12 +98,12 @@ public partial interface IRevitFilteredElementCollectorProxy : IRevitFilteredEle
|
||||
|
||||
public partial class FilteredElementCollectorProxy
|
||||
{
|
||||
public IEnumerable<T> OfClass<T>(IProxyMap proxyMap) =>
|
||||
public IEnumerable<T> OfClass<T>() =>
|
||||
_Instance
|
||||
.OfClass(
|
||||
proxyMap.GetHostTypeFromMappedType(typeof(T))
|
||||
ProxyMap.GetHostTypeFromMappedType(typeof(T))
|
||||
?? throw new InvalidOperationException($"Could not unmap type: {typeof(T).FullName}")
|
||||
)
|
||||
.Select(x => proxyMap.CreateProxy(typeof(T), x))
|
||||
.Select(x => ProxyMap.CreateProxy(typeof(T), x))
|
||||
.Cast<T>();
|
||||
}
|
||||
|
||||
@@ -101,12 +101,6 @@ public interface IRevitGroup : IRevitElement
|
||||
IList<IRevitElementId> GetMemberIds();
|
||||
}
|
||||
|
||||
public interface IRevitSolid : IRevitGeometryObject
|
||||
{
|
||||
IRevitFaceArray Faces { get; }
|
||||
double SurfaceArea { get; }
|
||||
}
|
||||
|
||||
public interface IRevitFace
|
||||
{
|
||||
IRevitMesh Triangulate();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Speckle.Revit.Interfaces;
|
||||
|
||||
@@ -19,31 +19,3 @@ public interface IRevitFilterFactory
|
||||
IRevitPointCloudFilter CreateMultiPlaneFilter(params IRevitPlane[] planes);
|
||||
IRevitElementCategoryFilter CreateElementCategoryFilter(RevitBuiltInCategory category);
|
||||
}
|
||||
|
||||
public interface IProxyMap
|
||||
{
|
||||
Type? GetMappedTypeFromHostType(Type type);
|
||||
Type? GetMappedTypeFromProxyType(Type type);
|
||||
Type? GetHostTypeFromMappedType(Type type);
|
||||
|
||||
object CreateProxy(Type type, object toWrap);
|
||||
}
|
||||
|
||||
// ghetto default interface implementation :(
|
||||
public static class ProxyMapExtensions
|
||||
{
|
||||
public static (Type, object)? WrapIfExists(this IProxyMap proxyMap, Type target, object toWrap)
|
||||
{
|
||||
var mappedType = proxyMap.GetMappedTypeFromHostType(target);
|
||||
if (mappedType is not null)
|
||||
{
|
||||
return (mappedType, proxyMap.CreateProxy(mappedType, toWrap));
|
||||
}
|
||||
mappedType = proxyMap.GetMappedTypeFromProxyType(target);
|
||||
if (mappedType is not null)
|
||||
{
|
||||
return (mappedType, toWrap);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
public interface IRevitFilteredElementCollector : IRevitElementFilter
|
||||
{
|
||||
IEnumerable<T> OfClass<T>(IProxyMap proxyMap);
|
||||
IEnumerable<T> OfClass<T>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#nullable enable
|
||||
namespace Speckle.Revit.Interfaces;
|
||||
|
||||
public interface IRevitSolid : IRevitGeometryObject
|
||||
{
|
||||
IRevitFaceArray Faces { get; }
|
||||
double SurfaceArea { get; }
|
||||
}
|
||||
Reference in New Issue
Block a user