﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace ObisoftWebCore.Services
{
    public static class StringOperation
    {
        public static string OTake(this string source, int Count)
        {
            if (source.Length <= Count)
            {
                return source;
            }
            else
            {
                return source.Substring(0, Count - 3) + "...";
            }
        }
        public static string ORemoveHTML(this string Content)
        {
            string s = string.Empty;
            Content = WebUtility.HtmlDecode(Content);
            if(!Content.Contains(">"))
            {
                return Content;
            }
            while (Content.Contains(">"))
            {
                s = s + Content.Substring(0, Content.IndexOf("<"));
                Content = Content.Substring(Content.IndexOf(">") + 1);
            }
            return s;
        }
    }
}
