private void EmitTemplate()

in Source/Tx.Windows.TypeGeneration/ManifestParser.cs [270:318]


        private void EmitTemplate(ref StringBuilder sb, XElement evt, XElement templates)
        {
            if (evt.Attribute(AttributeNames.Template) == null)
                return;

            IEnumerable<XElement> template = from t in templates.Elements()
                                             where
                                                 t.Attribute(AttributeNames.Tid).Value ==
                                                 evt.Attribute(AttributeNames.Template).Value
                                             select t;

            int order = 0;
            foreach (XElement f in template.Elements(ElementNames.Data))
            {
                if (order > 0)
                    sb.AppendLine();

                var length = f.Attribute(AttributeNames.Length);

                if (null != length)
                {
                    sb.AppendFormat("        [EventField(\"{0}\", \"{1}\")]",
                                    f.Attribute(AttributeNames.InType).Value, length.Value);
                }
                else
                {
                    sb.AppendFormat("        [EventField(\"{0}\")]",
                                f.Attribute(AttributeNames.InType).Value);
                }

                sb.AppendLine();

                if (f.Attribute(AttributeNames.Map) == null)
                {
                    sb.AppendFormat("        public {0} {1}",
                                    CleanType(f.Attribute(AttributeNames.InType).Value),
                                    NameUtils.CreateIdentifier(f.Attribute(AttributeNames.Name).Value));
                }
                else
                {
                    sb.AppendFormat("        public {0} {1}",
                        NameUtils.CreateIdentifier(f.Attribute(AttributeNames.Map).Value),
                        NameUtils.CreateIdentifier(f.Attribute(AttributeNames.Name).Value));
                }

                sb.AppendLine(" { get; set; }");
                order++;
            }
        }