/// <summary> /// Initializes a new instance of the <see cref="CachedProperty" /> class. /// </summary> /// <param name="propertyInfo">The property information.</param> public CachedProperty(PropertyInfo propertyInfo) { PropertyInfo = propertyInfo; PropertyType = propertyInfo.PropertyType; PropertyTypeInfo = PropertyType.GetTypeInfo(); if (!IsKey) { IsValidEntityType = !PropertyTypeInfo.IsPrimitive && PropertyType != typeof(string) && !PropertyTypeInfo.IsEnum; } _setter = new NotCompiledSetter(propertyInfo.SetMethod); _getter = new NotCompiledGetter(propertyInfo.GetMethod); IsVirtual = propertyInfo.GetMethod.IsVirtual; IsCollectionType = PropertyType.TryGetCollectionElement(out _elementType); }
/// <summary> /// Compiles the getter and setter accessor. /// </summary> public void Compile() { _getter = _getter.Compile(); _setter = _setter.Compile(); }