ConstructorsParameters is a misnamed property which contains the
actual arguments passed to the constructor.
Properties and Fields are dictionaries containing the values passed
to, well, attribute properties and fields, indexed by their name.
So for a class:
FooAttribute : Attribute {
public string Bar;
public string Baz { get; set; }
public FooAttribute (string gazonk) {}
}
And its use:
[Foo ("Gazonk", Bar = "bar", Baz = "baz")]
ConstructorParameters will contain Gazonk.
Fields will contain "Bar" => "bar", and Properties will contain "Baz" => "baz".
That's something that is working, not well for some corner cases, but
sufficiently enough for most cases.
On 8/9/09, Jorge Freitas Branco <
rush.of.d...@gmail.com> wrote:
> Attribute.Resolve returns true, but ConstructorParameters.Count seems to be
> always = 0.
>
> I feel maybe I dont understand well the working of ConstructorParameters.
> Its length should be the same as the number of properties of the attribute?
>
> Thanks
>
>
> On Sun, Aug 9, 2009 at 12:18 PM, Jb Evain <
j...@nurv.fr> wrote:
> >
> >
> > On 8/9/09, Jorge Freitas Branco
> <
rush.of.d...@gmail.com> wrote:
> > > attribute.ConstructorParameters.Count seems to be
> always =
> > > 0.
> > >
> > > Any help or comment?
> >
> > It depends on whether the attribute can be resolved or not.
> > What does attribute.Resolved says, and what happens if you call
> > attribute.Resolve () ?
> >
> > --
> >
> >
> >
> > Jb Evain <
j...@nurv.fr>
> >
> >
> >
>
>
> >
>
--
Jb Evain <
j...@nurv.fr>