This project has moved and is read-only. For the latest updates, please go here.

how sharpmap supports reflection

Aug 10, 2009 at 6:38 AM

Hi ,

I am very enthusiastic to know how well sharpmap supports the reflection concepts.

Suppose, if there are layers of kind vectorlayer,label layer in object. And I want to know the type of layers present in a object using reflection concepts. How can I use the Reflection on sharpmap. Please suggest appropriate solution



Aug 10, 2009 at 1:43 PM

Hi ram282, reflection isn't supported by sharpmap as such - it is an inherent property of the clr type system - each object has the GetType method which gets the Type information for the instance.

I guess the underlying question is along the lines of  "How do I determine the layer type of an arbitary layer in a map's layers collection" 

one way would be along the lines of :

for (ILayer lyr in myMap.Layers)
if(lyr is VectorLayer)

else if (lyr is LabelLayer)

or you can safe cast like so :
foreach(ILayer lyr in myMap.Layers)
VectorLayer vector = lyr as VectorLayer;
if(vector !=null)
hth jd
Aug 10, 2009 at 1:57 PM

Thanks Johndiss for ur information.

Aug 10, 2009 at 2:19 PM

I have one more question for you john.

I am using ajax slider extender for controlling the color transparency level of a map. But I am unable to set the transparency of a map. Could u please tell which property in rendering class  or any other class could be used for setting the transparency level.

Thanks in advance



Aug 10, 2009 at 2:33 PM

you will need to use colors with an alpha component i.e use Color.FromArgb .The A component controls alpha and is in the range 0 (invisible) to 255(opaque). the rgb components control red green blue and also range 0-255

Aug 10, 2009 at 3:14 PM

Thanks John.

I am using Fill property for rendering color to my map layer. For example here layCountries is a vectorlayer of countries.

<font size="2">

layCountries.Style.Fill =


new SolidBrush(Color.FromName(Color.Beige))

As you had said, to use Color.FromArgb. Should I use Color.FromArgb method for the fill property ? Or Is there any other property for Color.FromArgb.

If Fill property is used for Color.FromArgb, Should I use either one of the methods ( Color.FromName or Color.FromArgb). Because When I tried to use both these two methods for the Style.Fill property simultaneously I am not getting the correct results.  Could u please post an example on this context.



Aug 10, 2009 at 3:46 PM


layCountries.Style.Fill = new SolidBrush(Color.FromArgb(100, Color.Biege));

hth jd