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


C# Field.Equals方法代码示例

本文整理汇总了C#中System.Compiler.Field.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Field.Equals方法的具体用法?C# Field.Equals怎么用?C# Field.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Compiler.Field的用法示例。


在下文中一共展示了Field.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckField

    private void CheckField(Field field) {
      if (field == null) return;

      // if method is StateIndependent then has to be readonly or field of an immutable type
      if (Method.IsStateIndependent &&
          !(field.IsInitOnly || (field.DeclaringType != null && field.DeclaringType.GetAttribute(SystemTypes.ImmutableAttribute) != null)))
        this.IssueWarning();

      if (field.Equals(PTGraph.allFields) || field.Equals(PTGraph.allFieldsNotOwned)) // reading all reachable fields not admissible
        this.IssueWarning(); // NOTE: this could be refined by analysing whether only rep fields are reachable

      // if got an [ElementRep] or [ElementPeer] field then saving element-level for next visit (rep:2, peer:1, none:0) 
      currentElementLevel = previousElementLevel;
      if (Util.FieldIsElementsRepOrPeer(field))
        previousElementLevel = (byte)(Util.FieldIsElementsRep(field) ? 2 : 1);

      // first access in chain
      if (firstBoundMember) {
        firstBoundMember = false;
        // non-rep: we go out of owned cone
        if (!(field.IsRep || (field.Type != null && field.Type.IsValueType))) { // note: handling value types (e.g. structs) as owned             
          outsideOwnedCone = true;
        }
        else { // rep or struct
          if (!(field.Type != null && field.Type.IsValueType)) // field of value-type (e.g. structs) does not lead into the owned cone
            contextDepth = 1;
        }
      }
      // chain should have ended already
      else if (outsideOwnedCone) {
        // access may be any of: visible field, readonly field, field of an immutable type, state-independent method
        if (!(field.IsInitOnly || (field.DeclaringType != null && field.DeclaringType.GetAttribute(SystemTypes.ImmutableAttribute) != null)))
          this.IssueWarning();
      }
      // access is rep or struct
      else if (field.IsRep || (field.Type != null && field.Type is Struct)) {
        if (field.Type != null && !(field.Type is Struct)) // if struct then do not go down (structs cannot be owned)
          contextDepth++;
      }
      // access on an element of an ElementsPeer array (which means -1 level access relative to coll./array)
      else if (currentElementLevel == 1) { 
        contextDepth--;
        if (contextDepth < 1)
          outsideOwnedCone = true;
      }
      // NOTE: elementLevel==2 need not be handled as we stay at the same context-depth
      // access is not owned: we go outside of owned cone
      else if (currentElementLevel != 2 && !field.IsPeer) {
        outsideOwnedCone = true;
      }
    }
开发者ID:hesam,项目名称:SketchSharp,代码行数:51,代码来源:AdmissibilityChecker.cs


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