Ejemplo n.º 1
0
 internal TweetBlock(string type, JObject obj, JObject data)
     : base(type, obj)
 {
     Id = data.GetString("id");
     Text = data.GetString("text");
     User = data.GetObject("user", TweetUser.Parse);
     CreatedAt = data.GetString("created_at", TwitterUtils.ParseDateTimeUtc);
     StatusUrl = data.GetString("status_url");
     Entities = data.GetObject("entities", TweetEntities.Parse);
 }
        // metadata

        #endregion

        #region Constructors

        private PinterestPin(JObject obj) {
            Creator = obj.GetObject("creator", PinterestPinCreator.Parse);
            Url = obj.GetString("url");
            CreatedAt = obj.GetString("created_at", SocialDateTime.Parse);
            Note = obj.GetString("note");
            Color = obj.GetString("color");
            Link = obj.GetString("link");
            Board = obj.GetObject("board", PinterestPinBoard.Parse);
            Counts = obj.GetObject("counts", PinterestPinCounts.Parse);
            Id = obj.GetString("id");
        }
 private PinterestUser(JObject obj) : base(obj) {
     Username = obj.GetString("username");
     Bio = obj.GetString("bio");
     FirstName = obj.GetString("first_name");
     LastName = obj.GetString("last_name");
     AccountType = obj.GetString("account_type");
     Url = obj.GetString("url");
     CreatedAt = obj.GetString("created_at", SocialDateTime.Parse);
     Image = obj.GetObject("image", PinterestUserImage.Parse);
     Counts = obj.GetObject("counts", PinterestUserCounts.Parse);
     Id = obj.GetString("id");
 }
 private SpotifyArtist(JObject obj) : base(obj) {
     ExternalUrls = obj.GetObject("external_urls", SpotifyArtistUrlCollection.Parse);
     Followers = obj.GetObject("followers", SpotifyFollowers.Parse);
     Genres = obj.GetStringArray("genres");
     Href = obj.GetString("href");
     Id = obj.GetString("id");
     Images = obj.GetArray("images", SpotifyImage.Parse);
     Name = obj.GetString("name");
     Popularity = obj.GetInt32("popularity");
     Type = obj.GetString("type");
     Uri = obj.GetString("uri");
 }
Ejemplo n.º 5
0
        public static Category Parse(JObject obj)
        {
            if (obj == null)
                return null;
            Category item = new Category();

            item.name = obj.GetObject<string>("name");
            item.id = obj.GetObject<string>("id");
            item.urlname = obj.GetObject<string>("urlname");
            item.nav_link = $"favorite/{item.urlname}";

            return item;
        }
Ejemplo n.º 6
0
 private BoxFolderInfo(JObject obj) : base(obj) {
     Type = obj.GetString("type");
     Id = obj.GetString("id");
     Name = obj.GetString("name");
     CreatedAt = obj.GetString("created_at", SocialDateTime.Parse);
     ModifiedAt = obj.GetString("modified_at", SocialDateTime.Parse);
     Description = obj.GetString("description");
     Size = obj.GetInt64("size");
     CreatedBy = obj.GetObject("created_by", BoxUserInfo.Parse);
     ModifiedBy = obj.GetObject("modified_by", BoxUserInfo.Parse);
     TrashedAt = obj.GetString("trashed_at", SocialDateTime.Parse);
     PurgedAt = obj.GetString("purged_at", SocialDateTime.Parse);
     ContentCreatedAt = obj.GetString("content_created_at", SocialDateTime.Parse);
     ContentModifiedAt = obj.GetString("content_modified_at", SocialDateTime.Parse);
     OwnedBy = obj.GetObject("owned_by", BoxUserInfo.Parse);
 }
 /// <summary>
 /// Gets a macro value from the specified <code>JsonObject</code>.
 /// </summary>
 /// <param name="control">The parent control.</param>
 /// <param name="obj">The instance of <code>JObject</code> to be parsed.</param>
 public static GridControlMacroValue Parse(GridControl control, JObject obj) {
     if (obj == null) return null;
     return new GridControlMacroValue(control, obj) {
         Syntax = obj.GetString("syntax"),
         MacroAlias = obj.GetString("macroAlias"),
         Parameters = obj.GetObject("macroParamsDictionary").ToObject<Dictionary<string, object>>()
     };
 }
 private MailChimpMetadata(JObject obj) : base(obj) {
     DataCenter = obj.GetString("dc");
     AccountName = obj.GetString("accountname");
     Role = obj.GetString("role");
     UserId = obj.GetInt64("user_id");
     Login = obj.GetObject("login", MailChimpMetadataLogin.Parse);
     LoginUrl = obj.GetString("login_url");
     ApiEndpoint = obj.GetString("api_endpoint");
 }
 /// <summary>
 /// Gets a media value from the specified <code>JsonObject</code>.
 /// </summary>
 /// <param name="control">The parent control.</param>
 /// <param name="obj">The instance of <code>JObject</code> to be parsed.</param>
 public static GridControlMediaValue Parse(GridControl control, JObject obj) {
     if (obj == null) return null;
     return new GridControlMediaValue(obj) {
         Control = control,
         FocalPoint = obj.GetObject("focalPoint", GridControlMediaFocalPoint.Parse),
         Id = obj.GetInt32("id"),
         Image = obj.GetString("image"),
         Caption = obj.GetString("caption")
     };
 }
