// EventPropertyGetterAndIndexed public override EventPropertyGetterSPI GetGetter( BeanEventType eventType, EventBeanTypedEventFactory eventBeanTypedEventFactory, BeanEventTypeFactory beanEventTypeFactory) { var propertyDesc = eventType.GetIndexedProperty(PropertyNameAtomic); if (propertyDesc == null) { return null; } if (propertyDesc.IsIndexedReadMethod) { return new KeyedMethodPropertyGetter( propertyDesc.ReadMethod, Index, eventBeanTypedEventFactory, beanEventTypeFactory); } // Try the as a simple property if (!propertyDesc.PropertyType.IsSimple()) { return null; } var returnType = propertyDesc.ReturnType; if (returnType.IsArray) { return GetGetterFromArray( eventBeanTypedEventFactory, beanEventTypeFactory, propertyDesc); } if (returnType.IsGenericList()) { return GetGetterFromList( eventBeanTypedEventFactory, beanEventTypeFactory, propertyDesc); } if (returnType.IsGenericEnumerable() || TypeHelper.IsImplementsInterface(returnType, typeof(IEnumerable))) { return GetGetterFromEnumerable( eventBeanTypedEventFactory, beanEventTypeFactory, propertyDesc); } return null; }
public override Type GetPropertyType(BeanEventType eventType, EventAdapterService eventAdapterService) { var descriptor = eventType.GetIndexedProperty(PropertyNameAtomic); if (descriptor != null) { return(descriptor.ReturnType); } // Check if this is an method returning array which is a type of simple property descriptor = eventType.GetSimpleProperty(PropertyNameAtomic); if (descriptor == null) { return(null); } return(descriptor.ReturnType.GetIndexType()); }
public override GenericPropertyDesc GetPropertyTypeGeneric( BeanEventType eventType, BeanEventTypeFactory beanEventTypeFactory) { var descriptor = eventType.GetIndexedProperty(PropertyNameAtomic); if (descriptor == null) { return null; } if (descriptor.IsIndexedReadMethod) { return new GenericPropertyDesc(descriptor.ReturnType); } // Check if this is an method returning array which is a type of simple property if (!descriptor.PropertyType.IsSimple()) { return null; } var returnType = descriptor.ReturnType; if (returnType.IsArray) { return new GenericPropertyDesc(returnType.GetElementType()); } if (returnType.IsGenericEnumerable() || TypeHelper.IsImplementsInterface(returnType, typeof(IEnumerable))) { if (descriptor.AccessorProp != null) { var genericType = TypeHelper.GetGenericPropertyType(descriptor.AccessorProp, false); return new GenericPropertyDesc(genericType); } if (descriptor.ReadMethod != null) { var genericType = TypeHelper.GetGenericReturnType(descriptor.ReadMethod, false); return new GenericPropertyDesc(genericType); } if (descriptor.AccessorField != null) { var genericType = TypeHelper.GetGenericFieldType(descriptor.AccessorField, false); return new GenericPropertyDesc(genericType); } return null; } return null; }
public override GenericPropertyDesc GetPropertyTypeGeneric(BeanEventType eventType, EventAdapterService eventAdapterService) { var descriptor = eventType.GetIndexedProperty(PropertyNameAtomic); if (descriptor != null) { return(new GenericPropertyDesc(descriptor.ReturnType)); } // Check if this is an method returning array which is a type of simple property descriptor = eventType.GetSimpleProperty(PropertyNameAtomic); if (descriptor == null) { return(null); } var returnType = descriptor.ReturnType; if (returnType.IsArray) { return(new GenericPropertyDesc(returnType.GetElementType())); } else if (returnType.IsImplementsInterface(typeof(IEnumerable))) { if (descriptor.ReadMethod != null) { var genericType = TypeHelper.GetGenericReturnType(descriptor.ReadMethod, false); return(new GenericPropertyDesc(genericType)); } else if (descriptor.AccessorField != null) { var genericType = TypeHelper.GetGenericFieldType(descriptor.AccessorField, false); return(new GenericPropertyDesc(genericType)); } else { return(null); } } return(null); }
public override EventPropertyGetterSPI GetGetter(BeanEventType eventType, EventAdapterService eventAdapterService) { var fastClass = eventType.FastClass; var propertyDesc = eventType.GetIndexedProperty(PropertyNameAtomic); if (propertyDesc != null) { if (fastClass != null) { var method = propertyDesc.ReadMethod; var fastMethod = fastClass.GetMethod(method); return(new KeyedFastPropertyGetter(fastMethod, _index, eventAdapterService)); } else { return(new KeyedMethodPropertyGetter(propertyDesc.ReadMethod, _index, eventAdapterService)); } } // Try the array as a simple property propertyDesc = eventType.GetSimpleProperty(PropertyNameAtomic); if (propertyDesc == null) { return(null); } var returnType = propertyDesc.ReturnType; if (returnType == typeof(string)) { if (propertyDesc.ReadMethod != null) { var method = propertyDesc.ReadMethod; if (fastClass != null) { var fastMethod = fastClass.GetMethod(method); return(new StringFastPropertyGetter(fastMethod, _index, eventAdapterService)); } else { return(new StringMethodPropertyGetter(method, _index, eventAdapterService)); } } else { var field = propertyDesc.AccessorField; return(new StringFieldPropertyGetter(field, _index, eventAdapterService)); } } else if (returnType.IsArray) { if (propertyDesc.ReadMethod != null) { var method = propertyDesc.ReadMethod; if (fastClass != null) { var fastMethod = fastClass.GetMethod(method); return(new ArrayFastPropertyGetter(fastMethod, _index, eventAdapterService)); } else { return(new ArrayMethodPropertyGetter(method, _index, eventAdapterService)); } } else { var field = propertyDesc.AccessorField; return(new ArrayFieldPropertyGetter(field, _index, eventAdapterService)); } } else if (returnType.IsGenericDictionary()) { } else if (returnType.IsGenericList()) { if (propertyDesc.ReadMethod != null) { var method = propertyDesc.ReadMethod; if (fastClass != null) { var fastMethod = fastClass.GetMethod(method); return(new ListFastPropertyGetter(method, fastMethod, _index, eventAdapterService)); } else { return(new ListMethodPropertyGetter(method, _index, eventAdapterService)); } } else { var field = propertyDesc.AccessorField; return(new ListFieldPropertyGetter(field, _index, eventAdapterService)); } } else if (returnType.IsImplementsInterface(typeof(IEnumerable))) { if (propertyDesc.ReadMethod != null) { var method = propertyDesc.ReadMethod; if (fastClass != null) { var fastMethod = fastClass.GetMethod(method); return(new EnumerableFastPropertyGetter(method, fastMethod, _index, eventAdapterService)); } else { return(new EnumerableMethodPropertyGetter(method, _index, eventAdapterService)); } } else { var field = propertyDesc.AccessorField; return(new EnumerableFieldPropertyGetter(field, _index, eventAdapterService)); } } return(null); }
public override EventPropertyGetter GetGetter(BeanEventType eventType, EventAdapterService eventAdapterService) { FastClass fastClass = eventType.FastClass; InternalEventPropDescriptor propertyDesc = eventType.GetIndexedProperty(PropertyNameAtomic); if (propertyDesc != null) { if (fastClass != null) { MethodInfo method = propertyDesc.ReadMethod; FastMethod fastMethod = fastClass.GetMethod(method); return(new KeyedFastPropertyGetter(fastMethod, _index, eventAdapterService)); } else { return(new KeyedMethodPropertyGetter(propertyDesc.ReadMethod, _index, eventAdapterService)); } } // Try the array as a simple property propertyDesc = eventType.GetSimpleProperty(PropertyNameAtomic); if (propertyDesc == null) { return(null); } Type returnType = propertyDesc.ReturnType; if (returnType.IsArray) { if (propertyDesc.ReadMethod != null) { MethodInfo method = propertyDesc.ReadMethod; if (fastClass != null) { FastMethod fastMethod = fastClass.GetMethod(method); return(new ArrayFastPropertyGetter(fastMethod, _index, eventAdapterService)); } else { return(new ArrayMethodPropertyGetter(method, _index, eventAdapterService)); } } else { FieldInfo field = propertyDesc.AccessorField; return(new ArrayFieldPropertyGetter(field, _index, eventAdapterService)); } } else if (returnType.IsImplementsInterface(typeof(IList <object>))) { if (propertyDesc.ReadMethod != null) { MethodInfo method = propertyDesc.ReadMethod; if (fastClass != null) { FastMethod fastMethod = fastClass.GetMethod(method); return(new ListFastPropertyGetter(method, fastMethod, _index, eventAdapterService)); } else { return(new ListMethodPropertyGetter(method, _index, eventAdapterService)); } } else { FieldInfo field = propertyDesc.AccessorField; return(new ListFieldPropertyGetter(field, _index, eventAdapterService)); } } else if (returnType.IsImplementsInterface(typeof(IEnumerable))) { if (propertyDesc.ReadMethod != null) { MethodInfo method = propertyDesc.ReadMethod; if (fastClass != null) { FastMethod fastMethod = fastClass.GetMethod(method); return(new EnumerableFastPropertyGetter(method, fastMethod, _index, eventAdapterService)); } else { return(new EnumerableMethodPropertyGetter(method, _index, eventAdapterService)); } } else { FieldInfo field = propertyDesc.AccessorField; return(new EnumerableFieldPropertyGetter(field, _index, eventAdapterService)); } } return(null); }