public void JSONSerializerTestMethod1()
        {
            // Create a new instance of the Person class and serialize it to an XML file.
            CSharpSelectedTypesEncoding _p1 = new CSharpSelectedTypesEncoding();
            string _fileName = "DataContractExample.json";

            JSONDataContractSerializers.Save <CSharpSelectedTypesEncoding>(new FileInfo(_fileName), _p1, (x, y, z) => Assert.AreEqual(System.Diagnostics.TraceEventType.Verbose, x));
            FileInfo _newFile = new FileInfo(_fileName);

            Assert.IsTrue(_newFile.Exists);
            CSharpSelectedTypesEncoding _p2 = JSONDataContractSerializers.Load <CSharpSelectedTypesEncoding>
                                                  (new FileInfo(_fileName), (x, y, z) => Assert.AreEqual <System.Diagnostics.TraceEventType>(System.Diagnostics.TraceEventType.Verbose, x));

            Assert.IsNotNull(_p2);
            _p1.AreEqual(_p2);
        }
        /// <summary>
        /// Loads the <typeparamref name="ConfigurationDataType" /> instance using specified loader.
        /// </summary>
        /// <typeparam name="ConfigurationDataType">The type of the configuration data type.</typeparam>
        /// <param name="serializer">The serializer.</param>
        /// <param name="configurationFile">The configuration file.</param>
        /// <param name="trace">The trace.</param>
        /// <param name="onChanged">The on changed.</param>
        /// <returns>ConfigurationDataType.</returns>
        public static ConfigurationDataType Load <ConfigurationDataType>(SerializerType serializer, FileInfo configurationFile, Action <TraceEventType, int, string> trace, Action onChanged)
            where ConfigurationDataType : class, IConfigurationDataFactory, new()
        {
            Func <FileInfo, Action <TraceEventType, int, string>, ConfigurationDataType> _loader = null;

            if (serializer == SerializerType.Xml)
            {
                _loader = (file, tracer) => XmlDataContractSerializers.Load <ConfigurationDataType>(file, tracer);
            }
            else
            {
                _loader = (conf, tracer) => JSONDataContractSerializers.Load <ConfigurationDataType>(conf, tracer);
            }
            ConfigurationDataType _configuration = _loader(configurationFile, (x, y, z) => trace?.Invoke(x, y, z));

            _configuration.OnChanged = onChanged;
            _configuration.OnLoaded();
            return(_configuration);
        }
        private void LoadUsingSerializer(Role role, SerializerType serializer)
        {
            FileInfo _fileInfo = GetFileName(role, serializer, @"TestData\ConfigurationData{0}.{1}");

            Assert.IsTrue(_fileInfo.Exists, _fileInfo.ToString());
            ConfigurationData _mirror = null;
            ConfigurationData _source = null;

            switch (role)
            {
            case Role.Producer:
                _source = ReferenceConfiguration.LoadProducer();
                break;

            case Role.Consumer:
                _source = ReferenceConfiguration.LoadConsumer();
                break;
            }
            string _message = null;

            switch (serializer)
            {
            case SerializerType.Json:
                _mirror = ConfigurationDataFactoryIO.Load <ConfigurationData>
                              (() => JSONDataContractSerializers.Load <ConfigurationData>(_fileInfo, (x, y, z) => { _message = z; Assert.AreEqual <TraceEventType>(TraceEventType.Verbose, x); }), () => { });
                break;

            case SerializerType.Xml:
                _mirror = ConfigurationDataFactoryIO.Load <ConfigurationData>
                              (() => XmlDataContractSerializers.Load <ConfigurationData>(_fileInfo, (x, y, z) => { _message = z; Assert.AreEqual <TraceEventType>(TraceEventType.Verbose, x); }), () => { });
                break;
            }
            Console.WriteLine(_message);
            Assert.IsNotNull(_mirror);
            Assert.IsFalse(String.IsNullOrEmpty(_message));
            Assert.IsTrue(_message.Contains(_fileInfo.FullName));
            ReferenceConfiguration.Compare(_source, _mirror);
        }