Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2006

Tip: Looking for answers? Try searching our database.

DefinePropery with instance keyword...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick - 06 Jun 2006 19:35 GMT
Is it possible to Define a property with the TypeBuilder and having the IL
code definition use the instance keyword... seems like code generated with
the compiler shows this keyword and when i build my own types they dont have
this keyword...i use Reflector to check that the classe generated seems
ok..and reflector when in the absence of the instance keyword returns and
indexer property... im lost here since calling GetProperties on my emitted
type also returns a PropertyInfo indexer...

Thanks
GhostInAK - 06 Jun 2006 23:01 GMT
Hello Patrick,
I seem to get my properties defined with the instance keyword (though I dont
know what it leans in IL).

I do:

Dim tFieldBuilder As FieldBuilder = Nothing
Dim tPropertyBuilder As PropertyBuilder = Nothing
Dim tMethodBuilder As MethodBuilder = Nothing

tFieldBuilder = tTypeBuilder.DefineField("sSomeString", tType, FieldAttributes.Private)
tPropertyBuilder = tTypeBuilder.DefineProperty("SomeString", System.Reflection.PropertyAttributes.None,
tType, Nothing)
tMethodBuilder = tTypeBuilder.DefineMethod("get_SomeString", MethodAttributes.Public
Or MethodAttributes.SpecialName, tPropertyBuilder.PropertyType, New Type()
{})
tILGenerator = tMethodBuilder.GetILGenerator
With tILGenerator
    .DeclareLocal(tPropertyBuilder.PropertyType)
    .Emit(OpCodes.Nop)
    .Emit(OpCodes.Ldarg_0)
    .Emit(OpCodes.Ldfld, tFieldBuilder)
    .Emit(OpCodes.Stloc_0)
    .Emit(OpCodes.Ldloc_0)
    .Emit(OpCodes.Ret)
End With
tPropertyBuilder.SetGetMethod(tMethodBuilder)

> Is it possible to Define a property with the TypeBuilder and having
> the IL code definition use the instance keyword... seems like code
[quoted text clipped - 6 lines]
>
> Thanks
Patrick - 07 Jun 2006 14:21 GMT
Ok found out it was my DefineProperty that was wrong... i tought that the
ParameterTypes parameter was the "value" parameter (== to return type) ...now
i pass null and everything is back to normal.

Thanks

> Hello Patrick,
> I seem to get my properties defined with the instance keyword (though I dont
[quoted text clipped - 34 lines]
> >
> > Thanks
Patrick - 07 Jun 2006 15:43 GMT
Ok what I am doing is overriding a Property... its seems to work but when i
call GetProperties on my new type that overrides the property... i get two
distinct propertyInfos... and thats not what i want since one inherits the
attributes and the other doesnt... what do i need to do to define a overriden
property???

> Ok found out it was my DefineProperty that was wrong... i tought that the
> ParameterTypes parameter was the "value" parameter (== to return type) ...now
[quoted text clipped - 40 lines]
> > >
> > > Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.