當前位置: 首頁>>代碼示例>>C#>>正文


C# TypeNode.IsStructurallyEquivalentTo方法代碼示例

本文整理匯總了C#中System.Compiler.TypeNode.IsStructurallyEquivalentTo方法的典型用法代碼示例。如果您正苦於以下問題:C# TypeNode.IsStructurallyEquivalentTo方法的具體用法?C# TypeNode.IsStructurallyEquivalentTo怎麽用?C# TypeNode.IsStructurallyEquivalentTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Compiler.TypeNode的用法示例。


在下文中一共展示了TypeNode.IsStructurallyEquivalentTo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: IsAssignableToInstanceOf

 /// <summary>
 /// Returns true if this type is assignable to some instance of the given template.
 /// </summary>
 public virtual bool IsAssignableToInstanceOf(TypeNode targetTemplate)
 {
     if(this == CoreSystemTypes.Void || targetTemplate == null)
         return false;
     if(targetTemplate.IsStructurallyEquivalentTo(this.Template == null ? this : this.Template) ||
       this.BaseType != null && (this.BaseType.IsAssignableToInstanceOf(targetTemplate) ||
       this.BaseType.Template != null && this.BaseType.Template.IsAssignableToInstanceOf(targetTemplate)))
         return true;
     InterfaceList interfaces = this.Interfaces;
     if(interfaces == null)
         return false;
     for(int i = 0, n = interfaces.Count; i < n; i++)
     {
         Interface iface = interfaces[i];
         if(iface == null)
             continue;
         if(iface.IsAssignableToInstanceOf(targetTemplate))
             return true;
     }
     return false;
 }
開發者ID:modulexcite,項目名稱:SHFB-1,代碼行數:24,代碼來源:Nodes.cs

示例2: TypeMatch

        private static bool TypeMatch(TypeNode type1, TypeNode type2) {

            // the two types must be of the same kind
            if (type1.NodeType != type2.NodeType) return (false);

            if (type1.NodeType == NodeType.ArrayType) {
                // they are arrays, so check elements
                ArrayType array1 = (ArrayType)type1;
                ArrayType array2 = (ArrayType)type2;
                return (TypeMatch(array1.ElementType, array2.ElementType));
            } else {
                // they are normal types
                return (type1.IsStructurallyEquivalentTo(type2));
            }
        }
開發者ID:hnlshzx,項目名稱:DotNetOpenAuth,代碼行數:15,代碼來源:Reflection.cs

示例3: GetImplicitCoercionFromMethod

 public virtual Method GetImplicitCoercionFromMethod(TypeNode sourceType)
 {
     if(sourceType == null)
         return null;
     Method result = null;
     if(this.implicitCoercionFromTable != null)
         result = (Method)this.implicitCoercionFromTable[sourceType.UniqueKey];
     if(result == TypeNode.MethodDoesNotExist)
         return null;
     if(result != null)
         return result;
     lock(this)
     {
         if(this.implicitCoercionFromTable != null)
             result = (Method)this.implicitCoercionFromTable[sourceType.UniqueKey];
         if(result == TypeNode.MethodDoesNotExist)
             return null;
         if(result != null)
             return result;
         MemberList coercions = this.ImplicitCoercionMethods;
         for(int i = 0, n = coercions.Count; i < n; i++)
         {
             Method m = (Method)coercions[i];
             if(sourceType.IsStructurallyEquivalentTo(TypeNode.StripModifiers(m.Parameters[0].Type))) { result = m; break; }
         }
         if(this.implicitCoercionFromTable == null)
             this.implicitCoercionFromTable = new TrivialHashtable();
         if(result == null)
             this.implicitCoercionFromTable[sourceType.UniqueKey] = TypeNode.MethodDoesNotExist;
         else
             this.implicitCoercionFromTable[sourceType.UniqueKey] = result;
         return result;
     }
 }
開發者ID:modulexcite,項目名稱:SHFB-1,代碼行數:34,代碼來源:Nodes.cs


注:本文中的System.Compiler.TypeNode.IsStructurallyEquivalentTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。