Click here to Skip to main content
15,917,539 members
Home / Discussions / C#
   

C#

 
GeneralRe: c# port forwarding Pin
Harvey Saayman8-Aug-08 20:22
Harvey Saayman8-Aug-08 20:22 
GeneralRe: c# port forwarding Pin
VrIgHtEr8-Aug-08 21:03
VrIgHtEr8-Aug-08 21:03 
GeneralRe: c# port forwarding Pin
Harvey Saayman8-Aug-08 21:07
Harvey Saayman8-Aug-08 21:07 
GeneralRe: c# port forwarding Pin
VrIgHtEr8-Aug-08 23:10
VrIgHtEr8-Aug-08 23:10 
QuestionRe: c# port forwarding Pin
led mike8-Aug-08 4:21
led mike8-Aug-08 4:21 
QuestionContext Menus and Buttons Pin
kildareflare8-Aug-08 3:25
kildareflare8-Aug-08 3:25 
AnswerRe: Context Menus and Buttons Pin
Gareth H8-Aug-08 4:44
Gareth H8-Aug-08 4:44 
QuestionC# Pin
mphumeleli8-Aug-08 3:04
mphumeleli8-Aug-08 3:04 
AnswerRe: C# Pin
Manas Bhardwaj8-Aug-08 3:06
professionalManas Bhardwaj8-Aug-08 3:06 
AnswerRe: C# Pin
Colin Angus Mackay8-Aug-08 3:49
Colin Angus Mackay8-Aug-08 3:49 
RantRe: C# Pin
Paul Conrad8-Aug-08 8:31
professionalPaul Conrad8-Aug-08 8:31 
QuestionBest way to display 16x16 text Pin
Blubbo8-Aug-08 3:02
Blubbo8-Aug-08 3:02 
AnswerRe: Best way to display 16x16 text Pin
Manas Bhardwaj8-Aug-08 3:05
professionalManas Bhardwaj8-Aug-08 3:05 
QuestionApplication.Exit problem?? Pin
Tridip Bhattacharjee8-Aug-08 2:29
professionalTridip Bhattacharjee8-Aug-08 2:29 
AnswerRe: Application.Exit problem?? Pin
teejayem8-Aug-08 2:32
teejayem8-Aug-08 2:32 
AnswerRe: Application.Exit problem?? Pin
Manas Bhardwaj8-Aug-08 2:37
professionalManas Bhardwaj8-Aug-08 2:37 
QuestionHow to Get HardWare Information from CPU like Temparature,Voltage,FanSpeed. code in .Net Pin
madhu5218-Aug-08 2:06
madhu5218-Aug-08 2:06 
AnswerRe: How to Get HardWare Information from CPU like Temparature,Voltage,FanSpeed. code in .Net Pin
leppie8-Aug-08 2:21
leppie8-Aug-08 2:21 
AnswerRe: How to Get HardWare Information from CPU like Temparature,Voltage,FanSpeed. code in .Net Pin
Mark Salsbery8-Aug-08 9:35
Mark Salsbery8-Aug-08 9:35 
QuestionGetting the names of members without using strings Pin
Nicholas Butler8-Aug-08 1:57
sitebuilderNicholas Butler8-Aug-08 1:57 
I'm continuing my quest to get rid of magic strings to identify members. This is so the compiler can check more deeply and to avoid problems with obfuscators.

I've come up with this, but it seems more like a kludge than a hack. Has anyone got any bright ideas?

Thanks

Nick

class TestFirstClassMembers
{
  static readonly Module sModule = Assembly.GetExecutingAssembly().GetModules()[ 0 ];
 
  internal static void Test()
  {
    Trace.WriteLine( "\n\nTestFirstClassMembers" );

    var mi = new Member( ( Func<Class, int> ) ( o => o.Field ) );
    var ml = new Member( ( Func<Class, long> ) ( o => o.FieldLong ) );
    var ms = new Member( ( Func<Class, String> ) ( o => o.FieldString ) );
    var mp = new Member( ( Func<Class, int> ) ( o => o.Property ) );
    var mf = new Member( ( Func<Class, int> ) ( o => o.Function() ) );
    var mm = new Member( ( Action<Class, int, string> ) ( ( o, i, s ) => o.Method( i, s ) ) );
  }
 
  class Class
  {
    public int Field = 0;
    public long FieldLong = 0;
    public String FieldString = String.Empty;
    public int Property { get; set; }
    public int Function() { return 0; }
    public void Method( int i, string s ) { }
  }
 
  class Member
  {
    public Member( Delegate d )
    {
      MethodBody body = d.Method.GetMethodBody();
      byte[] il = body.GetILAsByteArray();
      for ( int i = 0 ; i < il.Length ; i++ )
      {
        switch ( il[ i ] )
        {
          case 0x6F: // callvirt
          case 0x7B: // ldfld
          {
            int token = BitConverter.ToInt32( il, i + 1 );
            var m = sModule.ResolveMember( token );
            Trace.WriteLine( m.ToString() + ": " + m.Name + " " + m.GetType().ToString() );
          }
          break;
        }
      }
    }
  }
}


----------------------------------
Be excellent to each other Smile | :)

AnswerRe: Getting the names of members without using strings Pin
leppie8-Aug-08 2:19
leppie8-Aug-08 2:19 
GeneralRe: Getting the names of members without using strings Pin
Nicholas Butler8-Aug-08 2:32
sitebuilderNicholas Butler8-Aug-08 2:32 
GeneralRe: Getting the names of members without using strings Pin
leppie8-Aug-08 2:41
leppie8-Aug-08 2:41 
GeneralRe: Getting the names of members without using strings Pin
Nicholas Butler8-Aug-08 2:50
sitebuilderNicholas Butler8-Aug-08 2:50 
GeneralRe: Getting the names of members without using strings Pin
leppie8-Aug-08 3:36
leppie8-Aug-08 3:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.