本文整理汇总了C#中IDeclaredElement.IsValid方法的典型用法代码示例。如果您正苦于以下问题:C# IDeclaredElement.IsValid方法的具体用法?C# IDeclaredElement.IsValid怎么用?C# IDeclaredElement.IsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDeclaredElement
的用法示例。
在下文中一共展示了IDeclaredElement.IsValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
public string Format(DeclaredElementPresenterStyle style, IDeclaredElement declaredElement, ISubstitution substitution, out DeclaredElementPresenterMarking marking)
{
if (!declaredElement.IsValid())
throw new ArgumentException("declaredElement should be valid", "declaredElement");
var nitraDeclaredElement = declaredElement as NitraDeclaredElement;
if (nitraDeclaredElement == null)
throw new ArgumentException("declaredElement should have language supported by Nitra", "declaredElement");
var result = new StringBuilder();
marking = new DeclaredElementPresenterMarking();
if (style.ShowEntityKind != EntityKindForm.NONE)
{
string entityKind = GetEntityKindStr(nitraDeclaredElement);
if (entityKind != "")
{
if (style.ShowEntityKind == EntityKindForm.NORMAL_IN_BRACKETS)
entityKind = "(" + entityKind + ")";
marking.EntityKindRange = AppendString(result, entityKind);
result.Append(" ");
}
}
if (style.ShowNameInQuotes)
result.Append("\'");
if (style.ShowName != NameStyle.NONE)
{
var elementName = nitraDeclaredElement.ShortName;
if (elementName == SharedImplUtil.MISSING_DECLARATION_NAME)
elementName = "<unknown name>";
marking.NameRange = AppendString(result, elementName);
}
if (style.ShowNameInQuotes)
{
if (result[result.Length - 1] == '\'')
result.Remove(result.Length - 1, 1);
else
{
TrimString(result);
result.Append("\' ");
}
}
TrimString(result);
return result.ToString();
}
示例2: GeneratedClassSearchRequest
public GeneratedClassSearchRequest(IDeclaredElement declaredElement)
{
if (declaredElement == null)
throw new ArgumentNullException("declaredElement");
Logger.Assert(declaredElement.IsValid(), "declaredElement should be valid");
mySolution = declaredElement.GetPsiServices().Solution;
var ruleDeclaration = declaredElement as RuleDeclaration;
if( ruleDeclaration == null)
throw new ArgumentNullException("ruleDeclaration");
if (ruleDeclaration.DerivedClasses.Count() > 0)
{
myTarget = new DeclaredElementEnvoy<IDeclaredElement>(ruleDeclaration.DerivedClasses.First());
}
else
{
myTarget = new DeclaredElementEnvoy<IDeclaredElement>(declaredElement);
}
}
示例3: CSharpToPsiSearchRequest
public CSharpToPsiSearchRequest(IDeclaredElement declaredElement)
{
if (declaredElement == null)
throw new ArgumentNullException("declaredElement");
Logger.Assert(declaredElement.IsValid(), "declaredElement should be valid");
mySolution = declaredElement.GetPsiServices().Solution;
var @class = declaredElement as IClass;
if (@class != null)
{
myTarget = new DeclaredElementEnvoy<IDeclaredElement>(DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForClass(@class));
}
var @method = declaredElement as IMethod;
if (@method != null)
{
myTarget = new DeclaredElementEnvoy<IDeclaredElement>(DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForMethod(@method));
}
var @interface = declaredElement as IInterface;
if (@interface != null)
{
myTarget = new DeclaredElementEnvoy<IDeclaredElement>(DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForInterface(@interface));
}
var @constructor = declaredElement as IConstructor;
if(@constructor != null)
{
@class = @constructor.GetContainingType() as IClass;
if(@class != null)
{
myTarget = new DeclaredElementEnvoy<IDeclaredElement>(DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForClass(@class));
}
}
}
示例4: EvalTestPartPredicate
private bool EvalTestPartPredicate(IDeclaredElement element, Predicate<TestPart> predicate)
{
#if RESHARPER_45_OR_NEWER
using (ReadLockCookie.Create())
#endif
{
if (!element.IsValid())
return false;
try
{
PsiReflectionPolicy reflectionPolicy = new PsiReflectionPolicy(element.GetManager());
ICodeElementInfo elementInfo = reflectionPolicy.Wrap(element);
if (elementInfo == null)
return false;
ITestDriver driver = CreateTestDriver();
IList<TestPart> testParts = driver.GetTestParts(reflectionPolicy, elementInfo);
return GenericCollectionUtils.Exists(testParts, predicate);
}
catch (Exception ex)
{
HandleEmbeddedProcessCancelledException(ex);
throw;
}
}
}
示例5: EvalTestPartPredicate
private bool EvalTestPartPredicate(IDeclaredElement element, Predicate<TestPart> predicate)
{
if (!element.IsValid())
return false;
try
{
#if RESHARPER_60
var reflectionPolicy = new PsiReflectionPolicy(element.GetPsiServices().PsiManager);
#else
var reflectionPolicy = new PsiReflectionPolicy(element.GetPsiServices().PsiManager, provider.CacheManager);
#endif
var elementInfo = reflectionPolicy.Wrap(element);
if (elementInfo == null)
return false;
var driver = CreateTestDriver();
var testParts = driver.GetTestParts(reflectionPolicy, elementInfo);
return GenericCollectionUtils.Exists(testParts, predicate);
}
catch (Exception ex)
{
HandleEmbeddedProcessCancelledException(ex);
throw;
}
}