本文整理汇总了C#中IContractResolver类的典型用法代码示例。如果您正苦于以下问题:C# IContractResolver类的具体用法?C# IContractResolver怎么用?C# IContractResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IContractResolver类属于命名空间,在下文中一共展示了IContractResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomJsonConverter
/// <summary>
/// default constructor with contract resolver
/// </summary>
/// <param name="resolver"></param>
public CustomJsonConverter(IContractResolver resolver)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
ContractResolver = resolver;
}
示例2: CypherQuery
public CypherQuery(
string queryText,
IDictionary<string, object> queryParameters,
CypherResultMode resultMode,
IContractResolver contractResolver = null)
: this(queryText, queryParameters, resultMode, CypherResultFormat.DependsOnEnvironment, contractResolver)
{
}
示例3: SetContractResolver
protected void SetContractResolver(IContractResolver contractResolver)
{
_contractResolver = contractResolver;
var cluster = ClusterHelper.Get();
cluster.Configuration.DeserializationSettings.ContractResolver = contractResolver;
cluster.Configuration.SerializationSettings.ContractResolver = contractResolver;
}
示例4: JsonNetResult
public JsonNetResult(Object jObject, IContractResolver contractResolver, params JsonConverter[] converters)
{
_jObject = jObject;
_contractResolver = contractResolver;
_converters = converters;
}
示例5: JsonNetMemberNameResolver
public JsonNetMemberNameResolver(IContractResolver contractResolver)
{
if (contractResolver == null)
{
throw new ArgumentNullException("contractResolver");
}
_contractResolver = contractResolver;
}
示例6: JsonContent
/// <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");
}
示例7: JsonValue
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;
}
示例8: SetContractResolver
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
}
示例9: HypermediaMediaTypeFormatter
/// <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));
}
示例10: SqLiteConfig
public SqLiteConfig(
string databaseName,
bool storeDateTimeAsTicks = true,
IBlobSerializer serializer = null,
IContractResolver resolver = null)
{
DatabaseName = databaseName;
StoreDateTimeAsTicks = storeDateTimeAsTicks;
BlobSerializer = serializer;
}
示例11: Build
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});
}
示例12: SwaggerGenerator
public SwaggerGenerator(
IApiExplorer apiExplorer,
IContractResolver jsonContractResolver,
IDictionary<string, Info> apiVersions,
SwaggerGeneratorOptions options = null)
{
_apiExplorer = apiExplorer;
_jsonContractResolver = jsonContractResolver;
_apiVersions = apiVersions;
_options = options ?? new SwaggerGeneratorOptions();
}
示例13: SQLiteConnectionString
public SQLiteConnectionString(string databasePath, bool storeDateTimeAsTicks,
IBlobSerializer serializer = null,
IContractResolver resolver = null)
{
ConnectionString = databasePath;
StoreDateTimeAsTicks = storeDateTimeAsTicks;
DatabasePath = databasePath;
Serializer = serializer;
Resolver = resolver ?? ContractResolver.Current;
}
示例14: Add
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);
}
}
示例15: NewtonsoftJsonSerializer
/// <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
};
}