protected String GetPropertyValue(String property) { PropertyInfo pinfo; MoSyncWidgetPropertyAttribute pattr = GetPropertyAttribute(property, out pinfo); if (pinfo == null || pinfo.CanRead == false) { throw new InvalidPropertyNameException(); } String ret = ""; if (pattr.ShouldExecuteOnMainThread) { MoSync.Util.RunActionOnMainThreadSync(() => { ret = GetProperty(pinfo); }); } else { ret = GetProperty(pinfo); } return(ret); }
public void SetProperty(String property, String stringValue) { PropertyInfo pinfo; MoSyncWidgetPropertyAttribute pattr = GetPropertyAttribute(property, out pinfo); if (pinfo == null) { throw new InvalidPropertyNameException(); } if (pattr.ShouldExecuteOnMainThread) { MoSync.Util.RunActionOnMainThreadSync(() => { SetProperty(pinfo, stringValue); }); } else { SetProperty(pinfo, stringValue); } }
public void SetProperty(String property, String stringValue) { PropertyInfo pinfo; MoSyncWidgetPropertyAttribute pattr = GetPropertyAttribute(property, out pinfo); Exception exception = null; IWidget i = this; if (pinfo == null) { throw new InvalidPropertyNameException(); } if (pattr.ShouldExecuteOnMainThread) { MoSync.Util.RunActionOnMainThread(() => { try { SetProperty(pinfo, stringValue); } catch (Exception e) { exception = e; } }, false); if (null != exception) { if (exception.InnerException is InvalidPropertyValueException) { throw new InvalidPropertyValueException(); } } } else { SetProperty(pinfo, stringValue); } }
protected MoSyncWidgetPropertyAttribute GetPropertyAttribute(String name, out PropertyInfo propertyInfoOut) { Type type = this.GetType(); propertyInfoOut = null; foreach (PropertyInfo pinfo in type.GetProperties()) { foreach (Attribute attr in pinfo.GetCustomAttributes(false)) { if (attr.GetType() == typeof(MoSyncWidgetPropertyAttribute)) { MoSyncWidgetPropertyAttribute e = (MoSyncWidgetPropertyAttribute)attr; if (e.Name.ToLower().Equals(name.ToLower())) { propertyInfoOut = pinfo; return(e); } } } } return(null); }