Ejemplo n.º 1
0
        /// <summary>
        /// Memorywise copy the properties from src.
        /// </summary>
        /// <param name="src">Src object.</param>
        public void CopyPropertiesFrom(ViewDataBase src)
        {
            if (src.GetType() != GetType())
            {
                throw new Exception("data 1 and data 2 must be the same type");
            }

            PropertyInfo[] infos = src.GetType().GetProperties();
            foreach (PropertyInfo info in infos)
            {
                info.SetValue(
                    this, info.GetValue(src, null), null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewDataPropertyBinder"/> class.
        /// </summary>
        /// <param name="data1">Data 1.</param>
        /// <param name="data2">Data 2.</param>
        public ViewDataPropertyBinder(ViewDataBase data1, ViewDataBase data2)
        {
            if (data1.GetType() != data2.GetType())
            {
                throw new Exception("data 1 and data 2 must be the same type");
            }

            _dataType = data1.GetType();
            PropertyInfo[] infos = _dataType.GetProperties();
            foreach (PropertyInfo info in infos)
            {
                _properties.Add(info.Name, info);
            }

            _data1 = data1;
            _data2 = data2;
            data1.PropertyChanged += OnData1PropertyChanged;
            data2.PropertyChanged += OnData2PropertyChanged;
            ExcludedProperties = new Collection<string>();
        }