public void InitializeContext()
 {
     this.store.TransactionManager.DoWithinTransaction(() =>
     {
         this.asset = this.store.ElementFactory.CreateElement<ProducedAsset>();
     });
 }
 public void InitializeContext()
 {
     this.store.TransactionManager.DoWithinTransaction(() =>
     {
         this.asset = this.store.ElementFactory.CreateElement<ProducedAsset>();
     });
     validationContext = new ValidationContext(ValidationCategories.Save, this.asset);
 }
Beispiel #3
0
        /// <summary>
        /// Returns the color of the current stereotype.
        /// </summary>
        internal Color GetStereotypeFillColor()
        {
            ProducedAsset asset = this.Subject as ProducedAsset;

            if (asset != null)
            {
                if (asset.IsFinal)
                {
                    return(this.IsFinalColor);
                }
                else
                {
                    return(this.IsIntermediateColor);
                }
            }

            return(Color.Empty);
        }
        /// <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 == ProducedAsset.IsFinalDomainPropertyId)
            {
                ProducedAsset element = e.ModelElement as ProducedAsset;
                if (element != null)
                {
                    // Get shape for the mel
                    var producedAssetShape = PresentationViewsSubject.GetPresentation(element).OfType <ProducedAssetShape>().FirstOrDefault();

                    if (producedAssetShape != null)
                    {
                        producedAssetShape.SetShapeBrushColor(DiagramBrushes.ShapeBackground, producedAssetShape.GetStereotypeFillColor());
                    }
                }
            }
        }
		internal static DslModeling::LinkedElementCollection<SuppliedAsset> GetSuppliedAssets(ProducedAsset element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<SuppliedAsset>, SuppliedAsset>(element, ProducedAssetDomainRoleId);
		}
		/// <summary>
		/// Constructor
		/// Creates a SuppliedAssetCopiesToProducedAssets 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">ProducedAsset to use as the target of the relationship.</param>
		internal SuppliedAssetCopiesToProducedAssets(SuppliedAsset source, ProducedAsset target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(SuppliedAssetCopiesToProducedAssets.SuppliedAssetDomainRoleId, source), new DslModeling::RoleAssignment(SuppliedAssetCopiesToProducedAssets.ProducedAssetDomainRoleId, target)}, null)
		{
		}
		internal static DslModeling::LinkedElementCollection<ProductionTool> GetProductionTools(ProducedAsset element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<ProductionTool>, ProductionTool>(element, ProducedAssetDomainRoleId);
		}
		/// <summary>
		/// Constructor
		/// Creates a ProducedAssetSuppliesProductionTools link in the same Partition as the given ProducedAsset
		/// </summary>
		/// <param name="source">ProducedAsset to use as the source of the relationship.</param>
		/// <param name="target">ProductionTool to use as the target of the relationship.</param>
		internal ProducedAssetSuppliesProductionTools(ProducedAsset source, ProductionTool target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ProducedAssetSuppliesProductionTools.ProducedAssetDomainRoleId, source), new DslModeling::RoleAssignment(ProducedAssetSuppliesProductionTools.ProductionToolDomainRoleId, target)}, null)
		{
		}
Beispiel #9
0
		private static void ReadProducedAssetSuppliesProductionToolsInstances(DslModeling::SerializationContext serializationContext, ProducedAsset element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newProducedAssetSuppliesProductionToolsSerializer = serializationContext.Directory.GetSerializer(ProducedAssetSuppliesProductionTools.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newProducedAssetSuppliesProductionToolsSerializer != null, "Cannot find serializer for ProducedAssetSuppliesProductionTools!");
				ProducedAssetSuppliesProductionTools newProducedAssetSuppliesProductionTools = newProducedAssetSuppliesProductionToolsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as ProducedAssetSuppliesProductionTools;
				if (newProducedAssetSuppliesProductionTools != null)
				{
					DslModeling::DomainRoleInfo.SetRolePlayer (newProducedAssetSuppliesProductionTools, ProducedAssetSuppliesProductionTools.ProducedAssetDomainRoleId, element);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newProducedAssetSuppliesProductionTools.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newProducedAssetSuppliesProductionTools.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newProducedAssetSuppliesProductionTools, reader);
				}
				else
				{	// Maybe the relationship is serialized in short-form by mistake.
					DslModeling::DomainClassXmlSerializer newProductionToolMonikerOfProducedAssetSuppliesProductionToolsSerializer = serializationContext.Directory.GetSerializer(ProductionTool.DomainClassId);
					global::System.Diagnostics.Debug.Assert(newProductionToolMonikerOfProducedAssetSuppliesProductionToolsSerializer != null, "Cannot find serializer for ProductionTool!");
					DslModeling::Moniker newProductionToolMonikerOfProducedAssetSuppliesProductionTools = newProductionToolMonikerOfProducedAssetSuppliesProductionToolsSerializer.TryCreateMonikerInstance(serializationContext, reader, element, ProducedAssetSuppliesProductionTools.DomainClassId, element.Partition);
					if (newProductionToolMonikerOfProducedAssetSuppliesProductionTools != null)
					{
						WorkflowDesignSerializationBehaviorSerializationMessages.ExpectingFullFormRelationship(serializationContext, reader, typeof(ProducedAssetSuppliesProductionTools));
						new ProducedAssetSuppliesProductionTools(element.Partition, new DslModeling::RoleAssignment(ProducedAssetSuppliesProductionTools.ProducedAssetDomainRoleId, element), new DslModeling::RoleAssignment(ProducedAssetSuppliesProductionTools.ProductionToolDomainRoleId, newProductionToolMonikerOfProducedAssetSuppliesProductionTools));
						DslModeling::SerializationUtilities.Skip(reader);	// Moniker contains no child XML elements, so just skip.
					}
					else
					{	// Unknown element, skip.
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
Beispiel #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 ProducedAsset instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, ProducedAsset element, global::System.Xml.XmlReader reader)
		{
			if (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				if (string.Compare(reader.LocalName, "productionTools", 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 <productionTools>
						ReadProducedAssetSuppliesProductionToolsInstances(serializationContext, element, reader);
						DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </productionTools>
					}
				}
			}
		}
Beispiel #11
0
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, ProducedAsset element, global::System.Xml.XmlWriter writer)
		{
			// ProducedAssetSuppliesProductionTools
			global::System.Collections.ObjectModel.ReadOnlyCollection<ProducedAssetSuppliesProductionTools> allProducedAssetSuppliesProductionToolsInstances = ProducedAssetSuppliesProductionTools.GetLinksToProductionTools(element);
			if (!serializationContext.Result.Failed && allProducedAssetSuppliesProductionToolsInstances.Count > 0)
			{
				writer.WriteStartElement("productionTools");
				foreach (ProducedAssetSuppliesProductionTools eachProducedAssetSuppliesProductionToolsInstance in allProducedAssetSuppliesProductionToolsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					DslModeling::DomainClassXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(eachProducedAssetSuppliesProductionToolsInstance.GetDomainClass().Id);
					global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for " + eachProducedAssetSuppliesProductionToolsInstance.GetDomainClass().Name + "!");
					relSerializer.Write(serializationContext, eachProducedAssetSuppliesProductionToolsInstance, writer);
				}
				writer.WriteEndElement();
			}
	
		}