示例#1
0
 public SignalRContractResolver()
 {
     _defaultContractSerializer =
         new Newtonsoft.Json.Serialization.DefaultContractResolver();
     _camelCaseContractResolver =
         new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
     _assembly =
         typeof(Microsoft.AspNetCore.SignalR.Infrastructure.Connection)
         .GetTypeInfo()
         .Assembly
     ;
 }
        public static void Serialize(object value, System.IO.Stream s, Newtonsoft.Json.Serialization.IContractResolver resolver)
        {
            using (System.IO.StreamWriter writer = new System.IO.StreamWriter(s, System.Text.Encoding.UTF8))
                using (Newtonsoft.Json.JsonTextWriter jsonWriter = new Newtonsoft.Json.JsonTextWriter(writer))
                {
                    Newtonsoft.Json.JsonSerializer ser = new Newtonsoft.Json.JsonSerializer();
                    ser.Formatting = Newtonsoft.Json.Formatting.Indented;

                    if (resolver != null)
                    {
                        ser.ContractResolver = resolver;
                    }

                    ser.Serialize(jsonWriter, value);

                    jsonWriter.Flush();
                }// End Using jsonWriter
        } // End Sub Serialize
示例#3
0
文件: Controllers.cs 项目: ili/NSwag
        private void SetExceptionFieldValue(Newtonsoft.Json.Linq.JObject jObject, string propertyName, object value, string fieldName, Newtonsoft.Json.Serialization.IContractResolver resolver, Newtonsoft.Json.JsonSerializer serializer)
        {
            var field            = System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(System.Exception)).GetDeclaredField(fieldName);
            var jsonPropertyName = resolver is Newtonsoft.Json.Serialization.DefaultContractResolver ? ((Newtonsoft.Json.Serialization.DefaultContractResolver)resolver).GetResolvedPropertyName(propertyName) : propertyName;
            var property         = System.Linq.Enumerable.FirstOrDefault(jObject.Properties(), p => System.String.Equals(p.Name, jsonPropertyName, System.StringComparison.OrdinalIgnoreCase));

            if (property != null)
            {
                var fieldValue = property.Value.ToObject(field.FieldType, serializer);
                field.SetValue(value, fieldValue);
            }
        }
示例#4
0
        private void SetExceptionFieldValue(Newtonsoft.Json.Linq.JObject jObject, string propertyName, object value, string fieldName, Newtonsoft.Json.Serialization.IContractResolver resolver, Newtonsoft.Json.JsonSerializer serializer)
        {
            var field            = System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(System.Exception)).GetDeclaredField(fieldName);
            var jsonPropertyName = resolver is Newtonsoft.Json.Serialization.DefaultContractResolver ? ((Newtonsoft.Json.Serialization.DefaultContractResolver)resolver).GetResolvedPropertyName(propertyName) : propertyName;

            if (jObject[jsonPropertyName] != null)
            {
                var fieldValue = jObject[jsonPropertyName].ToObject(field.FieldType, serializer);
                field.SetValue(value, fieldValue);
            }
        }
示例#5
0
 protected virtual bool TryGetJsonProperty(object target, Newtonsoft.Json.Serialization.IContractResolver contractResolver, string segment, out Newtonsoft.Json.Serialization.JsonProperty jsonProperty)
 {
     throw null;
 }
示例#6
0
 public virtual bool TryTraverse(object target, string segment, Newtonsoft.Json.Serialization.IContractResolver contractResolver, out object value, out string errorMessage)
 {
     throw null;
 }
示例#7
0
 public ObjectVisitor(Microsoft.AspNetCore.JsonPatch.Internal.ParsedPath path, Newtonsoft.Json.Serialization.IContractResolver contractResolver, Microsoft.AspNetCore.JsonPatch.Adapters.IAdapterFactory adapterFactory)
 {
 }
示例#8
0
 protected virtual bool TrySetDynamicObjectProperty(object target, Newtonsoft.Json.Serialization.IContractResolver contractResolver, string segment, object value, out string errorMessage)
 {
     throw null;
 }
示例#9
0
 public ObjectAdapter(Newtonsoft.Json.Serialization.IContractResolver contractResolver, System.Action <Microsoft.AspNetCore.JsonPatch.JsonPatchError> logErrorAction, Microsoft.AspNetCore.JsonPatch.Adapters.IAdapterFactory adapterFactory)
 {
 }
示例#10
0
 public virtual Microsoft.AspNetCore.JsonPatch.Internal.IAdapter Create(object target, Newtonsoft.Json.Serialization.IContractResolver contractResolver)
 {
     throw null;
 }
示例#11
0
 public JsonPatchDocument(System.Collections.Generic.List <Microsoft.AspNetCore.JsonPatch.Operations.Operation> operations, Newtonsoft.Json.Serialization.IContractResolver contractResolver)
 {
 }