Is it possible to dynamically inject an attribute using an IoC like Ninject or other IoC?

I am expanding my Diff object property value , but I realized that the object has too many properties that I might not want to distinguish between them. So I came up with

public class IgnorePropertyDiffAttribute : System.Attribute
{
}

      

so that I can mark the properties that I want diff to ignore. However, I don't want to pollute my domain object with [IgnorePropertyDiff].

public class Role
{
    [IgnorePropertyDiff]
    public String Description { set; get; }
    public Double Salary { set; get; }
    public Boolean HasBonus { set; get; }
}

      

My question is, is it possible to dynamically inject [IgnorePropertyDiff] using IoC like Ninject or other IoC? If I sound like a complete idiot, please, because I'm just a junior intermediate C # developer. Thanks in advance.

+1


source to share


1 answer


Attributes are a compile-time feature, so no: you cannot add them (or set values ​​against them) using IoC.



+3


source







All Articles