Exemplo n.º 1
0
        private string GetServiceContractName(SCModel.ServiceContract serviceContract)
        {
            if (serviceContract != null &&
                serviceContract.ObjectExtender != null)
            {
                PropertyInfo pi = serviceContract.ObjectExtender.GetType().GetProperty("ServiceContractName");

                if (pi == null)
                {
                    throw new ArgumentNullException(string.Format(
                                                        CultureInfo.CurrentCulture,
                                                        Properties.Resources.ExtenderNotFound,
                                                        serviceContract.GetType().ToString()
                                                        )
                                                    );
                }

                ArtifactLink alink = GetArtifactLink(serviceContract);
                if (alink != null)
                {
                    return(string.Concat(alink.Namespace, ".", pi.GetValue(serviceContract.ObjectExtender, null)));
                }
            }

            return(string.Empty);
        }
Exemplo n.º 2
0
        private static DslModeling::ElementLink ConnectServiceContractToService(ServiceContract sourceBeforePathTraverse, Service targetBeforePathTraverse)
        {
            DslModeling::ElementLink result = new ServiceReferencesServiceContract(targetBeforePathTraverse, sourceBeforePathTraverse);

            SetUniqueName(result);

            return(result);
        }
Exemplo n.º 3
0
        private static DslModeling::ElementLink ConnectServiceContractToOperation(ServiceContract sourceBeforePathTraverse, Operation targetBeforePathTraverse)
        {
            DslModeling::ElementLink result = new ServiceContractReferencesOperations(sourceBeforePathTraverse, targetBeforePathTraverse);

            SetUniqueName(result);

            targetBeforePathTraverse.Action = Operation.BuildDefaultAction(targetBeforePathTraverse);

            return(result);
        }
		public void CanAddStringPrimitiveMessageContractPart()
		{
			ServiceContract serviceContract = new ServiceContract(Store);
			serviceContract.ServiceContractModel = new ServiceContractModel(Store);

			Message message = new Message(Store);
			PrimitiveMessagePart primitiveMessagePart = new PrimitiveMessagePart(Store);
			primitiveMessagePart.Type = typeof(System.String).ToString();

			message.MessageParts.Add(primitiveMessagePart);
			serviceContract.ServiceContractModel.Messages.Add(message);

			Assert.AreEqual<int>(serviceContract.ServiceContractModel.Messages[0].MessageParts.Count, 1);
		}
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            ServiceContract      serviceContract = e.ModelElement as ServiceContract;
            ServiceContractModel root            = serviceContract.ServiceContractModel;

            if (root != null)
            {
                if (root.ImplementationTechnology != null)
                {
                    ExtensionProviderHelper.AttachObjectExtender(serviceContract, root.ImplementationTechnology);
                }

                if (String.IsNullOrEmpty(serviceContract.Namespace))
                {
                    serviceContract.Namespace = root.Namespace;
                }
            }
        }
		public void ReturnSuccessForValidCollection()
		{
			Store store = new Store(new MockServiceProvider(), typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel));
			Partition partition = new Partition(store);

			using(Transaction t = store.TransactionManager.BeginTransaction())
			{
				ServiceContractModel serviceContractModel = new ServiceContractModel(store);
				ServiceContract sc = new ServiceContract(store);

				sc.Operations.Add(new Operation(store));
				serviceContractModel.ServiceContracts.Add(sc);

				NotEmptyOperationCollectionValidator validator = new NotEmptyOperationCollectionValidator();
				ValidationResults validationResults = validator.Validate(sc.Operations);

				Assert.IsTrue(validationResults.IsValid);

				t.Rollback();
			}
		}
		public void CanAddDataContractMessageContractPart()
		{
			ServiceContract serviceContract = new ServiceContract(Store);
			serviceContract.ServiceContractModel = new ServiceContractModel(Store);

			Message message = new Message(Store);
			DataContractMessagePart dcMessagePart = new DataContractMessagePart(Store);

            string moniker = string.Format(@"mel://{0}\{1}\{2}@{3}\{4}",
                dcMessagePart.GetType().Namespace,
                dcMessagePart.GetType().Name,
                dcMessagePart.Id.ToString(),
                dataContractModelProjectName, dataContractModelFileName);

            //dcMessagePart.Type = moniker;

			message.MessageParts.Add(dcMessagePart);
			serviceContract.ServiceContractModel.Messages.Add(message);

			Assert.AreEqual<int>(serviceContract.ServiceContractModel.Messages[0].MessageParts.Count, 1);
		}
		private void CreateHostDesignerModel(ServiceContract sc)
		{
			hdStore = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));
			hdDomainModel = hdStore.GetDomainModel<HostDesignerDomainModel>();
			hdTransaction = hdStore.TransactionManager.BeginTransaction();
			hdModel = (HostDesignerModel)hdDomainModel.CreateElement(new Partition(hdStore), typeof(HostDesignerModel), null);

			HostApplication app = (HostApplication)hdStore.ElementFactory.CreateElement(HostApplication.DomainClassId);

			app.ImplementationTechnology = new HostDesignerWcfExtensionProvider();

			reference = (ServiceReference)hdStore.ElementFactory.CreateElement(ServiceReference.DomainClassId);

			//mel://[DSLNAMESPACE]\[MODELELEMENTTYPE]\[MODELELEMENT.GUID]@[PROJECT]\[MODELFILE]
			string serviceMoniker = string.Format(@"mel://{0}\{1}\{2}@{3}\{4}",
				sc.GetType().Namespace,
				serviceContractName,
				sc.Id.ToString(),
				serviceContractModelProjectName, serviceContractModelFileName);

			reference.Name = serviceMelReferenceName;
            reference.ServiceImplementationType = new MockModelBusReference(sc);

			app.ServiceDescriptions.Add(reference);
		}
		private ServiceContract CreateServiceContract(string name, string ns)
		{
			ServiceContract serviceContract = new ServiceContract(ServiceContractStore);
			serviceContract.Name = name;
			serviceContract.Namespace = ns;
			return serviceContract;
		}
