/// <summary>
		/// Return the model in XML format
		/// </summary>
		/// <param name="modelRoot">Root instance to be saved.</param>
		/// <param name="encoding">Encoding to use when saving the root instance.</param>
		/// <param name="serializationMode">Serialization Mode.</param>
		/// <returns>Model in XML form</returns>
		public virtual string GetSerializedModelStringVarianten(global::Tum.VModellXT.Varianten modelRoot, global::System.Text.Encoding encoding, DslEditorModeling.SerializationMode serializationMode)
		{
			string result = string.Empty;
			if (modelRoot == null)
			{
				return result;
			}
	
	        //DslEditorModeling::DomainModelStore dStore = (DslEditorModeling::DomainModelStore)modelRoot.Store;
            //if( dStore == null)
            //    throw new global::System.ArgumentNullException("dStore");
				
			//dStore.WaitForWritingLockRelease();
	
			DslModeling::SerializationResult serializationResult = new DslModeling::SerializationResult();
			using (global::System.IO.MemoryStream modelFileContent = this.InternalSaveModelVarianten(serializationResult, modelRoot, string.Empty, encoding, false, serializationMode))
			{
				if (!serializationResult.Failed && modelFileContent != null)
				{
					char[] chars = encoding.GetChars(modelFileContent.GetBuffer());
	
					// search the open angle bracket and trim off the Byte Of Mark.
					result = new string( chars);
					int indexPos = result.IndexOf('<');
					if (indexPos > 0)
					{
						// strip off the leading Byte Of Mark.
						result = result.Substring(indexPos);
					}
	
					// trim off trailing 0s.
					result = result.TrimEnd( '\0');
				}
			}
			return result;
		}
Exemplo n.º 2
0
		/// <summary>
		/// Return the model in XML format
		/// </summary>
		/// <param name="modelRoot">Root instance to be saved.</param>
		/// <param name="encoding">Encoding to use when saving the root instance.</param>
		/// <returns>Model in XML form</returns>
		public virtual string GetSerializedModelString(global::Microsoft.Practices.ServiceFactory.HostDesigner.HostDesignerModel modelRoot, global::System.Text.Encoding encoding)
		{
			string result = string.Empty;
			if (modelRoot == null)
			{
				return result;
			}
	
			DslModeling::SerializationResult serializationResult = new DslModeling::SerializationResult();
			using (global::System.IO.MemoryStream modelFileContent = this.InternalSaveModel(serializationResult, modelRoot, string.Empty, encoding, false))
			{
				if (!serializationResult.Failed && modelFileContent != null)
				{
					char[] chars = encoding.GetChars(modelFileContent.GetBuffer());
	
					// search the open angle bracket and trim off the Byte Of Mark.
					result = new string( chars);
					int indexPos = result.IndexOf('<');
					if (indexPos > 0)
					{
						// strip off the leading Byte Of Mark.
						result = result.Substring(indexPos);
					}
	
					// trim off trailing 0s.
					result = result.TrimEnd( '\0');
				}
			}
			return result;
		}