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); } }
private void Coerce(IXmlCursor cursor, Type clrType, bool replace) { if (replace) { cursor.Remove(); cursor.MoveNext(); cursor.Create(ClrType); } else { cursor.Coerce(clrType); } }
private void Coerce(IXmlCursor cursor, Type clrType, bool replace) { if (replace) { cursor.Remove(); cursor.MoveNext(); cursor.Create(ClrType); } else cursor.Coerce(clrType); }
private bool RollbackInsert() { cursor.Remove(); return(false); }
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); }