///------------------------------------------------------------------------------------------------- /// <summary> /// true this instance to the given stream. /// </summary> /// <param name="stream"> /// The stream. /// </param> /// <param name="domain"> /// The domain. /// </param> /// <param name="settings"> /// (Optional) options for controlling the operation. /// </param> /// <param name="elements"> /// (Optional) the elements. /// </param> ///------------------------------------------------------------------------------------------------- public static void Serialize(Stream stream, IDomainModel domain, SerializationSettings settings = null, IEnumerable <IModelElement> elements = null) { Contract.Requires(stream, "stream"); Contract.Requires(domain, "domain"); if (settings == null) { settings = new SerializationSettings(); } var ser = new HyperstoreSerializer(domain, settings); ser.Serialize(stream, elements != null ? elements.OfType <IModelEntity>() : domain.GetEntities(), elements != null ? elements.OfType <IModelRelationship>() : domain.GetRelationships()); }