public override void ElementAdded(ElementAddedEventArgs e) { Message messageContract = e.ModelElement as Message; ServiceContractModel root = messageContract.ServiceContractModel; if (root != null && root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(messageContract, root.ImplementationTechnology); } }
public override void ElementAdded(ElementAddedEventArgs e) { PrimitiveMessagePart messagePart = e.ModelElement as PrimitiveMessagePart; if (messagePart.Message != null) { ServiceContractModel root = messagePart.Message.ServiceContractModel; if (root != null && root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(messagePart, root.ImplementationTechnology); } } }
public override void ElementAdded(ElementAddedEventArgs e) { MessageBase contract = e.ModelElement as MessageBase; ServiceContractModel root = contract.ServiceContractModel; if (root != null) { if (String.IsNullOrEmpty(contract.Namespace)) { contract.Namespace = root.Namespace; } } }
public override void ElementAdded(ElementAddedEventArgs e) { XsdElementFault fault = e.ModelElement as XsdElementFault; if (fault.Operation != null) { ServiceContractModel root = fault.Operation.ServiceContractModel; if (root != null && root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(fault, root.ImplementationTechnology); } } }
public override void ElementAdded(ElementAddedEventArgs e) { Operation operation = e.ModelElement as Operation; ServiceContractModel root = operation.ServiceContractModel; if (root != null && root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(operation, root.ImplementationTechnology); } if (String.IsNullOrEmpty(operation.Action)) { operation.Action = Operation.BuildDefaultAction(operation); } }
private ServiceContract CreateServiceContractModel() { 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.ImplementationTechnology = new ServiceContractWCFExtensionProvider(); scModel.ProjectMappingTable = projectMappingTableName; ServiceContract sc = scStore.ElementFactory.CreateElement(ServiceContract.DomainClassId) as ServiceContract; sc.Name = serviceContractName; scModel.ServiceContracts.Add(sc); return sc; }
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; dc = dcStore.ElementFactory.CreateElement(DataContract.DomainClassId) as DataContract; primitiveDataElement = dcStore.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType; primitiveDataElement.Name = primitiveDataElementName; dc.DataMembers.Add(primitiveDataElement); dcModel.Contracts.Add(dc); #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; msg = scStore.ElementFactory.CreateElement(Message.DomainClassId) as Message; msg.Name = messageName; //Create the moniker //mel://[DSLNAMESPACE]\[MODELELEMENTTYPE]\[MODELELEMENT.GUID]@[PROJECT]\[MODELFILE] string requestMoniker = string.Format(@"mel://{0}\{1}\{2}@{3}\{4}", primitiveDataElement.GetType().Namespace, primitiveDataElement.GetType().Name, primitiveDataElement.Id.ToString(), dataContractModelProjectName, dataContractModelFileName); part = scStore.ElementFactory.CreateElement(DataContractMessagePart.DomainClassId) as DataContractMessagePart; part.Name = partName; part.Type = new MockModelBusReference(primitiveDataElement); msg.MessageParts.Add(part); scModel.Messages.Add(msg); #endregion }
public override void ElementAdded(ElementAddedEventArgs e) { Service service = e.ModelElement as Service; ServiceContractModel root = service.ServiceContractModel; if (root != null) { if (root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(service, root.ImplementationTechnology); } if (String.IsNullOrEmpty(service.Namespace)) { service.Namespace = root.Namespace; } } }
public void TestInitialize() { serviceProvider = new MockMappingServiceProvider(); 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.ImplementationTechnology = new ServiceContractWCFExtensionProvider(); scModel.ProjectMappingTable = projectMappingTableName; ServiceContract sc = scStore.ElementFactory.CreateElement(ServiceContract.DomainClassId) as ServiceContract; sc.Name = serviceContractName; scModel.ServiceContracts.Add(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); // Initialize validator's config attributes = new NameValueCollection(); attributes.Add("elementNameProperty", "Name"); }
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 }
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 ReturnSuccessForValidSerializer2() { 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); serviceContractModel.ImplementationTechnology = new ServiceContractWCFExtensionProvider(); serviceContractModel.SerializerType = SerializerType.XmlSerializer; ValidationResults validationResults = new ValidationResults(); TestImplementationTechnologyAndSerializerValidator validator = new TestImplementationTechnologyAndSerializerValidator(); validator.TestDoValidate(serviceContractModel.SerializerType, serviceContractModel, null, validationResults); Assert.IsTrue(validationResults.IsValid); t.Rollback(); } }
/// <summary> /// Reads all instances of relationship ServiceContractModelHasMessages. /// </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 ServiceContractModel instance that will get the deserialized data.</param> /// <param name="reader">XmlReader to read serialized data from.</param> private static void ReadServiceContractModelHasMessagesInstances(DslModeling::SerializationContext serializationContext, ServiceContractModel element, global::System.Xml.XmlReader reader) { while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { DslModeling::DomainClassXmlSerializer newMessageBaseOfServiceContractModelHasMessagesSerializer = serializationContext.Directory.GetSerializer(MessageBase.DomainClassId); global::System.Diagnostics.Debug.Assert(newMessageBaseOfServiceContractModelHasMessagesSerializer != null, "Cannot find serializer for MessageBase!"); MessageBase newMessageBaseOfServiceContractModelHasMessages = newMessageBaseOfServiceContractModelHasMessagesSerializer.TryCreateInstance(serializationContext, reader, element.Partition) as MessageBase; if (newMessageBaseOfServiceContractModelHasMessages != null) { element.Messages.Add(newMessageBaseOfServiceContractModelHasMessages); DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newMessageBaseOfServiceContractModelHasMessages.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newMessageBaseOfServiceContractModelHasMessages.GetDomainClass().Name + "!"); targetSerializer.Read(serializationContext, newMessageBaseOfServiceContractModelHasMessages, reader); } else { global::System.Type typeofServiceContractModelHasMessages = typeof(ServiceContractModelHasMessages); DslModeling::DomainRelationshipXmlSerializer newServiceContractModelHasMessagesSerializer = serializationContext.Directory.GetSerializer(ServiceContractModelHasMessages.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer; global::System.Diagnostics.Debug.Assert(newServiceContractModelHasMessagesSerializer != null, "Cannot find serializer for ServiceContractModelHasMessages!"); ServiceContractModelHasMessages newServiceContractModelHasMessages = newServiceContractModelHasMessagesSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as ServiceContractModelHasMessages; if (newServiceContractModelHasMessages != null) { if (newServiceContractModelHasMessages.GetType() == typeofServiceContractModelHasMessages) { // The relationship should be serialized in short-form. ServiceContractDslSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(ServiceContractModelHasMessages)); } DslModeling::DomainRoleInfo.SetRolePlayer (newServiceContractModelHasMessages, ServiceContractModelHasMessages.ServiceContractModelDomainRoleId, element); DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newServiceContractModelHasMessages.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newServiceContractModelHasMessages.GetDomainClass().Name + "!"); targetSerializer.Read(serializationContext, newServiceContractModelHasMessages, reader); } else { // Unknown element, skip DslModeling::SerializationUtilities.Skip(reader); } } } }
/// <summary> /// Saves the given model root to the given file, with default encoding (UTF-8), and optional properties with default value will not /// be written out. /// </summary> /// <param name="serializationResult">Stores serialization result from the save operation.</param> /// <param name="modelRoot">ServiceContractModel instance to be saved.</param> /// <param name="fileName">Name of the file in which the ServiceContractModel instance will be saved.</param> public virtual void SaveModel(DslModeling::SerializationResult serializationResult, ServiceContractModel modelRoot, string fileName) { this.SaveModel(serializationResult, modelRoot, fileName, global::System.Text.Encoding.UTF8, false); }
internal global::System.IO.MemoryStream InternalSaveModel(DslModeling::SerializationResult serializationResult, ServiceContractModel modelRoot, string fileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationResult != null); global::System.Diagnostics.Debug.Assert(modelRoot != null); global::System.Diagnostics.Debug.Assert(!serializationResult.Failed); #endregion serializationResult.Encoding = encoding; DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(modelRoot.Store); global::System.IO.MemoryStream newFileContent = new global::System.IO.MemoryStream(); DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, fileName, serializationResult); this.InitializeSerializationContext(modelRoot.Partition, serializationContext, false); // MonikerResolver shouldn't be required in Save operation, so not calling SetupMonikerResolver() here. serializationContext.WriteOptionalPropertiesWithDefaultValue = writeOptionalPropertiesWithDefaultValue; global::System.Xml.XmlWriterSettings settings = ServiceContractDslSerializationHelper.Instance.CreateXmlWriterSettings(serializationContext, false, encoding); using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(newFileContent, settings)) { this.WriteRootElement(serializationContext, modelRoot, writer); } return newFileContent; }
public virtual void SaveModelAndDiagram(DslModeling::SerializationResult serializationResult, ServiceContractModel modelRoot, string modelFileName, ServiceContractDiagram diagram, string diagramFileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue) { #region Check Parameters if (serializationResult == null) throw new global::System.ArgumentNullException("serializationResult"); 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"); #endregion if (serializationResult.Failed) return; // Save the model file first using (global::System.IO.MemoryStream modelFileContent = this.InternalSaveModel(serializationResult, modelRoot, modelFileName, encoding, writeOptionalPropertiesWithDefaultValue)) { if (serializationResult.Failed) return; using (global::System.IO.MemoryStream diagramFileContent = this.InternalSaveDiagram(serializationResult, diagram, diagramFileName, encoding, writeOptionalPropertiesWithDefaultValue)) { if (!serializationResult.Failed) { // Only write the contents if there's no error encountered during serialization. if (modelFileContent != null) { using (global::System.IO.FileStream fileStream = new global::System.IO.FileStream(modelFileName, global::System.IO.FileMode.Create, global::System.IO.FileAccess.Write, global::System.IO.FileShare.None)) { using (global::System.IO.BinaryWriter writer = new global::System.IO.BinaryWriter(fileStream, encoding)) { writer.Write(modelFileContent.ToArray()); } } } if (diagramFileContent != null) { using (global::System.IO.FileStream fileStream = new global::System.IO.FileStream(diagramFileName, global::System.IO.FileMode.Create, global::System.IO.FileAccess.Write, global::System.IO.FileShare.None)) { using (global::System.IO.BinaryWriter writer = new global::System.IO.BinaryWriter(fileStream, encoding)) { writer.Write(diagramFileContent.ToArray()); } } } } } } }
/// <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 ServiceContractModel instance that will get the deserialized data.</param> private static void ReadChildElements(DslModeling::SerializationContext serializationContext, ServiceContractModel element, global::System.Xml.XmlReader reader) { while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { switch (reader.LocalName) { case "serviceContracts": // Relationship "ServiceContractModelHasServiceContracts" if (reader.IsEmptyElement) { // No instance of this relationship, just skip DslModeling::SerializationUtilities.Skip(reader); } else { DslModeling::SerializationUtilities.SkipToFirstChild(reader); // Skip the open tag of <serviceContracts> ReadServiceContractModelHasServiceContractsInstances(serializationContext, element, reader); DslModeling::SerializationUtilities.Skip(reader); // Skip the close tag of </serviceContracts> } break; case "operations": // Relationship "ServiceContractModelHasOperations" 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> ReadServiceContractModelHasOperationsInstances(serializationContext, element, reader); DslModeling::SerializationUtilities.Skip(reader); // Skip the close tag of </operations> } break; case "services": // Relationship "ServiceContractModelHasServices" if (reader.IsEmptyElement) { // No instance of this relationship, just skip DslModeling::SerializationUtilities.Skip(reader); } else { DslModeling::SerializationUtilities.SkipToFirstChild(reader); // Skip the open tag of <services> ReadServiceContractModelHasServicesInstances(serializationContext, element, reader); DslModeling::SerializationUtilities.Skip(reader); // Skip the close tag of </services> } break; case "messages": // Relationship "ServiceContractModelHasMessages" if (reader.IsEmptyElement) { // No instance of this relationship, just skip DslModeling::SerializationUtilities.Skip(reader); } else { DslModeling::SerializationUtilities.SkipToFirstChild(reader); // Skip the open tag of <messages> ReadServiceContractModelHasMessagesInstances(serializationContext, element, reader); DslModeling::SerializationUtilities.Skip(reader); // Skip the close tag of </messages> } break; default: return; // Don't know this element. } } }
/// <summary> /// Constructor /// Creates a ServiceContractModelHasServices 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">Service to use as the target of the relationship.</param> public ServiceContractModelHasServices(ServiceContractModel source, Service target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ServiceContractModelHasServices.ServiceContractModelDomainRoleId, source), new DslModeling::RoleAssignment(ServiceContractModelHasServices.ServiceDomainRoleId, target)}, null) { }
public static DslModeling::LinkedElementCollection<Operation> GetOperations(ServiceContractModel element) { return GetRoleCollection<DslModeling::LinkedElementCollection<Operation>, Operation>(element, ServiceContractModelDomainRoleId); }
private static void WriteChildElements(DslModeling::SerializationContext serializationContext, ServiceContractModel element, global::System.Xml.XmlWriter writer) { // ServiceContractModelHasServiceContracts global::System.Collections.ObjectModel.ReadOnlyCollection<ServiceContractModelHasServiceContracts> allServiceContractModelHasServiceContractsInstances = ServiceContractModelHasServiceContracts.GetLinksToServiceContracts(element); if (!serializationContext.Result.Failed && allServiceContractModelHasServiceContractsInstances.Count > 0) { writer.WriteStartElement("serviceContracts"); global::System.Type typeofServiceContractModelHasServiceContracts = typeof(ServiceContractModelHasServiceContracts); foreach (ServiceContractModelHasServiceContracts eachServiceContractModelHasServiceContractsInstance in allServiceContractModelHasServiceContractsInstances) { if (serializationContext.Result.Failed) break; if (eachServiceContractModelHasServiceContractsInstance.GetType() != typeofServiceContractModelHasServiceContracts) { // Derived relationships will be serialized in full-form. DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachServiceContractModelHasServiceContractsInstance.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachServiceContractModelHasServiceContractsInstance.GetDomainClass().Name + "!"); derivedRelSerializer.Write(serializationContext, eachServiceContractModelHasServiceContractsInstance, writer); } else { // No need to serialize the relationship itself, just serialize the role-player directly. DslModeling::ModelElement targetElement = eachServiceContractModelHasServiceContractsInstance.ServiceContract; 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(); } // ServiceContractModelHasOperations global::System.Collections.ObjectModel.ReadOnlyCollection<ServiceContractModelHasOperations> allServiceContractModelHasOperationsInstances = ServiceContractModelHasOperations.GetLinksToOperations(element); if (!serializationContext.Result.Failed && allServiceContractModelHasOperationsInstances.Count > 0) { writer.WriteStartElement("operations"); global::System.Type typeofServiceContractModelHasOperations = typeof(ServiceContractModelHasOperations); foreach (ServiceContractModelHasOperations eachServiceContractModelHasOperationsInstance in allServiceContractModelHasOperationsInstances) { if (serializationContext.Result.Failed) break; if (eachServiceContractModelHasOperationsInstance.GetType() != typeofServiceContractModelHasOperations) { // Derived relationships will be serialized in full-form. DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachServiceContractModelHasOperationsInstance.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachServiceContractModelHasOperationsInstance.GetDomainClass().Name + "!"); derivedRelSerializer.Write(serializationContext, eachServiceContractModelHasOperationsInstance, writer); } else { // No need to serialize the relationship itself, just serialize the role-player directly. DslModeling::ModelElement targetElement = eachServiceContractModelHasOperationsInstance.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.Write(serializationContext, targetElement, writer); } } writer.WriteEndElement(); } // ServiceContractModelHasServices global::System.Collections.ObjectModel.ReadOnlyCollection<ServiceContractModelHasServices> allServiceContractModelHasServicesInstances = ServiceContractModelHasServices.GetLinksToServices(element); if (!serializationContext.Result.Failed && allServiceContractModelHasServicesInstances.Count > 0) { writer.WriteStartElement("services"); global::System.Type typeofServiceContractModelHasServices = typeof(ServiceContractModelHasServices); foreach (ServiceContractModelHasServices eachServiceContractModelHasServicesInstance in allServiceContractModelHasServicesInstances) { if (serializationContext.Result.Failed) break; if (eachServiceContractModelHasServicesInstance.GetType() != typeofServiceContractModelHasServices) { // Derived relationships will be serialized in full-form. DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachServiceContractModelHasServicesInstance.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachServiceContractModelHasServicesInstance.GetDomainClass().Name + "!"); derivedRelSerializer.Write(serializationContext, eachServiceContractModelHasServicesInstance, writer); } else { // No need to serialize the relationship itself, just serialize the role-player directly. DslModeling::ModelElement targetElement = eachServiceContractModelHasServicesInstance.Service; 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(); } // ServiceContractModelHasMessages global::System.Collections.ObjectModel.ReadOnlyCollection<ServiceContractModelHasMessages> allServiceContractModelHasMessagesInstances = ServiceContractModelHasMessages.GetLinksToMessages(element); if (!serializationContext.Result.Failed && allServiceContractModelHasMessagesInstances.Count > 0) { writer.WriteStartElement("messages"); global::System.Type typeofServiceContractModelHasMessages = typeof(ServiceContractModelHasMessages); foreach (ServiceContractModelHasMessages eachServiceContractModelHasMessagesInstance in allServiceContractModelHasMessagesInstances) { if (serializationContext.Result.Failed) break; if (eachServiceContractModelHasMessagesInstance.GetType() != typeofServiceContractModelHasMessages) { // Derived relationships will be serialized in full-form. DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachServiceContractModelHasMessagesInstance.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachServiceContractModelHasMessagesInstance.GetDomainClass().Name + "!"); derivedRelSerializer.Write(serializationContext, eachServiceContractModelHasMessagesInstance, writer); } else { // No need to serialize the relationship itself, just serialize the role-player directly. DslModeling::ModelElement targetElement = eachServiceContractModelHasMessagesInstance.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.Write(serializationContext, targetElement, writer); } } writer.WriteEndElement(); } }
private ServiceContract CreateServiceContract( ServiceContractModel model, string serviceContractName, string operationName) { return CreateServiceContract(model,serviceContractName, operationName, RequestName, ResponseName); }
/// <summary> /// Helper method to create and initialize a new ServiceContractModel. /// </summary> internal protected virtual ServiceContractModel CreateModelHelper(DslModeling::Partition modelPartition) { ServiceContractModel model = new ServiceContractModel(modelPartition); return model; }
/// <summary> /// Saves the given diagram to the given file, with default encoding (UTF-8), and optional properties with default value will not /// be written out. /// </summary> /// <param name="serializationResult">Stores serialization result from the save operation.</param> /// <param name="modelRoot">ServiceContractModel instance to be saved.</param> /// <param name="modelFileName">Name of the file in which the CanonicalSampleRoot instance will be saved.</param> /// <param name="diagram">ServiceContractDiagram to be saved.</param> /// <param name="diagramFileName">Name of the file in which the diagram will be saved.</param> public virtual void SaveModelAndDiagram(DslModeling::SerializationResult serializationResult, ServiceContractModel modelRoot, string modelFileName, ServiceContractDiagram diagram, string diagramFileName) { this.SaveModelAndDiagram(serializationResult, modelRoot, modelFileName, diagram, diagramFileName, global::System.Text.Encoding.UTF8, false); }
private ServiceContractModel CreateServiceContractRoot() { ServiceContractModel serviceContractModel = new ServiceContractModel(ServiceContractStore); serviceContractModel.ProjectMappingTable = "WCF"; return serviceContractModel; }
public static void SetServiceContractModel(Service element, ServiceContractModel newServiceContractModel) { DslModeling::DomainRoleInfo.SetLinkedElement(element, ServiceDomainRoleId, newServiceContractModel); }
public static DslModeling::LinkedElementCollection<Service> GetServices(ServiceContractModel element) { return GetRoleCollection<DslModeling::LinkedElementCollection<Service>, Service>(element, ServiceContractModelDomainRoleId); }
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; }
/// <summary> /// Saves the given diagram to the given file, with default encoding (UTF-8). /// </summary> /// <param name="serializationResult">Stores serialization result from the save operation.</param> /// <param name="modelRoot">ServiceContractModel instance to be saved.</param> /// <param name="modelFileName">Name of the file in which the CanonicalSampleRoot instance will be saved.</param> /// <param name="diagram">ServiceContractDiagram to be saved.</param> /// <param name="diagramFileName">Name of the file in which the diagram will be saved.</param> /// <param name="writeOptionalPropertiesWithDefaultValue">Whether optional properties with default value will be saved.</param> public virtual void SaveModelAndDiagram(DslModeling::SerializationResult serializationResult, ServiceContractModel modelRoot, string modelFileName, ServiceContractDiagram diagram, string diagramFileName, bool writeOptionalPropertiesWithDefaultValue) { this.SaveModelAndDiagram(serializationResult, modelRoot, modelFileName, diagram, diagramFileName, global::System.Text.Encoding.UTF8, writeOptionalPropertiesWithDefaultValue); }