Exemple #1
0
        public void PopulateData(CookieContainer cookies = null)
        {
            if (RootURI != null)
            {
                RootURLText = GetWebpages(new Uri[] { RootURI }, s => new StreamReader(s).ReadToEnd().Trim().Replace("\"", "æ"), cookies).First();
            }

            var regexs = (new T()).Regexs;

            foreach (var attribute in GetWebpageAttributes(RootURLText, regexs))
            {
                var commonProperties
                    = GetObjectProperties(new T())
                      .Intersect(attribute.Select(a => a.Key));

                var newClass = new T();
                newClass.Identifier = _currentIdentifier;

                foreach (var property in commonProperties)
                {
                    object[] update = new object[1];
                    update[0] = attribute[property];
                    typeof(T).InvokeMember(property,
                                           BindingFlags.SetProperty, null, newClass, update);
                }
                SiteData.Add(newClass);
            }
        }