Exemple #1
0
        public static List<Entity> LoadFromAtom(string atom)
        {
            var xml = Xml.Parse (atom);
            var entries = xml.ElementsWithName ("entry");

            var r = new List<Entity> ();

            foreach (var a in entries) {

            //				Console.WriteLine (a.OuterXml);

                try {
                    var e = new Entity ();

                    e.Id = a.ElementText ("id");
                    e.Title = a.ElementText ("title");
                    e.EntityTypeFullName = a.ElementsWithName ("category")[0].GetAttribute ("term");
                    e.UpdatedTime = DateTime.Parse (a.ElementText ("updated"));

                    foreach (var al in a.ElementsWithName ("link")) {
                        var l = new Entity.Link ();
                        l.Rel = al.GetAttribute ("rel");
                        l.Name = al.GetAttribute ("title");
                        l.Href = al.GetAttribute ("href");
                        l.Type = al.GetAttribute ("type");
                        e.Links.Add (l);
                    }

                    e.Links.Sort ((x, y) => x.Name.CompareTo (y.Name));

                    foreach (var pn in a.ElementsWithName ("properties")[0].ChildNodes) {
                        var pe = pn as System.Xml.XmlElement;
                        if (pe == null)
                            continue;

                        var p = new EntityProperty ();
                        p.Name = pe.LocalName;
                        p.ValueText = pe.InnerText.Trim ();
                        foreach (System.Xml.XmlAttribute attr in pe.Attributes) {
                            if (attr.LocalName == "type") {
                                p.ValueType = attr.InnerText;
                            }
                        }

                        e.Properties.Add (p);
                    }

                    r.Add (e);

                } catch (Exception ex) {
                    Console.WriteLine (ex);
                }
            }

            return r;
        }
Exemple #2
0
 public bool IsLocationProperty(EntityProperty p)
 {
     return((_latProp != null) && (_lonProp != null) && ((p == _latProp) || (p == _lonProp)));
 }
Exemple #3
0
 public bool IsLocationProperty(EntityProperty p)
 {
     return (_latProp != null) && (_lonProp != null) && ((p == _latProp) || (p == _lonProp));
 }
Exemple #4
0
        public static List <Entity> LoadFromAtom(string atom)
        {
            var xml     = Xml.Parse(atom);
            var entries = xml.ElementsWithName("entry");

            var r = new List <Entity> ();

            foreach (var a in entries)
            {
//				Console.WriteLine (a.OuterXml);

                try {
                    var e = new Entity();

                    e.Id    = a.ElementText("id");
                    e.Title = a.ElementText("title");
                    e.EntityTypeFullName = a.ElementsWithName("category")[0].GetAttribute("term");
                    e.UpdatedTime        = DateTime.Parse(a.ElementText("updated"));

                    foreach (var al in a.ElementsWithName("link"))
                    {
                        var l = new Entity.Link();
                        l.Rel  = al.GetAttribute("rel");
                        l.Name = al.GetAttribute("title");
                        l.Href = al.GetAttribute("href");
                        l.Type = al.GetAttribute("type");
                        e.Links.Add(l);
                    }

                    e.Links.Sort((x, y) => x.Name.CompareTo(y.Name));

                    foreach (var pn in a.ElementsWithName("properties")[0].ChildNodes)
                    {
                        var pe = pn as System.Xml.XmlElement;
                        if (pe == null)
                        {
                            continue;
                        }

                        var p = new EntityProperty();
                        p.Name      = pe.LocalName;
                        p.ValueText = pe.InnerText.Trim();
                        foreach (System.Xml.XmlAttribute attr in pe.Attributes)
                        {
                            if (attr.LocalName == "type")
                            {
                                p.ValueType = attr.InnerText;
                            }
                        }

                        e.Properties.Add(p);
                    }

                    r.Add(e);
                } catch (Exception ex) {
                    Console.WriteLine(ex);
                }
            }

            return(r);
        }