本文整理匯總了C#中Newtonsoft.Json.Serialization.JsonDictionaryContract.CreateTemporaryDictionary方法的典型用法代碼示例。如果您正苦於以下問題:C# JsonDictionaryContract.CreateTemporaryDictionary方法的具體用法?C# JsonDictionaryContract.CreateTemporaryDictionary怎麽用?C# JsonDictionaryContract.CreateTemporaryDictionary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Newtonsoft.Json.Serialization.JsonDictionaryContract
的用法示例。
在下文中一共展示了JsonDictionaryContract.CreateTemporaryDictionary方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateNewDictionary
private IDictionary CreateNewDictionary(JsonReader reader, JsonDictionaryContract contract, out bool createdFromNonDefaultCreator)
{
if (contract.OverrideCreator != null)
{
if (contract.HasParameterizedCreator)
{
createdFromNonDefaultCreator = true;
return contract.CreateTemporaryDictionary();
}
else
{
createdFromNonDefaultCreator = false;
return (IDictionary)contract.OverrideCreator();
}
}
else if (contract.IsReadOnlyOrFixedSize)
{
createdFromNonDefaultCreator = true;
return contract.CreateTemporaryDictionary();
}
else if (contract.DefaultCreator != null && (!contract.DefaultCreatorNonPublic || Serializer._constructorHandling == ConstructorHandling.AllowNonPublicDefaultConstructor))
{
object dictionary = contract.DefaultCreator();
if (contract.ShouldCreateWrapper)
{
dictionary = contract.CreateWrapper(dictionary);
}
createdFromNonDefaultCreator = false;
return (IDictionary)dictionary;
}
else if (contract.HasParameterizedCreatorInternal)
{
createdFromNonDefaultCreator = true;
return contract.CreateTemporaryDictionary();
}
else
{
if (!contract.IsInstantiable)
{
throw JsonSerializationException.Create(reader, "Could not create an instance of type {0}. Type is an interface or abstract class and cannot be instantiated.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
}
throw JsonSerializationException.Create(reader, "Unable to find a default constructor to use for type {0}.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
}
}
示例2: CreateNewDictionary
private IDictionary CreateNewDictionary(JsonReader reader, JsonDictionaryContract contract, out bool createdFromNonDefaultConstructor)
{
if (contract.IsReadOnlyOrFixedSize)
{
createdFromNonDefaultConstructor = true;
return contract.CreateTemporaryDictionary();
}
else if (contract.DefaultCreator != null && (!contract.DefaultCreatorNonPublic || Serializer._constructorHandling == ConstructorHandling.AllowNonPublicDefaultConstructor))
{
object dictionary = contract.DefaultCreator();
if (contract.ShouldCreateWrapper)
dictionary = contract.CreateWrapper(dictionary);
createdFromNonDefaultConstructor = false;
return (IDictionary) dictionary;
}
else if (contract.ParametrizedConstructor != null)
{
createdFromNonDefaultConstructor = true;
return contract.CreateTemporaryDictionary();
}
else
{
throw JsonSerializationException.Create(reader, "Unable to find a default constructor to use for type {0}.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
}
}
示例3: CreateNewDictionary
public object CreateNewDictionary(JsonReader reader, JsonDictionaryContract contract, out bool isTemporaryDictionary)
{
object dictionary;
if (contract.DefaultCreator != null && (!contract.DefaultCreatorNonPublic || Serializer.ConstructorHandling == ConstructorHandling.AllowNonPublicDefaultConstructor))
{
dictionary = contract.DefaultCreator();
isTemporaryDictionary = false;
}
else if (contract.IsReadOnlyDictionary)
{
dictionary = contract.CreateTemporaryDictionary();
isTemporaryDictionary = true;
}
else
{
throw JsonSerializationException.Create(reader, "Unable to find a default constructor to use for type {0}.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
}
return dictionary;
}