Click or drag to resize

IAnalysisModelReferenceSorter

[This is preliminary documentation and is subject to change.]

See IAnalysisModelReferenceSorter for technical documentation

This service is used to sort a list of objects, based on their dependencies to other objects.

This page was last updated 2021-12-03

Examples
Retrieve the service from the container
AnalysisDataModelBootstrapper bootstrapper = new AnalysisDataModelBootstrapper();

using (IScopedServiceProvider scope = bootstrapper.CreateThreadedScope())
{
  IAnalysisModelReferenceSorter service = scope.GetService<IAnalysisModelReferenceSorter>();
}
Sort a list of objects
AnalysisDataModelBootstrapper bootstrapper = new AnalysisDataModelBootstrapper();

using (IScopedServiceProvider scope = bootstrapper.CreateThreadedScope())
{
  IAnalysisModelReferenceSorter service = scope.GetService<IAnalysisModelReferenceSorter>();

  StructuralPointConnection node1 = new StructuralPointConnection(Guid.NewGuid(), "N1", Length.Zero, Length.Zero, Length.Zero);
  StructuralPointConnection node2 = new StructuralPointConnection(Guid.NewGuid(), "N2", Length.FromMeters(2), Length.Zero, Length.Zero);
  StructuralMaterial material = new StructuralMaterial(Guid.NewGuid(), "MAT1", MaterialType.Steel, "S235");
  StructuralManufacturedCrossSection css = new StructuralManufacturedCrossSection(Guid.NewGuid(), "CS1", material, "HEA200", FormCode.ISection, DescriptionId.EuropeanWideFlangeBeam);
  StructuralCurveMember beam = new StructuralCurveMember(Guid.NewGuid(), "B1", new []{ new Curve<StructuralPointConnection>(CurveGeometricalShape.Line, new []{ node1, node2 }) }, css);
  RelConnectsStructuralMember lineSupport = new RelConnectsStructuralMember(Guid.NewGuid(), "RCSM1", beam);
  StructuralLoadGroup loadgroup = new StructuralLoadGroup(Guid.NewGuid(), "LG1", LoadGroupType.Permanent);
  StructuralLoadCase loadcase = new StructuralLoadCase(Guid.NewGuid(), "LC1", ActionType.Permanent, loadgroup, LoadCaseType.SelfWeight);
  StructuralCurveAction<CurveStructuralReferenceOnBeam> lineforce = new StructuralCurveAction<CurveStructuralReferenceOnBeam>(Guid.NewGuid(), "LF1", CurveForceAction.OnBeam, ForcePerLength.FromKilonewtonsPerMeter(-2), loadcase, new CurveStructuralReferenceOnBeam(beam));

  IAnalysisObject[] sortThis = new IAnalysisObject[] {
    lineSupport,
    beam,
    loadcase,
    loadgroup,
    lineforce,
    node1,
    css,
    node2,
    material
  };

  IReadOnlyCollection<IAnalysisObject> sorted = service.Sort(sortThis);
}

In this example, the sortThis collection objects will be sorted based on their score, and the output will be as follows:

  • StructuralLoadGroup (has no dependency on another object, score 0)

  • StructuralPointConnections (has no dependency on other objects, score 0)

  • StructuralMaterial (has no dependency on other objects, score 0)

  • StructuralLoadCase (has 1 dependency, StructuralLoadGroup, score 1)

  • StructuralManufacturedCrossSection (has 1 dependency, StructuralMaterial, score 1)

  • StructuralCurveMember (has 2 dependencies, StructuralPointConnection and StructuralCrossSection which depends on StructuralMaterial, score 2)

  • RelConnectsStructuralMember (has 1 dependency, StructuralCurveMember, which depends on StructuralPointConnection and StructuralCrossSection which depends on StructuralMaterial, score 3)

  • StructuralCurveAction<CurveStructuralReferenceOnBeam> (has 2 dependencies, StructuralLoadCase which depends on StructuralLoadGroup and StructuralCurveMember, which depends on StructuralPointConnection and StructuralCrossSection which depends on StructuralMaterial, score 4)

See Also