196c503789
* trying a bold refactoring ETABSShared and CSiShared is strictly correct, but just looks horrible EtabsShared and CsiShared looks better * refactor: improve * property extraction foundation - better architectural approach for property extraction depending on csi product and wrapper type - correctly configures return type depending on the product (e.g. EtabsObject) * refactor(props): streamline property extraction across CSi and ETABS Reorganizes property extraction to better handle base and product-specific properties: - Introduces PropertyExtractionResult for cleaner property management - Separates shared CSi properties from product-specific ones - Implements dedicated extractors for Frame, Joint, and Shell - Standardizes property extraction patterns between CSi and ETABS - Removes property redundancy and improves null safety * frame data extraction 1/2 * remaining data extraction - finished data extraction for frames - added data extraction for joints and shells - re-instated collections * documentation - added some updates to the documentation * SpeckleApplicationIdExtensions - Extension methods for speckle applicationIds * IApplicationPropertiesExtractorConcretization - Renamed GeneralPropertiesExtractor to SharedPropertiesExtractor - Renamed EtabsClassPropertiesExtractor to ApplicationPropertiesExtractor - Removed PropertiesExtractor file - Enforced injection of shared properties extractor to application specific extractor - Output of Extract() of type PropertyExtractorResult - Application property extractor mutates dictionary * applicationId simplification * review comments - directly assigning applicationId to base - rename ApplicationPropertiesExtractor to EtabsPropertiesExtractor --------- Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using Speckle.Converters.Common;
|
|
using Speckle.Converters.CSiShared;
|
|
using Speckle.Sdk.Models;
|
|
using Speckle.Sdk.Models.Collections;
|
|
|
|
namespace Speckle.Connectors.CSiShared.HostApp;
|
|
|
|
/// <summary>
|
|
/// We can use the CSiWrappers to create our collection structure.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This class manages the collections. If the key (from the path) already exists, this collection is returned.
|
|
/// If it doesn't exist, a new collection is created and added to the rootObject.
|
|
/// </remarks>
|
|
public class CsiSendCollectionManager
|
|
{
|
|
protected IConverterSettingsStore<CsiConversionSettings> ConverterSettings { get; }
|
|
protected Dictionary<string, Collection> CollectionCache { get; } = new();
|
|
|
|
public CsiSendCollectionManager(IConverterSettingsStore<CsiConversionSettings> converterSettings)
|
|
{
|
|
ConverterSettings = converterSettings;
|
|
}
|
|
|
|
public virtual Collection AddObjectCollectionToRoot(Base convertedObject, Collection rootObject)
|
|
{
|
|
var path = GetCollectionPath(convertedObject);
|
|
|
|
if (CollectionCache.TryGetValue(path, out Collection? collection))
|
|
{
|
|
return collection;
|
|
}
|
|
|
|
Collection childCollection = CreateCollection(convertedObject);
|
|
rootObject.elements.Add(childCollection);
|
|
CollectionCache[path] = childCollection;
|
|
return childCollection;
|
|
}
|
|
|
|
protected virtual string GetCollectionPath(Base convertedObject) => convertedObject["type"]?.ToString() ?? "Unknown";
|
|
|
|
protected virtual Collection CreateCollection(Base convertedObject) => new(GetCollectionPath(convertedObject));
|
|
}
|