public static object ToType(this DataItem this_, YamlConfig conf) { Type type = this_.GetNodeType(); if (type != null) { return(conf.GetMappingObject(this_)); } if (!(this_ is Sequence)) { string textOrDefault = this_.GetTextOrDefault(""); type = StringTypeResolver.Resolve(textOrDefault); return(TConverter.ChangeType(type, textOrDefault)); } if (!typeof(Array).Equals(type) && !typeof(Array).IsSubclassOf(type) && !typeof(Object[]).Equals(type) && !typeof(Object[]).IsSubclassOf(type)) { Log.Warn(string.Format("[{0}] Cant parse Sequence to {1}", conf.GetURL(this_), type.Name), new object[0]); return(null); } List <object> list = new List <object>(); foreach (DataItem this_2 in (this_ as Sequence).Enties) { list.Add(this_2.ToType(conf)); } return(list.ToArray()); }
public bool Get <T>(string key, out T val) { val = default(T); DataItem item = this.Get(key); if (item == null) { return(false); } try { if (typeof(T).IsIMappingObject()) { val = (T)this._config.GetMappingObject(item); } else if (item is Scalar) { val = TConverter.ChangeType <T>((item as Scalar).Text); } return(val != null); } catch (Exception ex) { Log.Exception("Error while loading an IMappingObject", ex); } return(false); }