[nem-en] howto: "isBaseField"

Kamil Skalski kamil.skalski at gmail.com
Wed Apr 25 21:09:00 CEST 2007


I would rather do
   f.DeclaringType.Equals (tycon)

As for the other question - you can pass DeclaredOnly flag to
GetMembers. Also, you could use GetFields to fetch only fields (though
it is not much more efficient, since it first get all members and then
filer non-fields).

As for comparing member, the best would be to use Equals method,
though in practice == should work too, since members do not get
duplicated in standard scenario.

2007/4/25, Dmitry Ivankov <divanorama at gmail.com>:
> What is correct way to determine whether a class field belong to base class?
> (in Typer3)
>
> Following seems to work
>
> IsBaseField (f : IField) : bool {
>    CurrentType.parent_type != null &&
>    CurrentType.parent_type.tycon.GetMembers (). Exists (
>      x => x.MemberKind == MemberKinds.Field && (x :> IField) : object == f
>    )
>  }
>
> But it looks into all parents and all their members, looking only into class
> own fields can be more efficient.
> Is there a way to get only class own members?
> And is it a right way to compare IFields as objects?
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
>


-- 
Kamil Skalski
http://nazgul.omega.pl



More information about the devel-en mailing list