47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Consulenza.WebTemplateModeler.Entity
|
|
{
|
|
public class Option
|
|
{
|
|
|
|
public string Key { get; set; }
|
|
public string Value { get; set; }
|
|
|
|
|
|
public static List<Option> Format(string dato)
|
|
{
|
|
List<Option> opz = new List<Option>();
|
|
dato = dato.Trim();
|
|
if (!dato.Equals(""))
|
|
{
|
|
foreach (string o in dato.Split('&'))
|
|
{
|
|
if (!o.Equals(""))
|
|
{
|
|
string[] oo = o.Split('=');
|
|
Option option = new Option();
|
|
if (!oo[0].Equals("")) option.Key = oo[0];
|
|
if (oo.Length > 1 && !oo[1].Equals("")) option.Value = oo[1];
|
|
opz.Add(option);
|
|
}
|
|
}
|
|
}
|
|
return opz;
|
|
}
|
|
public static string Format(List<Option> opz)
|
|
{
|
|
string risp = "";
|
|
foreach (Option o in opz)
|
|
{
|
|
risp += "&" + o.Key + (!o.Value.Equals("") ? "=" + o.Value : "");
|
|
|
|
}
|
|
return risp;
|
|
}
|
|
}
|
|
}
|