Пример #1
0
 protected void OnSelect(RuntimeTable <ResultRow> results)
 {
     if (Select != null)
     {
         Select(results);
     }
 }
Пример #2
0
        public static RuntimeTable <DownloadImage> DownloadImage(IRuntime runtime, string url, int line)
        {
            var table = new RuntimeTable <DownloadImage>();

            var image = GetImage(runtime.RequestFactory, new WebRequestHttpWire(url, runtime, line));

            table.Add(image);
            return(table);
        }
Пример #3
0
        private static RuntimeTable <DownloadPage> DownloadPage(IRuntime runtime, IHttpWire[] wires)
        {
            var table = new RuntimeTable <DownloadPage>();

            foreach (var wire in wires)
            {
                int contentlength;
                var doc = GetDocument(runtime.RequestFactory, wire, out contentlength);
                table.Add(new DownloadPage()
                {
                    url = wire.Url, nodes = DownloadedNodes.FromHtmlDoc(doc), date = DateTime.Now, size = contentlength
                });
            }

            return(table);
        }
Пример #4
0
        private static RuntimeTable <DownloadPage> DownloadPage(IRuntime runtime, string[] urls)
        {
            var table = new RuntimeTable <DownloadPage>();

            foreach (var url in urls)
            {
                int contentlength;
                var doc = GetDocument(runtime.RequestFactory, url, out contentlength);
                table.Add(new DownloadPage()
                {
                    url = url, nodes = new[] { doc.DocumentNode }, date = DateTime.Now, size = contentlength
                });
            }

            return(table);
        }
Пример #5
0
        private static RuntimeTable <DynamicObject> ProcesJson(IHttpRequestFactory factory, IHttpWire wire)
        {
            var request = CreateRequest(factory, wire);
            var json    = request.Download() as string;

            if (json == null)
            {
                json = string.Empty;
            }

            dynamic serializedValue = JsonConvert.DeserializeObject(json);
            var     dynamics        = new List <DynamicObject>();

            if (serializedValue != null && serializedValue is IEnumerable <dynamic> )
            {
                IEnumerable <dynamic> jsonArray = serializedValue;

                if (!(serializedValue is JArray))
                {
                    jsonArray = new[] { serializedValue }
                }
                ;

                var properties = new List <Dictionary <string, object> >();
                foreach (dynamic v in jsonArray)
                {
                    var dynamic = new DynamicObject();
                    Dictionary <string, object> values = v.ToObject <Dictionary <string, object> >();

                    foreach (var p in values.Keys)
                    {
                        dynamic.Add(p, values[p].ToString());
                    }

                    dynamics.Add(dynamic);
                }
            }

            var table = new RuntimeTable <DynamicObject>();

            table.SetRows(dynamics);
            return(table);
        }