Ejemplo n.º 1
0
        private JSonSerializer(TextWriter writer, JSonSerializationSettings settings = null)
        {
            Contract.Requires(writer, "writer");

            _writer  = writer;
            _options = JSonSerializationOption.Json;
            if (settings != null)
            {
                _options    = settings.Options;
                _serializer = settings.Serializer;
                _schema     = settings.Schema;
            }

            if (((int)_options & 32) != 0) // Hyperstore guard
            {
                _options |= JSonSerializationOption.Hyperstore;
            }
            else
            {
                if (((int)_options & 256) == 0)
                {
                    throw new ArgumentException("Either Json or Hyperstore format must be set in the option parameter");
                }
            }
        }
Ejemplo n.º 2
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());
     }
 }
Ejemplo n.º 3
0
 private bool HasOption(JSonSerializationOption option)
 {
     return((_options & option) == option);
 }
Ejemplo n.º 4
0
 ///-------------------------------------------------------------------------------------------------
 /// <summary>
 ///  true this instance to the given stream.
 /// </summary>
 /// <param name="mel">
 ///  The mel.
 /// </param>
 /// <param name="option">
 ///  (Optional) the option.
 /// </param>
 /// <returns>
 ///  A string.
 /// </returns>
 ///-------------------------------------------------------------------------------------------------
 public static string Serialize(IModelElement mel, JSonSerializationOption option = JSonSerializationOption.Json)
 {
     return(Serialize(mel, new JSonSerializationSettings {
         Options = option
     }));
 }
Ejemplo n.º 5
0
 ///-------------------------------------------------------------------------------------------------
 /// <summary>
 ///  true this instance to the given stream.
 /// </summary>
 /// <param name="elements">
 ///  The elements.
 /// </param>
 /// <param name="option">
 ///  (Optional) the option.
 /// </param>
 /// <returns>
 ///  A string.
 /// </returns>
 ///-------------------------------------------------------------------------------------------------
 public static string Serialize(IEnumerable <IModelElement> elements, JSonSerializationOption option = JSonSerializationOption.Json)
 {
     return(Serialize(elements, new JSonSerializationSettings {
         Options = option
     }));
 }
Ejemplo n.º 6
0
 ///-------------------------------------------------------------------------------------------------
 /// <summary>
 ///  Serialize a domain with the sepecified options
 /// </summary>
 /// <param name="domain">
 ///  Domain to serialize
 /// </param>
 /// <param name="option">
 ///  (Optional) the option.
 /// </param>
 /// <returns>
 ///  A string.
 /// </returns>
 ///-------------------------------------------------------------------------------------------------
 public static string Serialize(IDomainModel domain, JSonSerializationOption option = JSonSerializationOption.Json)
 {
     return(Serialize(domain, new JSonSerializationSettings {
         Options = option
     }));
 }