public static SceneBuildSettings ByParameters(string transformationStrategy, string positioningStrategy, CRSTransform crs, UnitScale unitScale, string[] sceneContexts, string identificationStrategy) { if (string.IsNullOrEmpty(transformationStrategy) || string.IsNullOrEmpty(positioningStrategy) || string.IsNullOrEmpty(identificationStrategy)) { throw new ArgumentNullException("transformationStrategy | positioningStrategy | identificationStrategy"); } var settings = new SceneBuildSettings(new ExportPreferences { Transforming = DynamicArgumentDelegation.TryCastEnumOrDefault <SceneTransformationStrategy>(transformationStrategy), Positioning = DynamicArgumentDelegation.TryCastEnumOrDefault <ScenePositioningStrategy>(positioningStrategy), UserModelCenter = crs.Transform.T, CRS = crs.Transform.R * (unitScale?.UnitsPerMeter ?? 1), SelectedContext = sceneContexts?.Select(c => new SceneContext { Name = c.ToQualifier() }).ToArray() ?? new SceneContext[] { }, ComponentIdentificationStrategy = DynamicArgumentDelegation.TryCastEnumOrDefault <SceneComponentIdentificationStrategy>(identificationStrategy) }); return(settings); }
#pragma warning restore CS1591 /// <summary> /// Saves the settings to file as XML. /// </summary> /// <param name="fileName">The file name</param> /// <param name="settings">The settings</param> /// <returns>A log message</returns> public static LogMessage SaveAs(SceneBuildSettings settings, string fileName) { try { settings.Preferences.SaveTo(fileName); return(LogMessage.BySeverityAndMessage(fileName, LogSeverity.Info, LogReason.Saved, "Saved {0}", fileName)); } catch (Exception e) { return(LogMessage.BySeverityAndMessage(fileName, LogSeverity.Error, LogReason.Saved, "{0}: {1} ({2})", e, e.Message, fileName)); } }