public void TestInitialize()
        {
            serviceProvider = new MockMappingServiceProvider();

			attributes = new NameValueCollection();
			attributes.Add("elementNameProperty", "Name");

            #region Data Contract
            dcStore = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(DataContractDslDomainModel));
            dcDomainModel = dcStore.GetDomainModel<DataContractDslDomainModel>();
            dcTransaction = dcStore.TransactionManager.BeginTransaction();
            dcModel = (DataContractModel)dcDomainModel.CreateElement(new Partition(dcStore), typeof(DataContractModel), null);
            dcModel.ProjectMappingTable = projectMappingTableName;
            fc = dcStore.ElementFactory.CreateElement(FaultContract.DomainClassId) as FaultContract;
            fc.Name = faultContractName;
			dcModel.Contracts.Add(fc);
            #endregion

			#region Service Contract
			scStore = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel));
			scDomainModel = scStore.GetDomainModel<ServiceContractDslDomainModel>();
			scTransaction = scStore.TransactionManager.BeginTransaction();
			scModel = (ServiceContractModel)scDomainModel.CreateElement(new Partition(scStore), typeof(ServiceContractModel), null);
			scModel.ProjectMappingTable = projectMappingTableName;
            operation = scStore.ElementFactory.CreateElement(Operation.DomainClassId) as Operation;
            operation.Name = operationName;

            //Create the moniker
            //mel://[DSLNAMESPACE]\[MODELELEMENTTYPE]\[MODELELEMENT.GUID]@[PROJECT]\[MODELFILE]
            string requestMoniker = string.Format(@"mel://{0}\{1}\{2}@{3}\{4}",
                fc.GetType().Namespace,
                fc.GetType().Name,
                fc.Id.ToString(),
                dataContractModelProjectName, dataContractModelFileName);

            dcfault = scStore.ElementFactory.CreateElement(DataContractFault.DomainClassId) as DataContractFault;
			dcfault.Name = dcfaultName;
            dcfault.Type = new MockModelBusReference(fc);
            
            operation.Faults.Add(dcfault);
			scModel.Operations.Add(operation);
            #endregion
        }
コード例 #2
0
		private Operation CreateOperationContract(string name)
		{
			Operation operation = new Operation(ServiceContractStore);
			operation.Name = name;
			return operation;
		}
コード例 #3
0
		public static void SetServiceContract(Operation element, ServiceContract newServiceContract)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, OperationDomainRoleId, newServiceContract);
		}
コード例 #4
0
		/// <summary>
		/// Constructor
		/// Creates a ServiceContractReferencesOperations link in the same Partition as the given ServiceContract
		/// </summary>
		/// <param name="source">ServiceContract to use as the source of the relationship.</param>
		/// <param name="target">Operation to use as the target of the relationship.</param>
		public ServiceContractReferencesOperations(ServiceContract source, Operation target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ServiceContractReferencesOperations.ServiceContractDomainRoleId, source), new DslModeling::RoleAssignment(ServiceContractReferencesOperations.OperationDomainRoleId, target)}, null)
		{
		}
コード例 #5
0
		public static ServiceContract GetServiceContract(Operation element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, OperationDomainRoleId) as ServiceContract;
		}
コード例 #6
0
		public static MessageBase GetResponse(Operation element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, OperationDomainRoleId) as MessageBase;
		}
コード例 #7
0
		public static void SetResponse(Operation element, MessageBase newMessageBase)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, OperationDomainRoleId, newMessageBase);
		}
コード例 #8
0
		/// <summary>
		/// Constructor
		/// Creates a RequestReferencedByOperation link in the same Partition as the given MessageBase
		/// </summary>
		/// <param name="source">MessageBase to use as the source of the relationship.</param>
		/// <param name="target">Operation to use as the target of the relationship.</param>
		public RequestReferencedByOperation(MessageBase source, Operation target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(RequestReferencedByOperation.MessageBaseDomainRoleId, source), new DslModeling::RoleAssignment(RequestReferencedByOperation.OperationDomainRoleId, target)}, null)
		{
		}
