Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. public static Dictionary<string, string> CreateDictionary(Dictionary<string, string> data, string key)
  2. {
  3.     Dictionary<string, string> result = new Dictionary<string, string>();
  4.     if (data != null && (!key.IsNullOrWhiteSpace()))
  5.     {
  6.  
  7.         if (data.ContainsKey(key))
  8.         {
  9.             string value = data[key];
  10.             if (value.StartsWith("#"))
  11.             {
  12.                 string[] valueSplitted = value.Split(new char[] { ';' });
  13.                 if (valueSplitted.Length > 1)
  14.                 {
  15.                     string property = String.Empty;
  16.                     string dataArea = String.Empty;
  17.                     int positionFirstEqualSign = 0;
  18.                     for (int index = 1; index < valueSplitted.Length; index++)
  19.                     {
  20.                         positionFirstEqualSign = valueSplitted[index].IndexOf('=');
  21.                         if (positionFirstEqualSign > 0)
  22.                         {
  23.                             property = valueSplitted[index].Substring(0, positionFirstEqualSign);
  24.                             //falls sich im "Datenbereich" weitere '=' befinden
  25.                             dataArea = valueSplitted[index].Substring(positionFirstEqualSign + 1);
  26.                             result.Add(property, dataArea);
  27.                         }
  28.                     }
  29.                 }
  30.             }
  31.         }
  32.     }
  33.     return (result);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement