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 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();
			}
		}
Пример #3
0
		public static void SetClientApplication(Proxy element, ClientApplication newClientApplication)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ProxyDomainRoleId, newClientApplication);
		}
Пример #4
0
		public static DslModeling::LinkedElementCollection<Proxy> GetProxies(ClientApplication element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<Proxy>, Proxy>(element, ClientApplicationDomainRoleId);
		}
Пример #5
0
		public static void SetHostDesignerModel(ClientApplication element, HostDesignerModel newHostDesignerModel)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ClientApplicationDomainRoleId, newHostDesignerModel);
		}
Пример #6
0
		/// <summary>
		/// Constructor
		/// Creates a ClientApplicationHasProxies link in the same Partition as the given ClientApplication
		/// </summary>
		/// <param name="source">ClientApplication to use as the source of the relationship.</param>
		/// <param name="target">Proxy to use as the target of the relationship.</param>
		public ClientApplicationHasProxies(ClientApplication source, Proxy target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ClientApplicationHasProxies.ClientApplicationDomainRoleId, source), new DslModeling::RoleAssignment(ClientApplicationHasProxies.ProxyDomainRoleId, target)}, null)
		{
		}
Пример #7
0
		public static HostDesignerModel GetHostDesignerModel(ClientApplication element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, ClientApplicationDomainRoleId) as HostDesignerModel;
		}
Пример #8
0
		/// <summary>
		/// Constructor
		/// Creates a HostDesignerModelHasClientApplications 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">ClientApplication to use as the target of the relationship.</param>
		public HostDesignerModelHasClientApplications(HostDesignerModel source, ClientApplication target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(HostDesignerModelHasClientApplications.HostDesignerModelDomainRoleId, source), new DslModeling::RoleAssignment(HostDesignerModelHasClientApplications.ClientApplicationDomainRoleId, target)}, null)
		{
		}
Пример #9
0
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, ClientApplication element, global::System.Xml.XmlWriter writer)
		{
			// ClientApplicationHasProxies
			global::System.Collections.ObjectModel.ReadOnlyCollection<ClientApplicationHasProxies> allClientApplicationHasProxiesInstances = ClientApplicationHasProxies.GetLinksToProxies(element);
			if (!serializationContext.Result.Failed && allClientApplicationHasProxiesInstances.Count > 0)
			{
				writer.WriteStartElement("proxies");
				global::System.Type typeofClientApplicationHasProxies = typeof(ClientApplicationHasProxies);
				foreach (ClientApplicationHasProxies eachClientApplicationHasProxiesInstance in allClientApplicationHasProxiesInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					if (eachClientApplicationHasProxiesInstance.GetType() != typeofClientApplicationHasProxies)
					{	// Derived relationships will be serialized in full-form.
						DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachClientApplicationHasProxiesInstance.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachClientApplicationHasProxiesInstance.GetDomainClass().Name + "!");			
						derivedRelSerializer.Write(serializationContext, eachClientApplicationHasProxiesInstance, writer);
					}
					else
					{	// No need to serialize the relationship itself, just serialize the role-player directly.
						DslModeling::ModelElement targetElement = eachClientApplicationHasProxiesInstance.Proxy;
						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();
			}
	
		}
Пример #10
0
		/// <summary>
		/// Reads all instances of relationship ClientApplicationHasProxies.
		/// </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 ClientApplication instance that will get the deserialized data.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		private static void ReadClientApplicationHasProxiesInstances(DslModeling::SerializationContext serializationContext, ClientApplication element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newProxyOfClientApplicationHasProxiesSerializer = serializationContext.Directory.GetSerializer(Proxy.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newProxyOfClientApplicationHasProxiesSerializer != null, "Cannot find serializer for Proxy!");
				Proxy newProxyOfClientApplicationHasProxies = newProxyOfClientApplicationHasProxiesSerializer.TryCreateInstance(serializationContext, reader, element.Partition) as Proxy;
				if (newProxyOfClientApplicationHasProxies != null)
				{
					element.Proxies.Add(newProxyOfClientApplicationHasProxies);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newProxyOfClientApplicationHasProxies.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newProxyOfClientApplicationHasProxies.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newProxyOfClientApplicationHasProxies, reader);
				}
				else
				{
					global::System.Type typeofClientApplicationHasProxies = typeof(ClientApplicationHasProxies);
					DslModeling::DomainRelationshipXmlSerializer newClientApplicationHasProxiesSerializer = serializationContext.Directory.GetSerializer(ClientApplicationHasProxies.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer;
					global::System.Diagnostics.Debug.Assert(newClientApplicationHasProxiesSerializer != null, "Cannot find serializer for ClientApplicationHasProxies!");
					ClientApplicationHasProxies newClientApplicationHasProxies = newClientApplicationHasProxiesSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as ClientApplicationHasProxies;
					if (newClientApplicationHasProxies != null)
					{
						if (newClientApplicationHasProxies.GetType() == typeofClientApplicationHasProxies)
						{	// The relationship should be serialized in short-form.
							HostDesignerSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(ClientApplicationHasProxies));
						}
						DslModeling::DomainRoleInfo.SetRolePlayer (newClientApplicationHasProxies, ClientApplicationHasProxies.ClientApplicationDomainRoleId, element);
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newClientApplicationHasProxies.GetDomainClass().Id);	
						global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newClientApplicationHasProxies.GetDomainClass().Name + "!");
						targetSerializer.Read(serializationContext, newClientApplicationHasProxies, reader);
					}
					else
					{	// Unknown element, skip
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
Пример #11
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 ClientApplication instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, ClientApplication element, global::System.Xml.XmlReader reader)
		{
			if (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				if (string.Compare(reader.LocalName, "proxies", 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 <proxies>
						ReadClientApplicationHasProxiesInstances(serializationContext, element, reader);
						DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </proxies>
					}
				}
			}
		}