• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TypeNodeList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TypeNodeList的典型用法代码示例。如果您正苦于以下问题:C# TypeNodeList类的具体用法?C# TypeNodeList怎么用?C# TypeNodeList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TypeNodeList类属于命名空间,在下文中一共展示了TypeNodeList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Specializer

 public Specializer(Module targetModule, TypeNodeList pars, TypeNodeList args)
 {
     Debug.Assert(pars != null && pars.Count > 0);
     Debug.Assert(args != null && args.Count > 0);
     this.pars = pars;
     this.args = args;
     this.TargetModule = targetModule;
 }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:8,代码来源:Specializer.cs


示例2: AddExtensionMethod

        /// <summary>
        /// 
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="type">the current type being extended</param>
        /// <param name="extensionMethodTemplate">A reference to the extension method. For generic methods, this is a reference to the 
        /// non-specialized method, e.g. System.Linq.Enumerable.Select``2.
        /// </param>
        /// <param name="specialization">When the current type implements or inherits from a specialization of a generic type,
        /// this parameter has a TypeNode for the type used as apecialization of the generic type's first template param. 
        /// </param>
        private void AddExtensionMethod(XmlWriter writer, TypeNode type, Method extensionMethodTemplate, TypeNode specialization)
        {
            // If this is a specialization of a generic method, construct a Method object that describes the specialization
            Method extensionMethodTemplate2 = extensionMethodTemplate;
            if (extensionMethodTemplate2.IsGeneric && (specialization != null))
            {
                // the specialization type is the first of the method's template arguments
                TypeNodeList templateArgs = new TypeNodeList();
                templateArgs.Add(specialization);
                // add any additional template arguments
                for (int i = 1; i < extensionMethodTemplate.TemplateParameters.Count; i++)
                    templateArgs.Add(extensionMethodTemplate.TemplateParameters[i]);
                extensionMethodTemplate2 = extensionMethodTemplate.GetTemplateInstance(type, templateArgs);
            }
            TypeNode extensionMethodTemplateReturnType = extensionMethodTemplate2.ReturnType;
            ParameterList extensionMethodTemplateParameters = extensionMethodTemplate2.Parameters;

            ParameterList extensionMethodParameters = new ParameterList();
            for (int i = 1; i < extensionMethodTemplateParameters.Count; i++)
            {
                Parameter extensionMethodParameter = extensionMethodTemplateParameters[i];
                extensionMethodParameters.Add(extensionMethodParameter);
            }
            Method extensionMethod = new Method(extensionMethodTemplate.DeclaringType, new AttributeList(), extensionMethodTemplate.Name, extensionMethodParameters, extensionMethodTemplate.ReturnType, null);
            extensionMethod.Flags = extensionMethodTemplate.Flags & ~MethodFlags.Static;

            // for generic methods, set the template args and params so the template data is included in the id and the method data
            if (extensionMethodTemplate2.IsGeneric)
            {
                extensionMethod.IsGeneric = true;
                if (specialization != null)
                {
                    // set the template args for the specialized generic method
                    extensionMethod.TemplateArguments = extensionMethodTemplate2.TemplateArguments;
                }
                else
                {
                    // set the generic template params for the non-specialized generic method
                    extensionMethod.TemplateParameters = extensionMethodTemplate2.TemplateParameters;
                }
            }

            // Get the id
            string extensionMethodTemplateId = reflector.ApiNamer.GetMemberName(extensionMethodTemplate);

            // write the element node
            writer.WriteStartElement("element");
            writer.WriteAttributeString("api", extensionMethodTemplateId);
            writer.WriteAttributeString("source", "extension");
            isExtensionMethod = true;
            reflector.WriteMember(extensionMethod);
            isExtensionMethod = false;
            writer.WriteEndElement();
        }
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:65,代码来源:ExtensionMethodAddIn.cs


