private void HandleEncoder()
 {
     if (!PreviousName.Equals(CompileName()))
     {
         Encoder.End();
         PreviousName = CompileName();
         Encoder.Start(PreviousName);
     }
 }
Beispiel #2
0
        private void WriteAttributes(XmlWriter w, bool newGuids = false)
        {
            if (newGuids)
            {
                w.WriteAttributeString("Id", Guid.NewGuid().ToString());
            }
            else
            {
                w.WriteAttributeString("Id", Id.ToString());
            }

            w.WriteAttributeString("Order", Order.ToString());
            w.WriteAttributeString("Field", ConditionName);
            w.WriteAttributeString("Comparison", Comparison);
            if (Description.HasValue())
            {
                w.WriteAttributeString("Description", Description);
            }
            if (PreviousName.HasValue())
            {
                w.WriteAttributeString("PreviousName", Description);
            }
            if (TextValue.HasValue())
            {
                w.WriteAttributeString("TextValue", TextValue);
            }
            if (DateValue.HasValue)
            {
                w.WriteAttributeString("DateValue", DateValue.ToString());
            }
            if (CodeIdValue.HasValue())
            {
                w.WriteAttributeString("CodeIdValue", CodeIdValue);
            }
            if (StartDate.HasValue)
            {
                w.WriteAttributeString("StartDate", StartDate.ToString());
            }
            if (EndDate.HasValue)
            {
                w.WriteAttributeString("EndDate", EndDate.ToString());
            }
            if (Program > 0)
            {
                w.WriteAttributeString("Program", Program.ToString());
            }
            if (Division > 0)
            {
                w.WriteAttributeString("Division", Division.ToString());
            }
            if (Organization > 0)
            {
                w.WriteAttributeString("Organization", Organization.ToString());
            }
            if (OrgType > 0)
            {
                w.WriteAttributeString("OrgType", OrgType.ToString());
            }
            if (Days > 0)
            {
                w.WriteAttributeString("Days", Days.ToString());
            }
            if (Quarters.HasValue())
            {
                w.WriteAttributeString("Quarters", Quarters);
            }
            if (Tags.HasValue())
            {
                w.WriteAttributeString("Tags", Tags);
            }
            if (Schedule != 0)
            {
                w.WriteAttributeString("Schedule", Schedule.ToString());
            }
            if (Campus > 0)
            {
                w.WriteAttributeString("Campus", Campus.ToString());
            }
            if (ConditionName != "FamilyHasChildrenAged")
            {
                Age = null;
            }
            if (Age.HasValue)
            {
                w.WriteAttributeString("Age", Age.ToString());
            }
            if (SavedQuery.HasValue())
            {
                w.WriteAttributeString("SavedQueryIdDesc", SavedQuery);
            }
            if (OnlineReg.HasValue)
            {
                w.WriteAttributeString("OnlineReg", OnlineReg.ToString());
            }
            if (OrgStatus.HasValue)
            {
                w.WriteAttributeString("OrgStatus", OrgStatus.ToString());
            }
            if (OrgType2.HasValue)
            {
                w.WriteAttributeString("OrgType2", OrgType2.ToString());
            }
            if (OrgName.HasValue())
            {
                w.WriteAttributeString("OrgName", OrgName);
            }
        }
