/// <summary> /// Get the AnalysisResultsSchemaIndex for the SpatialFieldManager /// </summary> /// <returns></returns> protected int GetAnalysisResultSchemaIndex() { // Get the AnalysisResultSchema index - there is only one for Dynamo var schemaIndex = 0; if (!SpatialFieldManager.IsResultSchemaNameUnique(AbstractAnalysisDisplay.ResultsSchemaName, -1)) { var arses = SpatialFieldManager.GetRegisteredResults(); schemaIndex = arses.First( x => SpatialFieldManager.GetResultSchema(x).Name == AbstractAnalysisDisplay.ResultsSchemaName); } else { var ars = new AnalysisResultSchema(AbstractAnalysisDisplay.ResultsSchemaName, "Resulting analyses from Dynamo."); schemaIndex = SpatialFieldManager.RegisterResult(ars); } return(schemaIndex); }
/// <summary> /// Get the AnalysisResultsSchemaIndex for the SpatialFieldManager /// </summary> /// <returns></returns> protected virtual int GetAnalysisResultSchemaIndex(string resultsSchemaName, string resultsDescription, Type unitType) { // Get the AnalysisResultSchema index - there is only one for Dynamo var schemaIndex = 0; if (!SpatialFieldManager.IsResultSchemaNameUnique(resultsSchemaName, -1)) { var arses = SpatialFieldManager.GetRegisteredResults(); schemaIndex = arses.First( x => SpatialFieldManager.GetResultSchema(x).Name == resultsSchemaName); } else { var ars = new AnalysisResultSchema(resultsSchemaName, resultsDescription); if (unitType != null) { if (typeof(SIUnit).IsAssignableFrom(unitType)) { var prop = unitType.GetProperty("Conversions"); var conversions = (Dictionary <string, double>)prop.GetValue(null, new object[] { }); if (conversions != null) { var unitNames = conversions.Keys.ToList(); var multipliers = conversions.Values.ToList(); ars.SetUnits(unitNames, multipliers); ars.CurrentUnits = 0; } } } schemaIndex = SpatialFieldManager.RegisterResult(ars); } return(schemaIndex); }