Ejemplo n.º 1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public BindingData(Binding binding)
        {
            Binding = binding;

            this.targetPropertyObject = MethodUtil.GetPropertyObject(
                Binding.BindableTarget.GetType(), Binding.BindingPropertyName);
            if (this.targetPropertyObject == null)
            {
                throw new ArgumentException(
                          Binding.BindingPropertyName + ": 指定のプロパティが存在しません。");
            }

            this.sourcePropertyObject = MethodUtil.GetPropertyObject(
                Binding.DataSource.GetType(), Binding.DataSourcePropertyName);
            if (this.sourcePropertyObject == null)
            {
                throw new ArgumentException(
                          Binding.DataSourcePropertyName + ": 指定のプロパティが存在しません。");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// プロパティ値の取得・設定用オブジェクトを取得します。
        /// </summary>
        private IPropertyObject GetPropertyObject(object target)
        {
            var pobj = MethodUtil.GetPropertyObject(
                target.GetType(), TargetProperty);

            if (pobj == null)
            {
                throw new InvalidOperationException(
                          string.Format(
                              "{0}.{1}: プロパティ名が正しくありません。",
                              target.GetType(), TargetProperty));
            }

            if (!pobj.PropertyType.Equals(TargetPropertyType))
            {
                throw new InvalidOperationException(
                          string.Format(
                              "{0}.{1}: プロパティの型が正しくありません。",
                              target.GetType(), TargetProperty));
            }

            if (!pobj.CanRead)
            {
                throw new InvalidOperationException(
                          string.Format(
                              "{0}.{1}: このプロパティは読み込みできません。",
                              target.GetType(), TargetProperty));
            }

            if (!pobj.CanWrite)
            {
                throw new InvalidOperationException(
                          string.Format(
                              "{0}.{1}: このプロパティには書き込みできません。",
                              target.GetType(), TargetProperty));
            }

            return(pobj);
        }