コード例 #1
0
        /// <summary>
        /// Indexer
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public object this[string key]
        {
            get
            {
                DataObject obj = this.FindRecursive(key);

                if (obj is null)
                {
                    throw new KeyNotFoundException();
                }

                return(obj.GetValue());
            }
            set
            {
                DataObject obj = this.FindRecursive(key);

                if (obj is null)
                {
                    throw new KeyNotFoundException();
                }

                obj.SetValue(value);
            }
        }
コード例 #2
0
        /// <summary>
        /// Takes in 2 <see cref="IDataContainer"/> returns new instance of <see cref="IDataContainer"/>
        /// which containes properties which are both in LHS and RHS, the values will be from LHS
        /// </summary>
        /// <param name="lhs"></param>
        /// <param name="rhs"></param>
        /// <returns>LHS ^ RHS</returns>
        public static IDataContainer Intersect(this IDataContainer lhs, IDataContainer rhs)
        {
            IDataContainer intersect = lhs is IPropertyContainer
                ? (IDataContainer) new PropertyContainer()
                : new DataContainer();

            intersect.Name = lhs.Name;

            var lhsKeys = lhs.GetKeys();
            var rhsKeys = rhs.GetKeys();

            var intersectKeys = lhsKeys.Intersect(rhsKeys);

            foreach (var key in intersectKeys)
            {
                DataObject first = lhs.Find(key);

                // in case of nested IDataContainer
                if (first.GetValue() is IDataContainer dc)
                {
                    var second = rhs.Find(first.Name).GetValue() as IDataContainer;

                    if (dc.IsIdentical(second) == false)
                    {
                        first.SetValue(dc.Intersect(second));
                    }
                }

                intersect.Add(first);
            }

            return(intersect);
        }
コード例 #3
0
 /// <summary>
 /// Implementation for <see cref="PropertyDescriptor.SetValue(object, object)"/>
 /// </summary>
 /// <param name="component"></param>
 /// <param name="value"></param>
 public override void SetValue(object component, object value)
 {
     DataObject.SetValue(value);
 }