コード例 #9
0
		/// <summary>
		/// Constructor
		/// Creates a OperationReferencesResponse link in the same Partition as the given Operation
		/// </summary>
		/// <param name="source">Operation to use as the source of the relationship.</param>
		/// <param name="target">MessageBase to use as the target of the relationship.</param>
		public OperationReferencesResponse(Operation source, MessageBase target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(OperationReferencesResponse.OperationDomainRoleId, source), new DslModeling::RoleAssignment(OperationReferencesResponse.MessageBaseDomainRoleId, target)}, null)
		{
		}
コード例 #10
0
		public static void SetOperation(Fault element, Operation newOperation)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, FaultDomainRoleId, newOperation);
		}
コード例 #11
0
		public static DslModeling::LinkedElementCollection<Fault> GetFaults(Operation element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<Fault>, Fault>(element, OperationDomainRoleId);
		}
コード例 #12
0
		/// <summary>
		/// Constructor
		/// Creates a OperationHasFaults link in the same Partition as the given Operation
		/// </summary>
		/// <param name="source">Operation to use as the source of the relationship.</param>
		/// <param name="target">Fault to use as the target of the relationship.</param>
		public OperationHasFaults(Operation source, Fault target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(OperationHasFaults.OperationDomainRoleId, source), new DslModeling::RoleAssignment(OperationHasFaults.FaultDomainRoleId, target)}, null)
		{
		}
コード例 #13
0
ファイル: Serializer.cs プロジェクト: Phidiax/open-wssf-2015
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, Operation element, global::System.Xml.XmlWriter writer)
		{
			// OperationHasFaults
			global::System.Collections.ObjectModel.ReadOnlyCollection<OperationHasFaults> allOperationHasFaultsInstances = OperationHasFaults.GetLinksToFaults(element);
			if (!serializationContext.Result.Failed && allOperationHasFaultsInstances.Count > 0)
			{
				writer.WriteStartElement("faults");
				global::System.Type typeofOperationHasFaults = typeof(OperationHasFaults);
				foreach (OperationHasFaults eachOperationHasFaultsInstance in allOperationHasFaultsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					if (eachOperationHasFaultsInstance.GetType() != typeofOperationHasFaults)
					{	// Derived relationships will be serialized in full-form.
						DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachOperationHasFaultsInstance.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachOperationHasFaultsInstance.GetDomainClass().Name + "!");			
						derivedRelSerializer.Write(serializationContext, eachOperationHasFaultsInstance, writer);
					}
					else
					{	// No need to serialize the relationship itself, just serialize the role-player directly.
						DslModeling::ModelElement targetElement = eachOperationHasFaultsInstance.Fault;
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer(targetElement.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(targetSerializer != null, "Cannot find serializer for " + targetElement.GetDomainClass().Name + "!");			
						targetSerializer.Write(serializationContext, targetElement, writer);
					}
				}
				writer.WriteEndElement();
			}
	
			// OperationReferencesResponse
			OperationReferencesResponse theOperationReferencesResponseInstance = OperationReferencesResponse.GetLinkToResponse(element);
			if (!serializationContext.Result.Failed && theOperationReferencesResponseInstance != null)
			{
				DslModeling::DomainRelationshipXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(OperationReferencesResponse.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer;
				global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for OperationReferencesResponse!");
	
				writer.WriteStartElement("response");
				global::System.Type typeofOperationReferencesResponse = typeof(OperationReferencesResponse);
				if (theOperationReferencesResponseInstance.GetType() != typeofOperationReferencesResponse)
				{	// Derived relationships will be serialized in full-form.
					DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(theOperationReferencesResponseInstance.GetDomainClass().Id);
					global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + theOperationReferencesResponseInstance.GetDomainClass().Name + "!");			
					derivedRelSerializer.Write(serializationContext, theOperationReferencesResponseInstance, writer);
				}
				else
				{	// No need to serialize the relationship itself, just serialize the role-player directly.
					DslModeling::ModelElement targetElement = theOperationReferencesResponseInstance.MessageBase;
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer(targetElement.GetDomainClass().Id);
					global::System.Diagnostics.Debug.Assert(targetSerializer != null, "Cannot find serializer for " + targetElement.GetDomainClass().Name + "!");			
					targetSerializer.WriteMoniker(serializationContext, targetElement, writer, element, relSerializer);
				}
				writer.WriteEndElement();
			}
	
		}
