Example #1
0
        protected virtual void ProcessTemplateSections([NotNull] FileCodeModel fileCodeModel, [NotNull] Template template, [NotNull] CodeInterface2 codeInterface)
        {
            Debug.ArgumentNotNull(fileCodeModel, nameof(fileCodeModel));
            Debug.ArgumentNotNull(template, nameof(template));
            Debug.ArgumentNotNull(codeInterface, nameof(codeInterface));

            var templateSection = new TemplateSection();

            template.Sections.Add(templateSection);

            templateSection.Name = "Data";
            templateSection.TemplateSectionItemId = new ItemId(GuidExtensions.Hash(template.Name + @"/" + templateSection.Name));

            foreach (var property in codeInterface.Members.OfType <CodeProperty2>())
            {
                ProcessTemplateField(fileCodeModel, template, templateSection, property);
            }
        }
Example #2
0
        protected virtual void ProcessTemplateSections([NotNull] FileCodeModel fileCodeModel, [NotNull] Template template, [NotNull] IEnumerable <string> baseFields, [NotNull] CodeClass2 codeClass, bool isGlassMapper)
        {
            Debug.ArgumentNotNull(fileCodeModel, nameof(fileCodeModel));
            Debug.ArgumentNotNull(template, nameof(template));
            Debug.ArgumentNotNull(baseFields, nameof(baseFields));
            Debug.ArgumentNotNull(codeClass, nameof(codeClass));

            var templateSection = new TemplateSection();

            template.Sections.Add(templateSection);

            templateSection.Name = "Data";
            templateSection.TemplateSectionItemId = new ItemId(GuidExtensions.Hash(template.Name + @"/" + templateSection.Name));

            foreach (var property in codeClass.Members.OfType <CodeProperty2>())
            {
                if (!baseFields.Contains(property.Name))
                {
                    ProcessTemplateField(fileCodeModel, template, templateSection, property, isGlassMapper);
                }
            }
        }
Example #3
0
        public Guid GetHash([NotNull] CodeElements attributes, [NotNull] string defaultName)
        {
            Assert.ArgumentNotNull(attributes, nameof(attributes));
            Assert.ArgumentNotNull(defaultName, nameof(defaultName));

            foreach (var attribute in attributes.OfType <CodeAttribute2>())
            {
                if (attribute.Name == "SitecoreClass" || attribute.Name == "SitecoreClassAttribute")
                {
                    var templateId = attribute.Arguments.OfType <CodeAttributeArgument>().FirstOrDefault(a => a.Name == "TemplateId");
                    if (templateId != null)
                    {
                        Guid guid;
                        if (Guid.TryParse(templateId.Value, out guid))
                        {
                            return(guid);
                        }
                    }
                }

                if (attribute.Name == "Guid" || attribute.Name == "GuidAttribute")
                {
                    var templateId = attribute.Arguments.OfType <CodeAttributeArgument>().FirstOrDefault();
                    if (templateId != null)
                    {
                        Guid guid;
                        if (Guid.TryParse(templateId.Value, out guid))
                        {
                            return(guid);
                        }
                    }
                }
            }

            return(GuidExtensions.Hash(defaultName));
        }