Beispiel #3
0
        public string GenerateElement(ElementInfo element, string newName)
        {
            var lowerName = element.Name;
            var isVoid    = element.IsVoid ? "true" : "false";
            var className = "Html" + newName + "Element";

            var propertyCode = string.Format("\t\tpublic static {0} {1} => new {0}();", className, newName);

            if (!string.IsNullOrEmpty(PreviousName))
            {
                propertyCode = "\n" + propertyCode;

                var newLetter      = newName.Substring(0, 1);
                var previousLetter = PreviousName.Substring(0, 1);
                if (newLetter != previousLetter)
                {
                    propertyCode = "\n" + propertyCode;
                }
            }

            var attributesCode = "";

            foreach (var attribute in element.Attributes)
            {
                var methodName = attribute.ProperName;

                var attributeCodeFormat = "\n\n\t\t";
                var methodStart         = "";

                if (attribute.IsVoid)
                {
                    attributeCodeFormat += "public {0}{1} With{2}() => WithAttribute(Attribute.{2});";
                }
                else
                {
                    attributeCodeFormat += "public {0}{1} With{2}(string value) => WithAttribute(Attribute.{2}(value));";
                }

                attributesCode += string.Format(attributeCodeFormat, methodStart, className, methodName);
            }

            var code = string.Format(@"using System.Collections.ObjectModel;

namespace HtmlGenerator
{{
    public class {0} : HtmlElement 
    {{
        public {0}() : base(""{1}"", {2}) 
        {{    
        }}

        public new {0} WithChild(HtmlElement child) => ({0})base.WithChild(child);
        public new {0} WithChildren(Collection<HtmlElement> children) => ({0})base.WithChildren(children);

        public new {0} WithInnerText(string innerText) => ({0})base.WithInnerText(innerText);

        public new {0} WithAttribute(HtmlAttribute attribute) => ({0})base.WithAttribute(attribute);
        public new {0} WithAttributes(Collection<HtmlAttribute> attributes) => ({0})base.WithAttributes(attributes);{3}
    }}
}}
", className, lowerName, isVoid, attributesCode);

            GenerateClass(className, code);

            return(propertyCode);
        }
Beispiel #4
0
        public override void Generate()
        {
            PreviousName = "";

            var type       = typeof(MetaAttributes);
            var properties = type.GetProperties();

            var baseList   = "";
            var createList = "";

            foreach (var property in properties)
            {
                var htmlObject = property.GetValue(null) as AttributeInfo;
                if (htmlObject == null)
                {
                    continue;
                }

                var lowerName = htmlObject.Name;
                var upperName = property.Name;

                var isVoid   = htmlObject.IsVoid ? "true" : "false";
                var isGlobal = htmlObject.IsGlobal ? "true" : "false";

                var className = "Html" + upperName + "Attribute";

                string basePropertyCode   = string.Format("\t\tpublic static {0} {1} => new {0}();", className, upperName);
                string createPropertyCode = basePropertyCode;

                if (!htmlObject.IsVoid)
                {
                    createPropertyCode = string.Format("\t\tpublic static {0} {1}(string value) => new {0}(value);", className, upperName);
                }

                if (!string.IsNullOrEmpty(PreviousName))
                {
                    basePropertyCode   = "\n" + basePropertyCode;
                    createPropertyCode = "\n" + createPropertyCode;

                    var newLetter      = upperName.Substring(0, 1);
                    var previousLetter = PreviousName.Substring(0, 1);
                    if (newLetter != previousLetter)
                    {
                        basePropertyCode   = "\n" + basePropertyCode;
                        createPropertyCode = "\n" + createPropertyCode;
                    }
                }

                baseList   += basePropertyCode;
                createList += createPropertyCode;

                var valueCreationCode = "";
                if (!htmlObject.IsVoid)
                {
                    valueCreationCode = string.Format(
                        "\n\n" + @"        public {0}(string value) : base(""{1}"", ""{2}"", value, {3}, {4}) 
        {{
        }}", className, lowerName, upperName, isVoid, isGlobal);
                }

                var code = string.Format(@"namespace HtmlGenerator
{{
    public class {0} : HtmlAttribute 
    {{
        public {0}() : base(""{1}"", ""{2}"", null, {3}, {4}) 
        {{
        }}{5}
    }}
}}
", className, lowerName, upperName, isVoid, isGlobal, valueCreationCode);

                GenerateClass(className, code);

                PreviousName = upperName;
            }

            GenerateList("BaseAttribute", "public", "", baseList);
            GenerateList("Attribute", "public", "", createList);
        }
Beispiel #5
0
 public override void Rollback()
 {
     PreviousName.Apply(SemanticNetwork.Name);
 }