Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What would you do?
Message
From
08/11/2008 08:24:34
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01359667
Message ID:
01360665
Views:
11
>>basically to cross from VFOX to .NET is not that hard, Vfox is way more easy to program and therefore
>>simple tasks as to write down in Vfox Code will be very easy to re-code in .net, I assure you .Net is the thing
>>right now, Im a visual Fox Lover but I cant resist the tenderness of .NET, go for it man!
>
>I didn't follow such threads, but your answer was the first after refresh and UT opened it automatically.
>Very easy? (the accent is on VERY)
>
>How I could code this VERY easy :-)
>
>*** OK this not, let's assume these came from some recordset
>CREATE CURSOR crsTest (Fld1 C(20)) 
>INSERT INTO crsTest VALUES ([SomeVar])
>*********
>somevar = 1234
>myVar   = crsTest.Fld1
>? &myVar
>
>
>and that is just a simple example :-)

The question is - do we need that ? - or - do we want that ?

One of the things that .net offers is type checking at compile time - which I find great to have
Using that type of construct puts you in a mine field - some day there's going to be an explosion

Whilst it IS possible to do some macro substition at run time I see two disadvantages
(1) It is sooooooooooooooo slooooooooooooooooowwwwwwwwwwwwwwwww
(2) The compiler cannot check whether what I do is valid or not


I had written a basic object.SetProperty('FieldName', FieldValue) - but I will try not to use it if I can avoid it
public static class ExtensionMethodsGeneric
 {
#region TrySetProperty
  const BindingFlags BindingFlagsProperty =
        BindingFlags.Instance
       | BindingFlags.Public
       | BindingFlags.NonPublic
       | BindingFlags.SetField;


  public static bool TrySetProperty«TOBJECT»(this TOBJECT parent, string name, object value)
  {
   FieldInfo fieldInfo = parent.GetType().GetField(name, BindingFlagsProperty);

   if (fieldInfo == null)
    return false;

   // set the value
   try
   {
    fieldInfo.SetValue((object) parent, value);
    return true ;
   }
   catch
   {
    return false;
   }
  }
  #endregion
  //-------------------------------------------------------------------------
}
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform