public void input_for_a_different_model()
        {
            execute(page => {
                var model = new ConventionTarget {Name = "Max"};

                return page.InputFor(model, x => x.Name);
            });

            theResult.ShouldEqual("<input type=\"text\" value=\"Max\" name=\"Name\" />");
        }
        public void display_for_a_different_model()
        {
            execute(page =>
            {
                var model = new ConventionTarget { Name = "Max" };

                return page.DisplayFor(model, x => x.Name);
            });

            theResult.ShouldEqual("<span id=\"Name\">Max</span>");
        }
Esempio n. 3
0
        public void input_for_a_different_model()
        {
            execute(page => {
                var model = new ConventionTarget {
                    Name = "Max"
                };

                return(page.InputFor(model, x => x.Name));
            });

            theResult.ShouldEqual("<input type=\"text\" value=\"Max\" name=\"Name\" />");
        }
Esempio n. 4
0
        public void display_for_a_different_model()
        {
            execute(page =>
            {
                var model = new ConventionTarget {
                    Name = "Max"
                };

                return(page.DisplayFor(model, x => x.Name));
            });

            theResult.ShouldEqual("<span id=\"Name\">Max</span>");
        }
Esempio n. 5
0
        private static bool IsAcceptableTarget(NameSemantic semantic, ConventionTarget target, ITypeDefinition typeDef)
        {
            bool acceptable = true;

            switch (target)
            {
            case ConventionTarget.Class:
                acceptable = typeDef.Kind == TypeKind.Class;
                break;

            case ConventionTarget.Struct:
                acceptable = typeDef.Kind == TypeKind.Struct;
                break;

            case ConventionTarget.Enum:
                acceptable = typeDef.Kind == TypeKind.Enum;
                break;

            case ConventionTarget.Interface:
                acceptable = typeDef.Kind == TypeKind.Interface;
                break;

            case ConventionTarget.Delegate:
                acceptable = typeDef.Kind == TypeKind.Delegate;
                break;

            case ConventionTarget.ObjectLiteral:
                acceptable = semantic.IsObjectLiteral || typeDef.GetAttribute(new FullTypeName("H5.ObjectLiteralAttribute"), false) != null;
                break;

            case ConventionTarget.Anonymous:
                acceptable = typeDef.Kind == TypeKind.Anonymous;
                break;

            case ConventionTarget.External:
                string externalAttr = "H5.ExternalAttribute";

                var has =
                    typeDef.Attributes.Any(
                        attr =>
                        attr.Constructor != null &&
                        attr.Constructor.DeclaringType.FullName == externalAttr);

                if (!has && typeDef.DeclaringTypeDefinition != null)
                {
                    has =
                        typeDef.DeclaringTypeDefinition.Attributes.Any(
                            attr =>
                            attr.Constructor != null &&
                            attr.Constructor.DeclaringType.FullName == externalAttr);
                }

                if (!has)
                {
                    has = H5Types.IsTypeFromH5Core(typeDef.FullName) ||
                          typeDef.ParentAssembly.AssemblyAttributes.Any(
                        attr =>
                        attr.Constructor != null &&
                        attr.Constructor.DeclaringType.FullName == externalAttr);
                }

                acceptable = has;

                break;

            default:
                break;
            }
            return(acceptable);
        }
Esempio n. 6
0
 /// <summary>
 ///Initializes a new instance of the ConventionAttribute class with specified Notation and Target.
 /// </summary>
 /// <param name="notation"></param>
 /// <param name="target">Specifies target(s) to be filtered by [Convention] attribute.</param>
 public extern ConventionAttribute(Notation notation, ConventionTarget target);
Esempio n. 7
0
 /// <summary>
 ///Initializes a new instance of the ConventionAttribute class with specified Notation and Target.
 /// </summary>
 /// <param name="notation"></param>
 /// <param name="target">Specifies target(s) to be filtered by [Convention] attribute.</param>
 public ConventionAttribute(Notation notation, ConventionTarget target)
 {
 }