コード例 #1
0
        public static InjectionConfiguration Serialize(InjectionConfiguration instance, SimpleXmlSerializerBase serializer)
        {
            instance = instance ?? new InjectionConfiguration();

            serializer.ProcessStartElement(serializer.GetXmlRootName(instance.GetType()));
            serializer.ProcessEnterChildOnRead();
            {
                serializer.ProcessWithFlags(SimpleXmlSerializerFlags.CollectionUnorderedRequired, () => {
                    serializer.ProcessUnorderedSequence(() => {
                        if (serializer.ProcessStartElement(nameof(InjecteeAssemblies)))
                        {
                            serializer.ProcessEnterChildOnRead();
                            {
                                serializer.ProcessCollectionAsReadOnly(v => instance.InjecteeAssemblies = v, () => instance.InjecteeAssemblies);
                            }
                            serializer.ProcessEndElement();
                        }

                        if (serializer.ProcessStartElement(nameof(InjectedMethods)))
                        {
                            serializer.ProcessEnterChildOnRead();
                            {
                                serializer.ProcessCollectionAsReadOnly(v => instance.InjectedMethods = v, () => instance.InjectedMethods);
                            }
                            serializer.ProcessEndElement();
                        }
                    });
                });
            }
            serializer.ProcessEndElement();

            return(instance);
        }
コード例 #2
0
        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);
        }