Exemple #1
0
        public IBehavior LoadBehaviorFromXML(XElement element)
        {
            XAttribute classAttrib = element.Attribute("class"),
                       typeAttrib  = element.Attribute("type"),
                       nameAttrib  = element.Attribute("name");

            IBehavior behavior = null;

            if (classAttrib != null && typeAttrib != null)
            {
                string assembly;

                if (element.Attribute("assembly") != null)
                {
                    assembly = element.Attribute("assembly").Value;
                }
                else
                {
                    assembly = Assembly.GetExecutingAssembly().FullName;
                }

                var classType       = Type.GetType(String.Format("{0},{1}", classAttrib.Value, assembly));
                var stringInterface = element.Attribute("type").Value;

                behavior = GetBehavior(classType);
                behavior.Deserialize(element);

                behavior.Name = nameAttrib != null ? nameAttrib.Value : Guid.NewGuid().ToString();
            }

            return(behavior);
        }