Alterar o parâmetro do atributo customizado no tempo de execução

Preciso de um parâmetro para alterar o atributo durante o tempo de execução. Eu simplifiquei meu problema para um exemplo simples.

Classe de atributo:

<code>    [AttributeUsage(AttributeTargets.Property)]
    public class MyAttribute : Attribute
    {
        public string Name { get; set; }
    }
</code>

Entidade simples que decorou propriedades com atributos:

<code>    public class MyEntity
    {
        [MyAttribute(Name="OldValue1")]
        public string Data1{ get; set; }

        [MyAttribute(Name = "OldValue2")]
        public string Data2 { get; set; }
    }
</code>

Eu criei a instância da classe MyEntity. Eu posso alterar o valor das propriedades do objeto, mas não posso alterar o valor da propriedade do atributo Name na entidade do objeto. É possível?

Valor da propriedade na entidade de objeto eu posso mudar com esta parte do código:

<code>                entityProp.SetValue(entity,"NewData",null);
</code>

mas não sei como alterar o valor da propriedade do atributo Name on object entity

Isso não funciona:

<code>attProp.SetValue(attribute,"NewData",null);
</code>

Valor da propery O nome ainda é original.

Aqui está todo o código de teste. Obrigado pelo inferno.

<code>    [TestMethod]
    public  void Test()
    {
        var entity = new MyEntity
                         {
                             Data1 = "OldData",
                             Data2 = "OldData"
                         };

        PropertyInfo[] entityProps = entity.GetType().GetProperties();

        foreach (var entityProp in entityProps)
        {
            var attribute = Attribute.GetCustomAttribute(entityProp, typeof (MyAttribute)) as MyAttribute;

            if (attribute != null)
            {
                //get attribute’s property NAME
                PropertyInfo attProp= attribute.GetType().GetProperty("Name");

                //get entity property value
                var propertyValue = entityProp.GetValue(entity, null);

                //get attribute’s property NAME value
                var atributeNameValue = attProp.GetValue(entity, null);

                TestContext.WriteLine(string.Format("property name:{0} property value: {1} : atribute name value: {2}\n", 
                    entityProp.Name, propertyValue, atributeNameValue)); 

                //change values
                entityProp.SetValue(entity,"NewData",null);

                //how can I change value of property Name on object entity ?
                attProp.SetValue(attribute,"NewData",null);

            }

        }

        TestContext.WriteLine(string.Format("After change\n"));

        foreach (var entityProp in entityProps)
        {
            var attribute = Attribute.GetCustomAttribute(entityProp, typeof(MyAttribute)) as MyAttribute;

            if (attribute != null)
            {

                PropertyInfo attProp = attribute.GetType().GetProperty("Name");

                var propertyValue = entityProp.GetValue(entity, null);
                var atributeNameValue = attProp.GetValue(entity, null);

                TestContext.WriteLine(string.Format("property name:{0} property value: {1} : atribute name value: {2}\n",
                    entityProp.Name, propertyValue, atributeNameValue));
            }
        }



    }
</code>

EDITADO: eu excluo a postagem original e adicionei uma amostra clara muito simples. Desculpa

questionAnswers(2)

yourAnswerToTheQuestion