private XmlNode createRule(EntityRuleModel rule)
        {
            var e = xml.CreateElement("Rule");

            if (rule is RequiredRuleModel)
            {
                e.Attributes.Append(attr("type", "RequiredRuleModel"));
                e.Attributes.Append(attr("property", (rule as RequiredRuleModel).Property.Name));
                return(e);
            }
            else if (rule is UniqueRuleModel)
            {
                var ur = rule as UniqueRuleModel;
                e.Attributes.Append(attr("type", "UniqueRuleModel"));
                foreach (var p in ur.Properties)
                {
                    var pe = xml.CreateElement("Property");
                    pe.Attributes.Append(attr("name", p.Name));
                    e.AppendChild(pe);
                }
                return(e);
            }
            else if (rule is FutureOrPastDateRuleModel)
            {
                var dr = rule as FutureOrPastDateRuleModel;
                e.Attributes.Append(attr("type", "FutureOrPastDateRuleModel"));
                e.Attributes.Append(attr("property", dr.Property.Name));
                e.Attributes.Append(attr("offset", dr.Offset));
                e.Attributes.Append(attr("future", dr.Future));
                return(e);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
 private XmlNode createRule(EntityRuleModel rule)
 {
     var e = xml.CreateElement("Rule");
     if (rule is RequiredRuleModel)
     {
         e.Attributes.Append(attr("type", "RequiredRuleModel"));
         e.Attributes.Append(attr("property", (rule as RequiredRuleModel).Property.Name));
         return e;
     }
     else if (rule is UniqueRuleModel)
     {
         var ur = rule as UniqueRuleModel;
         e.Attributes.Append(attr("type", "UniqueRuleModel"));
         foreach (var p in ur.Properties)
         {
             var pe = xml.CreateElement("Property");
             pe.Attributes.Append(attr("name", p.Name));
             e.AppendChild(pe);
         }
         return e;
     }
     else if (rule is FutureOrPastDateRuleModel)
     {
         var dr = rule as FutureOrPastDateRuleModel;
         e.Attributes.Append(attr("type", "FutureOrPastDateRuleModel"));
         e.Attributes.Append(attr("property", dr.Property.Name));
         e.Attributes.Append(attr("offset", dr.Offset));
         e.Attributes.Append(attr("future", dr.Future));
         return e;
     }
     else
         throw new NotImplementedException();
 }