Exemplo n.º 1
0
 ///-------------------------------------------------------------------------------------------------
 /// <summary>
 ///  true this instance to the given stream.
 /// </summary>
 /// <param name="stream">
 ///  The stream.
 /// </param>
 /// <param name="domain">
 ///  The domain.
 /// </param>
 /// <param name="option">
 ///  (Optional) the option.
 /// </param>
 ///-------------------------------------------------------------------------------------------------
 public static void Serialize(Stream stream, IDomainModel domain, JSonSerializationOption option = JSonSerializationOption.Json)
 {
     using (var sw = new StreamWriter(stream))
     {
         var ser = new JSonSerializer(sw, new JSonSerializationSettings {
             Options = option
         });
         ser.Serialize(domain.GetElements());
     }
 }
Exemplo n.º 2
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  true this instance to the given stream.
        /// </summary>
        /// <param name="elements">
        ///  The elements.
        /// </param>
        /// <param name="settings">
        ///  Options for controlling the operation.
        /// </param>
        /// <returns>
        ///  A string.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        public static string Serialize(IEnumerable <IModelElement> elements, JSonSerializationSettings settings)
        {
            Contract.Requires(elements, "elements");
            Contract.Requires(settings, "settings");

            StringBuilder sb  = new StringBuilder(256);
            StringWriter  sw  = new StringWriter(sb, CultureInfo.InvariantCulture);
            var           ser = new JSonSerializer(sw, settings);

            ser.Serialize(elements);
            return(sw.ToString());
        }