Esempio n. 1
0
        public static IGenerateHtml GetGenerator(ModelInfo info,
            IHaveModelConventions conventions)
        {
           
            if (info.HasAttribute<DisplayTemplateAttribute>())
            {
                return DisplayTemplateGenerator.Instance;
            }
            
            if (info.HasAttribute<EditorTemplateAttribute>())
            {
                return EditorTemplateGenerator.Instance;
            }

            if (conventions.IsIgnored)
            {
                return NullHtmlGenerator.Instance;
            }
            
            if (conventions.Builder != null)
            {
                return conventions.CreateGenerator();
            }
            if (info.Type.IsUserDefinedClass())
            {
                if (info.HasAttribute<AsOneElementAttribute>())
                {
                    return new PrimitiveTypeGenerator(conventions); 
                }
                return new CustomTypeGenerator(info.Meta, conventions);
            }
            if (info.Type == typeof (string) || !info.Type.DerivesFrom<IEnumerable>())
            {
                return new PrimitiveTypeGenerator(conventions);
            }
            return NullHtmlGenerator.Instance;
        }
Esempio n. 2
0
        public static IGenerateHtml GetGenerator(ModelInfo info,
                                                 IHaveModelConventions conventions)
        {
            if (info.HasAttribute <DisplayTemplateAttribute>())
            {
                return(DisplayTemplateGenerator.Instance);
            }

            if (info.HasAttribute <EditorTemplateAttribute>())
            {
                return(EditorTemplateGenerator.Instance);
            }

            if (conventions.IsIgnored)
            {
                return(NullHtmlGenerator.Instance);
            }

            if (conventions.Builder != null)
            {
                return(conventions.CreateGenerator());
            }
            if (info.Type.IsUserDefinedClass())
            {
                if (info.HasAttribute <AsOneElementAttribute>())
                {
                    return(new PrimitiveTypeGenerator(conventions));
                }
                return(new CustomTypeGenerator(info.Meta, conventions));
            }
            if (info.Type == typeof(string) || !info.Type.DerivesFrom <IEnumerable>())
            {
                return(new PrimitiveTypeGenerator(conventions));
            }
            return(NullHtmlGenerator.Instance);
        }
Esempio n. 3
0
 protected BaseGenerator(IHaveModelConventions conventions)
 {
     _conventions = conventions;
 }
Esempio n. 4
0
 protected abstract void Configure(IHaveModelConventions conventions);
Esempio n. 5
0
 protected BaseGenerator(IHaveModelConventions conventions)
 {
     _conventions = conventions;
 }
Esempio n. 6
0
 protected abstract void Configure(IHaveModelConventions conventions);
 public CustomTypeGenerator(ModelMetadata meta, IHaveModelConventions conventions)
 {
     Meta = meta;
     Conventions = conventions;
 }
 public CustomTypeGenerator(ModelMetadata meta, IHaveModelConventions conventions)
 {
     Meta        = meta;
     Conventions = conventions;
 }
 protected override void Configure(IHaveModelConventions conventions)
 {
     conventions.Builder = conventions.Registry.GetDefaultBuilder();
 }
 public PrimitiveTypeGenerator(IHaveModelConventions conventions) : base(conventions)
 {
 }