コード例 #1
0
ファイル: Serializer.cs プロジェクト: mgagne-atman/Projects
		/// <summary>
		/// Saves the given Model and ActiveRecordMapping to the given files, with specified encoding.
		/// </summary>
		/// <param name="serializationResult">Stores serialization result from the save operation.</param>
		/// <param name="modelRoot">Model instance to be saved.</param>
		/// <param name="modelFileName">Name of the file in which the CanonicalSampleRoot instance will be saved.</param>
		/// <param name="diagram">ActiveRecordMapping to be saved.</param>
		/// <param name="diagramFileName">Name of the file in which the diagram will be saved.</param>
		/// <param name="encoding">Encoding to use when saving the diagram.</param>
		public void SaveModelAndDiagram(DslModeling::SerializationResult serializationResult, 
			DslModeling::ModelElement modelRoot, 
			string modelFileName, 
			DslModeling::ModelElement diagram, 
			string diagramFileName, 
			System.Text.Encoding encoding)
		{
			if (serializationResult == null) { throw new global::System.ArgumentNullException("serializationResult"); }
			if (modelRoot == null) { throw new global::System.ArgumentNullException("modelRoot"); }
			if (string.IsNullOrEmpty("modelFileName")) { throw new global::System.ArgumentNullException("modelFileName"); }
			if (diagram == null) { throw new global::System.ArgumentNullException("diagram"); }
			if (string.IsNullOrEmpty("diagramFileName")) { throw new global::System.ArgumentNullException("diagramFileName"); }
	
			global::Castle.ActiveWriter.Model typedRoot = modelRoot as global::Castle.ActiveWriter.Model;
			if (typedRoot == null)
			{
				string errorMessage = string.Format(global::System.Globalization.CultureInfo.CurrentCulture,
					global::Castle.ActiveWriter.ActiveWriterDomainModel.SingletonResourceManager.GetString("InvalidSaveRootElementType"),
					modelRoot.GetType().ToString());
	
				throw new global::System.ArgumentException(errorMessage, "modelRoot");
			}
			global::Castle.ActiveWriter.ActiveRecordMapping typedDiagram = diagram as global::Castle.ActiveWriter.ActiveRecordMapping;
			if (typedDiagram == null)
			{
				string errorMessage = string.Format(global::System.Globalization.CultureInfo.CurrentCulture,
					global::Castle.ActiveWriter.ActiveWriterDomainModel.SingletonResourceManager.GetString("InvalidSaveDiagramType"),
					diagram.GetType().ToString());
	
				throw new global::System.ArgumentException(errorMessage, "diagram");
			}
	
			ActiveWriterSerializationHelper.Instance.SaveModelAndDiagram(serializationResult, typedRoot, modelFileName, typedDiagram, diagramFileName, encoding, true);
		}
コード例 #2
0
		/// <summary>
		/// Gets the help keyword associated with the given shape or model element instance.
		/// </summary>
		/// <returns>Help keyword, or empty string if there is no associated help keyword.</returns>
		public virtual string GetHelpKeyword(DslModeling::ModelElement modelElement)
		{
			if(modelElement == null) throw new global::System.ArgumentNullException("modelElement");
			
			if(this.helpKeywords == null)
			{
				Initialize();
			}
			
			string helpKeyword;
			if(this.helpKeywords.TryGetValue(modelElement.GetType().FullName, out helpKeyword))
			{
				return helpKeyword;
			}
			
			return string.Empty;
		}
コード例 #3
0
ファイル: Serializer.cs プロジェクト: mgagne-atman/Projects
		/// <summary>
		/// Saves the given model root to the given file, with specified encoding.
		/// </summary>
		/// <param name="serializationResult">Stores serialization result from the save operation.</param>
		/// <param name="modelRoot">Model instance to be saved.</param>
		/// <param name="fileName">Name of the file in which the Model instance will be saved.</param>
		/// <param name="encoding">Encoding to use when saving the Model instance.</param>
		public void SaveModel(DslModeling::SerializationResult serializationResult, 
			DslModeling::ModelElement modelRoot, 
			string fileName, 
			System.Text.Encoding encoding)
		{
			if (serializationResult == null) { throw new global::System.ArgumentNullException("serializationResult"); }
			if (modelRoot == null) { throw new global::System.ArgumentNullException("modelRoot"); }
			if (string.IsNullOrEmpty("fileName")) { throw new global::System.ArgumentNullException("fileName"); }
	
			global::Castle.ActiveWriter.Model rootElement = modelRoot as global::Castle.ActiveWriter.Model;
			if (rootElement == null)
			{
				string errorMessage = string.Format(global::System.Globalization.CultureInfo.CurrentCulture,
					global::Castle.ActiveWriter.ActiveWriterDomainModel.SingletonResourceManager.GetString("InvalidSaveRootElementType"),
					modelRoot.GetType().ToString());
	
				throw new global::System.ArgumentException(errorMessage, "modelRoot");
	
			}
	
			ActiveWriterSerializationHelper.Instance.SaveModel(serializationResult, rootElement, fileName,encoding, true);
		}