|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Signum.Utilities;
namespace Signum.Web
{
public class JsOptionsBuilder : JsRenderer, IEnumerable<KeyValuePair<string, string>>
{
bool big;
Dictionary<string, string> dic = new Dictionary<string, string>();
public JsOptionsBuilder(bool big)
{
this.big = big;
Renderer = () => "{{{0}}}".Formato(this.dic.ToString(kvp => "{0}: {1}".Formato(kvp.Key, kvp.Value), big ? ",\r\n" : ", "));
}
public void Add(string key, string value)
{
if (value == null)
return;
dic[key] = value;
}
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
return dic.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return dic.GetEnumerator();
}
public override string ToString()
{
return ToJS();
}
public string this[string key]
{
get { return dic.TryGetC(key); }
set
{
if (dic == null)
dic.Remove(key);
else
dic[key] = value;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm Computer Scientist, one of the founders of Signum Software, and the lead developer behind Signum Framework.
www.signumframework.com
I love programming in C#, Linq, Compilers, Algorithms, Functional Programming, Computer Graphics, Maths...