Exemplo n.º 1
0
 public void InitializeContext()
 {
     this.store.TransactionManager.DoWithinTransaction(() =>
     {
         this.asset = this.store.ElementFactory.CreateElement<SuppliedAsset>();
     });
 }
 public virtual void Initialize()
 {
     this.store.TransactionManager.DoWithinTransaction(() =>
     {
         this.asset = this.store.ElementFactory.CreateElement<SuppliedAsset>();
     });
     validationContext = new ValidationContext(ValidationCategories.Save, this.asset);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the value of the StereotypeText property.
        /// </summary>
        internal string GetStereotypeTextValue()
        {
            SuppliedAsset asset = this.Subject as SuppliedAsset;

            if (asset != null)
            {
                if (asset.IsUserSupplied)
                {
                    return(this.IsUserSuppliedStereotypeText);
                }
                else
                {
                    return(this.IsMaterialStereotypeText);
                }
            }

            return(string.Empty);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the color of the current stereotype.
        /// </summary>
        internal Color GetStereotypeFillColor()
        {
            SuppliedAsset asset = this.Subject as SuppliedAsset;

            if (asset != null)
            {
                if (asset.IsUserSupplied)
                {
                    return(this.IsUserSuppliedColor);
                }
                else
                {
                    return(this.IsMaterialColor);
                }
            }

            return(Color.Empty);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the property change event for this element.
        /// </summary>
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            Guard.NotNull(() => e, e);
            base.ElementPropertyChanged(e);

            // Change the color of the shape for this element
            if (e.DomainProperty.Id == SuppliedAsset.IsUserSuppliedDomainPropertyId)
            {
                SuppliedAsset element = e.ModelElement as SuppliedAsset;
                if (element != null)
                {
                    // Get shape for the mel
                    var suppliedAssetShape = PresentationViewsSubject.GetPresentation(element).OfType <SuppliedAssetShape>().FirstOrDefault();

                    if (suppliedAssetShape != null)
                    {
                        suppliedAssetShape.SetShapeBrushColor(DiagramBrushes.ShapeBackground, suppliedAssetShape.GetStereotypeFillColor());
                    }
                }
            }
        }
		/// <summary>
		/// Constructor
		/// Creates a SuppliedAssetSuppliesProductionTools link in the same Partition as the given SuppliedAsset
		/// </summary>
		/// <param name="source">SuppliedAsset to use as the source of the relationship.</param>
		/// <param name="target">ProductionTool to use as the target of the relationship.</param>
		internal SuppliedAssetSuppliesProductionTools(SuppliedAsset source, ProductionTool target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(SuppliedAssetSuppliesProductionTools.SuppliedAssetDomainRoleId, source), new DslModeling::RoleAssignment(SuppliedAssetSuppliesProductionTools.ProductionToolDomainRoleId, target)}, null)
		{
		}
		internal static DslModeling::LinkedElementCollection<ProducedAsset> GetProducedAssets(SuppliedAsset element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<ProducedAsset>, ProducedAsset>(element, SuppliedAssetDomainRoleId);
		}
Exemplo n.º 8
0
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, SuppliedAsset element, global::System.Xml.XmlWriter writer)
		{
			// SuppliedAssetCopiesToProducedAssets
			global::System.Collections.ObjectModel.ReadOnlyCollection<SuppliedAssetCopiesToProducedAssets> allSuppliedAssetCopiesToProducedAssetsInstances = SuppliedAssetCopiesToProducedAssets.GetLinksToProducedAssets(element);
			if (!serializationContext.Result.Failed && allSuppliedAssetCopiesToProducedAssetsInstances.Count > 0)
			{
				writer.WriteStartElement("producedAssets");
				foreach (SuppliedAssetCopiesToProducedAssets eachSuppliedAssetCopiesToProducedAssetsInstance in allSuppliedAssetCopiesToProducedAssetsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					DslModeling::DomainClassXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(eachSuppliedAssetCopiesToProducedAssetsInstance.GetDomainClass().Id);
					global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for " + eachSuppliedAssetCopiesToProducedAssetsInstance.GetDomainClass().Name + "!");
					relSerializer.Write(serializationContext, eachSuppliedAssetCopiesToProducedAssetsInstance, writer);
				}
				writer.WriteEndElement();
			}
	
			// SuppliedAssetSuppliesProductionTools
			global::System.Collections.ObjectModel.ReadOnlyCollection<SuppliedAssetSuppliesProductionTools> allSuppliedAssetSuppliesProductionToolsInstances = SuppliedAssetSuppliesProductionTools.GetLinksToProductionTools(element);
			if (!serializationContext.Result.Failed && allSuppliedAssetSuppliesProductionToolsInstances.Count > 0)
			{
				writer.WriteStartElement("productionTools");
				foreach (SuppliedAssetSuppliesProductionTools eachSuppliedAssetSuppliesProductionToolsInstance in allSuppliedAssetSuppliesProductionToolsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					DslModeling::DomainClassXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(eachSuppliedAssetSuppliesProductionToolsInstance.GetDomainClass().Id);
					global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for " + eachSuppliedAssetSuppliesProductionToolsInstance.GetDomainClass().Name + "!");
					relSerializer.Write(serializationContext, eachSuppliedAssetSuppliesProductionToolsInstance, writer);
				}
				writer.WriteEndElement();
			}
	
		}
