Exemplo n.º 1
0
        private async Task AddNewsImage(string name, string path, int newsId)
        {
            var logoPath = new ImageNews
            {
                Name    = name,
                DirPath = path,
                NewsId  = newsId
            };

            await _context.ImageNews.AddAsync(logoPath);

            await _context.SaveChangesAsync();
        }
Exemplo n.º 2
0
    List <UnitNews> ContentToData(string content)
    {
        content = content.Replace("\n", "");
        content = content.Replace("\r", "");
        content = content.Replace("<br /><br />", "<br />");
        content = content.Replace("<p><br /><img", "<p><img");

        List <UnitNews> _list     = new List <UnitNews>();
        MatchCollection matchColl = Regex.Matches(content, regex);

        foreach (Match match in matchColl)
        {
            //Debug.Log(" ---------------- " + "\nValue: " + match.Value + "\nIndex: " + match.Index + "\nLength: " + match.Length);
            GroupCollection group = match.Groups;
            if (string.IsNullOrEmpty(group[srcImageTag].ToString()) == false)
            {
                ImageNews _item = new ImageNews();
                _item.type     = TypeNews.image;
                _item.urlImage = group[srcImageTag].ToString();
                _item.text     = group[altImageTag].ToString();
                if (string.IsNullOrEmpty(_item.urlImage) == false)
                {
                    _list.Add(_item);
                }
            }
            else if ((string.IsNullOrEmpty(group[heading1].ToString()) == false))
            {
                UnitNews _item = new UnitNews();
                _item.type = TypeNews.title;
                _item.text = group[heading1].ToString();
                if (string.IsNullOrEmpty(_item.text) == false)
                {
                    _list.Add(_item);
                }
            }
            else if ((string.IsNullOrEmpty(group[heading2].ToString()) == false))
            {
                UnitNews _item = new UnitNews();
                _item.type = TypeNews.title;
                _item.text = group[heading2].ToString();
                if (string.IsNullOrEmpty(_item.text) == false)
                {
                    _list.Add(_item);
                }
            }
            else if (string.IsNullOrEmpty(group[paragraphTag].ToString()) == false)
            {
                UnitNews _item = new UnitNews();
                _item.type = TypeNews.text;
                _item.text = group[paragraphTag].ToString();
                if (string.IsNullOrEmpty(_item.text) == false)
                {
                    _list.Add(_item);
                }
            }
            else
            {
            }
        }
        return(_list);
    }
Exemplo n.º 3
0
 public override void Init(UnitNews _data)
 {
     imgData = _data as ImageNews;
     StartCoroutine(LoadImage());
 }