Exemplo n.º 1
0
 /// <summary>
 /// Override this method to assign the de-serialized value using MemberInfo.SetValue().
 /// For collections/enumerables, we do not assign the value using SetValue(), because the
 /// items were assigned to the member value directly durning transformation in inherited
 /// method TransformValue.
 /// </summary>
 protected override void AssignValue(object target, object value)
 {
     if ((m_TargetType is LogicalCollection || m_TargetType is LogicalEnumerable) &&
         !m_TargetType.Type.GetTypeInfo().IsValueType)
     {
         return;
     }
     SerializationHelper.SetValue(target, m_member, value);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Override this method to return the target's enumerable object member.
        /// </summary>
        protected override object GetTargetEnumerable(object target)
        {
            object enumerable = SerializationHelper.GetValue(target, m_member);

            if (enumerable == null && m_CanWrite)
            {
                SerializationHelper.SetValue(target, m_member, SerializationHelper.CreateInstance(((LogicalEnumerable)m_TargetType).Type));
                enumerable = SerializationHelper.GetValue(target, m_member);
            }

            return(enumerable);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Override this method to return the target's collection object member.
        /// </summary>
        protected override object GetTargetCollection(object target)
        {
            object collection = SerializationHelper.GetValue(target, m_member);

            if (collection == null && m_CanWrite)
            {
                SerializationHelper.SetValue(target, m_member, SerializationHelper.CreateInstance(((LogicalCollection)m_TargetType).Type));
                collection = SerializationHelper.GetValue(target, m_member);
            }

            return(collection);
        }