private LinkedInUserInfo MapUser(Person person)
        {
            if (person == null)
                throw new ArgumentNullException("person");

            LinkedInUserInfo userInfo = new LinkedInUserInfo
            {
                UserID = person.Id,
                UserName = person.Name,
                ImageUrl = person.PictureUrl,
                FirstName = person.FirstName,
                LastName = person.LastName,
            };

            if (person.Positions != null && person.Positions.Count > 0)
            {
                userInfo.Position = person.Positions[0].Title;
                if (person.Positions[0].Company != null)
                    userInfo.CompanyName = person.Positions[0].Company.Name;
            }

            userInfo.PublicProfileUrl = person.PublicProfileUrl;

            return userInfo;
        }
Esempio n. 2
0
    /// <summary>
    /// Generates an object from its XML representation.
    /// </summary>
    /// <param name="reader">The <see cref="XmlReader" /> stream from which the object is deserialized.</param>
    public void ReadXml(System.Xml.XmlReader reader)
    {
      System.Xml.XmlReader shareReader = reader;
      if (reader.IsStartElement())
      {
        shareReader = reader.ReadSubtree();
      }

      while (shareReader.Read())
      {
        while (shareReader.IsStartElement())
        {
          switch (shareReader.Name)
          {
            case IdElementName:
              this.Id = shareReader.ReadString();
              break;
            case TimestampElementName:
              this.Timestamp = long.Parse(shareReader.ReadString());
              break;
            case CommentElementName:
              this.Comment = shareReader.ReadString();
              break;
            case ContentElementName:
              ShareContent content = new ShareContent();
              content.ReadXml(shareReader.ReadSubtree());
              this.Content = content;
              break;
            case VisibilityElementName:
              Visibility visibility = new Visibility();
              visibility.ReadXml(shareReader);
              this.Visibility = visibility;
              break;
            case SourceElementName:
              this.Source = Utility.Utilities.DeserializeXml<ShareSource>(shareReader.ReadOuterXml());
              break;
            case AuthorElementName:
              this.Author = Utility.Utilities.DeserializeXml<Person>(string.Format("<person>{0}</person>", shareReader.ReadInnerXml()));
              break;
            default:
              shareReader.Read();
              break;
          }
        }
      }

      shareReader.Close();
    }