コード例 #14
0
ファイル: Serializer.cs プロジェクト: Phidiax/open-wssf-2015
		private static void ReadOperationReferencesResponseInstance(DslModeling::SerializationContext serializationContext, Operation element, global::System.Xml.XmlReader reader)
		{
			if (DslModeling::DomainRoleInfo.GetElementLinks<OperationReferencesResponse> (element, OperationReferencesResponse.OperationDomainRoleId).Count > 0)
			{	// Only allow one instance, which already exists, so skip everything
				DslModeling::SerializationUtilities.Skip(reader);	// Moniker contains no child XML elements, so just skip.
				return;
			}
	
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newMessageBaseMonikerOfOperationReferencesResponseSerializer = serializationContext.Directory.GetSerializer(MessageBase.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newMessageBaseMonikerOfOperationReferencesResponseSerializer != null, "Cannot find serializer for MessageBase!");
				DslModeling::Moniker newMessageBaseMonikerOfOperationReferencesResponse = newMessageBaseMonikerOfOperationReferencesResponseSerializer.TryCreateMonikerInstance(serializationContext, reader, element, OperationReferencesResponse.DomainClassId, element.Partition);
				if (newMessageBaseMonikerOfOperationReferencesResponse != null)
				{
					new OperationReferencesResponse(element.Partition, new DslModeling::RoleAssignment(OperationReferencesResponse.OperationDomainRoleId, element), new DslModeling::RoleAssignment(OperationReferencesResponse.MessageBaseDomainRoleId, newMessageBaseMonikerOfOperationReferencesResponse));
					DslModeling::SerializationUtilities.Skip(reader);	// Moniker contains no child XML elements, so just skip.
					break;	// Only allow one instance.
				}
				else
				{
					global::System.Type typeofOperationReferencesResponse = typeof(OperationReferencesResponse);
					DslModeling::DomainRelationshipXmlSerializer newOperationReferencesResponseSerializer = serializationContext.Directory.GetSerializer(OperationReferencesResponse.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer;
					global::System.Diagnostics.Debug.Assert(newOperationReferencesResponseSerializer != null, "Cannot find serializer for OperationReferencesResponse!");
					OperationReferencesResponse newOperationReferencesResponse = newOperationReferencesResponseSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as OperationReferencesResponse;
					if (newOperationReferencesResponse != null)
					{
						if (newOperationReferencesResponse.GetType() == typeofOperationReferencesResponse)
						{	// The relationship should be serialized in short-form.
							ServiceContractDslSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(OperationReferencesResponse));
						}
						DslModeling::DomainRoleInfo.SetRolePlayer (newOperationReferencesResponse, OperationReferencesResponse.OperationDomainRoleId, element);
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newOperationReferencesResponse.GetDomainClass().Id);	
						global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newOperationReferencesResponse.GetDomainClass().Name + "!");
						targetSerializer.Read(serializationContext, newOperationReferencesResponse, reader);
						break;	// Only allow one instance.
					}
					else
					{	// Unknown element, skip
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
コード例 #15
0
ファイル: Serializer.cs プロジェクト: Phidiax/open-wssf-2015
		/// <summary>
		/// Reads all instances of relationship OperationHasFaults.
		/// </summary>
		/// <remarks>
		/// The caller will position the reader at the open tag of the first XML element inside the relationship tag, so it can be
		/// either the first instance, or a bogus tag. This method will deserialize all instances and ignore all bogus tags. When the
		/// method returns, the reader will be positioned at the end tag of the relationship (or EOF if somehow that happens).
		/// </remarks>
		/// <param name="serializationContext">Serialization context.</param>
		/// <param name="element">In-memory Operation instance that will get the deserialized data.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		private static void ReadOperationHasFaultsInstances(DslModeling::SerializationContext serializationContext, Operation element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newFaultOfOperationHasFaultsSerializer = serializationContext.Directory.GetSerializer(Fault.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newFaultOfOperationHasFaultsSerializer != null, "Cannot find serializer for Fault!");
				Fault newFaultOfOperationHasFaults = newFaultOfOperationHasFaultsSerializer.TryCreateInstance(serializationContext, reader, element.Partition) as Fault;
				if (newFaultOfOperationHasFaults != null)
				{
					element.Faults.Add(newFaultOfOperationHasFaults);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newFaultOfOperationHasFaults.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newFaultOfOperationHasFaults.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newFaultOfOperationHasFaults, reader);
				}
				else
				{
					global::System.Type typeofOperationHasFaults = typeof(OperationHasFaults);
					DslModeling::DomainRelationshipXmlSerializer newOperationHasFaultsSerializer = serializationContext.Directory.GetSerializer(OperationHasFaults.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer;
					global::System.Diagnostics.Debug.Assert(newOperationHasFaultsSerializer != null, "Cannot find serializer for OperationHasFaults!");
					OperationHasFaults newOperationHasFaults = newOperationHasFaultsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as OperationHasFaults;
					if (newOperationHasFaults != null)
					{
						if (newOperationHasFaults.GetType() == typeofOperationHasFaults)
						{	// The relationship should be serialized in short-form.
							ServiceContractDslSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(OperationHasFaults));
						}
						DslModeling::DomainRoleInfo.SetRolePlayer (newOperationHasFaults, OperationHasFaults.OperationDomainRoleId, element);
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newOperationHasFaults.GetDomainClass().Id);	
						global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newOperationHasFaults.GetDomainClass().Name + "!");
						targetSerializer.Read(serializationContext, newOperationHasFaults, reader);
					}
					else
					{	// Unknown element, skip
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
コード例 #16
0
ファイル: Serializer.cs プロジェクト: Phidiax/open-wssf-2015
		/// <summary>
		/// This method deserializes all child model elements.
		/// </summary>
		/// <remarks>
		/// The caller will position the reader at the open tag of the first child XML element to deserialized.
		/// This method will read as many child elements as it can. It returns under three circumstances:
		/// 1) When an unknown child XML element is encountered. In this case, this method will position the reader at the 
		///    open tag of the unknown element. This implies that if the first child XML element is unknown, this method 
		///    should return immediately and do nothing.
		/// 2) When all child XML elemnets are read. In this case, the reader will be positioned at the end tag of the parent element.
		/// 3) EOF.
		/// </remarks>
		/// <param name="serializationContext">Serialization context.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		/// <param name="element">In-memory Operation instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, Operation element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				switch (reader.LocalName)
				{
					case "faults":	// Relationship "OperationHasFaults"
						if (reader.IsEmptyElement)
						{	// No instance of this relationship, just skip
							DslModeling::SerializationUtilities.Skip(reader);
						}
						else
						{
							DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <faults>
							ReadOperationHasFaultsInstances(serializationContext, element, reader);
							DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </faults>
						}
						break;
					case "response":	// Relationship "OperationReferencesResponse"
						if (reader.IsEmptyElement)
						{	// No instance of this relationship, just skip
							DslModeling::SerializationUtilities.Skip(reader);
						}
						else
						{
							DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <response>
							ReadOperationReferencesResponseInstance(serializationContext, element, reader);
							DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </response>
						}
						break;
					default:
						return;  // Don't know this element.
				}
			}
		}