public static InjecteeAssembly Serialize(InjecteeAssembly instance, SimpleXmlSerializerBase serializer) { instance = instance ?? new InjecteeAssembly(); serializer.ProcessStartElement(nameof(InjecteeAssembly)); { serializer.ProcessAttributeString(nameof(AssemblyPath), s => instance.AssemblyPath = s, () => instance.AssemblyPath); serializer.ProcessEnterChildOnRead(); serializer.ProcessWithFlags(SimpleXmlSerializerFlags.IsOptional | SimpleXmlSerializerFlags.CollectionUnorderedRequired, () => { serializer.ProcessUnorderedSequence(() => { if (serializer.ProcessStartElement(nameof(IgnoredMemberReferences))) { serializer.ProcessEnterChildOnRead(); serializer.ProcessCollectionAsReadOnly( v => instance.IgnoredMemberReferences = v, () => instance.IgnoredMemberReferences, itemSerializer => serializer.CreateByKnownInheritors <IIgnoredMemberReference>( serializer.CurrentXmlElement.Name, itemSerializer ) ); } serializer.ProcessEndElement(); if (serializer.ProcessStartElement(nameof(AllowedAssemblyReferences))) { serializer.ProcessEnterChildOnRead(); serializer.ProcessCollectionAsReadOnly( v => instance.AllowedAssemblyReferences = v, () => instance.AllowedAssemblyReferences, itemSerializer => serializer.CreateByKnownInheritors <IAllowedAssemblyReference>( serializer.CurrentXmlElement.Name, itemSerializer ) ); } serializer.ProcessEndElement(); }); }); } serializer.ProcessEndElement(); return(instance); }
public static FileIncludeLoader <TItem> Serialize(FileIncludeLoader <TItem> instance, SimpleXmlSerializerBase serializer) { instance = instance ?? throw new ArgumentNullException(nameof(instance)); // Skip root element when reading serializer.ProcessEnterChildOnRead(); serializer.ProcessCollection( instance.Items, itemSerializer => serializer.CreateByKnownInheritors <TItem>( serializer.CurrentXmlElement.Name, itemSerializer )); return(instance); }