SilverlightMappingToolBasic.UI.SuperGraph.View.SuperGraphControl.SerializeToJsonDictionary C# (CSharp) Method

SerializeToJsonDictionary() private method

Lightweight helper method to serialise a Dictionary into a JSON object to pass to a JavaScript function
private SerializeToJsonDictionary ( string>.IEnumerable dictionary, System.Guid domainId, System.Guid selectedNodeId ) : string
dictionary string>.IEnumerable
domainId System.Guid
selectedNodeId System.Guid
return string
        private string SerializeToJsonDictionary(IEnumerable<KeyValuePair<Guid, string>> dictionary, Guid domainId,
            Guid selectedNodeId)
        {
            var json = new StringBuilder("[");
            var count = 0;
            foreach (KeyValuePair<Guid, string> mapNode in dictionary)
            {
                count++;
                json.Append("{");
                json.Append(
                    string.Format("\"MapNodeId\":\"{0}\",\"Name\":\"{1}\",\"DomainId\":\"{2}\",\"NodeId\":\"{3}\"",
                        mapNode.Key, Uri.EscapeDataString(mapNode.Value), domainId, selectedNodeId));
                json.Append("}");
                if (count < dictionary.Count())
                {
                    json.Append(",");
                }
            }
            json.Append("]");
            return json.ToString();
        }
SuperGraphControl