public static SpeckleObject ToSpeckle(this GSA1DInfluenceEffect dummyObject) { var newLines = ToSpeckleBase <GSA1DInfluenceEffect>(); var e1Ds = Initialiser.GSASenderObjects[typeof(GSA1DElement)].Cast <GSA1DElement>().ToList(); var infls = new List <GSA1DInfluenceEffect>(); foreach (var p in newLines.Values) { try { var infl = new GSA1DInfluenceEffect() { GWACommand = p }; infl.ParseGWACommand(e1Ds); infls.Add(infl); } catch { } } Initialiser.GSASenderObjects[typeof(GSA1DInfluenceEffect)].AddRange(infls); return((infls.Count() > 0) ? new SpeckleObject() : new SpeckleNull()); }
public static SpeckleObject ToSpeckle(this GSA1DInfluenceEffect dummyObject) { var newLines = ToSpeckleBase <GSA1DInfluenceEffect>(); var e1Ds = Initialiser.GSASenderObjects.Get <GSA1DElement>(); var inflsLock = new object(); var infls = new List <GSA1DInfluenceEffect>(); Parallel.ForEach(newLines.Values, p => { try { var infl = new GSA1DInfluenceEffect() { GWACommand = p }; infl.ParseGWACommand(e1Ds); lock (inflsLock) { infls.Add(infl); } } catch { } }); Initialiser.GSASenderObjects.AddRange(infls); return((infls.Count() > 0) ? new SpeckleObject() : new SpeckleNull()); }
public static SpeckleObject ToSpeckle(this GSA1DInfluenceEffect dummyObject) { var newLines = ToSpeckleBase <GSA1DInfluenceEffect>(); var typeName = dummyObject.GetType().Name; var e1Ds = Initialiser.GsaKit.GSASenderObjects.Get <GSA1DElement>(); var inflsLock = new object(); var infls = new SortedDictionary <int, GSA1DInfluenceEffect>(); Parallel.ForEach(newLines.Keys, k => { try { var infl = new GSA1DInfluenceEffect() { GWACommand = newLines[k] }; infl.ParseGWACommand(e1Ds); lock (inflsLock) { infls.Add(k, infl); } } 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(infls.Values.ToList()); return((infls.Keys.Count > 0) ? new SpeckleObject() : new SpeckleNull()); }