Exemplo n.º 9
0
		private static void ReadSuppliedAssetSuppliesProductionToolsInstances(DslModeling::SerializationContext serializationContext, SuppliedAsset element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newSuppliedAssetSuppliesProductionToolsSerializer = serializationContext.Directory.GetSerializer(SuppliedAssetSuppliesProductionTools.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newSuppliedAssetSuppliesProductionToolsSerializer != null, "Cannot find serializer for SuppliedAssetSuppliesProductionTools!");
				SuppliedAssetSuppliesProductionTools newSuppliedAssetSuppliesProductionTools = newSuppliedAssetSuppliesProductionToolsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as SuppliedAssetSuppliesProductionTools;
				if (newSuppliedAssetSuppliesProductionTools != null)
				{
					DslModeling::DomainRoleInfo.SetRolePlayer (newSuppliedAssetSuppliesProductionTools, SuppliedAssetSuppliesProductionTools.SuppliedAssetDomainRoleId, element);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newSuppliedAssetSuppliesProductionTools.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newSuppliedAssetSuppliesProductionTools.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newSuppliedAssetSuppliesProductionTools, reader);
				}
				else
				{	// Maybe the relationship is serialized in short-form by mistake.
					DslModeling::DomainClassXmlSerializer newProductionToolMonikerOfSuppliedAssetSuppliesProductionToolsSerializer = serializationContext.Directory.GetSerializer(ProductionTool.DomainClassId);
					global::System.Diagnostics.Debug.Assert(newProductionToolMonikerOfSuppliedAssetSuppliesProductionToolsSerializer != null, "Cannot find serializer for ProductionTool!");
					DslModeling::Moniker newProductionToolMonikerOfSuppliedAssetSuppliesProductionTools = newProductionToolMonikerOfSuppliedAssetSuppliesProductionToolsSerializer.TryCreateMonikerInstance(serializationContext, reader, element, SuppliedAssetSuppliesProductionTools.DomainClassId, element.Partition);
					if (newProductionToolMonikerOfSuppliedAssetSuppliesProductionTools != null)
					{
						WorkflowDesignSerializationBehaviorSerializationMessages.ExpectingFullFormRelationship(serializationContext, reader, typeof(SuppliedAssetSuppliesProductionTools));
						new SuppliedAssetSuppliesProductionTools(element.Partition, new DslModeling::RoleAssignment(SuppliedAssetSuppliesProductionTools.SuppliedAssetDomainRoleId, element), new DslModeling::RoleAssignment(SuppliedAssetSuppliesProductionTools.ProductionToolDomainRoleId, newProductionToolMonikerOfSuppliedAssetSuppliesProductionTools));
						DslModeling::SerializationUtilities.Skip(reader);	// Moniker contains no child XML elements, so just skip.
					}
					else
					{	// Unknown element, skip.
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
Exemplo n.º 10
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 SuppliedAsset instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, SuppliedAsset element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				switch (reader.LocalName)
				{
					case "producedAssets":	// Relationship "SuppliedAssetCopiesToProducedAssets"
						if (reader.IsEmptyElement)
						{	// No instance of this relationship, just skip
							DslModeling::SerializationUtilities.Skip(reader);
						}
						else
						{
							DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <producedAssets>
							ReadSuppliedAssetCopiesToProducedAssetsInstances(serializationContext, element, reader);
							DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </producedAssets>
						}
						break;
					case "productionTools":	// Relationship "SuppliedAssetSuppliesProductionTools"
						if (reader.IsEmptyElement)
						{	// No instance of this relationship, just skip
							DslModeling::SerializationUtilities.Skip(reader);
						}
						else
						{
							DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <productionTools>
							ReadSuppliedAssetSuppliesProductionToolsInstances(serializationContext, element, reader);
							DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </productionTools>
						}
						break;
					default:
						return;  // Don't know this element.
				}
			}
		}