public static IBObject GetInstance(IDictionary <String, String> attributes) { IBObject obj; switch (attributes["class"]) { case "NSArray": case "NSMutableArray": obj = new IBArray(attributes); break; case "NSDictionary": case "NSMutableDictionary": obj = new IBDictionary(attributes); break; case "IBClassDescriber": obj = new IBClassDescriber(attributes); break; case "IBPartialClassDescription": obj = new IBPartialClassDescription(attributes); break; case "NSSet": case "NSMutableSet": obj = new IBSet(attributes); break; default: obj = new IBObject(attributes); break; } return(obj); }
public static IBObject GetInstance(IDictionary<String, String> attributes) { IBObject obj; switch (attributes["class"]) { case "NSArray": case "NSMutableArray": obj = new IBArray(attributes); break; case "NSDictionary": case "NSMutableDictionary": obj = new IBDictionary(attributes); break; case "IBClassDescriber": obj = new IBClassDescriber(attributes); break; case "IBPartialClassDescription": obj = new IBPartialClassDescription(attributes); break; case "NSSet": case "NSMutableSet": obj = new IBSet(attributes); break; default: obj = new IBObject(attributes); break; } return obj; }
public override void Finish(IIBReferenceResolver resolver) { base.Finish(resolver); if (this.usesXmlCoder) { IIBItem item1 = this.Find <IIBItem>("dict.sortedKeys"); IBArray keys = this.DereferenceItem(resolver, item1) as IBArray; IIBItem item2 = this.Find <IIBItem>("dict.values"); IBArray values = this.DereferenceItem(resolver, item2) as IBArray; if (keys != null && values != null) { for (int i = 0; i < keys.Count; i++) { IBString key = keys[i] as IBString; IIBItem value = values[i]; if (key != null) { this.Add(key.ToString(), value); } } } else { throw new Exception("It seems that the parsing has really gone wrong. Can't find either keys or values..."); } } else if (this.Value.Count > 0) { bool useKeyValuePair; // Probe for the keys used. IIBItem item = this[0]; useKeyValuePair = item.Key.StartsWith("NS.key."); if (useKeyValuePair) { for (int i = 0; i < this.Value.Count;) { IIBItem keyItem = this[i++]; IIBItem valueItem = this[i++]; this.Add(keyItem.ToString(), valueItem); } } else { for (int i = 0; i < this.Value.Count; i++) { item = this[i]; this.Add(item.Key, item); } } } }