Is it possible to dynamically inject the attribute using IoC like Ninject or other IoC?
-
06-07-2019 - |
Question
I am extending my Object Property Value Diff but I realized if an object has too many properties I may not want to diff them all. So I came up with the
public class IgnorePropertyDiffAttribute : System.Attribute
{
}
so that I can mark the properties I want the 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 that is it possible to dynamically inject the [IgnorePropertyDiff] using IoC like Ninject or other IoC? If I sound like an completely idiot please execuse me as I am only a junior-mid level c# developer. Thanks in advance.
Solution
Attributes are a compile-time feature, so no: you can't add them (or set values against them) using IoC.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow