/// <summary> /// Registers an attached property by expression. /// </summary> /// <typeparam name="TType">The type of object the attached property targets.</typeparam> /// <typeparam name="TValue">The type of the value the attached property provides.</typeparam> /// <param name="this">The container to configure.</param> /// <param name="property">The expression that resolves to an attached property.</param> /// <returns>The configured IMemberConfiguration that represents the attached property.</returns> public static IMemberConfiguration <TType, TValue> AttachedProperty <TType, TValue>( this IConfigurationContainer @this, Expression <Func <Property <TType, TValue> > > property) { var instance = property.Compile()(); @this.Root.With <AttachedPropertiesExtension>() .Registrations.Instances.Add(instance); var subject = property.GetMemberInfo() .AsValid <PropertyInfo>(); var type = @this.GetTypeConfiguration(subject.DeclaringType); var current = type.AsInternal() .Member(subject); var result = new AttachedPropertyConfiguration <TType, TValue>(current); return(result); }
/// <summary> /// Gets or creates a type configuration from the container. Type configurations are configurations that deal /// specifically with a particular type and allow you to query its member configurations for further configuration of /// the type's members. /// </summary> /// <typeparam name="T">The requested type.</typeparam> /// <param name="this">The container from which to request the type configuration.</param> /// <returns>The type configuration.</returns> public static ITypeConfiguration <T> Type <T>(this IConfigurationContainer @this) => @this.GetTypeConfiguration(Support <T> .Key).AsValid <TypeConfiguration <T> >();