internal bool Read(IXReadOperation reader, XElement element, out T result, XObjectArgs args) { T compResult = default; if (ForEachComponent(x => x.Read(reader, element, out compResult, args))) { result = compResult; return(true); } result = compResult; return(false); }
internal bool Write <T>(IXWriteOperation writer, T obj, XAttribute attribute, XObjectArgs args) => OnWrite(writer, obj, attribute, args);
internal bool Write <T>(IXWriteOperation writer, T obj, XElement element, XObjectArgs args) => OnWrite(writer, obj, element, args);
/// <summary> /// Called when an <see cref="XAttribute"/> has been created with the intention of writing an <see cref="object"/> /// to it, but before any XML has been added by <see cref="XTypeComponent{T}"/>s. /// </summary> /// <param name="writer">An <see cref="IXWriteOperation"/> instance that exposes methods for writing XML /// using the active <see cref="XWriter"/>.</param> /// <param name="obj">The object to be written.</param> /// <param name="attribute">The <see cref="XAttribute"/> to which <paramref name="obj"/> is being written. The /// attribute will already have been assigned the correct <see cref="XName"/>.</param> /// <param name="args">Optional arguments to communicate to components how <paramref name="obj"/> should be /// written.</param> /// <returns>True if this <see cref="XWriterComponent"/> wrote the complete object to XML and all further /// processing of this element should end.</returns> protected virtual bool OnWrite <T>(IXWriteOperation writer, T obj, XAttribute attribute, XObjectArgs args) => false;
/// <summary> /// Called when an <see cref="XElement"/> has been created with the intention of writing an <see cref="object"/> /// to it, but before any XML has been added by <see cref="XTypeComponent{T}"/>s. /// </summary> /// <param name="writer">An <see cref="IXWriteOperation"/> instance that exposes methods for writing XML /// using the active <see cref="XWriter"/>.</param> /// <param name="obj">The object to be written.</param> /// <param name="element">The <see cref="XElement"/> to which <paramref name="obj"/> is being written. The /// element will already have been assigned the correct <see cref="XName"/>.</param> /// <param name="args">Optional arguments to communicate to components how <paramref name="obj"/> should be /// written.</param> /// <returns>True if this <see cref="XWriterComponent"/> wrote the complete object to XML and all further /// processing of this element should end.</returns> protected virtual bool OnWrite <T>(IXWriteOperation writer, T obj, XElement element, XObjectArgs args) => false;
internal bool Read <T>(IXReadOperation reader, XType <T> xType, XAttribute attribute, Func <object, bool> assign, XObjectArgs args) => OnRead(reader, xType, attribute, assign, args);
internal bool Read <T>(IXReadOperation reader, XType <T> xType, XElement element, Func <object, bool> assign, XObjectArgs args) => OnRead(reader, xType, element, assign, args);
/// <summary> /// Called when the <see cref="XReader"/> has arrived at an <see cref="XAttribute"/> expecting an object of type /// <typeparamref name="T"/>, but before <see cref="XTypeComponent{T}"/>s have attempted deserialization. /// </summary> /// <param name="reader">An <see cref="IXReadOperation"/> instance that exposes methods for reading XML and /// scheduling tasks using the active <see cref="XReader"/>.</param> /// <param name="xType">An <see cref="XType{T}"/> reflected from the <see cref="XDomain"/> to which this /// <see cref="XReader"/> belongs.</param> /// <param name="attribute">The <see cref="XAttribute"/> to be read.</param> /// <param name="assign">A delegate to perform on the deserialized <typeparamref name="T"/>. If it returns <c>false</c>, /// it will be added to the task queue and repeatedly attempted until it returns <c>true</c>.</param> /// <param name="args">Optional arguments to communicate to components how <paramref name="attribute"/> should be /// read.</param> /// <returns><c>True</c> if the <see cref="XReaderComponent"/> fully deserialized the object and all further /// processing of <paramref name="attribute"/> should stop.</returns> protected virtual bool OnRead <T>(IXReadOperation reader, XType <T> xType, XAttribute attribute, Func <object, bool> assign, XObjectArgs args) => false;
/// <summary> /// Called when the <see cref="XReader"/> has arrived at an <see cref="XElement"/> expecting an object of type /// <typeparamref name="T"/>, but before <see cref="XTypeComponent{T}"/>s have attempted deserialization. /// </summary> /// <param name="reader">An <see cref="IXReadOperation"/> instance that exposes methods for reading XML and /// scheduling tasks using the active <see cref="XReader"/>.</param> /// <param name="xType">An <see cref="XType{T}"/> reflected from the <see cref="XDomain"/> to which this /// <see cref="XReader"/> belongs.</param> /// <param name="element">The <see cref="XElement"/> to be read.</param> /// <param name="assign">A delegate to perform on the deserialized <typeparamref name="T"/>. If it returns <c>false</c>, /// it will be added to the task queue and repeatedly attempted until it returns <c>true</c>.</param> /// <param name="args">Optional arguments to communicate to components how <paramref name="element"/> should be /// read.</param> /// <returns><c>True</c> if the <see cref="XReaderComponent"/> fully deserialized the object and all further /// processing of <paramref name="element"/> should stop.</returns> protected virtual bool OnRead <T>(IXReadOperation reader, XType <T> xType, XElement element, Func <object, bool> assign, XObjectArgs args) => false;
internal void Build(IXReadOperation reader, XElement element, ObjectBuilder <T> objectBuilder, XObjectArgs args) => ForEachComponent(x => x.Build(reader, element, objectBuilder, args));
internal bool Write(IXWriteOperation writer, T obj, XAttribute attribute, XObjectArgs args) => ForEachComponent(x => x.Write(writer, obj, attribute, args));
internal bool Write(IXWriteOperation writer, T obj, XElement element, XObjectArgs args) => ForEachComponent(x => x.Write(writer, obj, element, args));