language: VB.NET (mono-2.4.2.3)
date: 602 days 6 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Imports system.collections.generic
Imports system.reflection
 
 
Module example 
 
    Public Function IsPropertyWritable(tT as Type, propertyName as string) as Boolean
        For Each prop as system.reflection.propertyinfo in  tT.GetProperties(bindingflags.public OR bindingflags.NonPublic OR _
                        bindingflags.instance OR bindingflags.static)
          
             if prop.name = propertyname then
                 return prop.canwrite
             End If
         Next
         Throw new exception("No property with the name'"+ propertyname +"' exist for class '"+ tT.Name)
    End Function
 
 
    Public Function IsPropertyWritable(of t) ( propertyname as String) as Boolean
        Dim tT as Type  = gettype(t)
        return IsPropertyWritable(tT, propertyName)
    End function
 
    Public Function IsPropertyWritable(Obj as object, propertyname as String) as Boolean
        Dim tT as Type  = obj.gettype
        return IsPropertyWritable(tT, propertyName)
    End function
 
 
    Public Sub Main() 
       System.console.writeline( IsPropertyWritable(of a) ( "r"))
       System.console.writeline( IsPropertyWritable(of a) ( "norm"))
       System.console.writeline( IsPropertyWritable(new a, "norm"))
       System.console.writeline( IsPropertyWritable(new a, "r"))
       
    End Sub
End Module
 
Public class a
 
Public Property norm As integer
Get 
   return 42
End get
Set (value as integer)
End set
End property
 
Public readonly property r as integer
Get
   Return 42
 End get
End property
 
End class
 
 
Visual Basic.Net Compiler version 0.0.0.5914 (Mono 2.4.2 - r)
Copyright (C) 2004-2008 Rolf Bjarne Kvinge. All rights reserved.


Assembly 'prog, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' saved successfully to '/home/japWoW/prog.exe'.
Compilation successful
Compilation took 00:00:01.0912130