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();
			}
		}
コード例 #2
0
 public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
 {
     if (e.NewValue is IExtensionProvider)
     {
         HostApplication hostApp = e.ModelElement as HostApplication;
         foreach (ServiceDescription sd in hostApp.ServiceDescriptions)
         {
             ExtensionProviderHelper.AttachObjectExtender((IExtensibleObject)sd, (IExtensionProvider)e.NewValue);
             foreach (Endpoint endpoint in sd.Endpoints)
             {
                 ExtensionProviderHelper.AttachObjectExtender((IExtensibleObject)endpoint, (IExtensionProvider)e.NewValue);
             }
         }
     }
 }
コード例 #3
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)
		{
		}
コード例 #4
0
		public static DslModeling::LinkedElementCollection<ServiceDescription> GetServiceDescriptions(HostApplication element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<ServiceDescription>, ServiceDescription>(element, HostApplicationDomainRoleId);
		}
コード例 #5
0
		/// <summary>
		/// Constructor
		/// Creates a HostApplicationHasServiceDescriptions link in the same Partition as the given HostApplication
		/// </summary>
		/// <param name="source">HostApplication to use as the source of the relationship.</param>
		/// <param name="target">ServiceDescription to use as the target of the relationship.</param>
		public HostApplicationHasServiceDescriptions(HostApplication source, ServiceDescription target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(HostApplicationHasServiceDescriptions.HostApplicationDomainRoleId, source), new DslModeling::RoleAssignment(HostApplicationHasServiceDescriptions.ServiceDescriptionDomainRoleId, target)}, null)
		{
		}
コード例 #6
0
		public static void SetHostApplication(ServiceDescription element, HostApplication newHostApplication)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ServiceDescriptionDomainRoleId, newHostApplication);
		}
コード例 #7
0
		public static void SetHostDesignerModel(HostApplication element, HostDesignerModel newHostDesignerModel)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, HostApplicationDomainRoleId, newHostDesignerModel);
		}
コード例 #8
0
		public static HostDesignerModel GetHostDesignerModel(HostApplication element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, HostApplicationDomainRoleId) as HostDesignerModel;
		}
コード例 #9
0
ファイル: Serializer.cs プロジェクト: Phidiax/open-wssf-2015
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, HostApplication element, global::System.Xml.XmlWriter writer)
		{
			// HostApplicationHasServiceDescriptions
			global::System.Collections.ObjectModel.ReadOnlyCollection<HostApplicationHasServiceDescriptions> allHostApplicationHasServiceDescriptionsInstances = HostApplicationHasServiceDescriptions.GetLinksToServiceDescriptions(element);
			if (!serializationContext.Result.Failed && allHostApplicationHasServiceDescriptionsInstances.Count > 0)
			{
				writer.WriteStartElement("serviceDescriptions");
				global::System.Type typeofHostApplicationHasServiceDescriptions = typeof(HostApplicationHasServiceDescriptions);
				foreach (HostApplicationHasServiceDescriptions eachHostApplicationHasServiceDescriptionsInstance in allHostApplicationHasServiceDescriptionsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					if (eachHostApplicationHasServiceDescriptionsInstance.GetType() != typeofHostApplicationHasServiceDescriptions)
					{	// Derived relationships will be serialized in full-form.
						DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachHostApplicationHasServiceDescriptionsInstance.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachHostApplicationHasServiceDescriptionsInstance.GetDomainClass().Name + "!");			
						derivedRelSerializer.Write(serializationContext, eachHostApplicationHasServiceDescriptionsInstance, writer);
					}
					else
					{	// No need to serialize the relationship itself, just serialize the role-player directly.
						DslModeling::ModelElement targetElement = eachHostApplicationHasServiceDescriptionsInstance.ServiceDescription;
						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
ファイル: Serializer.cs プロジェクト: Phidiax/open-wssf-2015
		/// <summary>
		/// Reads all instances of relationship HostApplicationHasServiceDescriptions.
		/// </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 HostApplication instance that will get the deserialized data.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		private static void ReadHostApplicationHasServiceDescriptionsInstances(DslModeling::SerializationContext serializationContext, HostApplication element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newServiceDescriptionOfHostApplicationHasServiceDescriptionsSerializer = serializationContext.Directory.GetSerializer(ServiceDescription.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newServiceDescriptionOfHostApplicationHasServiceDescriptionsSerializer != null, "Cannot find serializer for ServiceDescription!");
				ServiceDescription newServiceDescriptionOfHostApplicationHasServiceDescriptions = newServiceDescriptionOfHostApplicationHasServiceDescriptionsSerializer.TryCreateInstance(serializationContext, reader, element.Partition) as ServiceDescription;
				if (newServiceDescriptionOfHostApplicationHasServiceDescriptions != null)
				{
					element.ServiceDescriptions.Add(newServiceDescriptionOfHostApplicationHasServiceDescriptions);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newServiceDescriptionOfHostApplicationHasServiceDescriptions.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newServiceDescriptionOfHostApplicationHasServiceDescriptions.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newServiceDescriptionOfHostApplicationHasServiceDescriptions, reader);
				}
				else
				{
					global::System.Type typeofHostApplicationHasServiceDescriptions = typeof(HostApplicationHasServiceDescriptions);
					DslModeling::DomainRelationshipXmlSerializer newHostApplicationHasServiceDescriptionsSerializer = serializationContext.Directory.GetSerializer(HostApplicationHasServiceDescriptions.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer;
					global::System.Diagnostics.Debug.Assert(newHostApplicationHasServiceDescriptionsSerializer != null, "Cannot find serializer for HostApplicationHasServiceDescriptions!");
					HostApplicationHasServiceDescriptions newHostApplicationHasServiceDescriptions = newHostApplicationHasServiceDescriptionsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as HostApplicationHasServiceDescriptions;
					if (newHostApplicationHasServiceDescriptions != null)
					{
						if (newHostApplicationHasServiceDescriptions.GetType() == typeofHostApplicationHasServiceDescriptions)
						{	// The relationship should be serialized in short-form.
							HostDesignerSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(HostApplicationHasServiceDescriptions));
						}
						DslModeling::DomainRoleInfo.SetRolePlayer (newHostApplicationHasServiceDescriptions, HostApplicationHasServiceDescriptions.HostApplicationDomainRoleId, element);
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newHostApplicationHasServiceDescriptions.GetDomainClass().Id);	
						global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newHostApplicationHasServiceDescriptions.GetDomainClass().Name + "!");
						targetSerializer.Read(serializationContext, newHostApplicationHasServiceDescriptions, reader);
					}
					else
					{	// Unknown element, skip
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
コード例 #11
0
ファイル: Serializer.cs プロジェクト: Phidiax/open-wssf-2015
		/// <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 HostApplication instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, HostApplication element, global::System.Xml.XmlReader reader)
		{
			if (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				if (string.Compare(reader.LocalName, "serviceDescriptions", 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 <serviceDescriptions>
						ReadHostApplicationHasServiceDescriptionsInstances(serializationContext, element, reader);
						DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </serviceDescriptions>
					}
				}
			}
		}