Defines dictionary (map) based serialization options.
These options do NOT affect serialization of System.Collections.IDictionary and System.Collections.Generic.IDictionary{TKey, TValue}. The option only affect dictionary (map) based serialization which can be enabled via SerializationContext.SerializationMethod.
Exemplo n.º 1
0
		/// <summary>
		///		Initializes a new instance of the <see cref="SerializationContext"/> class with copy of <see cref="SerializerRepository.GetDefault()"/> for specified <see cref="PackerCompatibilityOptions"/>.
		/// </summary>
		/// <param name="packerCompatibilityOptions"><see cref="PackerCompatibilityOptions"/> which will be used on built-in serializers.</param>
		public SerializationContext( PackerCompatibilityOptions packerCompatibilityOptions )
		{
			this._compatibilityOptions =
				new SerializationCompatibilityOptions
				{
					PackerCompatibilityOptions =
						packerCompatibilityOptions
				};

			this._serializers = new SerializerRepository( SerializerRepository.GetDefault( this ) );

#if SILVERLIGHT || NETFX_35 || UNITY
			this._typeLock = new Dictionary<Type, object>();
#else
			this._typeLock = new ConcurrentDictionary<Type, object>();
#endif // SILVERLIGHT || NETFX_35 || UNITY
			this._generationLock = new object();
			this._defaultCollectionTypes = new DefaultConcreteTypeRepository();
			this._serializerGeneratorOptions = new SerializerOptions();
			this._dictionarySerializationOptions = new DictionarySerlaizationOptions();
			this._enumSerializationOptions = new EnumSerializationOptions();
		}
		/// <summary>
		///		Initializes a new instance of the <see cref="SerializationContext"/> class with copy of <see cref="SerializerRepository.GetDefault()"/> for specified <see cref="PackerCompatibilityOptions"/>.
		/// </summary>
		/// <param name="packerCompatibilityOptions"><see cref="PackerCompatibilityOptions"/> which will be used on built-in serializers.</param>
		public SerializationContext( PackerCompatibilityOptions packerCompatibilityOptions )
		{
			this._compatibilityOptions =
				new SerializationCompatibilityOptions
				{
					PackerCompatibilityOptions =
						packerCompatibilityOptions
				};

			this._serializers = new SerializerRepository( SerializerRepository.GetDefault( this ) );

#if !FEATURE_CONCURRENT
			this._typeLock = new Dictionary<Type, object>();
#else
			this._typeLock = new ConcurrentDictionary<Type, object>();
#endif // !FEATURE_CONCURRENT
			this._generationLock = new object();
			this._defaultCollectionTypes = new DefaultConcreteTypeRepository();
			this._serializerGeneratorOptions = new SerializerOptions();
			this._dictionarySerializationOptions = new DictionarySerlaizationOptions();
			this._enumSerializationOptions = new EnumSerializationOptions();
			this._bindingOptions = new BindingOptions();
		}