Пример #1
0
        private void AddTypeSerializer(IXleTypeSerializer serializer, bool allowInherit = false)
        {
            int count      = 0;
            var dictionary = allowInherit ? mInherited : mDirect;


            foreach (var type in serializer.AllowedTypes)
            {
                count++;

                dictionary.Add(type, serializer);
            }

            if (count == 0)
            {
                throw new InvalidOperationException("The serializer doesn't serialize any types!");
            }
        }
Пример #2
0
        /// <summary>
        /// Adds a type serializer to the colleciton
        /// </summary>
        /// <param name="type">The type of object to be serialized</param>
        /// <param name="serializer">The object which will perform the serialization</param>
        /// <param name="allowInherit">Indicates whether this serializer will also be used to serialize types which inherit
        /// from <c>type</c>.</param>
        public void AddTypeSerializer(Type type, IXleTypeSerializer serializer, bool allowInherit = false)
        {
            var dictionary = allowInherit ? mInherited : mDirect;

            dictionary.Add(type, serializer);
        }