Exemple #1
0
        public static PhotoUrlHelper ParsePicai(string photoUrl)
        {
            Match match = picaiPhotoUrlRegex.Match(photoUrl);

            if (match.Success)
            {
                string container = match.Groups["container"].Value;
                string name      = match.Groups["name"].Value;
                string size      = match.Groups["size"].Value;
                string extension = match.Groups["extension"].Value;

                int sizeInt = int.Parse(size);

                PhotoUrlHelper helper = new PhotoUrlHelper
                {
                    Container = container,
                    Name      = name,
                    Size      = sizeInt,
                    Extension = extension
                };

                return(helper);
            }

            return(null);
        }
Exemple #2
0
        public static PhotoUrlHelper ParseTumblr(string photoUrl)
        {
            Match match = tumblrPhotoUrlRegex.Match(photoUrl);

            if (match.Success)
            {
                string server    = match.Groups["server"].Value;
                string container = string.IsNullOrEmpty(match.Groups["container"].Value) ? null : match.Groups["container"].Value;
                string hash      = string.IsNullOrEmpty(match.Groups["hash"].Value) ? null : match.Groups["hash"].Value;
                string name      = match.Groups["name"].Value;
                string size      = match.Groups["size"].Value;
                string vsize     = string.IsNullOrEmpty(match.Groups["vsize"].Value) ? null : match.Groups["vsize"].Value;
                string extension = match.Groups["extension"].Value;

                int serverInt = int.Parse(server);
                int sizeInt   = int.Parse(size);
                int?vsizeInt  = null;

                if (vsize != null)
                {
                    vsizeInt = int.Parse(vsize);
                }

                PhotoUrlHelper helper = new PhotoUrlHelper
                {
                    Server    = serverInt,
                    Container = container,
                    Name      = name,
                    Size      = sizeInt,
                    VSize     = vsizeInt,
                    Hash      = hash,
                    Extension = extension
                };

                return(helper);
            }

            return(null);
        }