Esempio n. 1
0
        public override void Property(TVisitor visitor, PropertyInfo property)
        {
            if (property.PropertyType.HasInterface(typeof(Segment <>)))
            {
                var valueType = property.PropertyType.GetClosingArguments(typeof(Segment <>)).Single();

                var methodType = typeof(TVisitor)
                                 .GetMethod("Segment")
                                 .MakeGenericMethod(valueType);

                CompileCallMethod(methodType)(visitor, property);
            }
            else if (property.PropertyType.HasInterface(typeof(SegmentList <>)))
            {
                var valueType = property.PropertyType.GetClosingArguments(typeof(SegmentList <>)).Single();

                var methodType = typeof(TVisitor)
                                 .GetMethod("SegmentList")
                                 .MakeGenericMethod(valueType);

                CompileCallMethod(methodType)(visitor, property);
            }
            else
            {
                base.Property(visitor, property);
            }
        }
Esempio n. 2
0
        public virtual void Property(TVisitor visitor, PropertyInfo property)
        {
            if (property.PropertyType.HasInterface(typeof(Value <>)))
            {
                var valueType = property.PropertyType.GetClosingArguments(typeof(Value <>)).Single();

                var methodType = typeof(TVisitor)
                                 .GetMethod("Value")
                                 .MakeGenericMethod(valueType);

                CompileCallMethod(methodType)(visitor, property);
            }
            else if (property.PropertyType.HasInterface(typeof(ValueList <>)))
            {
                var valueType = property.PropertyType.GetClosingArguments(typeof(ValueList <>)).Single();

                var methodType = typeof(TVisitor)
                                 .GetMethod("ValueList")
                                 .MakeGenericMethod(valueType);

                CompileCallMethod(methodType)(visitor, property);
            }
            else if (property.PropertyType.HasInterface(typeof(Entity <>)))
            {
                var entityType = property.PropertyType.GetClosingArguments(typeof(Entity <>)).Single();

                var methodType = typeof(TVisitor)
                                 .GetMethod("Entity")
                                 .MakeGenericMethod(entityType);

                CompileCallMethod(methodType)(visitor, property);
            }
            else if (property.PropertyType.HasInterface(typeof(EntityList <>)))
            {
                var entityType = property.PropertyType.GetClosingArguments(typeof(EntityList <>)).Single();

                var methodType = typeof(TVisitor)
                                 .GetMethod("EntityList")
                                 .MakeGenericMethod(entityType);

                CompileCallMethod(methodType)(visitor, property);
            }
            else if (property.PropertyType.HasInterface(typeof(Layout <>)))
            {
                var layoutType = property.PropertyType.GetClosingArguments(typeof(Layout <>)).Single();

                var methodType = typeof(TVisitor)
                                 .GetMethod("Layout")
                                 .MakeGenericMethod(layoutType);

                CompileCallMethod(methodType)(visitor, property);
            }
            else if (property.PropertyType.HasInterface(typeof(LayoutList <>)))
            {
                var layoutType = property.PropertyType.GetClosingArguments(typeof(LayoutList <>)).Single();

                var methodType = typeof(TVisitor)
                                 .GetMethod("LayoutList")
                                 .MakeGenericMethod(layoutType);

                CompileCallMethod(methodType)(visitor, property);
            }
        }