Exemple #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();
		}
		/// <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();
		}
Exemple #3
0
 /// <summary>
 ///		Initializes a new instance of the <see cref="SerializationContext"/> class with copy of <see cref="SerializerRepository.GetDefault(PackerCompatibilityOptions)"/> 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(new SerializerRepository(SerializerRepository.GetDefault(packerCompatibilityOptions)), packerCompatibilityOptions)
 {
 }
 // For default init.
 private SerializationContext(SerializerRepository allwaysNull)
     : this(allwaysNull, PackerCompatibilityOptions.Classic)               // TODO: configurable
 {
     this._serializers = new SerializerRepository(SerializerRepository.GetDefault(this));
 }