>>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