protected override bool CanAddSerializerFactory(IYamlSerializableFactory factory)
        {
            var attribute = factory.GetType().GetCustomAttribute<YamlSerializerFactoryAttribute>();
            if (attribute == null)
                return profiles.Any(x => YamlSerializerFactoryAttribute.AreProfilesEqual(x, YamlSerializerFactoryAttribute.Default));

            return profiles.Any(x => attribute.ContainsProfile(x));
        }
Esempio n. 2
0
 /// <summary>
 /// Adds a serializer factory.
 /// </summary>
 /// <param name="factory">The factory.</param>
 /// <exception cref="System.ArgumentNullException">factory</exception>
 public void RegisterSerializerFactory(IYamlSerializableFactory factory)
 {
     if (factory == null)
     {
         throw new ArgumentNullException("factory");
     }
     AssemblyRegistry.SerializableFactories.Add(factory);
 }
 /// <inheritdoc/>
 public void TryAddFactory(IYamlSerializableFactory factory)
 {
     if (factory == null) throw new ArgumentNullException(nameof(factory));
     if (isSealed) throw new InvalidOperationException("Cannot add a factory to a serializer factory selector once it is sealed.");
     if (CanAddSerializerFactory(factory))
     {
         factories.Add(factory);
     }
 }
        public void Register(IYamlSerializableFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }

            factories.Add(factory);
        }
 /// <inheritdoc/>
 public void TryAddFactory(IYamlSerializableFactory factory)
 {
     if (factory == null) throw new ArgumentNullException(nameof(factory));
     if (isSealed) throw new InvalidOperationException("Cannot add a factory to a serializer factory selector once it is sealed.");
     if (CanAddSerializerFactory(factory))
     {
         factories.Add(factory);
     }
 }
        protected override bool CanAddSerializerFactory(IYamlSerializableFactory factory)
        {
            var attribute = factory.GetType().GetCustomAttribute <YamlSerializerFactoryAttribute>();

            if (attribute == null)
            {
                return(profiles.Any(x => YamlSerializerFactoryAttribute.AreProfilesEqual(x, YamlSerializerFactoryAttribute.Default)));
            }

            return(profiles.Any(x => attribute.ContainsProfile(x)));
        }
Esempio n. 7
0
 /// <summary>
 /// Adds a serializer factory.
 /// </summary>
 /// <param name="factory">The factory.</param>
 /// <exception cref="System.ArgumentNullException">factory</exception>
 public void RegisterSerializerFactory(IYamlSerializableFactory factory)
 {
     if (factory == null) throw new ArgumentNullException("factory");
     AssemblyRegistry.SerializableFactories.Add(factory);
 }
Esempio n. 8
0
 /// <summary>
 /// Indicates whether the given factory is supported by this selector.
 /// </summary>
 /// <param name="factory">The factory to evaluate.</param>
 /// <returns>True if the factory can be added to this selector, False otherwise.</returns>
 protected abstract bool CanAddSerializerFactory(IYamlSerializableFactory factory);
Esempio n. 9
0
 public void AddSerializerFactory(IYamlSerializableFactory factory)
 {
     factories.Add(factory);
 }
Esempio n. 10
0
 /// <summary>
 /// Registers a factory for <see cref="IYamlSerializable"/>.
 /// </summary>
 /// <param name="serializableFactory">The serializable factory.</param>
 public void Register(IYamlSerializableFactory serializableFactory)
 {
     Serializable.Register(serializableFactory);
 }
 public void AddSerializerFactory(IYamlSerializableFactory factory)
 {
     factories.Add(factory);
 }
        public void Register(IYamlSerializableFactory factory)
        {
            if (factory == null) throw new ArgumentNullException("factory");

            factories.Add(factory);
        }
 /// <summary>
 /// Indicates whether the given factory is supported by this selector.
 /// </summary>
 /// <param name="factory">The factory to evaluate.</param>
 /// <returns>True if the factory can be added to this selector, False otherwise.</returns>
 protected abstract bool CanAddSerializerFactory(IYamlSerializableFactory factory);