public void ConfigureType(IConfigurableTrackableType trackableType) { Contract.Requires(() => trackableType != null); if (trackableType.Type.GetTypeInfo().GetCustomAttribute <ChangeTrackableAttribute>() != null) { IEnumerable <PropertyInfo> trackableProperties = GetTrackableProperties(trackableType.Type); if (trackableProperties.Count() > 0) { trackableType.IncludeProperties(trackableProperties); } } }
/// <summary> /// Configures which types will support change tracking. /// </summary> /// <param name="types">The types to track its changes</param> public void TrackTheseTypes(params ITrackableType[] types) { Contract.Requires(() => types != null && types.Length > 0 && types.All(t => t != null), "Given types cannot be null"); lock (_syncLock) { foreach (ITrackableType type in types) { if (!type.Type.GetTypeInfo().IsInterface) { Contract.Assert(() => TrackableTypes.Add(type), "Type can only be configured to be tracked once"); } else { IConfigurableTrackableType trackableType = type as IConfigurableTrackableType; trackableType.IncludeProperties(type.Type.GetProperties()); Contract.Assert(() => TrackableInterfaceTypes.Add(type), "Interface type can only be configured to be tracked once"); } } } }
private void ConfigureWithAttributes(IConfigurableTrackableType trackableType) { AttributeConfigurationBuilder configBuilder = new AttributeConfigurationBuilder(this); configBuilder.ConfigureType(trackableType); }