本文整理汇总了C#中IElement.GetModelStore方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.GetModelStore方法的具体用法?C# IElement.GetModelStore怎么用?C# IElement.GetModelStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElement
的用法示例。
在下文中一共展示了IElement.GetModelStore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyStereotype
/// <summary>
/// 应用扩展项目
/// </summary>
/// <param name="opertion">模型对象</param>
/// <param name="ProfileName"></param>
/// <param name="StereotypeName"></param>
private void ApplyStereotype(IElement opertion, string ProfileName, string StereotypeName)
{
var q = opertion.GetModelStore().ProfileManager.AllProfiles.ToList();
foreach (IProfile ip in q)
{
if (ip.Name == ProfileName)
{
foreach (IStereotype istype in ip.Stereotypes)
{
if (istype.Name == StereotypeName && opertion.ApplicableStereotypes.ToList().Contains(istype))
{
var stereotypeInstaces = opertion.AppliedStereotypes.ToList();
int count = 0;
foreach (IStereotypeInstance isInstance in stereotypeInstaces)
{
if (isInstance.Name == istype.Name)
{
count = count + 1;
break;
}
}
if (count == 0)
{
opertion.ApplyStereotype(istype);
}
}
}
}
}
}
示例2: isExistModel
/// <summary>
/// 模型是否存在
/// </summary>
/// <param name="element">模型对象</param>
/// <param name="modeType">模型类型0==类 1==接口 2==包</param>
/// <param name="modelName">模型名称</param>
/// <returns>模型是否存在</returns>
private bool isExistModel(IElement element, int modeType, string modelName)
{
bool isExistModel = false;
var packages = element.GetModelStore().Root.NestedPackages;
foreach (IPackage package in packages)
{
isExistModel = isExistModelInPackage(package, modeType, modelName);
if (isExistModel == true)
{
break;
}
}
return isExistModel;
}
示例3: RemoveProjectItemByType
/// <summary>
/// 通过模型类型移除项目
/// </summary>
/// <param name="element">模型对象</param>
/// <param name="modeType">模型类型0==类 1==接口 2==包</param>
/// <param name="modelName">模型名称</param>
private void RemoveProjectItemByType(IElement element, int modeType, string modelName)
{
EnvDTE80.DTE2 dte = Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;
//获得TextTemplateBindings
//项目路径
string projectsPath = GetStereotypePropertyValue(element.GetModelStore().Root, "TextTemplateBindings", "ProjectPath"); ;
//文件名称
string targetsNames = GetStereotypePropertyValue(element.GetModelStore().Root, "TextTemplateBindings", "TargetName");
//类项目名称
string classProjectName = GetTemplateProjectName(projectsPath, "TelChinaClassTemplate");
//DTO项目名称
string dtoProjectName = GetTemplateProjectName(projectsPath, "TelChinaClassToDTOTemplate");
//接口项目名称
string interfaceProjectName = GetTemplateProjectName(projectsPath, "TelChinaInterfaceTemplate");
//实现项目名称
string contractProjectName = GetTemplateProjectName(projectsPath, "TelChinaImplTemplate");
//类文件集合
List<string> classFileNameList = new List<string>();
//DTO文件集合
List<string> dtoFileNameList = new List<string>();
//类文件集合
List<string> interfaceFileNameList = new List<string>();
//DTO文件集合
List<string> contractFileNameList = new List<string>();
if (modeType == 2)
{
classFileNameList = GetFileName(targetsNames, modelName, TemplateEnum.Package);
dtoFileNameList = GetFileName(targetsNames, modelName, TemplateEnum.Package);
interfaceFileNameList = GetFileName(targetsNames, modelName, TemplateEnum.Package);
contractFileNameList = GetFileName(targetsNames, modelName, TemplateEnum.Package);
}
else
{
classFileNameList = GetFileName(targetsNames, modelName, TemplateEnum.Class);
dtoFileNameList = GetFileName(targetsNames, modelName, TemplateEnum.DTO);
interfaceFileNameList = GetFileName(targetsNames, modelName, TemplateEnum.Interface);
contractFileNameList = GetFileName(targetsNames, modelName, TemplateEnum.Contract);
}
//取得project
var sln = dte.Solution;
bool isExistFile = false;
if (classFileNameList.Count > 0)
{
foreach (string fileName in classFileNameList)
{
isExistFile = IsExistProjectItem(sln, classProjectName, fileName);
if (isExistFile)
{ break; }
}
}
if (dtoFileNameList.Count > 0 && !isExistFile)
{
foreach (string fileName in dtoFileNameList)
{
isExistFile = IsExistProjectItem(sln, dtoProjectName, fileName);
if (isExistFile)
{ break; }
}
}
if (interfaceFileNameList.Count > 0 && !isExistFile)
{
foreach (string fileName in interfaceFileNameList)
{
isExistFile = IsExistProjectItem(sln, interfaceProjectName, fileName);
if (isExistFile)
{ break; }
}
}
if (contractFileNameList.Count > 0 && !isExistFile)
{
foreach (string fileName in contractFileNameList)
{
isExistFile = IsExistProjectItem(sln, contractProjectName, fileName);
if (isExistFile)
{ break; }
}
}
if (!isExistFile)
{
return;
//.........这里部分代码省略.........