/// <summary> /// Write an element as the root of XML. /// </summary> /// <param name="serializationContext">Serialization context.</param> /// <param name="rootElement">Root element instance that will be serialized.</param> /// <param name="writer">XmlWriter to write serialized data to.</param> public override void WriteRootElement(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement rootElement, global::System.Xml.XmlWriter writer) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationContext != null); if (serializationContext == null) throw new global::System.ArgumentNullException("serializationContext"); global::System.Diagnostics.Debug.Assert(rootElement != null); if (rootElement == null) throw new global::System.ArgumentNullException("rootElement"); global::System.Diagnostics.Debug.Assert(writer != null); if (writer == null) throw new global::System.ArgumentNullException("writer"); #endregion DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(rootElement.Store); DslModeling::DomainClassXmlSerializer rootSerializer = null; if (rootElement is DslDiagrams::Diagram) { rootSerializer = directory.GetSerializer(PatternModelSchemaDiagram.DomainClassId); } else { rootSerializer = directory.GetSerializer(rootElement.GetDomainClass().Id); } global::System.Diagnostics.Debug.Assert(rootSerializer != null, "Cannot find serializer for " + rootElement.GetDomainClass().Name + "!"); // Set up root element settings DslModeling::RootElementSettings rootElementSettings = new DslModeling::RootElementSettings(); if (!(rootElement is DslDiagrams::Diagram)) { // Only model has schema, diagram has no schema. rootElementSettings.SchemaTargetNamespace = "http://schemas.microsoft.com/visualstudio/patterning/runtime/patternmodel"; } rootElementSettings.Version = new global::System.Version("1.3.0.0"); // Carry out the normal serialization. rootSerializer.Write(serializationContext, rootElement, writer, rootElementSettings); }
/// <summary> /// Read an element from the root of XML. /// </summary> /// <param name="serializationContext">Serialization context.</param> /// <param name="rootElement">In-memory element instance that will get the deserialized data.</param> /// <param name="reader">XmlReader to read serialized data from.</param> /// <param name="schemaResolver">An ISchemaResolver that allows the serializer to do schema validation on the root element (and everything inside it).</param> protected virtual void ReadRootElementVModell(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement rootElement, global::System.Xml.XmlReader reader, DslModeling::ISchemaResolver schemaResolver) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationContext != null); if (serializationContext == null) throw new global::System.ArgumentNullException("serializationContext"); global::System.Diagnostics.Debug.Assert(rootElement != null); if (rootElement == null) throw new global::System.ArgumentNullException("rootElement"); global::System.Diagnostics.Debug.Assert(reader != null); if (reader == null) throw new global::System.ArgumentNullException("reader"); #endregion DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(rootElement.Store); DslModeling::DomainClassXmlSerializer rootSerializer = directory.GetSerializer(rootElement.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(rootSerializer != null, "Cannot find serializer for " + rootElement.GetDomainClass().Name + "!"); // Version check. //this.CheckVersion(serializationContext, reader); if (!serializationContext.Result.Failed) { rootSerializer.Read(serializationContext, rootElement, reader); } }
/// <summary> /// Write an element as the root of XML. /// </summary> /// <param name="serializationContext">Serialization context.</param> /// <param name="rootElement">Root element instance that will be serialized.</param> /// <param name="writer">XmlWriter to write serialized data to.</param> /// <param name="options">Serialization options.</param> public virtual void WriteRootElementVarianten(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement rootElement, global::System.Xml.XmlWriter writer, DslEditorModeling::SerializationOptions options) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationContext != null); if (serializationContext == null) throw new global::System.ArgumentNullException("serializationContext"); global::System.Diagnostics.Debug.Assert(rootElement != null); if (rootElement == null) throw new global::System.ArgumentNullException("rootElement"); global::System.Diagnostics.Debug.Assert(writer != null); if (writer == null) throw new global::System.ArgumentNullException("writer"); #endregion DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(rootElement.Store); DslEditorModeling::SerializationDomainClassXmlSerializer rootSerializer = directory.GetSerializer(rootElement.GetDomainClass().Id) as DslEditorModeling::SerializationDomainClassXmlSerializer; global::System.Diagnostics.Debug.Assert(rootSerializer != null, "Cannot find serializer for " + rootElement.GetDomainClass().Name + "!"); // Carry out the normal serialization. rootSerializer.Write(serializationContext, rootElement, writer, new DslModeling::RootElementSettings(), options); }
/// <summary> /// Construct the mapping from Moniker Xml tag name to DomainClassInfo that derives from ManyToOneRelation. /// </summary> /// <param name="serializationContext">Serialization context.</param> /// <param name="domainDataDirectory">DomainDataDirectory to be used to discover all derived classes.</param> private void ConstructDerivedClassMonikersLookupTable(DslModeling::SerializationContext serializationContext, DslModeling::DomainDataDirectory domainDataDirectory) { global::System.Diagnostics.Debug.Assert(derivedClassMonikers == null); // Shouldn't construct the table more than once. derivedClassMonikers = new global::System.Collections.Generic.Dictionary<string, DslModeling::DomainClassInfo> (global::System.StringComparer.CurrentCulture); DslModeling::DomainClassInfo thisClass = domainDataDirectory.GetDomainClass(ManyToOneRelation.DomainClassId); global::System.Diagnostics.Debug.Assert(thisClass != null, "Cannot find DomainClassInfo for ModelRoot!"); global::System.Collections.ObjectModel.ReadOnlyCollection<DslModeling::DomainClassInfo> descendents = thisClass.AllDescendants; if (descendents != null) { foreach (DslModeling::DomainClassInfo descendent in descendents) { DslModeling::DomainClassXmlSerializer descendentSerializer = serializationContext.Directory.GetSerializer(descendent.Id); if (descendentSerializer != null) { string descendentMonikerTagName = descendentSerializer.MonikerTagName; if (!string.IsNullOrEmpty (descendentMonikerTagName)) { global::System.Diagnostics.Debug.Assert(!derivedClassMonikers.ContainsKey (descendentMonikerTagName)); derivedClassMonikers.Add (descendentMonikerTagName, descendent); } } } } }
/// <summary> /// Construct the apping from XmlTagName to DomainClassInfo that derives from ModelHasClass. /// </summary> /// <param name="serializationContext">Serialization context.</param> /// <param name="domainDataDirectory">DomainDataDirectory to be used to discover all derived classes.</param> private void ConstructDerivedClassesLookupTable(DslModeling::SerializationContext serializationContext, DslModeling::DomainDataDirectory domainDataDirectory) { global::System.Diagnostics.Debug.Assert(derivedClasses == null); // Shouldn't construct the table more than once. derivedClasses = new global::System.Collections.Generic.Dictionary<string, DslModeling::DomainClassInfo> (global::System.StringComparer.CurrentCulture); DslModeling::DomainClassInfo thisClass = domainDataDirectory.GetDomainClass(ModelHasClass.DomainClassId); global::System.Diagnostics.Debug.Assert(thisClass != null, "Cannot find DomainClassInfo for ModelRoot!"); global::System.Collections.ObjectModel.ReadOnlyCollection<DslModeling::DomainClassInfo> descendents = thisClass.AllDescendants; if (descendents != null) { foreach (DslModeling::DomainClassInfo descendent in descendents) { global::System.Type descendentType = descendent.ImplementationClass; if (!descendentType.IsAbstract) { DslModeling::DomainClassXmlSerializer descendentSerializer = serializationContext.Directory.GetSerializer(descendent.Id); if (descendentSerializer != null) { string descendentXmlTagName = descendentSerializer.XmlTagName; if (!string.IsNullOrEmpty (descendentXmlTagName)) { global::System.Diagnostics.Debug.Assert(!derivedClasses.ContainsKey (descendentXmlTagName)); derivedClasses.Add (descendentXmlTagName, descendent); } } } else { // Ignore abstract derived classes because they cannot be instantiated directly. } } } }
/// <summary> /// Calculate the fully qualified monikerized string of the given ModelElement. /// </summary> /// <param name="mel">ModelElement to get moniker from.</param> /// <returns>Calculated moniker string, returns null or empty string is the given ModelElement cannot be monikerized.</returns> protected override string CalculateQualifiedName(DslModeling::ModelElement mel) { if (IsDisposed || directory == null || mel == null) return string.Empty; string result = string.Empty; DslModeling::DomainClassXmlSerializer serializer = directory.GetSerializer(mel.GetDomainClass().Id); if (serializer != null) result = serializer.CalculateQualifiedName(directory, mel); return result; }
/// <summary> /// Calculates a monikerized string reference to a ModelClass. /// </summary> /// <param name="serializationContext">Serialization context.</param> /// <param name="sourceElement">Source side of reference relationship. The referenced target element will be serialized.</param> /// <param name="targetElement">Target side of relationship that will be serialized.</param> /// <returns>A monikerized string reference to target element.</returns> public override string SerializeReference(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement sourceElement, DslModeling::ModelElement targetElement) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationContext != null); if (serializationContext == null) throw new global::System.ArgumentNullException("serializationContext"); global::System.Diagnostics.Debug.Assert(sourceElement != null); if (sourceElement == null) throw new global::System.ArgumentNullException ("sourceElement"); global::System.Diagnostics.Debug.Assert (sourceElement is ModelClass, "Expecting an instance of ModelClass!"); global::System.Diagnostics.Debug.Assert(targetElement != null); if (targetElement == null) throw new global::System.ArgumentNullException ("targetElement"); global::System.Diagnostics.Debug.Assert (targetElement is ModelClass, "Expecting an instance of ModelClass!"); #endregion // full form reference DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer(targetElement.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(targetSerializer != null, "Cannot find serializer for " + targetElement.GetDomainClass().Name + "!"); string targetMoniker = targetSerializer.CalculateQualifiedName(serializationContext.Directory, targetElement); string targetQualifier = targetSerializer.GetMonikerQualifier(serializationContext.Directory, targetElement); if (!string.IsNullOrEmpty(targetQualifier)) { DslModeling::DomainClassXmlSerializer sourceSerializer = serializationContext.Directory.GetSerializer(sourceElement.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(sourceSerializer != null, "Cannot find serializer for " + sourceElement.GetDomainClass().Name + "!"); string sourceQualifier = sourceSerializer.GetMonikerQualifier(serializationContext.Directory, sourceElement); if (string.Compare(targetQualifier, sourceQualifier, global::System.StringComparison.CurrentCulture) == 0) { // See if we can create a short form reference by omitting the qualifier global::System.Diagnostics.Debug.Assert(targetMoniker.StartsWith(targetQualifier + "/", global::System.StringComparison.CurrentCulture)); string shortFormTargetMoniker = targetMoniker.Substring(targetQualifier.Length + 1); if (!DslModeling::SimpleMonikerResolver.IsFullyQualified(shortFormTargetMoniker)) targetMoniker = shortFormTargetMoniker; } } return targetMoniker; }
/// <summary> /// Calculates a Moniker, given a reference to a ModelClass /// </summary> /// <param name="serializationContext">Serialization context.</param> /// <param name="sourceElement">Instance of ModelClass that contains the given serialized reference</param> /// <param name="domainClassId">DomainClassId of the model element that the given moniker string will be resolved to.</param> /// <param name="monikerString">Serialized string reference to an instance of ModelClass</param> /// <param name="store">Store where the Moniker will be created</param> /// <returns>A Moniker encapsulating the serialized string reference of ModelClass instance</returns> public override DslModeling::Moniker MonikerizeReference(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement sourceElement, global::System.Guid domainClassId, string monikerString, DslModeling::Store store) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationContext != null); if (serializationContext == null) throw new global::System.ArgumentNullException("serializationContext"); global::System.Diagnostics.Debug.Assert(sourceElement != null); if (sourceElement == null) throw new global::System.ArgumentNullException ("sourceElement"); global::System.Diagnostics.Debug.Assert (sourceElement is ModelClass, "Expecting an instance of ModelClass!"); global::System.Diagnostics.Debug.Assert (!string.IsNullOrEmpty (monikerString)); if (string.IsNullOrEmpty (monikerString)) throw new global::System.ArgumentNullException ("monikerString"); global::System.Diagnostics.Debug.Assert(store != null); if (store == null) throw new global::System.ArgumentNullException ("store"); #endregion DslModeling::MonikerKey key = null; if (DslModeling::SimpleMonikerResolver.IsFullyQualified(monikerString)) { key = new DslModeling::MonikerKey(monikerString, InheritanceRelation.DomainClassId, domainClassId, store); } else { DslModeling::DomainClassXmlSerializer sourceSerializer = serializationContext.Directory.GetSerializer(sourceElement.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(sourceSerializer != null, "Cannot find serializer for " + sourceElement.GetDomainClass().Name + "!"); string sourceQualifier = sourceSerializer.GetMonikerQualifier(serializationContext.Directory, sourceElement); key = new DslModeling::MonikerKey(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, "{0}/{1}", sourceQualifier, monikerString), InheritanceRelation.DomainClassId, domainClassId, store); } return new DslModeling::Moniker(key, store); }
/// <summary> /// Returns a collection of property view models for the given selected elements. /// </summary> /// <param name="models">Already gathered models.</param> /// <param name="modelElement">ModelElement.</param> /// <param name="handledStores">Stores that have already been processed.</param> /// <returns>Collection of property view models. Can be empty.</returns> public override bool AddPropertyEditorViewModels(System.Collections.Generic.List<DslEditorViewModelPropertyGrid::PropertyGridViewModel> models, DslModeling::ModelElement modelElement, System.Collections.Generic.List<DslEditorViewModelData::ViewModelStore> handledStores) { if( handledStores.Contains(this.Store) ) return false; else handledStores.Add(this.Store); if( modelElement.GetDomainClass().Id == global::Tum.FamilyTreeDSL.FamilyTreePerson.DomainClassId ) { models.Add(new PropertyGridFamilyTreePersonViewModel(this.Store, modelElement as global::Tum.FamilyTreeDSL.FamilyTreePerson)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.FamilyTreeDSL.ParentOf.DomainClassId ) { models.Add(new PropertyGridParentOfViewModel(this.Store, modelElement as global::Tum.FamilyTreeDSL.ParentOf)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.FamilyTreeDSL.MarriedTo.DomainClassId ) { models.Add(new PropertyGridMarriedToViewModel(this.Store, modelElement as global::Tum.FamilyTreeDSL.MarriedTo)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.FamilyTreeDSL.Pet.DomainClassId ) { models.Add(new PropertyGridPetViewModel(this.Store, modelElement as global::Tum.FamilyTreeDSL.Pet)); return true; } else { foreach(DslEditorViewModelData::ViewModelStore eS in this.Store.ExternStores) if( eS.Factory.AddPropertyEditorViewModels(models, modelElement, handledStores) ) return true; } return false; }
/// <summary> /// Read an element from the root of XML. /// </summary> /// <param name="serializationContext">Serialization context.</param> /// <param name="rootElement">In-memory element instance that will get the deserialized data.</param> /// <param name="reader">XmlReader to read serialized data from.</param> /// <param name="schemaResolver">An ISchemaResolver that allows the serializer to do schema validation on the root element (and everything inside it).</param> protected override void ReadRootElement(DslModeling::SerializationContext serializationContext, DslModeling::ModelElement rootElement, global::System.Xml.XmlReader reader, DslModeling::ISchemaResolver schemaResolver) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationContext != null); if (serializationContext == null) throw new global::System.ArgumentNullException("serializationContext"); global::System.Diagnostics.Debug.Assert(rootElement != null); if (rootElement == null) throw new global::System.ArgumentNullException("rootElement"); global::System.Diagnostics.Debug.Assert(reader != null); if (reader == null) throw new global::System.ArgumentNullException("reader"); #endregion DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(rootElement.Store); DslModeling::DomainClassXmlSerializer rootSerializer = null; if (rootElement is DslDiagrams::Diagram) { rootSerializer = directory.GetSerializer(PatternModelSchemaDiagram.DomainClassId); } else { rootSerializer = directory.GetSerializer(rootElement.GetDomainClass().Id); } global::System.Diagnostics.Debug.Assert(rootSerializer != null, @"Cannot find serializer for " + rootElement.GetDomainClass().Name + @"!"); // Version check. this.CheckVersion(serializationContext, reader); if (!serializationContext.Result.Failed) { // Use a validating reader if possible using (reader = TryCreateValidatingReader(schemaResolver, reader, serializationContext)) { rootSerializer.Read(serializationContext, rootElement, reader); } } }
/// <summary> /// Returns a collection of property view models for the given selected elements. /// </summary> /// <param name="models">Already gathered models.</param> /// <param name="modelElement">ModelElement.</param> /// <param name="handledStores">Stores that have already been processed.</param> /// <returns>Collection of property view models. Can be empty.</returns> public override bool AddPropertyEditorViewModels(System.Collections.Generic.List<DslEditorViewModelPropertyGrid::PropertyGridViewModel> models, DslModeling::ModelElement modelElement, System.Collections.Generic.List<DslEditorViewModelData::ViewModelStore> handledStores) { if( handledStores.Contains(this.Store) ) return false; else handledStores.Add(this.Store); if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.DomainElement.DomainClassId ) { models.Add(new PropertyGridDomainElementViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.DomainElement)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.ReferencingDRType.DomainClassId ) { models.Add(new PropertyGridReferencingDRTypeViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.ReferencingDRType)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.EmbeddingDRType.DomainClassId ) { models.Add(new PropertyGridEmbeddingDRTypeViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.EmbeddingDRType)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.DEType.DomainClassId ) { models.Add(new PropertyGridDETypeViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.DEType)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.ReferenceRelationship.DomainClassId ) { models.Add(new PropertyGridReferenceRelationshipViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.ReferenceRelationship)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.EmbeddingRelationship.DomainClassId ) { models.Add(new PropertyGridEmbeddingRelationshipViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.EmbeddingRelationship)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.ExternalType.DomainClassId ) { models.Add(new PropertyGridExternalTypeViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.ExternalType)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.DomainEnumeration.DomainClassId ) { models.Add(new PropertyGridDomainEnumerationViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.DomainEnumeration)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.DomainElementReferencesDEType.DomainClassId ) { models.Add(new PropertyGridDomainElementReferencesDETypeViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.DomainElementReferencesDEType)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.DomainPropertyReferencesDomainType.DomainClassId ) { models.Add(new PropertyGridDomainPropertyReferencesDomainTypeViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.DomainPropertyReferencesDomainType)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.DRTypeReferencesDETypeTarget.DomainClassId ) { models.Add(new PropertyGridDRTypeReferencesDETypeTargetViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.DRTypeReferencesDETypeTarget)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.DRTypeReferencesDETypeSource.DomainClassId ) { models.Add(new PropertyGridDRTypeReferencesDETypeSourceViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.DRTypeReferencesDETypeSource)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.DRTypeReferencesBaseElementSourceReferencesBaseElementTarget.DomainClassId ) { models.Add(new PropertyGridDRTypeReferencesBaseElementSourceReferencesBaseElementTargetViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.DRTypeReferencesBaseElementSourceReferencesBaseElementTarget)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.DomainProperty.DomainClassId ) { models.Add(new PropertyGridDomainPropertyViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.DomainProperty)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.EnumerationLiteral.DomainClassId ) { models.Add(new PropertyGridEnumerationLiteralViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.EnumerationLiteral)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.PDE.ModelingDSL.ConversionModelInfo.DomainClassId ) { models.Add(new PropertyGridConversionModelInfoViewModel(this.Store, modelElement as global::Tum.PDE.ModelingDSL.ConversionModelInfo)); return true; } else { foreach(DslEditorViewModelData::ViewModelStore eS in this.Store.ExternStores) if( eS.Factory.AddPropertyEditorViewModels(models, modelElement, handledStores) ) return true; } return false; }
/// <summary> /// Get the display name of type of the element as string. /// </summary> /// <param name="modelElement">ModelElement to get the type display name for.</param> /// <returns>Display name of the type as a string.</returns> public string GetTypeDisplayName(DslModeling::ModelElement modelElement) { if( modelElement == null ) return ""; return GetTypeDisplayName(modelElement.GetDomainClass().Id); }
/// <summary> /// Returns a collection of property view models for the given selected elements. /// </summary> /// <param name="models">Already gathered models.</param> /// <param name="modelElement">ModelElement.</param> /// <param name="handledStores">Stores that have already been processed.</param> /// <returns>Collection of property view models. Can be empty.</returns> public override bool AddPropertyEditorViewModels(System.Collections.Generic.List<DslEditorViewModelPropertyGrid::PropertyGridViewModel> models, DslModeling::ModelElement modelElement, System.Collections.Generic.List<DslEditorViewModelData::ViewModelStore> handledStores) { if( handledStores.Contains(this.Store) ) return false; else handledStores.Add(this.Store); if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.VModellvariante.DomainClassId ) { models.Add(new PropertyGridVModellvarianteViewModel(this.Store, modelElement as global::Tum.VModellXT.VModellvariante)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.VModell.DomainClassId ) { models.Add(new PropertyGridVModellViewModel(this.Store, modelElement as global::Tum.VModellXT.VModell)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.ReferenzmodellReferencesVModellvariante.DomainClassId ) { models.Add(new PropertyGridReferenzmodellReferencesVModellvarianteViewModel(this.Store, modelElement as global::Tum.VModellXT.ReferenzmodellReferencesVModellvariante)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.Variante.DomainClassId ) { models.Add(new PropertyGridVarianteViewModel(this.Store, modelElement as global::Tum.VModellXT.Variante)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.ThemenmusterReferencesThema.DomainClassId ) { models.Add(new PropertyGridThemenmusterReferencesThemaViewModel(this.Store, modelElement as global::Tum.VModellXT.ThemenmusterReferencesThema)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.VarianteSourceReferencesVarianteTarget.DomainClassId ) { models.Add(new PropertyGridVarianteSourceReferencesVarianteTargetViewModel(this.Store, modelElement as global::Tum.VModellXT.VarianteSourceReferencesVarianteTarget)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.ThemenmusterReferencesUnterthema.DomainClassId ) { models.Add(new PropertyGridThemenmusterReferencesUnterthemaViewModel(this.Store, modelElement as global::Tum.VModellXT.ThemenmusterReferencesUnterthema)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.Zusatzthema.DomainClassId ) { models.Add(new PropertyGridZusatzthemaViewModel(this.Store, modelElement as global::Tum.VModellXT.Zusatzthema)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.Musterbibliothek.DomainClassId ) { models.Add(new PropertyGridMusterbibliothekViewModel(this.Store, modelElement as global::Tum.VModellXT.Musterbibliothek)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.Referenzmodell.DomainClassId ) { models.Add(new PropertyGridReferenzmodellViewModel(this.Store, modelElement as global::Tum.VModellXT.Referenzmodell)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.Mustergruppe.DomainClassId ) { models.Add(new PropertyGridMustergruppeViewModel(this.Store, modelElement as global::Tum.VModellXT.Mustergruppe)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.Mustertext.DomainClassId ) { models.Add(new PropertyGridMustertextViewModel(this.Store, modelElement as global::Tum.VModellXT.Mustertext)); return true; } else if( modelElement.GetDomainClass().Id == global::Tum.VModellXT.Themenmuster.DomainClassId ) { models.Add(new PropertyGridThemenmusterViewModel(this.Store, modelElement as global::Tum.VModellXT.Themenmuster)); return true; } else { foreach(DslEditorViewModelData::ViewModelStore eS in this.Store.ExternStores) if( eS.Factory.AddPropertyEditorViewModels(models, modelElement, handledStores) ) return true; } return false; }
/// <summary> /// Returns a collection of property view models for the given selected elements. /// </summary> /// <param name="models">Already gathered models.</param> /// <param name="modelElement">ModelElement.</param> /// <param name="handledStores">Stores that have already been processed.</param> /// <returns>Collection of property view models. Can be empty.</returns> public override bool AddPropertyEditorViewModels(System.Collections.Generic.List<DslEditorViewModelPropertyGrid::PropertyGridViewModel> models, DslModeling::ModelElement modelElement, System.Collections.Generic.List<DslEditorViewModelData::ViewModelStore> handledStores) { if( handledStores.Contains(this.Store) ) return false; else handledStores.Add(this.Store); if( modelElement.GetDomainClass().Id == global::Tum.TestLanguage.Test.DomainClassId ) { models.Add(new PropertyGridTestViewModel(this.Store, modelElement as global::Tum.TestLanguage.Test)); return true; } else { foreach(DslEditorViewModelData::ViewModelStore eS in this.Store.ExternStores) if( eS.Factory.AddPropertyEditorViewModels(models, modelElement, handledStores) ) return true; } return false; }
/// <summary> /// Method to supply the name for ModelElementTreeNode object in the TreeView. /// </summary> /// <param name="modelElement">Element to be displayed in the tree node</param> /// <returns>Name shown in the Model Explorer</returns> private string GetModelElementDisplayName(DslModeling::ModelElement modelElement) { string treeNodeDisplayName = null; DslModeling::DomainDataDirectory directory = modelElement.Store.DomainDataDirectory; DslModeling::DomainPropertyInfo domainPropertyInfo = null; DslModeling::ModelElement redirectedElement = null; switch ( modelElement.GetDomainClass().Id.ToString( "D", System.Globalization.CultureInfo.InvariantCulture) ) { case "8022b63d-c856-4a0e-9881-c24888e718c5": // EntityMetadata.DomainClassId { domainPropertyInfo = directory.FindDomainProperty( global::nHydrate.Dsl.EntityMetadata.KeyDomainPropertyId); redirectedElement = modelElement; } break; case "e4d98918-02cc-4cb0-94fc-2da89080f5be": // FieldMetadata.DomainClassId { domainPropertyInfo = directory.FindDomainProperty( global::nHydrate.Dsl.FieldMetadata.KeyDomainPropertyId); redirectedElement = modelElement; } break; case "ced4ceba-e07d-4396-b2fe-a981c60933d0": // Index.DomainClassId { domainPropertyInfo = directory.FindDomainProperty( global::nHydrate.Dsl.Index.DefinitionDomainPropertyId); redirectedElement = modelElement; } break; case "06e94c72-d866-4c92-b5a9-624fdbebdf9e": // IndexColumn.DomainClassId { domainPropertyInfo = directory.FindDomainProperty( global::nHydrate.Dsl.IndexColumn.DefinitionDomainPropertyId); redirectedElement = modelElement; } break; } if (domainPropertyInfo != null && redirectedElement != null) { // Get the name based on the designated domian property treeNodeDisplayName = domainPropertyInfo.GetValue(redirectedElement) as string; } else { // The passed in modelElement does not have a DomainPath specified. Try access the default name from the element. DslModeling::DomainClassInfo.TryGetName(modelElement, out treeNodeDisplayName); } return treeNodeDisplayName; }