Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP Toolkit for .NET
Message
De
16/10/2009 09:12:30
 
 
À
16/10/2009 09:06:21
John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Database:
Visual FoxPro
Divers
Thread ID:
01428975
Message ID:
01429618
Vues:
109
>>>Has anyone actually used this function toolkit in a .NET app? Did this library ever catch on in the .Net world?
>>>
>>>http://foxcentral.net/microsoft/VFPToolkitNET.htm
>>>
>>>I'm just wondering if it is a good idea to use something like this in .Net, or if there are other more commonly used libraries to add string handling functionality to .Net apps.
>>>
>>>Would other devs see this as some weakness to hang on to a bunch of VFP methods, or would it be some great tool that even non-VFP'ers would use.
>>
>>Matt
>>
>>Replying to your original post since this thread has changed its tack as usual to something different.
>>
>>While the toolkit was introduced to get people to learn .NET, there are certain functions you may be used to in VFP which are oneliners which you would have to re write in .Net. (or at least this was the situation with VS2005)
>>
>>For instance while the string functions in .NET are numerous and powerful, I was unable to find one that I could use as a substitute for the powerful VFP STREXTRACT(), without writing my own.
>>
>>So I used the toolkit instead and called its STREXTRACT() and it worked fine. For me that was just one line of code as opposed to many more.
>>
>>The toolkit help file shows the VB and C# code that is used to create these functions. So as you can see this is what I would have had to write myself to get the similar functionality:
>>
>>
>>[C#]
>>public static string StrExtract(string cSearchExpression, string cBeginDelim, string cEndDelim, int nBeginOccurence, int nFlags)
>>{	
>>	string cstring = cSearchExpression;	
>>	string cb = cBeginDelim;	
>>	string ce = cEndDelim;	
>>	string lcRetVal = "";	
>>
>>	//Check for case-sensitive or insensitive search	
>>	if (nFlags == 1)	
>>	{		
>>		cstring = cstring.ToLower();		
>>		cb = cb.ToLower();		
>>		ce = ce.ToLower();	
>>	}	
>>	//Lookup the position in the string	
>>    int nbpos = At(cb, cstring, nBeginOccurence) + cb.Length - 1;
>>	int nepos = cstring.IndexOf(ce, nbpos + 1);
>>	//Extract the part of the strign if we get it right	if (nepos > nbpos)	
>>	{
>>		lcRetVal = cSearchExpression.Substring(nbpos , nepos - nbpos);
>>	}	
>>	return lcRetVal;
>>}
>>public static string StrExtract(string cSearchExpression, string cBeginDelim)
>>{
>>	int nbpos = At(cBeginDelim, cSearchExpression);
>>	return cSearchExpression.Substring(nbpos + cBeginDelim.Length - 1);
>>}
>>
>>public static string StrExtract(string cSearchExpression, string cBeginDelim, string cEndDelim)
>>{	
>>	return StrExtract(cSearchExpression, cBeginDelim, cEndDelim, 1, 0);
>>}
>>
>>public static string StrExtract(string cSearchExpression, string cBeginDelim, string cEndDelim, int nBeginOccurence)
>>{	
>>	return StrExtract(cSearchExpression, cBeginDelim, cEndDelim, nBeginOccurence, 0);
>>
>>
>>I don't know whether they have added any functions since VS2005 into .NET but for me I had a job to do not spend my time working out all the extra code. So I used the toolkit. So if you find you are having to resort to typing in multiple lines of code and build your own missing functions, then why not use the pre built functions already in the toolkit. This function alone is a ratio of 30 lines to 0.
>>
>>After all most .Net developers use other people's code and components anyway. Why re invent the wheel under the guise of learning? Of course with the time you have saved using the toolkit, you could research more and learn more or even read the help file and see how the function is written.
>>
>>Bernard
>
>
>
>I wouldn't use the command STREXTRACT in a .Net program. I would take that functionality and put it in an extension method so I'd call my string:
>
>string.Extract(.....)....
>
>It would then be part of the string class and available everywhere without using foreign commands to c#...

That is what we have done. We have an extensions class that has numerous methods that extend the string class.

There is a nice little and simple example at c-sharpcorner for this to get them started:
http://www.c-sharpcorner.com/UploadFile/mgold/ExtendingStringClass03162008132109PM/ExtendingStringClass.aspx
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform