Beispiel #1
0
        private static NSObject ParseObject(XMLElement n)
        {
			String type = n.GetName();
			if (type.Equals("dict",StringComparison.InvariantCultureIgnoreCase)) {
				NSDictionary dict = new NSDictionary();
				List<XMLElement> children = n.List();
				for (int i = 0; i < children.Count; i += 2) {
                    XMLElement key = (XMLElement)children[i + 0];
					XMLElement val = (XMLElement) children[i + 1];
					dict.Put(key.GetContents(), ParseObject(val));
				}
				return dict;
			} else if (type.Equals("array",StringComparison.InvariantCultureIgnoreCase)) {
				List<XMLElement> children = n.List();
				NSArray array = new NSArray(children.Count);
				for (int i = 0; i < children.Count; i++) {
					array.SetValue(i, ParseObject((XMLElement) children[i]));
				}
				return array;
			} else if (type.Equals("true",StringComparison.InvariantCultureIgnoreCase)
					|| type.Equals("yes",StringComparison.InvariantCultureIgnoreCase)) {
				return new NSNumber(true);
			} else if (type.Equals("false",StringComparison.InvariantCultureIgnoreCase)
					|| type.Equals("no",StringComparison.InvariantCultureIgnoreCase)) {
				return new NSNumber(false);
			} else if (type.Equals("integer",StringComparison.InvariantCultureIgnoreCase)) {
				return new NSNumber(n.GetContents());
			} else if (type.Equals("real",StringComparison.InvariantCultureIgnoreCase)) {
				return new NSNumber(n.GetContents());
			} else if (type.Equals("string",StringComparison.InvariantCultureIgnoreCase)) {
				return new NSString(n.GetContents());
			} else if (type.Equals("data",StringComparison.InvariantCultureIgnoreCase)) {
				return new NSData(n.GetContents());
			} else if (type.Equals("range",StringComparison.InvariantCultureIgnoreCase)) {
				List<XMLElement> children = n.List();
				if (children.Count == 2) {
					XMLElement key = (XMLElement) children[0];
					XMLElement val = (XMLElement) children[1];
					return new NSRange(Int32.Parse(key.GetContents()),
							Int32.Parse(val.GetContents()));
				}
			}
			return null;
		}
Beispiel #2
0
		public static NSArray ArrayWithArray(NSArray array) {
			return new NSArray(array);
		}
Beispiel #3
0
		public NSArray(NSArray array) {
			this._list = (ArrayList) this._list.Clone();
		}
Beispiel #4
0
 public void AddObjectsFromArray(NSArray a)
 {
     _list.AddAll(a._list);
 }
Beispiel #5
0
        private static NSObject ParseObject(XMLElement n)
        {
            String type = n.GetName();

            if (type.Equals("dict", StringComparison.InvariantCultureIgnoreCase))
            {
                NSDictionary      dict     = new NSDictionary();
                List <XMLElement> children = n.List();
                for (int i = 0; i < children.Count; i += 2)
                {
                    XMLElement key = (XMLElement)children[i + 0];
                    XMLElement val = (XMLElement)children[i + 1];
                    dict.Put(key.GetContents(), ParseObject(val));
                }
                return(dict);
            }
            else if (type.Equals("array", StringComparison.InvariantCultureIgnoreCase))
            {
                List <XMLElement> children = n.List();
                NSArray           array    = new NSArray(children.Count);
                for (int i = 0; i < children.Count; i++)
                {
                    array.SetValue(i, ParseObject((XMLElement)children[i]));
                }
                return(array);
            }
            else if (type.Equals("true", StringComparison.InvariantCultureIgnoreCase) ||
                     type.Equals("yes", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSNumber(true));
            }
            else if (type.Equals("false", StringComparison.InvariantCultureIgnoreCase) ||
                     type.Equals("no", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSNumber(false));
            }
            else if (type.Equals("integer", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSNumber(n.GetContents()));
            }
            else if (type.Equals("real", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSNumber(n.GetContents()));
            }
            else if (type.Equals("string", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSString(n.GetContents()));
            }
            else if (type.Equals("data", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new NSData(n.GetContents()));
            }
            else if (type.Equals("range", StringComparison.InvariantCultureIgnoreCase))
            {
                List <XMLElement> children = n.List();
                if (children.Count == 2)
                {
                    XMLElement key = (XMLElement)children[0];
                    XMLElement val = (XMLElement)children[1];
                    return(new NSRange(Int32.Parse(key.GetContents()),
                                       Int32.Parse(val.GetContents())));
                }
            }
            return(null);
        }
Beispiel #6
0
 public NSMutableArray(NSArray array)
 {
     this._list = array._list;
 }
Beispiel #7
0
 public new static NSMutableArray ArrayWithArray(NSArray array)
 {
     return new NSMutableArray(array);
 }
Beispiel #8
0
 public void AddObjectsFromArray(NSArray a)
 {
     _list.AddAll(a._list);
 }
Beispiel #9
0
 public NSMutableArray(NSArray array)
 {
     this._list = array._list;
 }
Beispiel #10
0
 public new static NSMutableArray ArrayWithArray(NSArray array)
 {
     return(new NSMutableArray(array));
 }