Exemplo n.º 1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ContentSerializableAttribute" /> class.
 /// </summary>
 /// <param name="reader">
 ///     the content reader type
 ///     <see cref="T:Exomia.Framework.ContentSerialization.IContentSerializationReader" />
 /// </param>
 /// <param name="writer">
 ///     the content writer type
 ///     <see cref="T:Exomia.Framework.ContentSerialization.IContentSerializationWriter" />
 /// </param>
 /// <exception cref="TypeLoadException"> Thrown when a Type Load error condition occurs. </exception>
 public ContentSerializableAttribute(Type reader, Type writer)
 {
     Reader = System.Activator.CreateInstance(reader) as IContentSerializationReader ??
              throw new TypeLoadException(
                        "cannot create an instance of IContentSerializationReader from type: " +
                        reader.AssemblyQualifiedName);
     Writer = System.Activator.CreateInstance(writer) as IContentSerializationWriter ??
              throw new TypeLoadException(
                        "cannot create an instance of IContentSerializationWriter from type: " +
                        writer.AssemblyQualifiedName);
 }
Exemplo n.º 2
0
 /// <summary>
 ///     Adds a new <see cref="IContentSerializationWriter" /> to the content pipeline.
 /// </summary>
 /// <param name="type">   The type the writer can write. </param>
 /// <param name="writer"> The <see cref="IContentSerializationWriter" />. </param>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <exception cref="CSWriterException">     Thrown when a Create struct Writer error condition occurs. </exception>
 public static void AddWriter(Type type, IContentSerializationWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException(nameof(writer));
     }
     if (!s_contentPipeLineWriters.ContainsKey(type))
     {
         s_contentPipeLineWriters.Add(type, writer);
         return;
     }
     throw new CSWriterException(
               "The content pipeline has already registered a writer of the type: '" + type + "'");
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Adds a new content pipeline writer to the content pipeline.
 /// </summary>
 /// <typeparam name="T"> Generic type parameter. </typeparam>
 /// <param name="writer"> The <see cref="IContentSerializationWriter" />. </param>
 public static void AddWriter <T>(IContentSerializationWriter writer)
 {
     AddWriter(typeof(T), writer);
 }