public void ValidationPassedWhenProjectDiffersButNameIsSame()
		{
			Store store = new Store(typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));
			using (Transaction t = store.TransactionManager.BeginTransaction())
			{
				ClientApplication clientApp1 = new ClientApplication(store,
									new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "Project1"));
				ClientApplication clientApp2 = new ClientApplication(store,
					new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "AnotherProject"));

				HostDesignerModel model = new HostDesignerModel(store);

				model.ClientApplications.Add(clientApp1);
				model.ClientApplications.Add(clientApp2);

				Proxy proxy1 = new Proxy(store,
					new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1"));
				Proxy proxy2 = new Proxy(store,
					new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1"));


				clientApp1.Proxies.Add(proxy1);
				clientApp2.Proxies.Add(proxy2);

				TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator validator = new TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator();


				t.Rollback();
			}
		}
		public void ValidationPassedWhenProjectDiffersButNameIsSame()
		{
			Store store = new Store(typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));
			using(Transaction t = store.TransactionManager.BeginTransaction())
			{
				HostApplication hostApp1 = new HostApplication(store, 
					new PropertyAssignment(HostApplication.ImplementationProjectDomainPropertyId, "Project1"));
				HostApplication hostApp2 = new HostApplication(store,
					new PropertyAssignment(HostApplication.ImplementationProjectDomainPropertyId, "SomeOtherProject"));
				
				HostDesignerModel model = new HostDesignerModel(store);
				
				model.HostApplications.Add(hostApp1);
				model.HostApplications.Add(hostApp2);
				
				ServiceReference serviceReference1 = new ServiceReference(store, 
					new PropertyAssignment(ServiceReference.NameDomainPropertyId, "ServiceRef1"));
				ServiceReference serviceReference2 = new ServiceReference(store,
					new PropertyAssignment(ServiceReference.NameDomainPropertyId, "ServiceRef1"));
				
				
				hostApp1.ServiceDescriptions.Add(serviceReference1);
				hostApp2.ServiceDescriptions.Add(serviceReference2);

				TestableHostModelContainsUniqueServiceReferencesAcrossHostsValidator validator = new TestableHostModelContainsUniqueServiceReferencesAcrossHostsValidator();

				Assert.IsTrue(validator.IsValid(model));
				
				
				t.Rollback();
			}
		}
        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");
        }
        private bool IsEnabled()
        {
            HostDesignerModel hdModel = this.CurrentDocData.RootElement as HostDesignerModel;
            Proxy             proxy   = DomainModelHelper.GetSelectedElement(this.ServiceProvider) as Proxy;
            bool enabled =
                proxy != null &&
                !this.IsCurrentDiagramEmpty() &&
                hdModel != null &&
                hdModel.ClientApplications.Count > 0;

            if (enabled)
            {
                if (!string.IsNullOrWhiteSpace(proxy.ClientApplication.ImplementationProject))
                {
                    if (proxy.Endpoint != null &&
                        proxy.Endpoint.ServiceDescription != null &&
                        IsWCF(proxy.ClientApplication.ImplementationTechnology.Name))
                    {
                        //In case this is a WCF service
                        ServiceDescription service = proxy.Endpoint.ServiceDescription;
                        if (service.ObjectExtender != null)
                        {
                            // Reflect EnableMetadataPublishing property to avoid coupling with Extender
                            PropertyInfo property = service.ObjectExtender.GetType().GetProperty("EnableMetadataPublishing");
                            enabled = property != null && Convert.ToBoolean(property.GetValue(service.ObjectExtender, null));
                            if (!enabled)
                            {
                                AddEnableMetadataPublishingWarning(proxy.Endpoint.ServiceDescription.Name);
                            }
                        }
                    }
                    else if (IsASMX(proxy.ClientApplication.ImplementationTechnology.Name))
                    {
                        // This may be an ASMX service
                        enabled = (proxy.Endpoint != null);
                    }
                }
            }
            return(enabled);
        }
