示例#1
0
        public virtual void SetValue(IXmlCursor cursor, IDictionaryAdapter parentObject, XmlReferenceManager references,
                                     bool hasCurrent, object oldValue, ref object newValue)
        {
            var hasValue    = null != newValue;
            var isNillable  = this.IsNillable;
            var isReference = this.IsReference;

            var clrType = hasValue
                                ? newValue.GetComponentType()
                                : this.clrType;

            if (hasValue || isNillable)
            {
                if (hasCurrent)
                {
                    Coerce(cursor, clrType, !hasValue && cursor.IsAttribute);                     // TODO: Refactor. (NB: && isNillable is emplied)
                }
                else
                {
                    cursor.Create(clrType);
                }
            }
            else if (!hasCurrent)
            {
                // No node exists + no value to assign + and not nillable = no work to do
                return;
            }

            object token = null;

            if (isReference)
            {
                if (!references.OnAssigningValue(cursor, oldValue, ref newValue, out token))
                {
                    return;
                }
            }

            var givenValue = newValue;

            if (hasValue)
            {
                serializer.SetValue(cursor, parentObject, this, oldValue, ref newValue);
            }
            else if (isNillable)
            {
                cursor.IsNil = true;
            }
            else
            {
                cursor.Remove(); cursor.RemoveAllNext();
            }

            if (isReference)
            {
                references.OnAssignedValue(cursor, givenValue, newValue, token);
            }
        }
示例#2
0
        public void Clear()
        {
            foreach (var item in items)
            {
                OnRemoving(item);
            }

            cursor.Reset();
            cursor.RemoveAllNext();
            items.Clear();
            // Don't call OnRemoved. Caller is already going to fire a Reset shortly.
        }
示例#3
0
        public virtual void Clear()
        {
            EndNew(addedIndex);

            foreach (var item in items)
            {
                DetachPropertyChanged(item.Value);
                if (accessor.IsReference)
                {
                    references.OnAssigningNull(item.Node, item.Value);
                }
            }

            cursor.Reset();
            cursor.RemoveAllNext();
            items.Clear();

            NotifyListReset();
        }
示例#4
0
		public virtual void SetValue(IXmlCursor cursor, IDictionaryAdapter parentObject, XmlReferenceManager references,
			bool hasCurrent, object oldValue, ref object newValue)
		{
			var hasValue    = null != newValue;
			var isNillable  = this.IsNillable;
			var isReference = this.IsReference;

			var clrType = hasValue
				? newValue.GetComponentType()
				: this.clrType;

			if (hasValue || isNillable)
			{
				if (hasCurrent)
					Coerce(cursor, clrType, !hasValue && cursor.IsAttribute); // TODO: Refactor. (NB: && isNillable is emplied)
				else
					cursor.Create(clrType);
			}
			else if (!hasCurrent)
			{
				// No node exists + no value to assign + and not nillable = no work to do
				return;
			}

			object token = null;
			if (isReference)
				if (!references.OnAssigningValue(cursor, oldValue, ref newValue, out token))
					return;

			var givenValue = newValue;

			if (hasValue)
				serializer.SetValue(cursor, parentObject, this, oldValue, ref newValue);
			else if (isNillable)
				cursor.IsNil = true;
			else
				{ cursor.Remove(); cursor.RemoveAllNext(); }

			if (isReference)
				references.OnAssignedValue(cursor, givenValue, newValue, token);
		}