public static SpeckleObject ToSpeckle(this GSABridgePath dummyObject) { var newLines = ToSpeckleBase <GSABridgePath>(); var paths = new SortedDictionary <int, GSABridgePath>(); var typeName = dummyObject.GetType().Name; var pathsLock = new object(); Parallel.ForEach(newLines.Keys, k => { var path = new GSABridgePath() { GWACommand = newLines[k] }; //Pass in ALL the nodes and members - the Parse_ method will search through them try { path.ParseGWACommand(); lock (pathsLock) { paths.Add(k, path); } } catch (Exception ex) { Initialiser.AppResources.Messenger.CacheMessage(MessageIntent.Display, MessageLevel.Error, typeName, k.ToString()); Initialiser.AppResources.Messenger.CacheMessage(MessageIntent.TechnicalLog, MessageLevel.Error, ex, typeName, k.ToString()); } }); Initialiser.GsaKit.GSASenderObjects.AddRange(paths.Values.ToList()); return((paths.Keys.Count > 0) ? new SpeckleObject() : new SpeckleNull()); }
public static SpeckleObject ToSpeckle(this GSABridgePath dummyObject) { var newLines = ToSpeckleBase <GSABridgePath>(); var paths = new List <GSABridgePath>(); foreach (var p in newLines.Values) { var path = new GSABridgePath() { GWACommand = p }; //Pass in ALL the nodes and members - the Parse_ method will search through them path.ParseGWACommand(); paths.Add(path); } Initialiser.GSASenderObjects[typeof(GSABridgePath)].AddRange(paths); return((paths.Count() > 0) ? new SpeckleObject() : new SpeckleNull()); }