本文整理汇总了C#中IDeclaredElement.GetContainingType方法的典型用法代码示例。如果您正苦于以下问题:C# IDeclaredElement.GetContainingType方法的具体用法?C# IDeclaredElement.GetContainingType怎么用?C# IDeclaredElement.GetContainingType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDeclaredElement
的用法示例。
在下文中一共展示了IDeclaredElement.GetContainingType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateContextSpecification
public ContextSpecificationElement CreateContextSpecification(IDeclaredElement field)
{
#if RESHARPER_6
IClass clazz = ((ITypeMember)field).GetContainingType() as IClass;
#else
IClass clazz = field.GetContainingType() as IClass;
#endif
if (clazz == null)
{
return null;
}
ContextElement context;
_cache.Classes.TryGetValue(clazz, out context);
if (context == null)
{
return null;
}
return GetOrCreateContextSpecification(_provider,
_project,
context,
_projectEnvoy,
#if RESHARPER_6
clazz.GetClrName().FullName,
#else
clazz.CLRName,
#endif
field.ShortName,
clazz.GetTags(),
field.IsIgnored());
}
示例2: CreateBehavior
public BehaviorElement CreateBehavior(IDeclaredElement field)
{
IClass clazz = field.GetContainingType() as IClass;
if (clazz == null)
{
return null;
}
ContextElement context;
_cache.Classes.TryGetValue(clazz, out context);
if (context == null)
{
return null;
}
string fullyQualifiedTypeName = null;
if (field is ITypeOwner)
{
// Work around the difference in how the MetaData API and Psi API return different type strings for generics.
TypeNameCache.TryGetValue(GetFirstGenericNormalizedTypeName(field), out fullyQualifiedTypeName);
}
return new BehaviorElement(_provider,
context,
_projectEnvoy,
clazz.CLRName,
field.ShortName,
field.IsIgnored(),
fullyQualifiedTypeName);
}
示例3: CreateBehaviorSpecification
BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
IDeclaredElement behaviorSpecification)
{
return new BehaviorSpecificationElement(_provider,
behavior,
_projectEnvoy,
behaviorSpecification.GetContainingType().CLRName,
behaviorSpecification.ShortName,
behaviorSpecification.IsIgnored());
}
示例4: CreateBehaviorSpecification
BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
IDeclaredElement behaviorSpecification)
{
return new BehaviorSpecificationElement(_provider,
behavior,
_projectEnvoy,
#if RESHARPER_6
behavior.FullyQualifiedTypeName ?? ((ITypeMember)behaviorSpecification).GetContainingType().GetClrName().FullName,
#else
behavior.FullyQualifiedTypeName ?? behaviorSpecification.GetContainingType().CLRName,
#endif
behaviorSpecification.ShortName,
behaviorSpecification.IsIgnored());
}
示例5: GetFullMethodName
/// <summary>
/// Gets the full name of the method.
/// </summary>
/// <param name="method">
/// The method.
/// </param>
/// <returns>
/// The get full method name.
/// </returns>
public static string GetFullMethodName(IDeclaredElement method)
{
var result = method.ShortName;
var typeElement = method.GetContainingType();
if (typeElement != null)
{
result = typeElement.ShortName + "." + result;
var ns = typeElement.GetContainingNamespace();
result = ns.QualifiedName + "." + result;
}
return result;
}
示例6: CreateBehavior
public BehaviorElement CreateBehavior(IDeclaredElement field)
{
#if RESHARPER_6
IClass clazz = ((ITypeMember)field).GetContainingType() as IClass;
#else
IClass clazz = field.GetContainingType() as IClass;
#endif
if (clazz == null)
{
return null;
}
ContextElement context;
_cache.Classes.TryGetValue(clazz, out context);
if (context == null)
{
return null;
}
string fullyQualifiedTypeName = null;
if (field is ITypeOwner)
{
// Work around the difference in how the MetaData API and Psi API return different type strings for generics.
TypeNameCache.TryGetValue(GetFirstGenericNormalizedTypeName(field), out fullyQualifiedTypeName);
}
return GetOrCreateBehavior(_provider,
#if RESHARPER_61
_manager, _psiModuleManager, _cacheManager,
#endif
_project,
_projectEnvoy,
context,
#if RESHARPER_6
clazz.GetClrName().FullName,
#else
clazz.CLRName,
#endif
field.ShortName,
field.IsIgnored(),
fullyQualifiedTypeName);
}
示例7: CreateContextSpecification
public ContextSpecificationElement CreateContextSpecification(IDeclaredElement field)
{
IClass clazz = field.GetContainingType() as IClass;
if (clazz == null)
{
return null;
}
ContextElement context = _cache.Classes[clazz];
if (context == null)
{
return null;
}
return new ContextSpecificationElement(_provider,
context,
_project,
clazz.CLRName,
field.ShortName,
field.IsIgnored());
}
示例8: CreateBehavior
public BehaviorElement CreateBehavior(IDeclaredElement field)
{
IClass clazz = field.GetContainingType() as IClass;
if (clazz == null)
{
return null;
}
ContextElement context = ContextCache.Classes[clazz];
if (context == null)
{
return null;
}
return new BehaviorElement(_provider,
context,
_project,
clazz.CLRName,
field.ShortName,
field.IsIgnored());
}
示例9: CreateContextSpecification
public ContextSpecificationElement CreateContextSpecification(IDeclaredElement field)
{
IClass clazz = field.GetContainingType() as IClass;
if (clazz == null)
{
return null;
}
ContextElement context;
_cache.Classes.TryGetValue(clazz, out context);
if (context == null)
{
return null;
}
return new ContextSpecificationElement(_provider,
context,
_projectEnvoy,
clazz.CLRName,
field.ShortName,
clazz.GetTags(),
field.IsIgnored());
}
示例10: IsInSpecificationContainer
/// <summary>
/// Determines if the declared element is contained in a MSpec-related container type,
/// i.e.: Context, context base class, class with <see cref="BehaviorsAttribute" />.
/// </summary>
static bool IsInSpecificationContainer(IDeclaredElement declaredElement)
{
var containingType = declaredElement.GetContainingType();
return IsContext(containingType) || containingType.IsBehaviorContainer() || IsContextBase(containingType);
}
示例11: IsInSpecificationContainer
/// <summary>
/// Determines if the declared element is contained in a MSpec-related container type,
/// i.e.: Context, context base class, class with <see cref="BehaviorsAttribute" />.
/// </summary>
static bool IsInSpecificationContainer(IDeclaredElement declaredElement)
{
#if RESHARPER_6
ITypeElement containingType = null;
if (declaredElement is ITypeMember)
containingType = ((ITypeMember) declaredElement).GetContainingType();
else if (declaredElement is ITypeElement)
containingType = (ITypeElement) declaredElement;
#else
var containingType = declaredElement.GetContainingType();
#endif
return IsContext(containingType) || containingType.IsBehaviorContainer() || IsContextBase(containingType);
}
示例12: IsBehavior
static bool IsBehavior(IDeclaredElement declaredElement)
{
return declaredElement.IsBehavior() && IsTestElement(declaredElement.GetContainingType());
}
示例13: IsInTestElementOrContext
static bool IsInTestElementOrContext(IDeclaredElement declaredElement)
{
return IsTestElement(declaredElement.GetContainingType()) || IsContextBase(declaredElement.GetContainingType());
}
示例14: IsSupportingField
static bool IsSupportingField(IDeclaredElement declaredElement)
{
return declaredElement.IsSupportingField() &&
(IsTestElement(declaredElement.GetContainingType()) || IsContextBase(declaredElement.GetContainingType()));
}