45 using System.Collections.Generic;
46 using System.Text.RegularExpressions;
47 using System.Windows.Forms;
110 string lvsReturn =
string.Empty;
112 Logger.Instance.LogFunctionStartDebug(
"OKW_Helper.Boolean2String",
"fpbTrueOrFalse", fpbTrueOrFalse.ToString());
127 Logger.Instance.LogFunctionEndDebug(lvsReturn);
184 string lvsReturn =
string.Empty;
185 List<string> lvLsSplitedSource = null;
194 Log.LogFunctionStartDebug(
"OKW_Helper.GetLeftFromDelimiterNumber",
"fpsSource", fpsSource,
"fpsDelimiter", fpsDelimiter,
"fpiCount", fpiCount.ToString());
196 if (fpsDelimiter !=
string.Empty)
198 lvLsSplitedSource =
StrSplit(fpsSource, fpsDelimiter);
201 RangeMax = lvLsSplitedSource.Count - 1;
205 if ((RangeMin <= fpiCount) & (fpiCount <= RangeMax))
208 lvsReturn = lvLsSplitedSource[0];
210 for (
int i = 1; i < fpiCount; i++)
212 lvsReturn = lvsReturn + fpsDelimiter + lvLsSplitedSource[i];
217 string lvsLM = LM.
GetMessage(
"GetLeftFromDelimiterNumber",
"OKWDelimiterCountOutOfRangeException", fpiCount.ToString(), RangeMax.ToString());
218 throw new System.IndexOutOfRangeException(lvsLM);
223 string lvsLM = LM.
GetMessage(
"GetLeftFromDelimiterNumber",
"OKWDelimiterIsEmptyException");
224 throw new System.ArgumentException(lvsLM);
233 Log.LogFunctionEndDebug(lvsReturn);
237 Log.LogFunctionEndDebug();
286 string lvsReturn =
string.Empty;
287 List<string> lvLsSplitedSource = null;
293 Log.LogFunctionStartDebug(
"OKW_Helper.GetLeftFromDelimiterNumber",
"fpsSource", fpsSource,
"fpsDelimiter", fpsDelimiter,
"fpiCount", fpiCount.ToString());
294 if (fpsDelimiter !=
string.Empty)
296 lvLsSplitedSource =
StrSplit(fpsSource, fpsDelimiter);
299 RangeMax = lvLsSplitedSource.Count - 1;
303 if ((RangeMin <= fpiCount) & (fpiCount <= RangeMax))
306 lvsReturn = lvLsSplitedSource[fpiCount];
308 for (
int i = fpiCount + 1; i < lvLsSplitedSource.Count; i++)
310 lvsReturn = lvsReturn + fpsDelimiter + lvLsSplitedSource[i];
315 string lvsLM = LM.
GetMessage(
"GetLeftFromDelimiterNumber",
"OKWDelimiterCountOutOfRangeException", fpiCount.ToString(), RangeMax.ToString());
316 throw new System.IndexOutOfRangeException(lvsLM);
321 string lvsLM = LM.
GetMessage(
"GetLeftFromDelimiterNumber",
"OKWDelimiterIsEmptyException");
322 throw new System.ArgumentException(lvsLM);
331 Log.LogFunctionEndDebug(lvsReturn);
335 Log.LogFunctionEndDebug();
363 bool lvbReturn =
true;
366 Logger.Instance.LogFunctionStartDebug(
"OKW_Helper.ListStringCompare",
"ListString1", ListString1.ToString(),
"ListString2", ListString2.ToString());
371 if (ListString1.Count == ListString2.Count)
373 for (
int i = 0; i < ListString1.Count; i++)
375 if (ListString1[i] != ListString2[i])
399 Logger.Instance.LogFunctionEndDebug(lvbReturn);
403 Logger.Instance.LogFunctionEndDebug();
449 public static string ListStringConcat(List<string> fps_ListString2Concat,
string fps_Separator)
451 string lvsReturn =
string.Empty;
454 Log.LogFunctionStartDebug(
"OKW_Helper.ListStringConcat",
"fps_ListString2Concat", fps_ListString2Concat.ToString(),
"fps_Separator", fps_Separator);
458 lvsReturn =
string.Join(fps_Separator, fps_ListString2Concat.ToArray());
465 Log.LogFunctionEndDebug(lvsReturn);
469 Log.LogFunctionEndDebug();
491 public static bool MatchStr(
string fpsPattern,
string fpsStringToMatch)
494 bool lvbReturn =
false;
500 Logger.Instance.LogFunctionStartDebug(
"OKW_Helper.MatchStr",
"String fpsPattern", fpsPattern,
"String fpsStringToMatch", fpsStringToMatch);
504 string pattern =
"^" + Regex.Escape(fpsPattern).Replace(
@"\*",
".*").Replace(
@"\?",
".") +
"$";
508 regex =
new Regex(pattern);
510 lvbReturn = regex.IsMatch(fpsStringToMatch);
517 Log.LogFunctionEndDebug(lvbReturn);
521 Log.LogFunctionEndDebug();
546 bool lvb_Return =
false;
552 Logger.Instance.LogFunctionStartDebug(
"OKW_Helper.MatchStrIgnoreCase",
"String fpsPattern", fpsPattern,
"String fpsStringToMatch", fpsStringToMatch);
556 string pattern =
"^" + Regex.Escape(fpsPattern).Replace(
@"\*",
".*").Replace(
@"\?",
".") +
"$";
560 regex =
new Regex(pattern, RegexOptions.IgnoreCase);
562 lvb_Return = regex.IsMatch(fpsStringToMatch);
569 Logger.Instance.LogFunctionEndDebug(lvb_Return);
573 Logger.Instance.LogFunctionEndDebug();
602 string lvs_Return = Regex.Replace(fps_StringinQuotations,
"^\"|\"$",
string.Empty);
625 Logger.Instance.LogFunctionStartDebug(
"OKW_Helper.StrArray2ListStr",
"fpsStringArray", fpsStringArray.ToString());
627 List<string> lvls_Splited =
new List<string>();
628 lvls_Splited.Clear();
632 lvls_Splited =
new List<string>(fpsStringArray);
636 Logger.Instance.LogFunctionEndDebug(lvls_Splited);
674 bool lvbReturn =
false;
677 string lvsTrueOrFalse = fpsTrueOrFalse.ToLower();
679 Logger.Instance.LogFunctionStartDebug(
"OKW_Helper.String2Boolean",
"fpsTrueOrFalse", fpsTrueOrFalse);
683 if ( lvsTrueOrFalse ==
"true")
688 else if ( lvsTrueOrFalse ==
"false" )
697 string lvsLM = LM.
GetMessage(
"String2Boolean",
"OKWNotAllowedValueException", fpsTrueOrFalse);
705 Log.LogFunctionEndDebug(lvbReturn);
709 Log.LogFunctionEndDebug();
737 public static List<string>
StrSplit(
string fpsString2Split,
string fpsSeparator)
741 string[] lvsA_Splited;
742 List<string> lvls_Splited =
new List<string>();
744 string[] lvsSeparators =
new string[] { fpsSeparator };
746 Log.LogFunctionStartDebug(
"OKW_Helper.StrSplit",
"fpsString2Split", fpsString2Split,
"fpsSeparator", fpsSeparator);
750 lvsA_Splited = fpsString2Split.Split(lvsSeparators, StringSplitOptions.None);
758 Log.LogFunctionEndDebug(lvls_Splited);
762 Log.LogFunctionEndDebug();
static Logger Log
Hält eine Referenz auf die Klasse Logger vor.
string GetMessage(string MethodName, string TextKey)
Holt die Log-Meldung für MethodeNmae/Textkey ohne weitere Parameter.
Klasse enthält OKW-Hilfsfunktionen.
static string GetLeftFromDelimiterNumber(string fpsSource, string fpsDelimiter, int fpiCount)
Der String wird am fpiCount-ten Trennzeichen abgetrennt und die linke Hälfte des String wird zurückge...
static string RemoveBeginEndQuotations(string fps_StringinQuotations)
Entfernt Anführungstriche " am Anfang und am Ende. Anführungstriche, die sich im String-Inneren befin...
static bool String2Boolean(string fpsTrueOrFalse)
Konvertiert string "true"/"false" nach bool.
static bool ListStringCompare(List< string > ListString1, List< string > ListString2)
Vergleicht zwei ListStrings inhaltlich miteinander.
static string GetRigthFromDelimiterNumber(string fpsSource, string fpsDelimiter, int fpiCount)
Schneidet fpsSource am fpiCount-ten fpsDelimiter ab und liefert den rechten Teil des string zurück...
static List< string > StrArray2ListStr(string[] fpsStringArray)
Konvertiert einen String-Array nach List-String.
LogMessenger liest Log-Meldungen sprachspezifisch für die im Konstruktor gegeben Klasse aus der Zugeh...
void LogPrintDebug(string fpsMessage)
Loggt eine Nachricht.
static string ListStringConcat(List< string > fps_ListString2Concat, string fps_Separator)
Wandelt List in einen string um und trennt die Werte durch das vorgegebene Trennzeichen vonei...
static LogMessenger LM
Hält eine Referenz auf die Klasse LogMessenger für die sprachabhängige Log-Ausgabe vor...
static string Boolean2String(bool fpbTrueOrFalse)
Konvertiert bool true/false nach string "true"/"false".
static List< string > StrSplit(string fpsString2Split, string fpsSeparator)
Splittet einen string am angegebenen Separator auf. Der Separator kann aus mehr als einem Zeichen bes...
static bool MatchStr(string fpsPattern, string fpsStringToMatch)
Quelle: http://stackoverflow.com/questions/6907720/need-to-perform-wildcard-etc-search-on-a-string-us...
static bool MatchStrIgnoreCase(string fpsPattern, string fpsStringToMatch)
Quelle: http://stackoverflow.com/questions/6907720/need-to-perform-wildcard-etc-search-on-a-string-us...