Since there were a few interesting looks, here is what it will look like:
a) No form of reflection can get a list of properties for obfuscation. I tried to go through all types to find those with ProtoContract, I could find them but the property names are all changed to a, m, b, j, g.
I also tried Me.GetType.GetProperties with the same result.
You could implement a map from the output to indicate that Employee.FirstName is now a0.j, but propagating this leads to a loss of purpose.
b) That works to some extent to free the NAME class from obfuscation. Since PB-N is looking for ProtoMember attributes to retrieve data, you can confuse Property / Members rather than the class / type name. If this name is similar to FederalReserveLogIn, your class / type has an “apple” on it.
I had an initial success:
1) Create a simple class to save the token and property value. Save everything as a string using ConvertFromInvariantString
. Taking a hint from PBN, I used an integer for the token:
<ProtoMember(propIndex.Foo)> Property Foo As String
Enumeration helps to tie everything together later. Save them to Dictionary(Of T, NameValuePair)
2) add some accessors. they can perform type conversions for you:
Public Sub Add(ByVal Key As T, ByVal value As Object) If _col.ContainsKey(Key) Then _col.Remove(Key) End If _col.Add(Key, New TValue(value)) End Sub Public Function GetTItem(Of TT)(key As T) As TT If _col.ContainsKey(key) Then Return CType(_col(key).TValue, TT) Else Return Nothing End If End Function
T
is any type of key that you want to use. An integer produces the smallest result and still allows the subscription code to use Enum. But it could be a string.
TT
is the original type:
myFoo = props.GetTItem(Of Long)(propsEnum.Foo)
3) Open the internal list (dictionary) for PBN and bingo, everything is done.
It is also very easy to add converters for Point, Rectangle, Font, Size, Color and even bitmap.
NTN