Exemplo n.º 1
0
        /// <summary>
        /// New interface factory with specific serializer and exception settings
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="trapExceptions"></param>
        public JsonInterfaceFactory(
            JsonSerializerSettings settings,
            bool trapExceptions = false)
        {
            var interfaceSettings = new JsonInterfaceSettings
            {
                JsonSerializerSettings = settings,
                TrapExceptions         = trapExceptions
            };

            Initialize(interfaceSettings);
        }
        public JsonInterfacePropertyInterceptor(JsonInterfaceSettings settings)
        {
            if (IsFaulted)
            {
                throw new Exception($"Fault creating facade object. \n{string.Join("\n", FaultMessages)}");
            }

            var contractResolver = settings.JsonSerializerSettings.ContractResolver ??
                                   new DefaultContractResolver();

            var contract = (JsonObjectContract)contractResolver.ResolveContract(typeof(T));

            ObjectPropertyNameToJsonPropertyName = contract.Properties.ToDictionary(v => v.UnderlyingName, v => v.PropertyName);
        }
Exemplo n.º 3
0
 private void Initialize(JsonInterfaceSettings jsonInterfaceSettings)
 {
     Settings = jsonInterfaceSettings;
 }
Exemplo n.º 4
0
 /// <summary>
 /// New interface factory with settings
 /// </summary>
 /// <param name="jsonInterfaceSettings"></param>
 public JsonInterfaceFactory(JsonInterfaceSettings jsonInterfaceSettings) =>