Exemplo n.º 1
0
        /// <summary>
        /// Maps all C# keywords base types and its nullable counter parts.
        /// 'int', 'string', 'bool', 'long', 'double', 'decimal' and all these with '?'.
        /// </summary>
        /// <param name="collection">Target collection of mappings.</param>
        /// <returns>Modified <paramref name="collection"/>.</returns>
        public static XmlTypeMappingCollection AddStandartKeywords(this XmlTypeMappingCollection collection)
        {
            Ensure.NotNull(collection, "collection");
            return(collection
                   .Add("string", typeof(String))
                   .Add("int", typeof(Int32))
                   .Add("bool", typeof(Boolean))
                   .Add("long", typeof(Int64))
                   .Add("double", typeof(Double))
                   .Add("decimal", typeof(Decimal))

                   .Add("int?", typeof(Int32?))
                   .Add("bool?", typeof(Boolean?))
                   .Add("long?", typeof(Int64?))
                   .Add("double?", typeof(Double?))
                   .Add("decimal?", typeof(Decimal?)));
        }
 /// <summary>
 /// Creates new instance with type name mappings.
 /// </summary>
 /// <param name="typeMappings">Type name mappings between XML file and .NET type system.</param>
 public XmlModelDefinitionSerializer(XmlTypeMappingCollection typeMappings)
 {
     Ensure.NotNull(typeMappings, "typeMappings");
     this.typeMappings = typeMappings;
 }
 /// <summary>
 /// Creates new instance of model definition builder from XML content.
 /// </summary>
 /// <param name="typeMappings">Collection of type name mappings.</param>
 /// <param name="contentFactory">Source XML activator.</param>
 public XmlModelDefinitionBuilder(XmlTypeMappingCollection typeMappings, IFactory <Stream> contentFactory)
 {
     Ensure.NotNull(contentFactory, "contentFactory");
     this.factory        = new XmlModelDefinitionFactory(typeMappings);
     this.contentFactory = contentFactory;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Maps XML name <paramref name="xmlName"/> to the .NET type <typeparamref name="T"/> and vice versa.
 /// </summary>
 /// <typeparam name="T">.NET type.</typeparam>
 /// <param name="collection">Target collection of mappings.</param>
 /// <param name="xmlName">XML type name.</param>
 /// <returns>Self (for fluency).</returns>
 public static XmlTypeMappingCollection Add <T>(this XmlTypeMappingCollection collection, string xmlName)
 {
     Ensure.NotNull(collection, "collection");
     return(collection.Add(xmlName, typeof(T)));
 }