Esempio n. 1
0
        public YamlCassetteStorage()
        {
            var uriYamlTypeConverter                 = new UriYamlTypeConverter();
            var versionYamlTypeConverter             = new VersionYamlTypeConverter();
            var nameValueCollectionYamlTypeConverter = new NameValueCollectionYamlTypeConverter();
            var cassetteBodyYamlTypeConverter        = new CassetteBodyYamlTypeConverter();

            var serializerBuilder = new SerializerBuilder()
                                    .DisableAliases()
                                    .WithTypeConverter(versionYamlTypeConverter)
                                    .WithTypeConverter(nameValueCollectionYamlTypeConverter)
                                    .WithTypeConverter(uriYamlTypeConverter)
                                    .WithTypeConverter(cassetteBodyYamlTypeConverter)
                                    .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitDefaults);

            _serializer = serializerBuilder.BuildValueSerializer();

            var deserializerBuilder = new DeserializerBuilder()
                                      .WithTypeConverter(versionYamlTypeConverter)
                                      .WithTypeConverter(nameValueCollectionYamlTypeConverter)
                                      .WithTypeConverter(uriYamlTypeConverter)
                                      .WithTypeConverter(cassetteBodyYamlTypeConverter)
                                      .WithNodeDeserializer(new ConstructorNodeDeserializer <CassetteRecord>(), r => r.OnTop())
                                      // We want to ignore nullable checks in lambda function
                #nullable disable
                                      .WithNodeDeserializer(new ConstructorNodeDeserializer <CassetteRecordRequest>(() => new CassetteRecordRequest(null, null, null, (CassetteBody)null)), r => r.OnTop())
                                      .WithNodeDeserializer(new ConstructorNodeDeserializer <CassetteRecordResponse>(() => new CassetteRecordResponse(null, 0, null, null, (CassetteBody)null, (CassetteRecordRequest)null)), r => r.OnTop());

                #nullable enable