Пример #1
0
        /// <summary>
        /// Parse XML and use it to produce a SetDefinition.
        /// </summary>
        /// <param name="data">Data for the set definition.</param>
        /// <returns>The Constructed Set.</returns>
        public static SetDefinition ParseSet(XmlNode data)
        {
            // If this set says it's based on another set, and that set exists
            SetDefinition set;

            if (data.Attributes["base"] != null && m_Sets.ContainsKey(data.Attributes["base"].Value))
            {
                // Zip that set together with the passed in data.
                set = SetDefinition.ZipTogether(m_Sets[data.Attributes["base"].Value], data);
            }
            else
            {
                // Otherwise, we can just make it from scratch
                set = new SetDefinition(data.Attributes["name"].Value);

                // and add each entity node to the set.  The entities will get resolved/zipped when you
                // actually produce the set.
                foreach (XmlNode node in data.ChildNodes)
                {
                    set.Entities.Add(node);
                }
            }

            // And return the newly created/modified set definition.
            return(set);
        }
Пример #2
0
 /// <summary>
 /// Produce a set from a definition.  This produces each of the entities as well.
 /// </summary>
 /// <param name="setName">Name of the set to produce.</param>
 /// <param name="customizationData">Data to customize the set with.</param>
 /// <returns>List of produced entities.</returns>
 public static List <Entity> ProduceSet(String setName, XmlNode customizationData = null)
 {
     if (m_Sets.ContainsKey(setName))
     {
         // Customize the existing set data with the customizationData
         SetDefinition set     = SetDefinition.ZipTogether(m_Sets[setName], customizationData);
         List <Entity> entList = new List <Entity>();
         // And for each of the entities in it's Entities list,
         foreach (XmlNode node in set.Entities)
         {
             // Produce the base entity, using the stored node as customization data.
             entList.Add(ProduceEntity(node.Attributes["base"].Value, node));
         }
         // And return that list.
         return(entList);
     }
     return(null);
 }