public static SpeckleObject ToSpeckle(this GSA2DMember dummyObject)
        {
            var newLines = ToSpeckleBase <GSA2DMember>();

            var members = new List <GSA2DMember>();
            var nodes   = Initialiser.GSASenderObjects[typeof(GSANode)].Cast <GSANode>().ToList();
            var props   = Initialiser.GSASenderObjects[typeof(GSA2DProperty)].Cast <GSA2DProperty>().ToList();

            foreach (var p in newLines.Values)
            {
                var pPieces = p.ListSplit("\t");
                if (pPieces[4].Is2DMember())
                {
                    // Check if dummy
                    if (pPieces[pPieces.Length - 4] == "ACTIVE")
                    {
                        try
                        {
                            var member = new GSA2DMember()
                            {
                                GWACommand = p
                            };
                            member.ParseGWACommand(nodes, props);
                            members.Add(member);
                        }
                        catch { }
                    }
                }
            }

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

            return((members.Count() > 0) ? new SpeckleObject() : new SpeckleNull());
        }
Example #2
0
    public static SpeckleObject ToSpeckle(this GSA2DMember dummyObject)
    {
      var newLines = ToSpeckleBase<GSA2DMember>();
      var typeName = dummyObject.GetType().Name;
      var membersLock = new object();
      var members = new SortedDictionary<int, GSA2DMember>();
      var nodes = Initialiser.GsaKit.GSASenderObjects.Get<GSANode>();
      var props = Initialiser.GsaKit.GSASenderObjects.Get<GSA2DProperty>();
      
      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);
        if (pPieces[4].Is2DMember())
        {
          // Check if dummy
          if (pPieces[20] == "ACTIVE")
          {
            var gsaId = pPieces[1];
            try
            {
              var member = new GSA2DMember() { GWACommand = newLines[k] };
              member.ParseGWACommand(nodes, props, GetGsaPropDict());
              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();
    }
Example #3
0
        public static SpeckleObject ToSpeckle(this GSA2DMember dummyObject)
        {
            var newLines = ToSpeckleBase <GSA2DMember>();

            var membersLock = new object();
            var members     = new List <GSA2DMember>();
            var nodes       = Initialiser.GSASenderObjects.Get <GSANode>();
            var props       = Initialiser.GSASenderObjects.Get <GSA2DProperty>();

            Parallel.ForEach(newLines.Values, p =>
            {
                var pPieces = p.ListSplit("\t");
                if (pPieces[4].Is2DMember())
                {
                    // Check if dummy
                    if (pPieces[pPieces.Length - 4] == "ACTIVE")
                    {
                        try
                        {
                            var member = new GSA2DMember()
                            {
                                GWACommand = p
                            };
                            member.ParseGWACommand(nodes, props);
                            lock (membersLock)
                            {
                                members.Add(member);
                            }
                        }
                        catch { }
                    }
                }
            });

            Initialiser.GSASenderObjects.AddRange(members);

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