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


C# TypeNodeList类代码示例

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


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


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