示例3: Checker

 public Checker(ErrorHandler errorHandler, TypeSystem typeSystem, TrivialHashtable scopeFor, TrivialHashtable ambiguousTypes, TrivialHashtable referencedLabels)
   : base(errorHandler) {
   this.typeSystem = typeSystem;
   this.Errors = errorHandler == null ? null : errorHandler.Errors;
   this.scopeFor = scopeFor;
   this.ambiguousTypes = ambiguousTypes;
   this.referencedLabels = referencedLabels;
   this.MayNotReferenceThisFromFieldInitializer = true;
   this.allowedExceptions = new TypeNodeList();
   this.useGenerics = TargetPlatform.UseGenerics;
   this.AllowPropertiesIndexersAsRef = true;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:12,代码来源:Checker.cs


示例4: VisitTypeNodeList

 public override TypeNodeList VisitTypeNodeList(TypeNodeList types){
   if (types == null) return null;
   for (int i = 0, n = types.Count; i < n; i++){
     TypeNode type = types[i]; if (type == null) continue;
     if (this.Line != int.MinValue){
       if (!type.SourceContext.Encloses(this.Line, this.Column)) continue;
     }else{
       if (!type.SourceContext.Encloses(this.SourceContext)) continue;
     }
     this.Visit(type);
     break;
   }
   return types;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:14,代码来源:Finders.cs


示例5: GetTypeList

 internal static TypeNodeList GetTypeList(string typeList, IDebugContext context){
   TypeNodeList list = new TypeNodeList();
   int startIndex = typeList.LastIndexOf(".")+1;
   int endIndex;
   IDebugType typ;
   while((endIndex = typeList.IndexOf("Or", startIndex)) > 0){
     typ = context.GetType(typeList.Substring(startIndex, endIndex - startIndex));
     if (typ != null) list.Add(typ.CompilerType);
     startIndex = endIndex+2;
   }
   typ = context.GetType(typeList.Substring(startIndex));
   if (typ != null) list.Add(typ.CompilerType);
   return list;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:14,代码来源:Symbol.cs


示例6: VisitTypeNodeList

        public override void VisitTypeNodeList(TypeNodeList types)
        {
            if (types == null) return;

            for (int i = 0, n = types.Count; i < n; i++)
            {
                var type = types[i];
                if (type == null) continue;

                Class c = type as Class;
                if (c != null && HelperMethods.IsContractTypeForSomeOtherType(c))
                {
                    types[i] = null;
                }
                else
                {
                    // for nested types
                    this.VisitTypeNode(type);
                }
            }
        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:21,代码来源:RemoveContractClasses.cs


示例7: VisitTypeNodeList

 public virtual Differences VisitTypeNodeList(TypeNodeList list1, TypeNodeList list2,
   out TypeNodeList changes, out TypeNodeList deletions, out TypeNodeList insertions){
   changes = list1 == null ? null : list1.Clone();
   deletions = list1 == null ? null : list1.Clone();
   insertions = list1 == null ? new TypeNodeList() : list1.Clone();
   //^ assert insertions != null;
   Differences differences = new Differences();
   //Compare definitions that have matching key attributes
   TrivialHashtable matchingPosFor = new TrivialHashtable();
   TrivialHashtable matchedNodes = new TrivialHashtable();
   for (int j = 0, n = list2 == null ? 0 : list2.Count; j < n; j++){
     //^ assert list2 != null;
     TypeNode nd2 = list2[j];
     if (nd2 == null || nd2.Name == null) continue;
     string fullName = nd2.FullName;
     if (fullName == null) continue;
     matchingPosFor[Identifier.For(fullName).UniqueIdKey] = j;
     insertions.Add(null);
   }
   for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
     //^ assert list1 != null && changes != null && deletions != null;
     TypeNode nd1 = list1[i];
     if (nd1 == null || nd1.Name == null) continue;
     string fullName = nd1.FullName;
     if (fullName == null) continue;
     object pos = matchingPosFor[Identifier.For(fullName).UniqueIdKey];
     if (!(pos is int)) continue;
     //^ assert pos != null;
     //^ assume list2 != null; //since there was entry int matchingPosFor
     int j = (int)pos;
     TypeNode nd2 = list2[j];
     //^ assume nd2 != null;
     //nd1 and nd2 have the same key attributes and are therefore treated as the same entity
     matchedNodes[nd1.UniqueKey] = nd1;
     matchedNodes[nd2.UniqueKey] = nd2;
     //nd1 and nd2 may still be different, though, so find out how different
     Differences diff = this.VisitTypeNode(nd1, nd2);
     if (diff == null){Debug.Assert(false); continue;}
     if (diff.NumberOfDifferences != 0){
       changes[i] = diff.Changes as TypeNode;
       deletions[i] = diff.Deletions as TypeNode;
       insertions[i] = diff.Insertions as TypeNode;
       insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
       //Debug.Assert(diff.Changes == changes[i] && diff.Deletions == deletions[i] && diff.Insertions == insertions[i]);
       differences.NumberOfDifferences += diff.NumberOfDifferences;
       differences.NumberOfSimilarities += diff.NumberOfSimilarities;
       if (nd1.DeclaringModule == this.OriginalModule || 
         (nd1.DeclaringType != null && nd1.DeclaringType.DeclaringModule == this.OriginalModule)){
         if (this.MembersThatHaveChanged == null) this.MembersThatHaveChanged = new MemberList();
         this.MembersThatHaveChanged.Add(nd1);
       }
       continue;
     }
     changes[i] = null;
     deletions[i] = null;
     insertions[i] = null;
     insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
   }
   //Find deletions
   for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
     //^ assert list1 != null && changes != null && deletions != null;
     TypeNode nd1 = list1[i]; 
     if (nd1 == null) continue;
     if (matchedNodes[nd1.UniqueKey] != null) continue;
     changes[i] = null;
     deletions[i] = nd1;
     insertions[i] = null;
     differences.NumberOfDifferences += 1;
     if (nd1.DeclaringModule == this.OriginalModule || 
       (nd1.DeclaringType != null && nd1.DeclaringType.DeclaringModule == this.OriginalModule)){
       if (this.MembersThatHaveChanged == null) this.MembersThatHaveChanged = new MemberList();
       this.MembersThatHaveChanged.Add(nd1);
     }
   }
   //Find insertions
   for (int j = 0, n = list1 == null ? 0 : list1.Count, m = list2 == null ? 0 : list2.Count; j < m; j++){
     //^ assert list2 != null;
     TypeNode nd2 = list2[j]; 
     if (nd2 == null) continue;
     if (matchedNodes[nd2.UniqueKey] != null) continue;
     insertions[n+j] = nd2;  //Records nd2 as an insertion into list1, along with its position in list2
     differences.NumberOfDifferences += 1; //REVIEW: put the size of the tree here?
   }
   if (differences.NumberOfDifferences == 0){
     changes = null;
     deletions = null;
     insertions = null;
   }
   return differences;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:90,代码来源:Comparer.cs


示例8: TransformOriginalConsolidatedTypeFormalsIntoMethodFormals

        private static void TransformOriginalConsolidatedTypeFormalsIntoMethodFormals(Method dupMethod,
            Method closureMethod, Method closureInstanceMethod, out TypeNodeList actuals)
        {
            // make sure that if we copy it from a generic context, the method becomes generic in the target context
            // if we are copying from the same declaring type (not instantiated), then don't add enclosing type parameters.
            var originals = closureInstanceMethod.DeclaringType.ConsolidatedTemplateArguments == null
                ? null
                : closureMethod.DeclaringType.ConsolidatedTemplateParameters;

            if (originals != null)
            {
                originals = originals.Clone();
            }
            
            if (closureMethod.TemplateParameters != null && closureMethod.TemplateParameters.Count > 0)
            {
                if (originals == null)
                {
                    originals = closureMethod.TemplateParameters.Clone();
                }
                else
                {
                    foreach (var tp in closureMethod.TemplateParameters)
                    {
                        originals.Add(tp);
                    }
                }
            }

            if (originals == null)
            {
                actuals = null;
                return;
            }

            actuals = closureInstanceMethod.DeclaringType.ConsolidatedTemplateArguments == null
                ? null
                : closureInstanceMethod.DeclaringType.ConsolidatedTemplateArguments.Clone();
            
            if (closureInstanceMethod.TemplateArguments != null && closureInstanceMethod.TemplateArguments.Count > 0)
            {
                if (actuals == null)
                {
                    actuals = closureInstanceMethod.TemplateArguments.Clone();
                }
                else
                {
                    foreach (var tp in closureInstanceMethod.TemplateArguments)
                    {
                        actuals.Add(tp);
                    }
                }
            }

            var declaringModule = dupMethod.DeclaringType.DeclaringModule;

            // new method formals
            var tparams = originals.Clone();

            for (int i = 0; i < originals.Count; i++)
            {
                // setup forwarding of tparams to method params
                ITypeParameter tp = originals[i] as ITypeParameter;
                
                TypeNode mtp = NewEqualMethodTypeParameter(tp, dupMethod, i);
                
                tparams[i] = mtp;
            }

            var specializer = new Specializer(declaringModule, originals, tparams);
            
            // System.Console.WriteLine("Made {0} a generic method", dupMethod.FullName);
            dupMethod.TemplateParameters = tparams;
            dupMethod.IsGeneric = true;

            specializer.VisitMethod(dupMethod);
            
            var bodySpecializer = new MethodBodySpecializer(declaringModule, originals, tparams);
            
            bodySpecializer.CurrentType = dupMethod.DeclaringType;
            bodySpecializer.CurrentMethod = dupMethod;
            bodySpecializer.VisitBlock(dupMethod.Body);
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:83,代码来源:HelperMethods.cs


示例9: DuplicateTypeParameterList

        private static TypeNodeList DuplicateTypeParameterList(TypeNodeList typeParameters, int offsetIndex, TypeNode declaringType)
        {
            if (typeParameters == null) return null;

            Duplicator dup = new Duplicator(declaringType.DeclaringModule, null);
            dup.FindTypesToBeDuplicated(typeParameters);
            
            TypeNodeList result = dup.VisitTypeParameterList(typeParameters);
            
            for (int i = 0; i < result.Count; i++)
            {
                TypeNode tn = result[i];
                
                tn.DeclaringType = declaringType;
                tn.DeclaringModule = declaringType.DeclaringModule;

                ITypeParameter tp = (ITypeParameter) tn;
                
                tp.ParameterListIndex = offsetIndex + i;
                tp.DeclaringMember = declaringType;
            }

            return result;
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:24,代码来源:HelperMethods.cs


示例10: VisitTry

    public override Statement VisitTry(Try Try) {
      if (Try == null) return null;
      bool savedInsideTryBlock = this.insideTryBlock;
      this.insideTryBlock = true;

      // when visiting the try block, use a newly computed set of allowed exceptions.
      // the set is whatever the current set is augmented with the set of exceptions listed in the
      // catch clauses
      TypeNodeList newAllowedExceptions = this.allowedExceptions.Clone();
      CatchList cl = Try.Catchers;
      if (cl != null) {
        for (int i = 0, n = cl.Count; i < n; i++) {
          Catch c = cl[i];
          if (c == null) continue;
          // BUGBUG? In both cases, should we just automatically add to the list or first see if
          // some exception already in the list is a supertype of the one that is currently added?
          if (c.Type == null)
            // then this was "catch { }" meaning catch everything, so all checked exceptions will be caught
            newAllowedExceptions.Add(SystemTypes.ICheckedException);
          else if (this.GetTypeView(c.Type).IsAssignableTo(SystemTypes.ICheckedException))
            newAllowedExceptions.Add(c.Type);
        }
      }
      TypeNodeList saveAllowedExceptions = this.allowedExceptions;
      this.allowedExceptions = newAllowedExceptions;

      /* can't call the base visitor because after visiting the try block, the allowedExceptions
       * need to be restored before visiting the catchers.
       * So this is a copy of the body of StandardVisitor.VisitTry. If that ever changes, this
       * will need to be changed too!
      Statement result = base.VisitTry(Try);
      */
      Try.TryBlock = this.VisitBlock(Try.TryBlock);

      /* restore the list of allowed exceptions */
      this.allowedExceptions = saveAllowedExceptions;

      Try.Catchers = this.VisitCatchList(Try.Catchers);
      Try.Filters = this.VisitFilterList(Try.Filters);
      Try.FaultHandlers = this.VisitFaultHandlerList(Try.FaultHandlers);
      Try.Finally = (Finally)this.VisitFinally(Try.Finally);

      this.insideTryBlock = savedInsideTryBlock;
      CatchList catchers = Try.Catchers;
      if (catchers != null) {
        for (int i = 0, n = catchers.Count; i < n; i++) {
          Catch c = catchers[i];
          if (c == null) continue;
          if (c.Type == null) continue;
          for (int j = 0; j < i; j++) {
            Catch c0 = catchers[j];
            if (c0 == null || c0.Type == null) continue;
            if (this.GetTypeView(c.Type).IsAssignableTo(c0.Type))
              this.HandleError(c.TypeExpression, Error.UnreachableCatch, this.GetTypeName(c0.Type));
          }
        }
      }
      return Try;
    }
开发者ID:hesam,项目名称:SketchSharp,代码行数:59,代码来源:Checker.cs


示例11: FindNonStandardTypeParametersToBeDuplicated

        /// <summary>
        /// If source type is insided target type, only grab the type parameters up to the target type. Otherwise, grab consolidated.
        /// </summary>
        private static TypeNodeList FindNonStandardTypeParametersToBeDuplicated(FindClosurePartsToDuplicate fmd, TypeNode sourceType, TypeNode targetType)
        {
            Debug.Assert(TypeNode.IsCompleteTemplate(sourceType));
            Debug.Assert(TypeNode.IsCompleteTemplate(targetType));

            TypeNodeList result = null;
            if (sourceType.DeclaringType != null)
            {
                if (fmd.MembersToDuplicate.Contains(sourceType.DeclaringType))
                {
                    Debug.Assert(false);
                    return null;
                }

                if (sourceType.DeclaringType == targetType) return null;

                if (IsInsideOf(sourceType, targetType))
                {
                    // difficult case. Grab consolidated type parameters, except the ones up from the target type
                    var sourceConsolidated = sourceType.ConsolidatedTemplateParameters;
                    if (sourceConsolidated == null || sourceConsolidated.Count == 0) return null;

                    var targetConsolidated = targetType.ConsolidatedTemplateParameters;
                    if (targetConsolidated == null || targetConsolidated.Count == 0) return sourceConsolidated;
                    
                    if (sourceConsolidated.Count == targetConsolidated.Count) return null; // no extra type parameters

                    result = new TypeNodeList(sourceConsolidated.Count - targetConsolidated.Count);
                    for (int i = 0; i < sourceConsolidated.Count; i++)
                    {
                        if (i < targetConsolidated.Count) continue;
                        result.Add(sourceConsolidated[i]);
                        
                        return result;
                    }
                }
                else
                {
                    // For Roslyn-based closures we need to combine all the types from source and target types together.
                    if (sourceType.IsRoslynBasedStaticClosure())
                    {
                        var sourceConsolidated = sourceType.ConsolidatedTemplateParameters;
                        if (sourceConsolidated == null || sourceConsolidated.Count == 0) return null;
                        
                        var targetConsolidated = targetType.ConsolidatedTemplateParameters;
                        
                        if (targetConsolidated == null || targetConsolidated.Count == 0) return sourceConsolidated;
                        
                        if (sourceConsolidated.Count == targetConsolidated.Count)
                            return null; // no extra type parameters

                        result = new TypeNodeList(sourceConsolidated.Count + targetConsolidated.Count);

                        for (int i = 0; i < targetConsolidated.Count; i++)
                        {
                            result.Add(targetConsolidated[i]);
                        }

                        for (int i = 0; i < sourceConsolidated.Count; i++)
                        {
                            result.Add(sourceConsolidated[i]);
                        }

                        return result;
                    }

                    result = sourceType.ConsolidatedTemplateParameters;
                }
            }

            return result;
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:75,代码来源:HelperMethods.cs


示例12: StoreTypes

        /// <summary>
        /// This is used to build the catalog of types in the parsed assemblies
        /// </summary>
        /// <param name="types">The list of types from an assembly</param>
        private void StoreTypes(TypeNodeList types)
        {
            for(int i = 0; i < types.Count; i++)
            {
                this.StoreType(types[i]);

                if(this.Canceled)
                    break;
            }
        }
开发者ID:armin-bauer,项目名称:SHFB,代码行数:14,代码来源:ApiVisitor.cs


示例13: VisitTypeReferenceList

 public virtual TypeNodeList VisitTypeReferenceList(TypeNodeList typeReferences, TypeNodeList changes, TypeNodeList deletions, TypeNodeList insertions){
   if (typeReferences == null) return changes;
   if (changes != null){
     if (deletions == null || insertions == null)
       Debug.Assert(false);
     else{
     }
   }else if (deletions != null)
     return null;
   return typeReferences;
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:11,代码来源:Updater.cs


示例14: VisitTypeReferenceList

 public virtual TypeNodeList VisitTypeReferenceList(TypeNodeList typeReferences)
 {
     if (typeReferences == null) return null;
     for (int i = 0, n = typeReferences.Count; i < n; i++)
         typeReferences[i] = this.VisitTypeReference(typeReferences[i]);
     return typeReferences;
 }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:7,代码来源:StandardVisitor.cs


示例15: MyMethodBodySpecializer

 public MyMethodBodySpecializer(Module module, TypeNodeList source, TypeNodeList target)
     : base(module, source, target)
 {
 }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:4,代码来源:ExtractorVisitor.cs


示例16: VisitTypeNodeList

 public virtual TypeNodeList VisitTypeNodeList(TypeNodeList types)
 {
     if (types == null) return null;
     for (int i = 0; i < types.Count; i++) //Visiting a type may result in a new type being appended to this list
         types[i] = (TypeNode)this.Visit(types[i]);
     return types;
 }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:7,代码来源:StandardVisitor.cs


示例17: VisitTypeParameterList

 public virtual TypeNodeList VisitTypeParameterList(TypeNodeList typeParameters)
 {
     if (typeParameters == null) return null;
     for (int i = 0, n = typeParameters.Count; i < n; i++)
         typeParameters[i] = this.VisitTypeParameter(typeParameters[i]);
     return typeParameters;
 }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:7,代码来源:StandardVisitor.cs


示例18: ImplementedTypesOverlap

 public virtual bool ImplementedTypesOverlap(TypeNodeList types1, TypeNodeList types2) {
   if (types1 == types2) return true; //usually means they are both null
   if (types1 == null || types2 == null) return false;
   for (int i = 0, n = types1.Count; i < n; i++) {
     TypeNode t1 = types1[i];
     if (t1 == null) continue;
     for (int j = 0, m = types2.Count; j < m; j++) {
       TypeNode t2 = types2[j];
       if (t2 == null) continue;
       if (t1 == t2) return true;
     }
   }
   return false;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:14,代码来源:Checker.cs


示例19: CheckForInterfaceImplementationsOfOutOfBandContractedMethods

    /// <summary>
    /// If type has an explicit or implicit implementation of a method that has an out-of-band contract,
    /// then need to create a proxy that has the same signature as the "real" interface
    /// method and have it call the one the programmer wrote.
    /// </summary>
    /// <param name="type">The type whose members should be checked to find such methods.</param>
    public virtual void CheckForInterfaceImplementationsOfOutOfBandContractedMethods(TypeNode type) {
      MemberList members = this.GetTypeView(type).Members;  // do we need to check all methods?
      for (int i = 0, n = members == null ? 0 : members.Count; i < n; i++) {
        Method method = members[i] as Method;
        if (method == null) continue;

        // If a method is a proxy (created in CheckAbstractMethods), then it can be ignored.
        ProxyMethod pMethod = method as ProxyMethod;
        if (pMethod != null) continue;

        #region Implicit implementation
        // If the method isn't virtual, then it will have been given a proxy as part of CheckAbstractMethods
        if (method.IsVirtual && method.ImplicitlyImplementedInterfaceMethods != null) {
          MethodList remainingImplicitImplementedInterfaceMethods = new MethodList(method.ImplicitlyImplementedInterfaceMethods.Count);
          for (int j = 0, m = method.ImplicitlyImplementedInterfaceMethods.Count; j < m; j++) {
            Method ifaceMethod = method.ImplicitlyImplementedInterfaceMethods[j];
            if (ifaceMethod != null && ifaceMethod.HasOutOfBandContract) {
              this.CreateProxy(type, ifaceMethod, method);
            } else {
              remainingImplicitImplementedInterfaceMethods.Add(ifaceMethod);
            }
          }
          method.ImplicitlyImplementedInterfaceMethods = remainingImplicitImplementedInterfaceMethods;
        }
        #endregion Implicit implementation

        #region Explicit implementation
        if (method.ImplementedInterfaceMethods != null) {
          MethodList remainingImplementedInterfaceMethods = new MethodList(method.ImplementedInterfaceMethods.Count);
          TypeNodeList remainingImplementedTypes = new TypeNodeList(method.ImplementedTypes.Count);
          for (int j = 0, m = method.ImplementedInterfaceMethods.Count; j < m; j++) {
            Method ifaceMethod = method.ImplementedInterfaceMethods[j];
            TypeNode ifaceType = method.ImplementedTypes[j];
            if (ifaceMethod != null && ifaceMethod.HasOutOfBandContract) {
              this.CreateProxy(type, ifaceMethod, method);
              // We may need to modify the name if there is another method
              // in the type that has the same name. That is, method's name
              // was written by the programmer as I.f where I is the name of
              // the interface. But since it no longer implements the interface
              // (the proxy does instead), its name will be just "f" in the
              // assembly. If there is another method in the same type with
              // that name, the IL will be bad. So just to play it safe, make
              // the name "fully qualified", i.e., I.f.
              method.Name = new Identifier(ifaceMethod.FullName, method.Name.SourceContext);
            } else {
              remainingImplementedInterfaceMethods.Add(ifaceMethod);
              remainingImplementedTypes.Add(ifaceType);
            }
          }
          method.ImplementedInterfaceMethods = remainingImplementedInterfaceMethods;
          method.ImplementedTypes = remainingImplementedTypes;
        }
        #endregion Explicit implementation
      }
    }
开发者ID:hesam,项目名称:SketchSharp,代码行数:61,代码来源:Checker.cs


示例20: VisitConstructArray

 public override Expression VisitConstructArray(ConstructArray consArr){
   if (consArr == null) return consArr;
   TypeNode et = consArr.ElementType = this.VisitTypeReference(consArr.ElementType);
   ExpressionList dims = consArr.Operands = this.VisitExpressionList(consArr.Operands);
   consArr.Initializers = this.VisitExpressionList(consArr.Initializers);
   if (et == null && consArr.ElementTypeExpression == null) {
     TypeNodeList tl = new TypeNodeList();
     for (int i = 0, n = consArr.Initializers == null ? 0 : consArr.Initializers.Count; i < n; i++) {
       Expression e = consArr.Initializers[i];
       if (e == null || e.Type == null) continue;
       Literal lit = e as Literal;
       if (lit != null && lit.Value == null) continue; //This prevents null from participating in the type unification, which is by design.
       if (e.Type == null) continue; //e is a bad expression
       tl.Add(e.Type);
     }
     et = this.typeSystem.UnifiedType(tl, this.TypeViewer);
     if (et == null) et = SystemTypes.Object;
     consArr.ElementType = et;
   }
   if (et is DelegateNode) {
     for (int i = 0, n = consArr.Initializers == null ? 0 : consArr.Initializers.Count; i < n; i++) {
       Expression e = consArr.Initializers[i];
       if (e is MemberBinding && ((MemberBinding)e).BoundMember is Method)
         consArr.Initializers[i] = this.VisitExpression(new Construct(new MemberBinding(null, et), new ExpressionList(e)));
     }
   }
   consArr.Owner = this.VisitExpression(consArr.Owner);
   consArr.Type = SystemTypes.Object;
   if (et == null) return null;
   consArr.Type = et.GetArrayType(consArr.Rank);
   if (this.currentPreprocessorDefinedSymbols != null && this.NonNullChecking)
     consArr.Type = OptionalModifier.For(SystemTypes.NonNullType, consArr.Type);
   return consArr;
 }
开发者ID:dbremner,项目名称:specsharp,代码行数:34,代码来源:Resolver.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TypeOfExpression类代码示例发布时间:2022-05-24
下一篇:
C# TypeNode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap