AddProperty() public method

增加一个属性,类型为string
public AddProperty ( string name ) : void
name string 属性名
return void
示例#1
0
        /// <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);
        }
示例#2
0
 /// <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);
 }