/// <summary> /// default constructor with contract resolver /// </summary> /// <param name="resolver"></param> public CustomJsonConverter(IContractResolver resolver) { if (resolver == null) throw new ArgumentNullException("resolver"); ContractResolver = resolver; }
public SchemaRegistry( JsonSerializerSettings jsonSerializerSettings, IDictionary<Type, Func<Schema>> customSchemaMappings, IEnumerable<ISchemaFilter> schemaFilters, IEnumerable<IModelFilter> modelFilters, Func<Type, string> schemaIdSelector, bool ignoreObsoleteProperties, bool describeAllEnumsAsStrings, bool describeStringEnumsInCamelCase, AutoRestEnumSupportType? autoRestEnumSupport) { _jsonSerializerSettings = jsonSerializerSettings; _customSchemaMappings = customSchemaMappings; _schemaFilters = schemaFilters; _modelFilters = modelFilters; _schemaIdSelector = schemaIdSelector; _ignoreObsoleteProperties = ignoreObsoleteProperties; _describeAllEnumsAsStrings = describeAllEnumsAsStrings; _describeStringEnumsInCamelCase = describeStringEnumsInCamelCase; _autoRestEnumSupport = autoRestEnumSupport; _contractResolver = jsonSerializerSettings.ContractResolver ?? new DefaultContractResolver(); _referencedTypes = new Dictionary<Type, SchemaInfo>(); Definitions = new Dictionary<string, Schema>(); }
public CypherQuery( string queryText, IDictionary<string, object> queryParameters, CypherResultMode resultMode, IContractResolver contractResolver = null) : this(queryText, queryParameters, resultMode, CypherResultFormat.DependsOnEnvironment, contractResolver) { }
public JsonNetResult(Object jObject, IContractResolver contractResolver, params JsonConverter[] converters) { _jObject = jObject; _contractResolver = contractResolver; _converters = converters; }
protected void SetContractResolver(IContractResolver contractResolver) { _contractResolver = contractResolver; var cluster = ClusterHelper.Get(); cluster.Configuration.DeserializationSettings.ContractResolver = contractResolver; cluster.Configuration.SerializationSettings.ContractResolver = contractResolver; }
public JsonValue(IContractResolver resolver, object value) { if (value != null && !IsPrimitive(resolver, value.GetType())) { throw new ArgumentException("value must be a primitive recognized by Json.NET", "value"); } _getValue = t => value; }
/// <summary> /// Constructor. /// </summary> /// <param name="endpoint">The endpoint to connect the client to.</param> /// <param name="accessToken">The access token.</param> public HypermediaSampleClient(string endpoint, string accessToken) { _httpClient = new HttpClient { BaseAddress = new Uri(endpoint) }; _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaTypeName)); _contractResolver = CreateResolver(); }
/// <summary> /// Constructorul principal care seteaza variabila readonly _responseValue serializata in metoda SerializeToStreamAsync si optional si contractResolver folosit pentru serializare /// </summary> /// <param name="responseValue">Obiectul care va fi serializat si scris in Stream de metoda SerializeToStreamAsync</param> /// <param name="contractResolver">Daca parametrul este null sau nespecificat se foloseste o instanta noua de tip DefaultContractResolver</param> public JsonContent(object responseValue, IContractResolver contractResolver = null) { _responseValue = responseValue; if (contractResolver == null) contractResolver = new DefaultContractResolver(); _contractResolver = contractResolver; Headers.ContentType = new MediaTypeHeaderValue("application/json"); }
public JsonNetMemberNameResolver(IContractResolver contractResolver) { if (contractResolver == null) { throw new ArgumentNullException("contractResolver"); } _contractResolver = contractResolver; }
/// <summary> /// Initializes a new instance of the <see cref="AbpSignalRContractResolver"/> class. /// </summary> public AbpSignalRContractResolver() { _defaultContractSerializer = new DefaultContractResolver(); _camelCaseContractResolver = new CamelCasePropertyNamesContractResolver(); IgnoredAssemblies = new List<Assembly> { typeof (Connection).Assembly }; }
public SchemaRegistry( JsonSerializerSettings jsonSerializerSettings, SchemaRegistryOptions options = null) { _jsonSerializerSettings = jsonSerializerSettings; _jsonContractResolver = _jsonSerializerSettings.ContractResolver ?? new DefaultContractResolver(); _options = options ?? new SchemaRegistryOptions(); _referencedTypeMap = new Dictionary<string, Type>(); Definitions = new Dictionary<string, Schema>(); }
protected void SetContractResolver(IContractResolver contractResolver) { _contractResolver = contractResolver; var cluster = ClusterHelper.Get(); #pragma warning disable CS0618 // Type or member is obsolete cluster.Configuration.DeserializationSettings.ContractResolver = contractResolver; cluster.Configuration.SerializationSettings.ContractResolver = contractResolver; #pragma warning restore CS0618 // Type or member is obsolete }
/// <summary> /// Constructor. /// </summary> /// <param name="name">The friendly name of the format.</param> /// <param name="mediaTypeName">The correct media type name for content negotiation.</param> /// <param name="contractResolver">The resource contract resolver used to resolve the contracts at runtime.</param> protected HypermediaMediaTypeFormatter(string name, string mediaTypeName, IContractResolver contractResolver) { ContractResolver = contractResolver; SupportedMediaTypes.Clear(); SupportedMediaTypes.Insert(0, new MediaTypeHeaderValue(mediaTypeName)); MediaTypeMappings.Clear(); MediaTypeMappings.Add(new QueryStringMapping("$format", name, mediaTypeName)); }
public SQLiteConnectionString(string databasePath, bool storeDateTimeAsTicks, IBlobSerializer serializer = null, IContractResolver resolver = null) { ConnectionString = databasePath; StoreDateTimeAsTicks = storeDateTimeAsTicks; DatabasePath = databasePath; Serializer = serializer; Resolver = resolver ?? ContractResolver.Current; }
public SqLiteConfig( string databaseName, bool storeDateTimeAsTicks = true, IBlobSerializer serializer = null, IContractResolver resolver = null) { DatabaseName = databaseName; StoreDateTimeAsTicks = storeDateTimeAsTicks; BlobSerializer = serializer; }
public CustomJsonConverter(IContractResolver resolver, JsonSerializerSettings settings) { if (resolver == null) throw new ArgumentNullException("resolver"); if (settings == null) throw new ArgumentNullException("settings"); ContractResolver = resolver; JsonSerializerSettings = settings; }
public SwaggerGenerator( IApiExplorer apiExplorer, IContractResolver jsonContractResolver, IDictionary<string, Info> apiVersions, SwaggerGeneratorOptions options = null) { _apiExplorer = apiExplorer; _jsonContractResolver = jsonContractResolver; _apiVersions = apiVersions; _options = options ?? new SwaggerGeneratorOptions(); }
private static JsonConverter Build(Type type, Func<object, IEnumerable<object>> linkEnumerator, IContractResolver contractResolver) { var enumerable = type.GetInterface(typeof (IEnumerable<>).FullName); if (enumerable != null) { return Build(enumerable.GetGenericArguments().Single(), linkEnumerator, contractResolver); } var concreteType = typeof(LinkConverter<>).MakeGenericType(type); var newMethod = concreteType.GetMethod("New", BindingFlags.Static | BindingFlags.Public); return (JsonConverter)newMethod.Invoke(null, new object[] {linkEnumerator, contractResolver}); }
/// <summary> /// Initializes a new instance of the <see cref="BaseJsonMediaTypeFormatter"/> class. /// </summary> protected BaseJsonMediaTypeFormatter() { // Initialize serializer settings #if !NETFX_CORE // DataContractResolver is not supported in portable library _defaultContractResolver = new JsonContractResolver(this); #endif _jsonSerializerSettings = CreateDefaultSerializerSettings(); // Set default supported character encodings SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true)); SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true)); }
/// <summary> /// Initializes a new instance of <see cref="ObjectAdapter"/>. /// </summary> /// <param name="contractResolver">The <see cref="IContractResolver"/>.</param> /// <param name="logErrorAction">The <see cref="Action"/> for logging <see cref="JsonPatchError"/>.</param> public ObjectAdapter( IContractResolver contractResolver, Action<JsonPatchError> logErrorAction) { if (contractResolver == null) { throw new ArgumentNullException(nameof(contractResolver)); } ContractResolver = contractResolver; LogErrorAction = logErrorAction; }
protected void InitializeCluster(IContractResolver contractResolver = null) { if (contractResolver != null) { _contractResolver = contractResolver; } var config = TestConfigurations.DefaultConfig(); config.DeserializationSettings.ContractResolver = _contractResolver; config.SerializationSettings.ContractResolver = _contractResolver; ClusterHelper.Initialize(config); }
public SwaggerGenerator( IApiExplorer apiExplorer, JsonSerializerSettings jsonSerializerSettings, IDictionary<string, Info> apiVersions, SwaggerGeneratorOptions options = null) { _apiExplorer = apiExplorer; _jsonSerializerSettings = jsonSerializerSettings; _contractResolver = jsonSerializerSettings.ContractResolver ?? new DefaultContractResolver(); _apiVersions = apiVersions; _options = options ?? new SwaggerGeneratorOptions(); }
public static bool IsPrimitive(IContractResolver resolver, Type type) { if (resolver == null) { //get default from json serializer (since no public access to default resolver instance) resolver = new JsonSerializer().ContractResolver; } var contract = resolver.ResolveContract(type); return contract is JsonPrimitiveContract; }
private static void Add(Type type, IList<JsonConverter> converters, HashSet<Type> knownTypes, Func<object, IEnumerable<object>> linkEnumerator, HashSet<Type> done, IContractResolver contractResolver) { if (knownTypes.Contains(type)) { converters.Add(Create(type, linkEnumerator, contractResolver)); } done.Add(type); foreach (var property in type.GetProperties().Where(p => (!Ignore(p.PropertyType)) && (!done.Contains(p.PropertyType)))) { Add(property.PropertyType, converters, knownTypes, linkEnumerator, done, contractResolver); } }
/// <summary> /// Initializes a new instance of <see cref="NewtonsoftJsonSerializer"/> with a set of custom <see cref="JsonConverter"/> instances to be used by <see cref="ConverterContractResolver"/>. /// </summary> /// <param name="contractResolver">The underlying JSON.NET contract resolver.</param> public NewtonsoftJsonSerializer(IContractResolver contractResolver) { Serializer = new JsonSerializer { ContractResolver = contractResolver, DateFormatHandling = DateFormatHandling.IsoDateFormat, MissingMemberHandling = MissingMemberHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, TypeNameHandling = TypeNameHandling.Auto }; }
public CypherQuery( string queryText, IDictionary<string, object> queryParameters, CypherResultMode resultMode, CypherResultFormat resultFormat, IContractResolver contractResolver = null) { this.queryText = queryText; this.queryParameters = queryParameters; this.resultMode = resultMode; this.resultFormat = resultFormat; jsonContractResolver = contractResolver ?? GraphClient.DefaultJsonContractResolver; }
protected void InitializeCluster(IContractResolver contractResolver = null) { if (contractResolver == null) { contractResolver = new DefaultContractResolver(); } var config = new ClientConfiguration(); config.Servers.Add(new Uri("http://127.0.0.1:8091")); config.DeserializationSettings.ContractResolver = contractResolver; config.SerializationSettings.ContractResolver = contractResolver; ClusterHelper.Initialize(config); }
public CypherQuery ToCypherQuery(IContractResolver contractResolver = null) { var queryText = queryTextBuilder .ToString() .TrimEnd(Environment.NewLine.ToCharArray()); return new CypherQuery( queryText, new Dictionary<string, object>(queryParameters), resultMode, resultFormat, contractResolver); }
public SQLiteConnectionString(string databasePath, bool storeDateTimeAsTicks, IBlobSerializer serializer = null, IContractResolver resolver = null, SQLiteOpenFlags? openFlags = null) { ConnectionString = databasePath; StoreDateTimeAsTicks = storeDateTimeAsTicks; DatabasePath = databasePath; Serializer = serializer; Resolver = resolver ?? ContractResolver.Current; OpenFlags = openFlags ?? SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create; }
public SqLiteConfig( string databaseName, bool storeDateTimeAsTicks = true, IBlobSerializer serializer = null, IContractResolver resolver = null, SQLiteOpenFlags? openFlags = null) { DatabaseName = databaseName; StoreDateTimeAsTicks = storeDateTimeAsTicks; BlobSerializer = serializer; //OpenFlags = openFlags ?? SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create; }
/// <summary> /// Gets a list of entities. /// </summary> /// <typeparam name="TEntity">The element type.</typeparam> /// <param name="contractResolver">The contract resolver.</param> /// <param name="cache">The entity cache to use for resolving existing instances in the object graph.</param> /// <returns>The list of JSON API entities.</returns> public IEnumerable <TEntity> GetMany <TEntity>(IContractResolver contractResolver, IJsonApiEntityCache cache) { return(GetMany <TEntity>(new JsonApiSerializer(new JsonApiSerializerOptions(contractResolver)), cache)); }
/// <summary>Initializes a new instance of the <see cref="JsonReferenceVisitorBase"/> class. </summary> /// <param name="contractResolver">The contract resolver.</param> protected JsonReferenceVisitorBase(IContractResolver contractResolver) { _contractResolver = contractResolver; }
/// <summary> /// Initializes a new instance of the <see cref="AbpSignalRContractResolver"/> class. /// </summary> public AbpSignalRContractResolver() { _defaultContractSerializer = new DefaultContractResolver(); _camelCaseContractResolver = new CamelCasePropertyNamesContractResolver(); }
/// <summary> /// Initializes a new instance of the AmqpSerializer class with a custom contract /// resolver. See documentation for the order followed by the serializer to resolve /// a type. /// </summary> /// <param name="contractResolver">A contract resolver to create a serialization /// contract for a given type.</param> public AmqpSerializer(IContractResolver contractResolver) { this.typeCache = new ConcurrentDictionary <Type, SerializableType>(); this.contractResolver = contractResolver; }
/// <summary> /// Gets the JSON representation of an object. /// </summary> /// <param name="obj">The specified object.</param> /// <param name="formatting">The Newtonsoft.Json.Formatting options.</param> /// <param name="contractResolver">An optional Newtonsoft.Json.Serialization.IContractResolver. /// If not present, the Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver is used.</param> /// <returns>The JSON representation of the object.</returns> public static string ToJson(this object obj, Formatting formatting = Formatting.None, IContractResolver contractResolver = null) { return(JsonConvert.SerializeObject(obj, new JsonSerializerSettings() { Formatting = formatting, ContractResolver = contractResolver ?? new CamelCasePropertyNamesContractResolver(), NullValueHandling = NullValueHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); }
/// <summary> /// Gets a list of entities. /// </summary> /// <typeparam name="TEntity">The element type.</typeparam> /// <param name="contractResolver">The contract resolver.</param> /// <returns>The list of JSON API entities.</returns> public IEnumerable <TEntity> GetMany <TEntity>(IContractResolver contractResolver) { return(GetMany <TEntity>(contractResolver, new JsonApiEntityCache())); }
public static TEntity DeserializeOnOtherConverter <TEntity>(this JsonConverter source, JsonReader reader, JsonSerializer jsonSerializer, IContractResolver newContractResolver = null) { var isNeedToRestoreConverter = jsonSerializer.Converters.Any(c => c == source); if (isNeedToRestoreConverter) { jsonSerializer.Converters.Remove(source); } var oldContractResolver = jsonSerializer.ContractResolver; if (newContractResolver != null) { jsonSerializer.ContractResolver = newContractResolver; } try { var entity = jsonSerializer.Deserialize <TEntity>(reader); return(entity); } finally { if (isNeedToRestoreConverter) { jsonSerializer.Converters.Add(source); } if (newContractResolver != null) { jsonSerializer.ContractResolver = oldContractResolver; } } }
/// <summary> /// Create a new JsonPatchDocument from a list of operations, and pass in a custom contract resolver /// to use when applying the document. /// </summary> /// <param name="operations">A list of operations</param> /// <param name="contractResolver">A custom IContractResolver</param> public JsonPatchDocument(List <Operation <T> > operations, IContractResolver contractResolver) { Operations = operations; ContractResolver = contractResolver; }
public NewtonsoftDataContractResolver(JsonSerializerSettings serializerSettings) { _serializerSettings = serializerSettings; _contractResolver = serializerSettings.ContractResolver ?? new DefaultContractResolver(); }
/// <summary>Updates the <see cref="IJsonReferenceBase.Reference" /> properties /// from the available <see cref="IJsonReferenceBase.Reference" /> properties.</summary> /// <param name="rootObject">The root object.</param> /// <param name="removeExternalReferences">Specifies whether to remove external references (otherwise they are inlined).</param> /// <param name="contractResolver">The contract resolver.</param> public static void UpdateSchemaReferencePaths(object rootObject, bool removeExternalReferences, IContractResolver contractResolver) { var schemaReferences = new Dictionary <IJsonReference, IJsonReference>(); var updater = new JsonReferencePathUpdater(rootObject, schemaReferences, removeExternalReferences, contractResolver); updater.Visit(rootObject); var searchedSchemas = schemaReferences.Select(p => p.Value).Distinct(); var result = JsonPathUtilities.GetJsonPaths(rootObject, searchedSchemas, contractResolver); foreach (var p in schemaReferences) { p.Key.ReferencePath = result[p.Value]; } }
internal DerivedClassJsonConverterBase() { _contractResolver = new SafeContractResolver(); }
private static IList <Field> BuildForTypeRecursive( Type modelType, JsonObjectContract contract, IContractResolver contractResolver, Stack <Type> processedTypes) { Field BuildField(JsonProperty prop) { bool ShouldIgnore(Attribute attribute) => attribute is JsonIgnoreAttribute || attribute is FieldBuilderIgnoreAttribute; IList <Attribute> attributes = prop.AttributeProvider.GetAttributes(true); if (attributes.Any(ShouldIgnore)) { return(null); } Field CreateComplexField(DataType dataType, Type underlyingClrType, JsonObjectContract jsonObjectContract) { try { if (processedTypes.Contains(underlyingClrType)) { // Skip recursive types. return(null); } processedTypes.Push(underlyingClrType); IList <Field> subFields = BuildForTypeRecursive(underlyingClrType, jsonObjectContract, contractResolver, processedTypes); return(new Field(prop.PropertyName, dataType, subFields)); } finally { processedTypes.Pop(); } } Field CreateSimpleField(DataType dataType) { var field = new Field(prop.PropertyName, dataType); foreach (Attribute attribute in attributes) { switch (attribute) { case IsSearchableAttribute _: field.IsSearchable = true; break; case IsFilterableAttribute _: field.IsFilterable = true; break; case IsSortableAttribute _: field.IsSortable = true; break; case IsFacetableAttribute _: field.IsFacetable = true; break; case IsRetrievableAttribute isRetrievableAttribute: field.IsRetrievable = isRetrievableAttribute.IsRetrievable; break; case AnalyzerAttribute analyzerAttribute: field.Analyzer = analyzerAttribute.Name; break; case SearchAnalyzerAttribute searchAnalyzerAttribute: field.SearchAnalyzer = searchAnalyzerAttribute.Name; break; case IndexAnalyzerAttribute indexAnalyzerAttribute: field.IndexAnalyzer = indexAnalyzerAttribute.Name; break; case SynonymMapsAttribute synonymMapsAttribute: field.SynonymMaps = synonymMapsAttribute.SynonymMaps; break; default: Type attributeType = attribute.GetType(); // Match on name to avoid dependency - don't want to force people not using // this feature to bring in the annotations component. // // Also, ignore key attributes on sub-fields. if (attributeType.FullName == "System.ComponentModel.DataAnnotations.KeyAttribute" && processedTypes.Count <= 1) { field.IsKey = true; } break; } } return(field); } ArgumentException FailOnUnknownDataType() { string errorMessage = $"Property '{prop.PropertyName}' is of type '{prop.PropertyType}', which does not map to an " + "Azure Search data type. Please use a supported data type or mark the property with [JsonIgnore] or " + "[FieldBuilderIgnore] and define the field by creating a Field object."; return(new ArgumentException(errorMessage, nameof(modelType))); } IDataTypeInfo dataTypeInfo = GetDataTypeInfo(prop.PropertyType, contractResolver); return(dataTypeInfo.Match( onUnknownDataType: () => throw FailOnUnknownDataType(), onSimpleDataType: CreateSimpleField, onComplexDataType: CreateComplexField)); } return(contract.Properties.Select(BuildField).Where(field => field != null).ToArray()); }
/// <summary> /// Gets a single entity. /// </summary> /// <typeparam name="TEntity">The element type.</typeparam> /// <param name="contractResolver">The contract resolver.</param> /// <returns>The list of JSON API entities.</returns> public TEntity Get <TEntity>(IContractResolver contractResolver) { return(Get <TEntity>(contractResolver, new JsonApiEntityCache())); }
public JsonPatchDocument() { Operations = new List <Operation <TModel> >(); ContractResolver = new DefaultContractResolver(); }
/// <summary> /// Gets a single entity. /// </summary> /// <typeparam name="TEntity">The element type.</typeparam> /// <param name="contractResolver">The contract resolver.</param> /// <param name="cache">The entity cache to use for resolving existing instances in the object graph.</param> /// <returns>The list of JSON API entities.</returns> public TEntity Get <TEntity>(IContractResolver contractResolver, IJsonApiEntityCache cache) { return(Get <TEntity>(new JsonApiSerializerOptions(contractResolver), cache)); }
/// <summary> /// Initializes a new instance of <see cref="ObjectAdapter"/>. /// </summary> /// <param name="contractResolver">The <see cref="IContractResolver"/>.</param> /// <param name="logErrorAction">The <see cref="Action"/> for logging <see cref="JsonPatchError"/>.</param> public ObjectAdapter( IContractResolver contractResolver, Action <JsonPatchError> logErrorAction) : this(contractResolver, logErrorAction, Adapters.AdapterFactory.Default) { }
public SignalRContractResolver() { _defaultContractSerializer = new DefaultContractResolver(); _camelCaseContractResolver = new CamelCasePropertyNamesContractResolver(); _assembly = typeof(Connection).Assembly; }
public CypherQuery ToCypherQuery(IContractResolver contractResolver = null, bool isWrite = true) { return(QueryWriter.ToCypherQuery(contractResolver, isWrite)); }
// Create from list of operations public JsonPatchDocument(List <Operation <TModel> > operations, IContractResolver contractResolver) { Operations = operations ?? throw new ArgumentNullException(nameof(operations)); ContractResolver = contractResolver ?? throw new ArgumentNullException(nameof(contractResolver)); }
/// <summary> /// Create a new JsonPatchDocument from a list of operations /// </summary> /// <param name="operations">A list of operations</param> public JsonPatchDocument(List <Operation <T> > operations) { Operations = operations; ContractResolver = new DefaultContractResolver(); }
/// <summary> /// Create a new JsonPatchDocument, and pass in a custom contract resolver /// to use when applying the document. /// </summary> /// <param name="contractResolver">A custom IContractResolver</param> public JsonPatchDocument(IContractResolver contractResolver) { Operations = new List <Operation <T> >(); ContractResolver = contractResolver; }
public object TryParseEntity <T>(WebApiConsumerResponse response, string entityName, IContractResolver contractResolver) { if (response == null || string.IsNullOrWhiteSpace(response.Content)) { return(null); } //dynamic dynamicJson = JObject.Parse(response.Content); //foreach (dynamic customer in dynamicJson.value) //{ // string str = string.Format("{0} {1} {2}", customer.Id, customer.CustomerGuid, customer.Email); // Debug.WriteLine(str); //} var json = JObject.Parse(response.Content); string metadata = (string)json["odata.metadata"]; if (!string.IsNullOrWhiteSpace(metadata) && metadata.Contains(entityName)) { // var entitys = json.ToObject(typeof(T)); var entitys = JsonConvert.DeserializeObject <T>(response.Content, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, ContractResolver = contractResolver }); return(entitys); } return(null); }
public ServiceAndBehaviorsContractResolver(IContractResolver serviceResolver) { this.serviceResolver = serviceResolver; behaviorContracts = new Dictionary <string, ContractDescription>(); }
/// <summary> /// Creates a collection of <see cref="Field"/> objects corresponding to /// the properties of the type supplied. /// </summary> /// <typeparam name="T"> /// The type for which fields will be created, based on its properties. /// </typeparam> /// <param name="contractResolver"> /// Contract resolver that the SearchIndexClient will use. /// This ensures that the field names are generated in a way that is /// consistent with the way the model will be serialized. /// </param> /// <returns>A collection of fields.</returns> public static IList <Field> BuildForType <T>(IContractResolver contractResolver) => BuildForType(typeof(T), contractResolver);
public JsonReaderService(IContractResolver contractResolver) { ContractResolver = contractResolver; // ?? new JsonFileContractResolver(); DeserializeMethodInfo = typeof(JsonReaderService) .GetMethods().Single(x => x.Name == "Deserialize" && x.IsGenericMethodDefinition); }
public SettingsContractResolver(IContractResolver wrapped, IConnectionSettingsValues connectionSettings) { this.ConnectionSettings = connectionSettings; this.Infer = new ElasticInferrer(this.ConnectionSettings); this._wrapped = wrapped; }
public DefaultMoneyWriter(Money instance, CurrencyStyle style, IContractResolver resolver) : base(resolver) { _instance = instance; _style = style; }
public JsonReferenceUpdater(object rootObject, JsonReferenceResolver referenceResolver, IContractResolver contractResolver) : base(contractResolver) { _rootObject = rootObject; _referenceResolver = referenceResolver; _contractResolver = contractResolver; }
public static object GetJsonProperty <T>(T obj, string jsonName, bool exact = false, IContractResolver resolver = null) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } resolver = resolver ?? defaultResolver; var contract = resolver.ResolveContract(obj.GetType()) as JsonObjectContract; if (contract == null) { throw new ArgumentException(string.Format("{0} is not serialized as a JSON object", obj)); } var property = contract.Properties.GetProperty(jsonName, exact ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); if (property == null) { throw new ArgumentException(string.Format("Property {0} was not found.", obj)); } return(property.ValueProvider.GetValue(obj)); }
public NewtonsoftMetadataResolver(SchemaGeneratorOptions generatorOptions, JsonSerializerSettings serializerSettings) { _generatorOptions = generatorOptions; _serializerSettings = serializerSettings; _contractResolver = serializerSettings.ContractResolver ?? new DefaultContractResolver(); }