public static SpeckleObject ToSpeckle(this GSA1DMember dummyObject)
        {
            var nodes    = Initialiser.GSASenderObjects[typeof(GSANode)].Cast <GSANode>().ToList();
            var members  = new List <GSA1DMember>();
            var newLines = ToSpeckleBase <GSA1DMember>();

            foreach (var p in newLines.Values)
            {
                var pPieces = p.ListSplit("\t");
                if (pPieces[4].Is1DMember())
                {
                    try
                    {
                        var member = new GSA1DMember()
                        {
                            GWACommand = p
                        };
                        member.ParseGWACommand(nodes);
                        members.Add(member);
                    }
                    catch { }
                }
            }

            Initialiser.GSASenderObjects[typeof(GSA1DMember)].AddRange(members);

            return((members.Count() > 0) ? new SpeckleObject() : new SpeckleNull());
        }
Пример #2
0
        public static SpeckleObject ToSpeckle(this GSA1DMember dummyObject)
        {
            var nodes       = Initialiser.GSASenderObjects.Get <GSANode>();
            var membersLock = new object();
            var members     = new List <GSA1DMember>();
            var newLines    = ToSpeckleBase <GSA1DMember>();

            Parallel.ForEach(newLines.Values, p =>
            {
                var pPieces = p.ListSplit("\t");
                if (pPieces[4].Is1DMember())
                {
                    try
                    {
                        var member = new GSA1DMember()
                        {
                            GWACommand = p
                        };
                        member.ParseGWACommand(nodes);
                        lock (membersLock)
                        {
                            members.Add(member);
                        }
                    }
                    catch { }
                }
            });

            Initialiser.GSASenderObjects.AddRange(members);

            return((members.Count() > 0) ? new SpeckleObject() : new SpeckleNull());
        }
    public static SpeckleObject ToSpeckle(this GSA1DMember dummyObject)
    {
      var nodes = Initialiser.GsaKit.GSASenderObjects.Get<GSANode>();
      var membersLock = new object();
      var members = new SortedDictionary<int, GSA1DMember>();
      var newLines = ToSpeckleBase<GSA1DMember>();
      var typeName = dummyObject.GetType().Name;
      var keyword = dummyObject.GetGSAKeyword();

#if DEBUG
      foreach (var k in newLines.Keys)
#else
      Parallel.ForEach(newLines.Keys, k =>
#endif
      {
        var pPieces = newLines[k].ListSplit(Initialiser.AppResources.Proxy.GwaDelimiter);
        var gsaId = pPieces[1];
        if (pPieces[4].Is1DMember())
        {
          try
          {
            var member = new GSA1DMember() { GWACommand = newLines[k] };
            member.ParseGWACommand(nodes);
            lock (membersLock)
            {
              members.Add(k, member);
            }
          }
          catch (Exception ex)
          {
            Initialiser.AppResources.Messenger.Message(MessageIntent.TechnicalLog, MessageLevel.Error, ex,
              "Keyword=" + keyword, "Index=" + k);
          }
        }
      }
#if !DEBUG
      );
#endif

      if (members.Values.Count() > 0)
      {
        Initialiser.GsaKit.GSASenderObjects.AddRange(members.Values.ToList());
      }

      return (members.Keys.Count() > 0) ? new SpeckleObject() : new SpeckleNull();
    }