public TemplateInSetBase(Item item, string[] databases, string setNamespace)
 {
     TemplateItem = new TemplateItem(item);
     TemplateId = item.ID.ToString();
     TemplateName = item.Name;
     ClassName = DomUtil.ConvertCaseString(item.Name);
     FullClassName = string.Format("{0}.{1}", setNamespace, ClassName);
     Databases = databases;
     TemplateSectionItem[] sectionItems = TemplateItem.GetSections();
     Sections = sectionItems != null ? sectionItems.Select(sectionItem => new TemplateSection(sectionItem, false)) : null;
 }
 /// <summary>
 /// Loads the template.
 /// </summary>
 /// <param name="templateItem">The template item.</param>
 /// <returns>
 /// The template.
 /// </returns>
 private static TemplateDefinition LoadTemplate(TemplateItem templateItem)
 {
     Assert.ArgumentNotNull((object)templateItem, "templateItem");
     TemplateDefinition template = new TemplateDefinition()
         {
             TemplateID = templateItem.ID.ToString(),
             DisplayName = templateItem.DisplayName
         };
     foreach (TemplateSectionItem section in templateItem.GetSections())
         TemplateBuilderForm.LoadSection(template, section);
     return template;
 }
예제 #3
0
 public virtual TemplateSectionItem[] GetSections()
 {
     return(_templateItem.GetSections());
 }
        private void WriteTemplate([Diagnostics.NotNull] XmlTextWriter output, [Diagnostics.NotNull] Item item, bool writeParentItemPath)
        {
            output.WriteStartElement("Template");
            output.WriteAttributeString("Id", item.ID.ToString());
            output.WriteAttributeString("Name", item.Name);

            var baseTemplates = item[FieldIDs.BaseTemplate];
            if (!string.IsNullOrEmpty(baseTemplates) && baseTemplates != "{1930BBEB-7805-471A-A3BE-4858AC7CF696}")
            {
                output.WriteAttributeString("BaseTemplates", baseTemplates);
            }

            if (writeParentItemPath)
            {
                output.WriteAttributeString("Database", item.Database.Name);
                output.WriteAttributeString("ParentItemPath", item.Parent == null ? "/" : item.Parent.Paths.Path);
            }

            var templateItem = new TemplateItem(item);
            foreach (var templateSectionItem in templateItem.GetSections())
            {
                output.WriteStartElement("Section");
                output.WriteAttributeString("Id", templateSectionItem.ID.ToString());
                output.WriteAttributeString("Name", templateSectionItem.Name);

                foreach (var templateFieldItem in templateSectionItem.GetFields())
                {
                    output.WriteStartElement("Field");
                    output.WriteAttributeString("Id", templateFieldItem.ID.ToString());
                    output.WriteAttributeString("Name", templateFieldItem.Name);
                    output.WriteEndElement();
                }

                output.WriteEndElement();
            }

            output.WriteEndElement();
        }
 /// <summary>
 /// Gets the template's immediate fields (ie. those defined on this template and not any inherited templates).
 /// </summary>
 /// <param name="templateItem">Template Item definition.</param>
 /// <returns>Array of fields found.</returns>
 public static TemplateFieldItem[] GetImmediateFields(this TemplateItem templateItem)
 {
     return(templateItem.GetSections().SelectMany(s => s.GetFields()).ToArray());
 }
        public virtual Template ImportTemplate(IProject project, Data.Items.Item item)
        {
            var templateItem = new TemplateItem(item);

            var templateBuilder = new TemplateBuilder(Factory);
            templateBuilder.DatabaseName = templateItem.Database.Name;
            templateBuilder.Guid = templateItem.ID.ToString();
            templateBuilder.TemplateName = templateItem.Name;
            templateBuilder.ItemIdOrPath = templateItem.InnerItem.Paths.Path;
            templateBuilder.Icon = templateItem.InnerItem.Appearance.Icon;
            templateBuilder.ShortHelp = templateItem.InnerItem.Help.ToolTip;
            templateBuilder.LongHelp = templateItem.InnerItem.Help.Text;

            var baseTemplates = templateItem.BaseTemplates;
            if (baseTemplates.Length > 1 || (baseTemplates.Length == 1 && baseTemplates[0].ID != TemplateIDs.StandardTemplate))
            {
                templateBuilder.BaseTemplates = string.Join("|", baseTemplates.Select(i => i.InnerItem.Paths.Path));
            }

            foreach (var templateSectionItem in templateItem.GetSections())
            {
                var templateSectionBuilder = new TemplateSectionBuilder(Factory).With(templateBuilder, TextNode.Empty);
                templateSectionBuilder.SectionId = templateSectionItem.ID.ToString();
                templateSectionBuilder.SectionName = templateSectionItem.Name;

                foreach (var templateFieldItem in templateSectionItem.GetFields())
                {
                    var templateFieldBuilder = new TemplateFieldBuilder(Factory).With(templateSectionBuilder, TextNode.Empty);
                    templateFieldBuilder.FieldId = templateFieldItem.ID.ToString();
                    templateFieldBuilder.FieldName = templateFieldItem.Name;
                    templateFieldBuilder.Source = templateFieldItem.Source;
                    templateFieldBuilder.Type = templateFieldItem.Type;
                    templateFieldBuilder.TemplateFieldShortHelp = templateFieldItem.InnerItem.Help.ToolTip;
                    templateFieldBuilder.TemplateFieldLongHelp = templateFieldItem.InnerItem.Help.Text;

                    templateSectionBuilder.Fields.Add(templateFieldBuilder);
                }

                templateBuilder.Sections.Add(templateSectionBuilder);
            }

            return templateBuilder.Build(project, TextNode.Empty);
        }
예제 #7
0
        private Template BuildTemplate([Diagnostics.NotNull] IProject project, [Diagnostics.NotNull] Item item)
        {
            var templateItem = new TemplateItem(item);

            var templateBuilder = new TemplateBuilder(Factory);
            templateBuilder.DatabaseName = templateItem.Database.Name;
            templateBuilder.Guid = templateItem.ID.ToString();
            templateBuilder.TemplateName = templateItem.Name;
            templateBuilder.ItemIdOrPath = templateItem.InnerItem.Paths.Path;
            templateBuilder.Icon = templateItem.InnerItem.Appearance.Icon;

            foreach (var templateSectionItem in templateItem.GetSections())
            {
                var templateSectionBuilder = new TemplateSectionBuilder(Factory).With(templateBuilder, TextNode.Empty);
                templateSectionBuilder.SectionId = templateSectionItem.ID.ToString();
                templateSectionBuilder.SectionName = templateSectionItem.Name;

                foreach (var templateFieldItem in templateSectionItem.GetFields())
                {
                    var templateFieldBuilder = new TemplateFieldBuilder(Factory).With(templateSectionBuilder, TextNode.Empty);
                    templateFieldBuilder.FieldId = templateFieldItem.ID.ToString();
                    templateFieldBuilder.FieldName = templateFieldItem.Name;
                    templateFieldBuilder.Source = templateFieldItem.Source;
                    templateFieldBuilder.Type = templateFieldItem.Type;

                    templateSectionBuilder.Fields.Add(templateFieldBuilder);
                }

                templateBuilder.Sections.Add(templateSectionBuilder);
            }

            return templateBuilder.Build(project, TextNode.Empty);
        }