Ejemplo n.º 5
0
		/// <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">HostDesignerModel instance to be saved.</param>
		/// <param name="modelFileName">Name of the file in which the CanonicalSampleRoot instance will be saved.</param>
		/// <param name="diagram">HostDesignerDiagram 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, HostDesignerModel modelRoot, string modelFileName, HostDesignerDiagram diagram, string diagramFileName)
		{
			this.SaveModelAndDiagram(serializationResult, modelRoot, modelFileName, diagram, diagramFileName, global::System.Text.Encoding.UTF8, false);
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Helper method to create and initialize a new HostDesignerModel.
		/// </summary>
		internal protected virtual HostDesignerModel CreateModelHelper(DslModeling::Partition modelPartition)
		{
			HostDesignerModel model = new HostDesignerModel(modelPartition);
			return model;
		}
Ejemplo n.º 7
0
		internal global::System.IO.MemoryStream InternalSaveModel(DslModeling::SerializationResult serializationResult, HostDesignerModel 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 = HostDesignerSerializationHelper.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;
		}
Ejemplo n.º 8
0
		/// <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">HostDesignerModel instance to be saved.</param>
		/// <param name="fileName">Name of the file in which the HostDesignerModel instance will be saved.</param>
		public virtual void SaveModel(DslModeling::SerializationResult serializationResult, HostDesignerModel modelRoot, string fileName)
		{
			this.SaveModel(serializationResult, modelRoot, fileName, global::System.Text.Encoding.UTF8, false);
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Reads all instances of relationship HostDesignerModelHasClientApplications.
		/// </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 HostDesignerModel instance that will get the deserialized data.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		private static void ReadHostDesignerModelHasClientApplicationsInstances(DslModeling::SerializationContext serializationContext, HostDesignerModel element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newClientApplicationOfHostDesignerModelHasClientApplicationsSerializer = serializationContext.Directory.GetSerializer(ClientApplication.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newClientApplicationOfHostDesignerModelHasClientApplicationsSerializer != null, "Cannot find serializer for ClientApplication!");
				ClientApplication newClientApplicationOfHostDesignerModelHasClientApplications = newClientApplicationOfHostDesignerModelHasClientApplicationsSerializer.TryCreateInstance(serializationContext, reader, element.Partition) as ClientApplication;
				if (newClientApplicationOfHostDesignerModelHasClientApplications != null)
				{
					element.ClientApplications.Add(newClientApplicationOfHostDesignerModelHasClientApplications);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newClientApplicationOfHostDesignerModelHasClientApplications.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newClientApplicationOfHostDesignerModelHasClientApplications.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newClientApplicationOfHostDesignerModelHasClientApplications, reader);
				}
				else
				{
					global::System.Type typeofHostDesignerModelHasClientApplications = typeof(HostDesignerModelHasClientApplications);
					DslModeling::DomainRelationshipXmlSerializer newHostDesignerModelHasClientApplicationsSerializer = serializationContext.Directory.GetSerializer(HostDesignerModelHasClientApplications.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer;
					global::System.Diagnostics.Debug.Assert(newHostDesignerModelHasClientApplicationsSerializer != null, "Cannot find serializer for HostDesignerModelHasClientApplications!");
					HostDesignerModelHasClientApplications newHostDesignerModelHasClientApplications = newHostDesignerModelHasClientApplicationsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as HostDesignerModelHasClientApplications;
					if (newHostDesignerModelHasClientApplications != null)
					{
						if (newHostDesignerModelHasClientApplications.GetType() == typeofHostDesignerModelHasClientApplications)
						{	// The relationship should be serialized in short-form.
							HostDesignerSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(HostDesignerModelHasClientApplications));
						}
						DslModeling::DomainRoleInfo.SetRolePlayer (newHostDesignerModelHasClientApplications, HostDesignerModelHasClientApplications.HostDesignerModelDomainRoleId, element);
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newHostDesignerModelHasClientApplications.GetDomainClass().Id);	
						global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newHostDesignerModelHasClientApplications.GetDomainClass().Name + "!");
						targetSerializer.Read(serializationContext, newHostDesignerModelHasClientApplications, reader);
					}
					else
					{	// Unknown element, skip
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
		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);
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Constructor
		/// Creates a HostDesignerModelHasHostApplications link in the same Partition as the given HostDesignerModel
		/// </summary>
		/// <param name="source">HostDesignerModel to use as the source of the relationship.</param>
		/// <param name="target">HostApplication to use as the target of the relationship.</param>
		public HostDesignerModelHasHostApplications(HostDesignerModel source, HostApplication target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(HostDesignerModelHasHostApplications.HostDesignerModelDomainRoleId, source), new DslModeling::RoleAssignment(HostDesignerModelHasHostApplications.HostApplicationDomainRoleId, target)}, null)
		{
		}
Ejemplo n.º 12
0
		public static DslModeling::LinkedElementCollection<HostApplication> GetHostApplications(HostDesignerModel element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<HostApplication>, HostApplication>(element, HostDesignerModelDomainRoleId);
		}
Ejemplo n.º 13
0
		public static void SetHostDesignerModel(ClientApplication element, HostDesignerModel newHostDesignerModel)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ClientApplicationDomainRoleId, newHostDesignerModel);
		}