Ejemplo n.º 10
0
        public static ImageFile Parse(JObject obj)
        {
            if (obj == null)
                return null;

            var file = new ImageFile();
            file.fileid = obj.GetObject<string>("id");
            file.type = obj.GetObject<string>("type");
            file.farm = obj.GetObject<string>("farm");
            file.bucket = obj.GetObject<string>("bucket");
            file.key = obj.GetObject<string>("key");
            file.width = obj.GetObject<int>("width");
            file.height = obj.GetObject<int>("height");
            file.key = obj.GetObject<string>("key");
            return file;
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new image picker item based on the specified <see cref="JObject"/>.
 /// </summary>
 /// <param name="obj">An instanceo of <see cref="JObject"/> representing the item.</param>
 protected ImagePickerItem(JObject obj) {
     JObject = obj;
     Image = obj.GetInt32("imageId", ImagePickerImage.GetFromId);
     Title = obj.GetString("title") ?? "";
     Description = obj.GetString("description") ?? "";
     Link = obj.GetObject("link", LinkPickerItem.Parse) ?? LinkPickerItem.Parse(new JObject());
 }
Ejemplo n.º 12
0
		public static Pin Parse(JObject obj, bool deptParse = false)
		{
			if (obj == null)
				return null;

			Pin item = new Pin();
			item.pin_id = obj.GetObject<string>("pin_id");
			item.user_id = obj.GetObject<string>("user_id");
			item.board_id = obj.GetObject<string>("board_id");
			item.file_id = obj.GetObject<string>("file_id");
			item.seq = obj.GetObject<string>("seq");
			item.media_type = obj.GetObject<string>("media_type");
			item.source = obj.GetObject<string>("source");
			item.link = obj.GetObject<string>("link");
			item.raw_text = HtmlDecode(obj.GetObject<string>("raw_text"));
			item.via = obj.GetObject<string>("via");
			item.original = obj.GetObject<string>("original");
			item.created_at = obj.GetObject<string>("created_at");
			item.like_count = obj.GetObject<string>("like_count");
			item.comment_count = obj.GetObject<string>("comment_count");
			item.repin_count = obj.GetObject<string>("repin_count");
			item.orig_source = obj.GetObject<string>("orig_source");
			item.file = ImageFile.Parse(obj["file"] as JObject);
			item.liked = obj.GetObject<bool>("liked");
			item.user = User.Parse(obj["user"] as JObject);
			item.board = Board.Parse(obj["board"] as JObject);
			if (deptParse)
			{
				item.repins = Pin.ParseList(obj["repins"] as JArray, false);
				item.comments = Comment.ParseList(obj["repins"] as JArray, false);
				item.likes = User.ParseList(obj["likes"] as JArray, false);
			}
			return item;
		}
Ejemplo n.º 13
0
        /// <summary>
        /// Parses a row from the specified <code>obj</code>.
        /// </summary>
        /// <param name="section">The parent section of the row.</param>
        /// <param name="obj">The instance of <code>JObject</code> to be parsed.</param>
        public static GridRow Parse(GridSection section, JObject obj) {

            // Some input validation
            if (obj == null) throw new ArgumentNullException("obj");
            
            // Parse basic properties
            GridRow row = new GridRow(obj) {
                Section = section,
                Id = obj.GetString("id"),
                Alias = obj.GetString("alias"),
                Name = obj.GetString("name"),
                Styles = obj.GetObject("styles", GridDictionary.Parse),
                Config = obj.GetObject("config", GridDictionary.Parse)
            };

            // Parse the areas
            row.Areas = obj.GetArray("areas", x => GridArea.Parse(row, x)) ?? new GridArea[0];

            // Update "PreviousArea" and "NextArea" properties
            for (int i = 1; i < row.Areas.Length; i++) {
                row.Areas[i - 1].NextArea = row.Areas[i];
                row.Areas[i].PreviousArea = row.Areas[i - 1];
            }

            // Return the row
            return row;

        }
Ejemplo n.º 14
0
        public static Board Parse(JObject obj, bool deptParse = false)
        {
            if (obj == null)
                return null;

            Board board = new Board();
            try
            {
                if (obj.GetObject<int>("is_private") > 0)
                    return null;
                board.board_id = obj.GetObject<string>("board_id");
                board.user_id = obj.GetObject<string>("user_id");
                board.description = obj.GetObject<string>("description");
                board.title = HtmlDecode(obj.GetObject<string>("title"));
                board.category_id = obj.GetObject<string>("category_id");
                board.pin_count = obj.GetObject<string>("pin_count");
                board.follow_count = obj.GetObject<string>("follow_count");
                board.like_count = obj.GetObject<string>("like_count");
                board.created_at = obj.GetObject<string>("created_at");
                board.updated_at = obj.GetObject<string>("updated_at");

                board.following = obj.GetObject<bool>("following");
                board.user = User.Parse(obj["user"] as JObject);
                board.cover = Pin.Parse(obj["cover"] as JObject);
                board.seq = obj.GetObject<int>("seq");

                board.pins = Pin.ParseList(obj["pins"] as JArray);
                if (board.cover == null && board.pins != null && board.pins.Count > 0)
                    board.cover = board.pins[0];

            }
            catch (Exception ex)
            {
                string aaa = ex.Message;
            }
            return board;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Parses an area from the specified <code>obj</code>.
        /// </summary>
        /// <param name="row">The parent row of the area.</param>
        /// <param name="obj">The instance of <code>JObject</code> to be parsed.</param>
        public static GridArea Parse(GridRow row, JObject obj) {

            // Some input validation
            if (obj == null) throw new ArgumentNullException("obj");
            
            // Parse the array of allow blocks
            JArray allowed = obj.GetArray("allowed");
            
            // Parse basic properties
            GridArea area = new GridArea(obj) {
                Row = row,
                Grid = obj.GetInt32("grid"),
                AllowAll = obj.GetBoolean("allowAll"),
                Allowed = allowed == null ? new string[0] : allowed.Select(x => (string)x).ToArray(),
                Styles = obj.GetObject("styles", GridDictionary.Parse),
                Config = obj.GetObject("config", GridDictionary.Parse)
            };

            // Parse the controls
            area.Controls = obj.GetArray("controls", x => GridControl.Parse(area, x)) ?? new GridControl[0];
            
            // Update "PreviousArea" and "NextArea" properties
            for (int i = 1; i < area.Controls.Length; i++) {
                area.Controls[i - 1].NextControl = area.Controls[i];
                area.Controls[i].PreviousControl = area.Controls[i - 1];
            }
            
            // Return the row
            return area;
        
        }
Ejemplo n.º 16
0
		public static User Parse(JObject obj, bool deptParse = false)
		{
			if (obj == null)
				return null;
			User user = new User();
			user.user_id = obj.GetObject<string>("user_id");
			user.username = HtmlDecode(obj.GetObject<string>("username"));
			user.created_at = obj.GetObject<string>("created_at");
			user.urlname = obj.GetObject<string>("urlname");
			user.avatar = ImageFile.Parse(obj["avatar"] as JObject) ?? GetDefaultAvatar();
			user.seq = obj.GetObject<int>("seq");
			user.email = obj.GetObject<string>("email");
			user.follower_count = obj.GetObject<int>("follower_count");
			user.following_count = obj.GetObject<int>("following_count");
			user.board_count = obj.GetObject<int>("board_count");
			user.following = obj.GetObject<bool>("following");
			user.like_count = obj.GetObject<int>("like_count");
			user.pin_count = obj.GetObject<int>("pin_count");

			user.boards = Board.ParseList(obj["boards"] as JArray);

			return user;
		}
 /// <summary>
 /// Gets an instance of <code>GridEditorMediaConfig</code> from the specified <code>JsonObject</code>.
 /// </summary>
 /// <param name="editor">The parent editor.</param>
 /// <param name="obj">The instance of <code>JObject</code> to be parsed.</param>
 public static GridEditorMediaConfig Parse(GridEditor editor, JObject obj) {
     if (obj == null) return null;
     return new GridEditorMediaConfig(editor, obj) {
         Size = obj.GetObject("size", GridEditorMediaConfigSize.Parse)
     };
 }