private void ProvideSpecificTraits(ProjectionProperty property, ITraitAggregator aggregator) { PropertyScope scope; var scopes = specificPropertyScopes; if (scopes != null && scopes.TryGetValue(property.Name, out scope)) scope.ProvideTraits(aggregator); }
internal PropertyInitializerInvocation( ProjectionProperty property, Cell<IProjectionBehavior> behavior) { this.property = property; this.behavior = behavior; }
public MemberKey(ProjectionProperty property) { if (property == null) throw new ArgumentNullException("property"); MemberName = property.Name; DeclaringType = property.DeclaringType.UnderlyingType; }
private void ProvideGeneralTraits(ProjectionProperty property, ITraitAggregator aggregator) { var scopes = generalPropertyScopes; if (scopes != null) foreach (var scope in scopes) if (scope.AppliesTo(property)) scope.ProvideTraits(aggregator); }
internal PropertySetterInvocation( Projection projection, ProjectionProperty property, Cell<IProjectionBehavior> behavior) { this.projection = projection; this.property = property; this.behavior = behavior; }
internal bool AppliesTo(ProjectionProperty property) { var restrictions = this.restrictions; if (restrictions != null) foreach (var restriction in restrictions) if (!restriction.AppliesTo(property)) return false; return true; }
internal PropertyGetterInvocation( Projection projection, ProjectionProperty property, GetterOptions options, Cell<IProjectionBehavior> behavior) { this.projection = projection; this.property = property; this.options = options; this.behavior = behavior; }
// TODO: 'trait' instead of 'attribute'? internal static Exception AttributeConflict(ProjectionProperty property, Type attributeType) { var message = string.Format ( "Conflicting '{0}' attributes inherited by property {1}.{2}. " + "Override the attribute, or use inheritance directives to resolve the conflict.", attributeType.GetPrettyName(false).RemoveSuffix(AttributeSuffix), property.DeclaringType.UnderlyingType.GetPrettyName(true), property.Name ); return new ProjectionException(message); }
public void ProvidePropertyTraits( ProjectionProperty projectionProperty, PropertyInfo underlyingProperty, ITraitAggregator aggregator) { if (projectionProperty == null) throw Error.ArgumentNull("projectionProperty"); if (underlyingProperty == null) throw Error.ArgumentNull("underlyingProperty"); if (aggregator == null) throw Error.ArgumentNull("aggregator"); ProvideAttributes(underlyingProperty, aggregator); var scopes = this.scopes; if (scopes != null) foreach (var scope in scopes) scope.ProvideTraits(projectionProperty, aggregator); }
public bool AppliesTo(ProjectionProperty property) { return property.PropertyType.Kind == kind; }
public bool AppliesTo(ProjectionProperty property) { return property.Name.StartsWith("Test"); }
private static MethodBuilder ImplementSetMethod(TypeBuilder typeBuilder, ProjectionProperty propertyInfo, FieldInfo propertyField) { var setMethod = typeBuilder.DefineMethod ( string.Concat(SetterPrefix, propertyInfo.Name), MethodAttributes.Private | MethodAttributes.NewSlot | MethodAttributes.Virtual | MethodAttributes.Final | MethodAttributes.HideBySig | MethodAttributes.SpecialName, null, // void new[] { propertyInfo.PropertyType.UnderlyingType } ); setMethod.DefineParameter(1, ParameterAttributes.None, "value"); var il = setMethod.GetILGenerator(); EmitCallBaseSetter(il, BaseSetMethod, propertyField); typeBuilder.DefineMethodOverride(setMethod, propertyInfo.UnderlyingSetter); return setMethod; }
private static void ImplementProjectionProperty(TypeBuilder typeBuilder, ProjectionProperty propertyInfo, string propertyFieldName) { var propertyField = typeBuilder.DefineField ( propertyFieldName, typeof(ProjectionProperty), FieldAttributes.Public | FieldAttributes.Static ); var property = typeBuilder.DefineProperty ( propertyInfo.Name, PropertyAttributes.None, CallingConventions.HasThis, propertyInfo.PropertyType, null // parameterTypes ); if (propertyInfo.CanRead) { var getMethod = ImplementGetMethod(typeBuilder, propertyInfo, propertyField); property.SetGetMethod(getMethod); } if (propertyInfo.CanWrite) { var setMethod = ImplementSetMethod(typeBuilder, propertyInfo, propertyField); property.SetSetMethod(setMethod); } }
private static MethodBuilder ImplementGetMethod(TypeBuilder typeBuilder, ProjectionProperty propertyInfo, FieldInfo propertyField) { var getMethod = typeBuilder.DefineMethod ( string.Concat(GetterPrefix, propertyInfo.Name), MethodAttributes.Private | MethodAttributes.NewSlot | MethodAttributes.Virtual | MethodAttributes.Final | MethodAttributes.HideBySig | MethodAttributes.SpecialName, propertyInfo.PropertyType, Type.EmptyTypes ); var il = getMethod.GetILGenerator(); EmitCallBaseGetter (il, BaseGetMethod, propertyField); EmitReturnTypedOrDefault(il, propertyInfo.PropertyType.UnderlyingType); typeBuilder.DefineMethodOverride(getMethod, propertyInfo.UnderlyingGetter); return getMethod; }
private static string GetPropertyFieldName(ProjectionProperty property, int index) { // TODO: Use a name that is illegal in most .NET languages return string.Concat ( "_p", index.ToString(), "_", property.Name ); }
// TODO: 'trait' instead of 'attribute'? internal static Exception InvalidOverride(string name, Type declaringType, ProjectionProperty newProperty) { var message = string.Format ( "Invalid 'Override' attribute on property {0}.{1}. " + "The specified base property was not found: {2}.{3}.", newProperty.DeclaringType.UnderlyingType.GetPrettyName(true), newProperty.Name, declaringType.GetPrettyName(true), name ); return new ProjectionException(message); }
public bool AppliesTo(ProjectionProperty property) { return property.Name.Equals(name, comparison); }
public bool AppliesTo(ProjectionProperty property) { return regex.IsMatch(property.Name); }
internal void ProvideTraits(ProjectionProperty property, ITraitAggregator aggregator) { ProvideGeneralTraits (property, aggregator); ProvideSpecificTraits(property, aggregator); }
public bool AppliesTo(ProjectionProperty property) { return HasKind(property.PropertyType.Kind); }
public bool AppliesTo(ProjectionProperty property) { return AppliesTo(property.Name); }