Ejemplo n.º 14
0
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, HostDesignerModel element, global::System.Xml.XmlWriter writer)
		{
			// HostDesignerModelHasHostApplications
			global::System.Collections.ObjectModel.ReadOnlyCollection<HostDesignerModelHasHostApplications> allHostDesignerModelHasHostApplicationsInstances = HostDesignerModelHasHostApplications.GetLinksToHostApplications(element);
			if (!serializationContext.Result.Failed && allHostDesignerModelHasHostApplicationsInstances.Count > 0)
			{
				writer.WriteStartElement("hostApplications");
				global::System.Type typeofHostDesignerModelHasHostApplications = typeof(HostDesignerModelHasHostApplications);
				foreach (HostDesignerModelHasHostApplications eachHostDesignerModelHasHostApplicationsInstance in allHostDesignerModelHasHostApplicationsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					if (eachHostDesignerModelHasHostApplicationsInstance.GetType() != typeofHostDesignerModelHasHostApplications)
					{	// Derived relationships will be serialized in full-form.
						DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachHostDesignerModelHasHostApplicationsInstance.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachHostDesignerModelHasHostApplicationsInstance.GetDomainClass().Name + "!");			
						derivedRelSerializer.Write(serializationContext, eachHostDesignerModelHasHostApplicationsInstance, writer);
					}
					else
					{	// No need to serialize the relationship itself, just serialize the role-player directly.
						DslModeling::ModelElement targetElement = eachHostDesignerModelHasHostApplicationsInstance.HostApplication;
						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();
			}
	
			// HostDesignerModelHasClientApplications
			global::System.Collections.ObjectModel.ReadOnlyCollection<HostDesignerModelHasClientApplications> allHostDesignerModelHasClientApplicationsInstances = HostDesignerModelHasClientApplications.GetLinksToClientApplications(element);
			if (!serializationContext.Result.Failed && allHostDesignerModelHasClientApplicationsInstances.Count > 0)
			{
				writer.WriteStartElement("clientApplications");
				global::System.Type typeofHostDesignerModelHasClientApplications = typeof(HostDesignerModelHasClientApplications);
				foreach (HostDesignerModelHasClientApplications eachHostDesignerModelHasClientApplicationsInstance in allHostDesignerModelHasClientApplicationsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					if (eachHostDesignerModelHasClientApplicationsInstance.GetType() != typeofHostDesignerModelHasClientApplications)
					{	// Derived relationships will be serialized in full-form.
						DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachHostDesignerModelHasClientApplicationsInstance.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachHostDesignerModelHasClientApplicationsInstance.GetDomainClass().Name + "!");			
						derivedRelSerializer.Write(serializationContext, eachHostDesignerModelHasClientApplicationsInstance, writer);
					}
					else
					{	// No need to serialize the relationship itself, just serialize the role-player directly.
						DslModeling::ModelElement targetElement = eachHostDesignerModelHasClientApplicationsInstance.ClientApplication;
						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();
			}
	
		}
Ejemplo n.º 15
0
		/// <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">HostDesignerModel instance to be saved.</param>
		/// <param name="modelFileName">Name of the file in which the CanonicalSampleRoot instance will be saved.</param>
		/// <param name="diagram">HostDesignerDiagram 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, HostDesignerModel modelRoot, string modelFileName, HostDesignerDiagram diagram, string diagramFileName, bool writeOptionalPropertiesWithDefaultValue)
		{
			this.SaveModelAndDiagram(serializationResult, modelRoot, modelFileName, diagram, diagramFileName, global::System.Text.Encoding.UTF8, writeOptionalPropertiesWithDefaultValue);
		}
Ejemplo n.º 16
0
		public virtual void SaveModelAndDiagram(DslModeling::SerializationResult serializationResult, HostDesignerModel modelRoot, string modelFileName, HostDesignerDiagram 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());
								}
							}
						}
					}
				}
			}
		}
		public void ValidationOnlyAppliesToServicesReferencesInDifferentHosts()
		{
			Store store = new Store(typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));
			using (Transaction t = store.TransactionManager.BeginTransaction())
			{
				ClientApplication clientApp = new ClientApplication(store,
					new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "Project1"));

				HostDesignerModel model = new HostDesignerModel(store);

				model.ClientApplications.Add(clientApp);

				Proxy proxy1 = new Proxy(store,
					new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1"));
				Proxy proxy2 = new Proxy(store,
					new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1"));


				clientApp.Proxies.Add(proxy1);
				clientApp.Proxies.Add(proxy2);

				TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator validator = new TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator();

				Assert.IsTrue(validator.IsValid(model));


				t.Rollback();
			}
		}
			public bool IsValid(HostDesignerModel hostModel)
			{
				ValidationResults vrs = new ValidationResults();
				this.DoValidate(hostModel.HostApplications, hostModel.HostApplications, "", vrs);
				
				return new List<ValidationResult>(vrs).Count == 0;
			}
Ejemplo n.º 19
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 HostDesignerModel instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, HostDesignerModel element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				switch (reader.LocalName)
				{
					case "hostApplications":	// Relationship "HostDesignerModelHasHostApplications"
						if (reader.IsEmptyElement)
						{	// No instance of this relationship, just skip
							DslModeling::SerializationUtilities.Skip(reader);
						}
						else
						{
							DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <hostApplications>
							ReadHostDesignerModelHasHostApplicationsInstances(serializationContext, element, reader);
							DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </hostApplications>
						}
						break;
					case "clientApplications":	// Relationship "HostDesignerModelHasClientApplications"
						if (reader.IsEmptyElement)
						{	// No instance of this relationship, just skip
							DslModeling::SerializationUtilities.Skip(reader);
						}
						else
						{
							DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <clientApplications>
							ReadHostDesignerModelHasClientApplicationsInstances(serializationContext, element, reader);
							DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </clientApplications>
						}
						break;
					default:
						return;  // Don't know this element.
				}
			}
		}