public static Activation <T> Property <T, TProperty>(this RuntimeConfigurator configurator, PropertyInfo propertyInfo) where T : class { PropertySelector propertySelector = configurator.GetPropertySelector(propertyInfo); Type propertyNodeType = typeof(PropertyNode <, ,>) .MakeGenericType(typeof(T), propertySelector.PropertyType, propertySelector.ValueType); return(configurator.CreateNode( id => (Activation <T>)Activator.CreateInstance(propertyNodeType, id, propertyInfo, propertySelector))); }
public static NodeSelector Create <T, TProperty>(RuntimeConfigurator configurator, NodeSelectorFactory nextSelectorFactory, PropertyInfo propertyInfo) { PropertySelector propertySelector = configurator.GetPropertySelector(propertyInfo); Type type = typeof(PropertyNodeSelector <, ,>) .MakeGenericType(typeof(T), propertySelector.PropertyType, propertySelector.ValueType); var nodeSelector = (NodeSelector) Activator.CreateInstance(type, configurator, nextSelectorFactory, propertyInfo, propertySelector); return(nodeSelector); }
public static NodeSelector Create(RuntimeConfigurator configurator, NodeSelectorFactory nextSelectorFactory, PropertyInfo propertyInfo, params Type[] tokenTypes) { if (tokenTypes.Length != 2) { throw new NotImplementedException("Only handling two right now"); } PropertySelector propertySelector = configurator.GetPropertySelector(propertyInfo); Type type = typeof(PropertyNodeSelector <, , ,>) .MakeGenericType(tokenTypes[0], tokenTypes[1], propertySelector.PropertyType, propertySelector.ValueType); var nodeSelector = (NodeSelector) Activator.CreateInstance(type, configurator, nextSelectorFactory, propertyInfo, propertySelector); return(nodeSelector); }