コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XSerializerSerializer"/> class
        /// with the specified configuration.
        /// </summary>
        /// <param name="configuration">The configuration used to initialize objects from the XSerializer library.</param>
        public XSerializerSerializer(IXSerializerSerializerConfiguration configuration)
        {
            var c = configuration;

            _createOptions =
                type =>
            {
                string rootElementName;

                return(new XmlSerializationOptions(
                           c.Namespaces,
                           c.Encoding,
                           c.DefaultNamespace,
                           c.Indent,
                           c.RootElementNameMap == null
                            ? null
                            : c.RootElementNameMap.TryGetValue(type, out rootElementName)
                                ? rootElementName
                                : null,
                           c.AlwaysEmitTypes,
                           c.Redact,
                           c.TreatEmptyElementAsString,
                           c.EmitNil));
            };
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XSerializerSerializer"/> class
        /// with the specified configuration.
        /// </summary>
        /// <param name="configuration">The configuration used to initialize objects from the XSerializer library.</param>
        public XSerializerSerializer(IXSerializerSerializerConfiguration configuration)
        {
            var c = configuration;

            _createOptions =
                type =>
                {
                    string rootElementName;

                    return new XmlSerializationOptions(
                        c.Namespaces,
                        c.Encoding,
						false,
                        c.DefaultNamespace,
                        c.Indent,
                        c.RootElementNameMap == null
                            ? null
                            : c.RootElementNameMap.TryGetValue(type, out rootElementName)
                                ? rootElementName
                                : null,
                        c.AlwaysEmitTypes,
                        c.Redact,
                        c.TreatEmptyElementAsString,
                        c.EmitNil);
                };
        }