This project is read-only.

Idee: Add a Method IngoreProperty ...

Apr 15, 2011 at 10:05 AM
Edited Apr 15, 2011 at 10:11 AM
There is only a idee:
I modified the base class AuditPropertyResolver with follow code:
public abstract class AuditPropertyResolver<TEntity> : IAuditPropertyResolver
{
  private readonly DefaultAuditPropertyResolver mDefaultResolver;
  private readonly Dictionary<MemberInfo, CustomizedAuditProperty> mCustomizedProperties;
  private readonly HashSet<MemberInfo> mIngoredProperties;

  protected AuditPropertyResolver()
  {
    mDefaultResolver = new DefaultAuditPropertyResolver();
    mCustomizedProperties = new Dictionary<MemberInfo, CustomizedAuditProperty>();
    mIngoredProperties = new HashSet<MemberInfo>();

    CustomizeProperties();
  }

  // ....

  public void IngoreProperty<TProperty>(Expression<Func<TEntity, TProperty>> propertySelector)
  {
    var exp = propertySelector.Body as MemberExpression;
    mIngoredProperties.Add(exp.Member);
  }

  public ModifiedEntityProperty GetAuditValue(MemberInfo member, object oldValue, object newValue)
  {
    ModifiedEntityProperty value;

    if (mIngoredProperties.Contains(member))
      return null;

    // ...
  }
}

// Example of my inherited class ..
// ModifiedOn, ModifiedBy are allways modified,
// but i need dont a audit record for this fields ...
protected override void CustomizeProperties()
{
  IngoreProperty(p => p.ModifiedOn);
  IngoreProperty(p => p.ModifiedBy);
  // .. }
}
Apr 15, 2011 at 10:10 AM
may i know who is dis pls?

On Fri, Apr 15, 2011 at 2:35 PM, donaldpeter <notifications@codeplex.com> wrote:

From: donaldpeter

There is only a idee:
I modified the base class AuditPropertyResolver with follow code:
public abstract class AuditPropertyResolver<TEntity> : IAuditPropertyResolver
  {
    private readonly DefaultAuditPropertyResolver mDefaultResolver;
    private readonly Dictionary<MemberInfo, CustomizedAuditProperty> mCustomizedProperties;
    private readonly HashSet<MemberInfo> mIngoredProperties;

    protected AuditPropertyResolver()
    {
      mDefaultResolver = new DefaultAuditPropertyResolver();
      mCustomizedProperties = new Dictionary<MemberInfo, CustomizedAuditProperty>();
      mIngoredProperties = new HashSet<MemberInfo>();

      CustomizeProperties();
    }

    // ....
    public void IngoreProperty<TProperty>(Expression<Func<TEntity, TProperty>> propertySelector)
    {
      var exp = propertySelector.Body as MemberExpression;
      mIngoredProperties.Add(exp.Member);
    }
    public ModifiedEntityProperty GetAuditValue(MemberInfo member, object oldValue, object newValue)
    {
      ModifiedEntityProperty value;

      if (mIngoredProperties.Contains(member))
        return null;

      // ...


// Example of my inherited class ..
// ModifiedOn, ModifiedBy are allways modified,
// but i need dont a audit record for this fields ...

protected override void CustomizeProperties() { IngoreProperty(p => p.ModifiedOn); IngoreProperty(p => p.ModifiedBy); // .. }

Read the full discussion online.

To add a post to this discussion, reply to this email (DoddleAudit@discussions.codeplex.com)

To start a new discussion for this project, email DoddleAudit@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Apr 15, 2011 at 10:28 AM

Hi Gopikishan

(sorry, my English is very bad)

I send you my modified source-code …

Perhaps you can it need …

Best regards:

Donald Peter

Von: gopikishan [email removed]
Gesendet: Freitag, 15. April 2011 11:11
An: Peter Donald
Betreff: Re: Idee: Add a Method IngoreProperty ... [DoddleAudit:254017]

From: gopikishan

may i know who is dis pls?

On Fri, Apr 15, 2011 at 2:35 PM, donaldpeter <notifications@codeplex.com> wrote:

From: donaldpeter

There is only a idee:
I modified the base class AuditPropertyResolver with follow code:
public abstract class AuditPropertyResolver<TEntity> : IAuditPropertyResolver
  {
    private readonly DefaultAuditPropertyResolver mDefaultResolver;
    private readonly Dictionary<MemberInfo, CustomizedAuditProperty> mCustomizedProperties;
    private readonly HashSet<MemberInfo> mIngoredProperties;
 
    protected AuditPropertyResolver()
    {
      mDefaultResolver = new DefaultAuditPropertyResolver();
      mCustomizedProperties = new Dictionary<MemberInfo, CustomizedAuditProperty>();
      mIngoredProperties = new HashSet<MemberInfo>();
 
      CustomizeProperties();
    }
 
    // ....
    public void IngoreProperty<TProperty>(Expression<Func<TEntity, TProperty>> propertySelector)
    {
      var exp = propertySelector.Body as MemberExpression;
      mIngoredProperties.Add(exp.Member);
    }
    public ModifiedEntityProperty GetAuditValue(MemberInfo member, object oldValue, object newValue)
    {
      ModifiedEntityProperty value;
 
      if (mIngoredProperties.Contains(member))
        return null;
 
      // ...
 
 
 
 
// Example of my inherited class ..
// ModifiedOn, ModifiedBy are allways modified,
// but i need dont a audit record for this fields ...
 

protected override void CustomizeProperties() { IngoreProperty(p => p.ModifiedOn); IngoreProperty(p => p.ModifiedBy); // .. }

Read the full discussion online.

To add a post to this discussion, reply to this email (DoddleAudit@discussions.codeplex.com)

To start a new discussion for this project, email DoddleAudit@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com



The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.