Exemplo n.º 1
0
 //copy constructor
 public SpeakerAttribute(SpeakerAttribute a)
 {
     this.ID    = a.ID;
     this.Name  = a.Name;
     this.Value = a.Value;
     this.Date  = a.Date;
 }
Exemplo n.º 2
0
        internal static Speaker DeserializeV2(XElement s, bool isStrict)
        {
            Speaker sp = new Speaker();

            if (!s.CheckRequiredAtributes("id", "surname"))
            {
                throw new ArgumentException("required attribute missing on v2format speaker  (id, surname)");
            }

            sp.SerializationID = int.Parse(s.Attribute("id").Value);
            sp.Surname         = s.Attribute("surname").Value;
            sp.FirstName       = (s.Attribute("firstname") ?? EmptyAttribute).Value;

            switch ((s.Attribute("sex") ?? EmptyAttribute).Value)
            {
            case "M":
                sp.Sex = Sexes.Male;
                break;

            case "F":
                sp.Sex = Sexes.Female;
                break;

            default:
                sp.Sex = Sexes.X;
                break;
            }

            sp.Elements = s.Attributes().ToDictionary(a => a.Name.ToString(), a => a.Value);

            string rem;

            if (sp.Elements.TryGetValue("comment", out rem))
            {
                SpeakerAttribute sa = new SpeakerAttribute("comment", "comment", rem);
                sp.Attributes.Add(sa);
            }

            if (sp.Elements.TryGetValue("lang", out rem))
            {
                int idx = Langs.IndexOf(rem);
                sp.DefaultLang = rem;
            }

            sp.Elements.Remove("id");
            sp.Elements.Remove("firstname");
            sp.Elements.Remove("surname");
            sp.Elements.Remove("sex");
            sp.Elements.Remove("comment");
            sp.Elements.Remove("lang");

            return(sp);
        }