예제 #1
0
        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);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
        }