Click here to Skip to main content
15,891,529 members
Home / Discussions / C#
   

C#

 
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 
QuestionLaunch my program when pressing <ctrl 1=""></ctrl> Pin
anderslundsgard8-Aug-08 1:44
anderslundsgard8-Aug-08 1:44 
AnswerRe: Launch my program when pressing Pin
J a a n s8-Aug-08 2:57
professionalJ a a n s8-Aug-08 2:57 
GeneralRe: Launch my program when pressing Pin
anderslundsgard8-Aug-08 3:25
anderslundsgard8-Aug-08 3:25 
AnswerRe: Launch my program when pressing Pin
Guffa8-Aug-08 3:41
Guffa8-Aug-08 3:41 
GeneralRe: Launch my program when pressing Pin
anderslundsgard8-Aug-08 20:21
anderslundsgard8-Aug-08 20:21 
QuestionPowerpoint Automation with COM Object Lib. Pin
selcuks8-Aug-08 1:27
selcuks8-Aug-08 1:27 
QuestionImage Processing In C# Pin
krinaljariwala8-Aug-08 1:27
krinaljariwala8-Aug-08 1:27 
AnswerRe: Image Processing In C# Pin
astanton19788-Aug-08 6:50
astanton19788-Aug-08 6:50 
AnswerRe: Image Processing In C# Pin
Alan Balkany8-Aug-08 7:50
Alan Balkany8-Aug-08 7:50 
Questionhyperthreading Pin
arkiboys8-Aug-08 1:13
arkiboys8-Aug-08 1:13 
AnswerRe: hyperthreading Pin
leppie8-Aug-08 2:22
leppie8-Aug-08 2:22 
AnswerRe: hyperthreading Pin
Mark Salsbery8-Aug-08 9:39
Mark Salsbery8-Aug-08 9:39 

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.