예제 #1
0
        /// <summary>
        /// Converts a collection into a ListAtom
        /// </summary>
        public static ListAtom ToAtom(this ICollection list)
        {
            Validation.IsNotNull(list, "list");

            var atom = new ListAtom();

            list.Cast <object>().Where(value => value != null).ToList().ForEach(value =>
            {
                if (value is int)
                {
                    atom.Add(((int)value).ToAtom <IntAtom>());
                }
                else if (value is long || value is double || value is float)
                {
                    atom.Add(((long)value).ToAtom <RealAtom>());
                }
                else if (value is bool)
                {
                    atom.Add(((bool)value).ToAtom <BoolAtom>());
                }
                else
                {
                    var s = value as string;
                    if (s != null)
                    {
                        atom.Add(ToAtom <StringAtom>(s));
                    }
                    else
                    {
                        atom.Add(value.ToDictionaryAtom());
                    }
                }
            });

            return(atom);
        }
예제 #2
0
 /// <summary>
 /// SEts a list atom value
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public void Set(string key, ListAtom value)
 {
     _map.AddOrUpdate(new StringAtom(key), value, (k, o) => value);
 }
예제 #3
0
 /// <summary>
 /// Adds a list atom to the list
 /// </summary>
 /// <param name="value"></param>
 public void Add(ListAtom value)
 {
     Add((Atom)value);
 }