コード例 #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
ファイル: MoSyncNativeUI.cs プロジェクト: ghuman/MoSync
        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);
        }