src/NetStandard/Json/Json/src/Utils/TeronisJsonUtils.cs
/// <summary>
/// Deserialize only a part of an instance with the type of <paramref name="containerType"/> by one or more "variable name and its content"-pairs.
/// </summary>
/// <param name="containerType">The type of the container which contains all "variable name and its content"-pairs</param>
/// <param name="settings">The settings when serializing and deserializing the dummy dictionary. Passing null is handled by Json.NET.</param>
/// <param name="variableNameAndContentPairs">The variable members of the container</param>
Deserialize only a part of an instance with the type of  by one or more "variable name and its content"-pairs.
Deserialize only a part of an instance with the type of by one or more " variable name and its content " - pairs .
public static object GetDeserializePropertiesContainer(Type containerType, JsonSerializerSettings settings, params KeyValuePair<string, object>[] variableNameAndContentPairs)
        {
            var dummyDictionary = new Dictionary<string, object>();
            var dummyCollection = (ICollection<KeyValuePair<string, object>>)dummyDictionary;
            var contractResolver = new IncludedVariablesContractResolver();
            foreach (var variableNameAndContentPair in variableNameAndContentPairs) {
                dummyCollection.Add(variableNameAndContentPair);
                contractResolver.IncludeVariable(containerType, variableNameAndContentPair.Key);
            }
            var deserializedDuckContainer = JsonConvert.SerializeObject(dummyDictionary, settings);
            JsonSerializerSettings copiedSettings;
            if (settings != null) {
                copiedSettings = ShallowCopy(settings);
                copiedSettings.ContractResolver = contractResolver;
            } else {
                copiedSettings = null;
            }
            return deserializedDuckContainer.DeserializeJson(containerType, copiedSettings);
        }
public static object GetDeserializePropertiesContainer ( Type containerType , JsonSerializerSettings settings , params KeyValuePair < string , object > [ ] variableNameAndContentPairs ) { var dummyDictionary = new Dictionary < string , object > ( ) ; var dummyCollection = ( ICollection < KeyValuePair < string , object > > ) dummyDictionary ; var contractResolver = new IncludedVariablesContractResolver ( ) ; foreach ( var variableNameAndContentPair in variableNameAndContentPairs ) { dummyCollection . Add ( variableNameAndContentPair ) ; contractResolver . IncludeVariable ( containerType , variableNameAndContentPair . Key ) ; } var deserializedDuckContainer = JsonConvert . SerializeObject ( dummyDictionary , settings ) ; JsonSerializerSettings copiedSettings ; if ( settings != null ) { copiedSettings = ShallowCopy ( settings ) ; copiedSettings . ContractResolver = contractResolver ; } else { copiedSettings = null ; } return deserializedDuckContainer . DeserializeJson ( containerType , copiedSettings ) ; }
Deserialize only a part of an instance with the type of  by one or more "variable name and its content"-pairs.
Deserialize only a part of an instance with the type of by one or more " variable name and its content " - pairs .
// Here we attach the hole key value pair to the dictionary // Settings can be null, so do not copy it when null
containerType
Type
The type of the container which contains all "variable name and its content"-pairs
The type of the container which contains all " variable name and its content " - pairs
settings
JsonSerializerSettings
The settings when serializing and deserializing the dummy dictionary. Passing null is handled by Json.NET.
The settings when serializing and deserializing the dummy dictionary . Passing null is handled by Json . NET .
variableNameAndContentPairs
The variable members of the container
The variable members of the container