Exemplo n.º 10
0
		private static void ReadServiceContractReferencesOperationsInstances(DslModeling::SerializationContext serializationContext, ServiceContract element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newOperationMonikerOfServiceContractReferencesOperationsSerializer = serializationContext.Directory.GetSerializer(Operation.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newOperationMonikerOfServiceContractReferencesOperationsSerializer != null, "Cannot find serializer for Operation!");
				DslModeling::Moniker newOperationMonikerOfServiceContractReferencesOperations = newOperationMonikerOfServiceContractReferencesOperationsSerializer.TryCreateMonikerInstance(serializationContext, reader, element, ServiceContractReferencesOperations.DomainClassId, element.Partition);
				if (newOperationMonikerOfServiceContractReferencesOperations != null)
				{
					new ServiceContractReferencesOperations(element.Partition, new DslModeling::RoleAssignment(ServiceContractReferencesOperations.ServiceContractDomainRoleId, element), new DslModeling::RoleAssignment(ServiceContractReferencesOperations.OperationDomainRoleId, newOperationMonikerOfServiceContractReferencesOperations));
					DslModeling::SerializationUtilities.Skip(reader);	// Moniker contains no child XML elements, so just skip.
				}
				else
				{
					global::System.Type typeofServiceContractReferencesOperations = typeof(ServiceContractReferencesOperations);
					DslModeling::DomainRelationshipXmlSerializer newServiceContractReferencesOperationsSerializer = serializationContext.Directory.GetSerializer(ServiceContractReferencesOperations.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer;
					global::System.Diagnostics.Debug.Assert(newServiceContractReferencesOperationsSerializer != null, "Cannot find serializer for ServiceContractReferencesOperations!");
					ServiceContractReferencesOperations newServiceContractReferencesOperations = newServiceContractReferencesOperationsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as ServiceContractReferencesOperations;
					if (newServiceContractReferencesOperations != null)
					{
						if (newServiceContractReferencesOperations.GetType() == typeofServiceContractReferencesOperations)
						{	// The relationship should be serialized in short-form.
							ServiceContractDslSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(ServiceContractReferencesOperations));
						}
						DslModeling::DomainRoleInfo.SetRolePlayer (newServiceContractReferencesOperations, ServiceContractReferencesOperations.ServiceContractDomainRoleId, element);
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newServiceContractReferencesOperations.GetDomainClass().Id);	
						global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newServiceContractReferencesOperations.GetDomainClass().Name + "!");
						targetSerializer.Read(serializationContext, newServiceContractReferencesOperations, reader);
					}
					else
					{	// Unknown element, skip
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
Exemplo n.º 11
0
		private static DslModeling::ElementLink ConnectOperationToServiceContract(Operation sourceBeforePathTraverse, ServiceContract targetBeforePathTraverse)
		{
			DslModeling::ElementLink result = new ServiceContractReferencesOperations(targetBeforePathTraverse, sourceBeforePathTraverse);

			SetUniqueName(result);

			sourceBeforePathTraverse.Action = Operation.BuildDefaultAction(sourceBeforePathTraverse);

			return result;
		}
		private ServiceContract CreateRoot(string name, string ns)
		{
			ServiceContract rootElement = new ServiceContract(Store);
			rootElement.ServiceContractModel = new ServiceContractModel(Store);
			rootElement.Name = name;
			rootElement.Namespace = ns;
			rootElement.ServiceContractModel.ProjectMappingTable = "WCF";
			dataContractStore = new Store(ServiceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(DataContractDslDomainModel));
			ResolveModelElement("foo");
			return rootElement;
		}
Exemplo n.º 13
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)
		{
		}
Exemplo n.º 14
0
		public static void SetServiceContract(Operation element, ServiceContract newServiceContract)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, OperationDomainRoleId, newServiceContract);
		}
Exemplo n.º 15
0
		public static void SetServiceContractModel(ServiceContract element, ServiceContractModel newServiceContractModel)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ServiceContractDomainRoleId, newServiceContractModel);
		}
