本文整理汇总了C#中ModelElement.GetDomainClass方法的典型用法代码示例。如果您正苦于以下问题:C# ModelElement.GetDomainClass方法的具体用法?C# ModelElement.GetDomainClass怎么用?C# ModelElement.GetDomainClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelElement
的用法示例。
在下文中一共展示了ModelElement.GetDomainClass方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetChildren
/// <summary>
/// Retrieves all children of a specific parent element. This includes all model elements that are reachable
/// from the parent element through the embedding relationship.
/// </summary>
/// <param name="parentElement">Parent element to retrieve children for.</param>
/// <param name="bOnlyLocal">Specifies if children of the found children of the given element should be processed too.</param>
/// <returns>List of model elements that are embedded under the parent element. May be empty.</returns>
public virtual List<ModelElement> GetChildren(ModelElement parentElement, bool bOnlyLocal)
{
List<ModelElement> allChildren = new List<ModelElement>();
DomainClassInfo info = parentElement.GetDomainClass();
ReadOnlyCollection<DomainRoleInfo> roleInfoCol = info.AllDomainRolesPlayed;
foreach (DomainRoleInfo roleInfo in roleInfoCol)
{
if (roleInfo.IsSource)
if ((parentElement as IDomainModelOwnable).Store.DomainDataAdvDirectory.IsEmbeddingRelationship(roleInfo.DomainRelationship.Id))
{
global::System.Collections.Generic.IList<ElementLink> links = DomainRoleInfo.GetElementLinks<ElementLink>(parentElement, roleInfo.Id);
foreach (ElementLink link in links)
{
ModelElement child = DomainRoleInfo.GetTargetRolePlayer(link);
allChildren.Add(child);
if (!bOnlyLocal)
{
allChildren.AddRange(
(child as IDomainModelOwnable).GetDomainModelServices().ElementChildrenProvider.GetChildren(child, bOnlyLocal));
}
}
}
}
return allChildren;
}
示例2: ModelProtoElement
/// <summary>
/// Constructor.
/// </summary>
/// <param name="element">Model element.</param>
public ModelProtoElement(ModelElement element)
{
if (element == null)
throw new System.ArgumentNullException("element");
elementId = element.Id;
domainClassId = element.GetDomainClass().Id;
List<PropertyAssignment> list = GetAssignablePropertyValues(element);
properties = new System.Collections.ArrayList(list.Count);
foreach (PropertyAssignment propertyAssignment in list)
properties.Add(new ModelProtoPropertyValue(propertyAssignment.PropertyId, propertyAssignment.Value));
DomainClassInfo d = element.GetDomainClass();
name = d.Name;
}
示例3: GetElementNames
private IDictionary<string, ModelElement> GetElementNames(ModelElement element)
{
var names = new Dictionary<string, ModelElement>();
element.Store.ElementDirectory.AllElements
.Where(e => e.GetDomainClass().ImplementationClass == element.GetDomainClass().ImplementationClass)
.Where(e => !e.Equals(element))
.ForEach(e =>
{
var name = (string)this.DomainProperty.GetValue(e);
if (!names.ContainsKey(name))
{
names.Add(name, e);
}
});
return names;
}
示例4: CreateName
/// <summary>
/// Method used to create a new element's name based on the range of available names.
/// Excluded are names used by the child elements embedded in the given parent element.
/// </summary>
/// <param name="parent">Parent element, embedding the model element.</param>
/// <param name="modelElement">ModelElement to create the name for.</param>
/// <returns>Created name for the given ModelElement. </returns>
public virtual string CreateName(ModelElement parent, ModelElement modelElement)
{
if (parent is IDomainModelOwnable && modelElement is IDomainModelOwnable)
{
if (!(modelElement as IDomainModelOwnable).DomainElementHasName)
return null;
DomainClassInfo infoParent = parent.GetDomainClass();
DomainClassInfo infoChild = modelElement.GetDomainClass();
IModelElementParentProvider parentprovider = (parent as IDomainModelOwnable).GetDomainModelServices().ElementParentProvider;
foreach (DomainRoleInfo roleInfo in infoParent.AllDomainRolesPlayed)
{
if (roleInfo.IsSource)
//if (roleInfo.OppositeDomainRole.RolePlayer.Id == infoChild.Id)
if( infoChild.IsDerivedFrom(roleInfo.OppositeDomainRole.RolePlayer) )
if ((modelElement as IDomainModelOwnable).Store.DomainDataAdvDirectory.IsEmbeddingRelationship(roleInfo.DomainRelationship.Id))
{
int counter = 0;
string name = (modelElement as IDomainModelOwnable).DomainElementTypeDisplayName;
while (true)
{
bool bFound = false;
IList<ElementLink> links = DomainRoleInfo.GetElementLinks<ElementLink>(parent, roleInfo.Id);
foreach (ElementLink c in links)
{
if ((DomainRoleInfo.GetTargetRolePlayer(c) as IDomainModelOwnable).DomainElementName == name + counter.ToString())
{
bFound = true;
break;
}
}
if (!bFound)
return name + counter.ToString();
counter++;
}
}
}
}
return null;
}
示例5: BaseModelElementViewModel
/// <summary>
/// Constructor. This view model constructed with 'bHookUpEvents=true' does react on model changes.
/// </summary>
/// <param name="viewModelStore">The store this view model belongs to.</param>
/// <param name="element">Element represented by this view model.</param>
/// <param name="bHookUpEvents">Hook up into model events to update the created view model on changes in model if true.</param>
public BaseModelElementViewModel(ViewModelStore viewModelStore, ModelElement element, bool bHookUpEvents)
: base(viewModelStore)
{
this.element = element;
this.bHookUpEvents = bHookUpEvents;
if (element != null)
if (ImmutabilityExtensionMethods.GetLocks(element) != Locks.None)
this.IsLocked = true;
if( this.bHookUpEvents )
if (element != null)
{
DomainPropertyInfo info = element.GetDomainClass().NameDomainProperty;
if (info != null)
this.EventManager.GetEvent<ModelElementPropertyChangedEvent>().Subscribe(
info, this.Element.Id, new System.Action<ElementPropertyChangedEventArgs>(NamePropertyChanged));
}
}
示例6: GetAllEmbeddedElements
private static HashSet<ModelElement> GetAllEmbeddedElements(ModelElement element)
{
HashSet<ModelElement> embeddedElements = new HashSet<ModelElement>();
HashSet<DomainRoleInfo> embeddingRoles = GetAllEmbeddingRoles(element.GetDomainClass());
foreach (DomainRoleInfo roleInfo in embeddingRoles)
{
// The role could have a multiplicity of 1 or many - which is it?
if (roleInfo.IsMany)
{
// Fetch and add each of the elements to the set
roleInfo.GetLinkedElements(element).ForEach(e => { embeddedElements.Add(e); });
}
else
{
// Add the single element to the set
ModelElement linkedElement = roleInfo.GetLinkedElement(element);
if (linkedElement != null)
{
embeddedElements.Add(linkedElement);
}
}
}
return embeddedElements;
}
示例7: CreateChildShape
protected override Microsoft.VisualStudio.Modeling.Diagrams.ShapeElement CreateChildShape(ModelElement element)
{
var btProcess = (SubProcess)ModelElement;
if (btProcess.VisioId == string.Empty)
using (Transaction trans = this.Store.TransactionManager.BeginTransaction("create process visio id"))
{
btProcess.VisioId = btProcess.Id.ToString().ToLower();
trans.Commit();
}
var elementClass = element.GetDomainClass();
using (Transaction trans = Store.TransactionManager.BeginTransaction("create activity code id"))
{
if (element is FlowMinimal)
{
if (string.IsNullOrEmpty(((FlowMinimal)element).VisioId))
((FlowMinimal)element).VisioId = element.Id.ToString().ToLower();
}
else if (element is Activity)
{
if (string.IsNullOrEmpty(((Activity)element).VisioId))
((Activity)element).VisioId = element.Id.ToString().ToLower();
}
trans.Commit();
}
switch (elementClass.Name)
{
case "CloudcoreUser":
SubProcessFiles.AddPage(Store, ((Activity)element).VisioId, btProcess.VisioId);
break;
case "MobileActivity":
SubProcessFiles.AddPage(Store, ((Activity)element).VisioId, btProcess.VisioId);
break;
case "HybridActivity":
SubProcessFiles.AddPage(Store, ((Activity)element).VisioId, btProcess.VisioId);
break;
case "WorkflowRule":
SubProcessFiles.AddSql(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.SqlWorkflowRuleActivity));
break;
case "DatabaseEvent":
SubProcessFiles.AddSql(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.SqlCustomActivity));
break;
case "DatabasePark":
SubProcessFiles.AddSql(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.SqlParkedActivity));
break;
case "CloudPark":
SubProcessFiles.AddClass(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.CloudParkedActivity));
break;
case "CloudCustom":
SubProcessFiles.AddClass(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.CloudCustomActivity));
break;
case "PostageApp":
SubProcessFiles.AddClass(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.CloudPostageActivity));
break;
case "Email":
SubProcessFiles.AddClass(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.Email));
break;
case "Clickatell":
SubProcessFiles.AddClass(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.CloudClickatellActivity));
break;
case "DatabaseCosting":
SubProcessFiles.AddSql(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.SqlCostingActivity));
break;
case "CloudCosting":
SubProcessFiles.AddClass(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.CloudCostingActivity));
break;
case "DatabaseBatchStart":
SubProcessFiles.AddSql(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.SqlBatchStartActivity));
break;
case "CloudBatchStart":
SubProcessFiles.AddClass(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.CloudBatchStartActivity));
break;
case "BatchWait":
SubProcessFiles.AddClass(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.CloudBatchWaitActivity));
break;
case "DatabaseBatchWait":
SubProcessFiles.AddSql(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.SqlBatchWaitActivity));
break;
case "Corticon":
SubProcessFiles.AddClass(Store, ((Activity)element).VisioId, btProcess.VisioId, FileTypes.getFileType(FileType.CloudCorticonActivity));
break;
}
return base.CreateChildShape(element);
}
示例8: ShouldExcludeDomainClass
/// <summary>
/// Verifies if a specific model element should be excluded or not.
/// </summary>
/// <param name="modelElement">Model element to verify</param>
/// <returns>True if the specified element should be excluded; False otherwise.</returns>
public virtual bool ShouldExcludeDomainClass(ModelElement modelElement)
{
if (bUseExcludedDomainClasses || bUseIncludedDomainClasses || bUseExcludedDomainModels || bUseIncludedDomainModels)
{
Guid t = modelElement.GetDomainClass().Id;
if (bUseExcludedDomainClasses)
if (this.excludedDomainClasses.Contains(t))
return true;
if (bUseIncludedDomainClasses)
if (!this.includedDomainClasses.Contains(t))
return true;
if (bUseExcludedDomainModels)
{
IDomainModelOwnable o = modelElement as IDomainModelOwnable;
if (this.excludedDomainModels.Contains(o.GetDomainModelTypeId()))
return true;
}
if (bUseIncludedDomainModels)
{
IDomainModelOwnable o = modelElement as IDomainModelOwnable;
if (!this.includedDomainModels.Contains(o.GetDomainModelTypeId()))
return true;
}
}
return false;
}
示例9: GetAssignablePropertyValues
/// <summary>
/// Gets a list of PropertyAssignments for all assignable properties.
/// </summary>
/// <param name="element">Element to get PropertyAssignments for.</param>
/// <returns>List of PropertyAssignment.</returns>
public static List<PropertyAssignment> GetAssignablePropertyValues(ModelElement element)
{
List<PropertyAssignment> list = new List<PropertyAssignment>();
ReadOnlyCollection<DomainPropertyInfo> readOnlyCollection = element.GetDomainClass().AllDomainProperties;
foreach (DomainPropertyInfo domainPropertyInfo in readOnlyCollection)
{
if (domainPropertyInfo.Kind != Microsoft.VisualStudio.Modeling.DomainPropertyKind.Calculated)
{
object obj = domainPropertyInfo.GetValue(element);
if (obj != null)
list.Add(new PropertyAssignment(domainPropertyInfo.Id, obj));
}
}
return list;
}
示例10: Search
/// <summary>
/// Search a specific model element by using the given search criteria.
/// </summary>
/// <param name="modelElement">Model element to be searched.</param>
/// <param name="criteria">Search criteria to use.</param>
/// <param name="searchText">Text to search.</param>
/// <param name="options">Search options.</param>
/// <returns>Search result list if any found. Empty list otherwise.</returns>
public virtual List<SearchResult> Search(ModelElement modelElement, SearchCriteriaEnum criteria, string searchText, SearchOptions options)
{
List<SearchResult> results = new List<SearchResult>();
DomainClassInfo info = modelElement.GetDomainClass();
Type modelElementType = modelElement.GetType();
#region properties
if (criteria == SearchCriteriaEnum.Name ||
criteria == SearchCriteriaEnum.NameAndType ||
criteria == SearchCriteriaEnum.All ||
criteria == SearchCriteriaEnum.Properties ||
criteria == SearchCriteriaEnum.PropertiesWithoutName)
foreach (DomainPropertyInfo propertyInfo in info.AllDomainProperties)
{
if (propertyInfo == info.NameDomainProperty &&
criteria != SearchCriteriaEnum.Name &&
criteria != SearchCriteriaEnum.NameAndType &&
criteria != SearchCriteriaEnum.Properties &&
criteria != SearchCriteriaEnum.All)
continue;
else if (propertyInfo != info.NameDomainProperty &&
criteria != SearchCriteriaEnum.All &&
criteria != SearchCriteriaEnum.Properties &&
criteria != SearchCriteriaEnum.PropertiesWithoutName)
continue;
object nameValue = GetPropertyValue(modelElement, modelElementType, propertyInfo.Name);
if (nameValue == null && System.String.IsNullOrEmpty(searchText))
{
SearchResult searchResult = new SearchResult();
searchResult.IsSuccessFull = true;
searchResult.Source = modelElement;
searchResult.Reason = "Property " + propertyInfo.Name + " is 'null'";
results.Add(searchResult);
}
else if (nameValue != null && !System.String.IsNullOrEmpty(searchText))
if (Contains(nameValue.ToString(), searchText, options))
{
SearchResult searchResult = new SearchResult();
searchResult.IsSuccessFull = true;
searchResult.Source = modelElement;
searchResult.Reason = "Property " + propertyInfo.Name + " contains '" + searchText + "'";
results.Add(searchResult);
}
}
#endregion
#region roles
if (criteria == SearchCriteriaEnum.Roles ||
criteria == SearchCriteriaEnum.All)
{
foreach (DomainRoleInfo roleInfo in info.AllDomainRolesPlayed)
{
if (!roleInfo.IsSource)
continue;
DomainRelationshipInfo relInfo = roleInfo.DomainRelationship;
if (!IsLinkIncludedInDomainTree(modelElement.Store as DomainModelStore, relInfo.Id))
continue;
ReadOnlyCollection<ElementLink> links = DomainRoleInfo.GetElementLinks<ElementLink>(modelElement, roleInfo.Id);
if (links.Count == 0 && String.IsNullOrEmpty(searchText))
{
SearchResult searchResult = new SearchResult();
searchResult.IsSuccessFull = true;
searchResult.Source = modelElement;
searchResult.Reason = "Role " + roleInfo.PropertyName + " is empty";
results.Add(searchResult);
}
foreach (ElementLink link in links)
{
ModelElement m = DomainRoleInfo.GetTargetRolePlayer(link);
if (m == null && System.String.IsNullOrEmpty(searchText))
{
SearchResult searchResult = new SearchResult();
searchResult.IsSuccessFull = true;
searchResult.Source = modelElement;
searchResult.Reason = "Role " + roleInfo.PropertyName + " is null";
results.Add(searchResult);
}
else if (m != null && !System.String.IsNullOrEmpty(searchText))
if (Contains((m as IDomainModelOwnable).DomainElementFullName, searchText, options))
{
SearchResult searchResult = new SearchResult();
searchResult.IsSuccessFull = true;
searchResult.Source = modelElement;
//.........这里部分代码省略.........
示例11: GetRelatedElements
protected virtual IList<ModelElement> GetRelatedElements(ModelElement element)
{
List<ModelElement> elementList = new List<ModelElement>();
List<ModelElement> elementLinks = IncludeLinks ? new List<ModelElement>() : null;
// All the links to this element needs to be examined to determine whether we should continue copying process or not
// Find all the links connect to this element (or elementLink since it's legal to have element link to be a roleplayer as well...)
foreach(DomainRoleInfo domainRole in element.GetDomainClass().AllDomainRolesPlayed)
{
// this function supports demand loading
ReadOnlyCollection<ElementLink> links = domainRole.GetElementLinks(element);
foreach(ElementLink eachElemLink in links)
{
if(eachElemLink.GetType() != typeof(PresentationViewsSubject))
{
DomainRelationshipInfo domainRelInfo = eachElemLink.GetDomainRelationship();
if(Filter.ShouldVisitRelationship(this, element, domainRole, domainRelInfo, eachElemLink) == VisitorFilterResult.Yes)
{
if(IncludeLinks)
{
elementLinks.Add(eachElemLink);
}
IList<DomainRoleInfo> domainRoles = domainRelInfo.DomainRoles;
for(int i = 0; i < domainRoles.Count; i++)
{
DomainRoleInfo role = domainRoles[i];
ModelElement rolePlayer = role.GetRolePlayer(eachElemLink);
// Find each roleplayer and add them to the queue list
if((rolePlayer != element) && !Visited(rolePlayer) && (Filter.ShouldVisitRolePlayer(this, element, eachElemLink, role, rolePlayer) == VisitorFilterResult.Yes))
{
elementList.Add(rolePlayer);
}
}
}
}
}
}
if(IncludeLinks)
{
elementList.AddRange(elementLinks);
}
elementList.TrimExcess();
return elementList;
}