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); }
private static DslModeling::ElementLink ConnectServiceContractToService(ServiceContract sourceBeforePathTraverse, Service targetBeforePathTraverse) { DslModeling::ElementLink result = new ServiceReferencesServiceContract(targetBeforePathTraverse, sourceBeforePathTraverse); SetUniqueName(result); return(result); }
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; }
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); } } } }
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; }
/// <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) { }
public static void SetServiceContract(Operation element, ServiceContract newServiceContract) { DslModeling::DomainRoleInfo.SetLinkedElement(element, OperationDomainRoleId, newServiceContract); }
public static void SetServiceContractModel(ServiceContract element, ServiceContractModel newServiceContractModel) { DslModeling::DomainRoleInfo.SetLinkedElement(element, ServiceContractDomainRoleId, newServiceContractModel); }
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(); } }
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; }
/// <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> } } } }
public static DslModeling::LinkedElementCollection<Operation> GetOperations(ServiceContract element) { return GetRoleCollection<DslModeling::LinkedElementCollection<Operation>, Operation>(element, ServiceContractDomainRoleId); }
/// <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) { }
private static DslModeling::ElementLink ConnectServiceToServiceContract(Service sourceBeforePathTraverse, ServiceContract targetBeforePathTraverse) { DslModeling::ElementLink result = new ServiceReferencesServiceContract(sourceBeforePathTraverse, targetBeforePathTraverse); SetUniqueName(result); return result; }