/// <summary> /// 开始到后台加载类型信息 /// </summary> public void Load() { Uri uri = new Uri(WebClientInfo.BaseAddress + Path); WebClient client = new WebClient(); client.OpenReadCompleted += (o, a) => { if (a.Error == null) { JsonObject types = JsonValue.Load(a.Result) as JsonObject; //设置所有动态类型的属性 foreach (string type in types.Keys) { CustomType cType = new CustomType(typeof(GeneralObject)); JsonObject attrs = (JsonObject)types[type]; foreach (string attr in attrs.Keys) { string attrType = attrs[attr]; cType.AddProperty(attr, attrType.ToType()); } //把类型放到类型表中 _types[type] = cType; } State = State.Loaded; } else { State = State.LoadError; Error = a.Error.GetMessage(); } IsBusy = false; //通知加载完成 OnCompleted(a); OnDataLoaded(a); }; IsBusy = true; OnLoading(); State = State.StartLoad; client.OpenReadAsync(uri); }