Ejemplo n.º 1
0
        public override async Task <IDataToSent> TransformData(IDataToSent receiveData)
        {
            if (receiveData == null)
            {
                receiveData = new DataToSentTable();
            }
            var tr = new AHrefToTable();
            var dt = tr.TransformToTable(Content);

            var id = receiveData.AddNewTable(dt);

            receiveData.Metadata.AddTable(dt, id);
            return(await Task.FromResult(receiveData));
        }
Ejemplo n.º 2
0
        public override async Task <IDataToSent> TransformData(IDataToSent receiveData)
        {
            var ret = new DataToSentTable();

            var file = new ReadFileToString
            {
                FileEnconding = this.Encoding,
                FileToRead    = this.File
            };

            var data = await file.LoadData();

            bool web = file.FileType == FileType.Web;

            var startWeb = "";

            if (web)
            {
                var uri = new Uri(File);
                startWeb = uri.GetLeftPart(UriPartial.Authority);
            }
            var tr = new AHrefToTable();
            var dt = tr.TransformToTable(data);


            if (web)
            {
                foreach (DataRow item in dt.Rows)
                {
                    string val = item["href"]?.ToString();
                    if (val == null)
                    {
                        continue;
                    }

                    if (val.StartsWith("/"))
                    {
                        val = (startWeb + val).Replace("//", "/");
                    }
                    item["href"] = val;
                }
            }
            var id = ret.AddNewTable(dt);

            ret.Metadata.AddTable(dt, id);
            return(ret);
        }