当前位置: 首页>>代码示例>>C#>>正文


C# IDeclaredElement.IsValid方法代码示例

本文整理汇总了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();
        }
开发者ID:lhsail,项目名称:Nitra,代码行数:51,代码来源:NitraDeclaredElementPresenter.cs

示例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);
      }
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:20,代码来源:GeneratedClassSearchRequest.cs

示例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));
        }
      }
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:39,代码来源:CSharpToPsiSearchRequest.cs

示例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;
                    }
                }
            }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:27,代码来源:GallioTestProvider.cs

示例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;
				}
			}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:26,代码来源:GallioTestProvider6.cs


注:本文中的IDeclaredElement.IsValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。