Exemplo n.º 16
0
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, ServiceContract element, global::System.Xml.XmlWriter writer)
		{
			// ServiceContractReferencesOperations
			global::System.Collections.ObjectModel.ReadOnlyCollection<ServiceContractReferencesOperations> allServiceContractReferencesOperationsInstances = ServiceContractReferencesOperations.GetLinksToOperations(element);
			if (!serializationContext.Result.Failed && allServiceContractReferencesOperationsInstances.Count > 0)
			{
				DslModeling::DomainRelationshipXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(ServiceContractReferencesOperations.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer;
				global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for ServiceContractReferencesOperations!");
	
				writer.WriteStartElement("operations");
				global::System.Type typeofServiceContractReferencesOperations = typeof(ServiceContractReferencesOperations);
				foreach (ServiceContractReferencesOperations eachServiceContractReferencesOperationsInstance in allServiceContractReferencesOperationsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					if (eachServiceContractReferencesOperationsInstance.GetType() != typeofServiceContractReferencesOperations)
					{	// Derived relationships will be serialized in full-form.
						DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachServiceContractReferencesOperationsInstance.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachServiceContractReferencesOperationsInstance.GetDomainClass().Name + "!");			
						derivedRelSerializer.Write(serializationContext, eachServiceContractReferencesOperationsInstance, writer);
					}
					else
					{	// No need to serialize the relationship itself, just serialize the role-player directly.
						DslModeling::ModelElement targetElement = eachServiceContractReferencesOperationsInstance.Operation;
						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();
			}
	
		}
Exemplo n.º 17
0
		public static ServiceContractModel GetServiceContractModel(ServiceContract element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, ServiceContractDomainRoleId) as ServiceContractModel;
		}
		private ServiceContract CreateServiceContract(
			ServiceContractModel model,string serviceContractName, string operationName, string requestName, string responseName)
		{
			ServiceContract serviceContract = new ServiceContract(Store);
			serviceContract.ServiceContractModel = model;
			serviceContract.Name = serviceContractName;
			WCFServiceContract serviceContractExtender = new WCFServiceContract();
			serviceContractExtender.ModelElement = serviceContract;
			serviceContract.ObjectExtender = serviceContractExtender;

			Operation op1 = new Operation(Store);
			WCFOperationContract wcfOp1 = new WCFOperationContract();
			op1.ObjectExtender = wcfOp1;
			op1.Name = operationName;
			op1.Action = operationName;
			op1.Request = string.IsNullOrEmpty(requestName) ? null : CreateMessageContract(requestName);
			op1.Response = string.IsNullOrEmpty(responseName) ? null : CreateMessageContract(responseName);
			op1.ServiceContract = serviceContract;

			return serviceContract;
		}
		private ServiceContract CreateServiceContract(
			string serviceContractName, string operationName, string requestName, string responseName)
		{
			ServiceContract serviceContract = new ServiceContract(Store);
			serviceContract.Name = serviceContractName;
			Operation op1 = new Operation(Store);
			op1.Name = operationName;
			op1.Action = operationName;
			op1.Request = string.IsNullOrEmpty(requestName) ? null : CreateMessage(requestName);
			op1.Response = string.IsNullOrEmpty(responseName) ? null : CreateMessage(responseName);
			op1.ServiceContract = serviceContract;

			return serviceContract;
		}
Exemplo n.º 20
0
		/// <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 ServiceContract instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, ServiceContract element, global::System.Xml.XmlReader reader)
		{
			if (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				if (string.Compare(reader.LocalName, "operations", global::System.StringComparison.CurrentCulture) == 0)
				{
					if (reader.IsEmptyElement)
					{	// No instance of this relationship, just skip
						DslModeling::SerializationUtilities.Skip(reader);
					}
					else
					{
						DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <operations>
						ReadServiceContractReferencesOperationsInstances(serializationContext, element, reader);
						DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </operations>
					}
				}
			}
		}
Exemplo n.º 21
0
		public static DslModeling::LinkedElementCollection<Operation> GetOperations(ServiceContract element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<Operation>, Operation>(element, ServiceContractDomainRoleId);
		}
Exemplo n.º 22
0
		/// <summary>
		/// Constructor
		/// Creates a ServiceContractModelHasServiceContracts link in the same Partition as the given ServiceContractModel
		/// </summary>
		/// <param name="source">ServiceContractModel to use as the source of the relationship.</param>
		/// <param name="target">ServiceContract to use as the target of the relationship.</param>
		public ServiceContractModelHasServiceContracts(ServiceContractModel source, ServiceContract target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ServiceContractModelHasServiceContracts.ServiceContractModelDomainRoleId, source), new DslModeling::RoleAssignment(ServiceContractModelHasServiceContracts.ServiceContractDomainRoleId, target)}, null)
		{
		}
Exemplo n.º 23
0
		private static DslModeling::ElementLink ConnectServiceToServiceContract(Service sourceBeforePathTraverse, ServiceContract targetBeforePathTraverse)
		{
			DslModeling::ElementLink result = new ServiceReferencesServiceContract(sourceBeforePathTraverse, targetBeforePathTraverse);

			SetUniqueName(result);

			return result;
		}