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


C# IType.Equals方法代码示例

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


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

示例1: NormalizeType

        protected override IType NormalizeType(IType type)
        {
            if (type == null)
            {
                return null;
            }
            // Using Any instead of Contains since object hash is bound to a property which is modified during normalization
            if (_normalizedTypes.Any(item => type.Equals(item)))
            {
                return _normalizedTypes.First(item => type.Equals(item));
            }

            _normalizedTypes.Add(type);
            if (type is PrimaryType)
            {
                return NormalizePrimaryType(type as PrimaryType);
            }
            if (type is SequenceType)
            {
                return NormalizeSequenceType(type as SequenceType);
            }
            if (type is DictionaryType)
            {
                return NormalizeDictionaryType(type as DictionaryType);
            }
            if (type is CompositeType)
            {
                return NormalizeCompositeType(type as CompositeType);
            }
            if (type is EnumType)
            {
                return NormalizeEnumType(type as EnumType);
            }

            throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, 
                "Type {0} is not supported.", type.GetType()));
        }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:37,代码来源:CSharpCodeNamer.cs

示例2: AreCompatible

		/// <summary>
		/// Determine whether the two types are "assignment compatible".
		/// </summary>
		/// <param name="target">The type defined in the into-clause.</param>
		/// <param name="source">The type defined in the select clause.</param>
		/// <returns>True if they are assignment compatible.</returns>
		private bool AreCompatible(IType target, IType source)
		{
			if (target.Equals(source))
			{
				// if the types report logical equivalence, return true...
				return true;
			}

			// otherwise, perform a "deep equivalence" check...

			if (!target.ReturnedClass.IsAssignableFrom(source.ReturnedClass))
			{
				return false;
			}

			SqlType[] targetDatatypes = target.SqlTypes(SessionFactoryHelper.Factory);
			SqlType[] sourceDatatypes = source.SqlTypes(SessionFactoryHelper.Factory);

			if (targetDatatypes.Length != sourceDatatypes.Length)
			{
				return false;
			}

			for (int i = 0; i < targetDatatypes.Length; i++)
			{
				if (!AreSqlTypesCompatible(targetDatatypes[i], sourceDatatypes[i]))
				{
					return false;
				}
			}

			return true;
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:39,代码来源:IntoClause.cs

示例3: IsProtectedAccessible

 static bool IsProtectedAccessible(IType sourceType, IType targetType)
 {
     return sourceType.GetAllBaseTypes().Any(type => targetType.Equals(type));
 }
开发者ID:segaman,项目名称:NRefactory,代码行数:4,代码来源:VariableHidesMemberIssue.cs

示例4: CompareTypeParam

        /// <summary>
        /// </summary>
        /// <param name="p1">
        /// </param>
        /// <param name="p2">
        /// </param>
        /// <returns>
        /// </returns>
        private static bool CompareTypeParam(IType p1, IType p2)
        {
            if (p1.IsGenericParameter && p2.IsGenericParameter && !p1.Equals(p2))
            {
                return false;
            }

            if (p1.IsGenericParameter || p2.IsGenericParameter)
            {
                return true;
            }

            if (!p1.Equals(p2))
            {
                return false;
            }

            return true;
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:27,代码来源:OpCodeExtentions.cs

示例5: IsFloatType

        public static bool IsFloatType(IType type, IMemberResolver resolver)
        {
            type = type.IsKnownType(KnownTypeCode.NullableOfT) ? ((ParameterizedType)type).TypeArguments[0] : type;

            return type.Equals(resolver.Compilation.FindType(KnownTypeCode.Decimal))
                || type.Equals(resolver.Compilation.FindType(KnownTypeCode.Double))
                || type.Equals(resolver.Compilation.FindType(KnownTypeCode.Single));
        }
开发者ID:txdv,项目名称:Builder,代码行数:8,代码来源:Helpers.cs

示例6: IsIntegerType

        public static bool IsIntegerType(IType type, IMemberResolver resolver)
        {
            type = type.IsKnownType(KnownTypeCode.NullableOfT) ? ((ParameterizedType)type).TypeArguments[0] : type;

            return type.Equals(resolver.Compilation.FindType(KnownTypeCode.Byte))
                || type.Equals(resolver.Compilation.FindType(KnownTypeCode.SByte))
                || type.Equals(resolver.Compilation.FindType(KnownTypeCode.Char))
                || type.Equals(resolver.Compilation.FindType(KnownTypeCode.Int16))
                || type.Equals(resolver.Compilation.FindType(KnownTypeCode.UInt16))
                || type.Equals(resolver.Compilation.FindType(KnownTypeCode.Int32))
                || type.Equals(resolver.Compilation.FindType(KnownTypeCode.UInt32))
                || type.Equals(resolver.Compilation.FindType(KnownTypeCode.Int64))
                || type.Equals(resolver.Compilation.FindType(KnownTypeCode.UInt64));
        }
开发者ID:txdv,项目名称:Builder,代码行数:14,代码来源:Helpers.cs

示例7: IsDecimalType

        public static bool IsDecimalType(IType type, IMemberResolver resolver, bool allowArray = false)
        {
            if (allowArray && type.Kind == TypeKind.Array)
            {
                var elements = (TypeWithElementType)type;
                type = elements.ElementType;
            }

            type = type.IsKnownType(KnownTypeCode.NullableOfT) ? ((ParameterizedType)type).TypeArguments[0] : type;

            return type.Equals(resolver.Compilation.FindType(KnownTypeCode.Decimal));
        }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:12,代码来源:Helpers.cs

示例8: IsSubtypeOf

		// Determines whether s is a subtype of t.
		// Helper method used for ImplicitReferenceConversion and BoxingConversion
		bool IsSubtypeOf(IType s, IType t)
		{
			// conversion to dynamic + object are always possible
			if (t == SharedTypes.Dynamic || t.Equals(objectType))
				return true;
			
			// let GetAllBaseTypes do the work for us
			foreach (IType baseType in s.GetAllBaseTypes(context)) {
				if (IdentityOrVarianceConversion(baseType, t))
					return true;
			}
			return false;
		}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:15,代码来源:Conversions.cs

示例9: InheritsFrom

        /// <summary>
        /// Determines if this type inherits from the given base type.
        /// </summary>
        /// <param name="baseType">The type to check inheritance from.</param>
        /// <returns>
        /// Returns true if this type inherits from the given base type, otherwise false.
        /// </returns>
        public bool InheritsFrom(IType baseType)
        {
            if (this.Equals(baseType))
            {
                return true;
            }
            else
            {
                IType objectType = typeof(object).Wrap();
                if (baseType.Equals(objectType))
                {
                    return true;
                }

                if (baseType.IsInterface)
                {
                    return this.WrappedType.GetInterfaces().Any(a => a.Wrap().Equals(baseType));
                }
                else
                {
                    IType inheritedType = this.BaseType;

                    //Otherwise, go through the inheritance chain and check for the type.
                    while (inheritedType != null && !inheritedType.Equals(objectType))
                    {
                        if (inheritedType.Equals(inheritedType))
                        {
                            return true;
                        }
                        inheritedType = inheritedType.BaseType;
                    }
                }
                return false;
            }
        }
开发者ID:KallynGowdy,项目名称:ReflectionExtensions,代码行数:42,代码来源:TypeWrapperBase.cs

示例10: NeedsInserting

		/// <summary>
		/// 
		/// </summary>
		/// <param name="entry"></param>
		/// <param name="i"></param>
		/// <param name="elemType"></param>
		/// <returns></returns>
		public override bool NeedsInserting( object entry, int i, IType elemType )
		{
			IList sn = ( IList ) GetSnapshot();
			if( sn.Count > i && elemType.Equals( sn[ i ], entry ) )
			{
				// a shortcut if its location didn't change
				return false;
			}
			else
			{
				//search for it
				foreach( object oldObject in sn )
				{
					if( elemType.Equals( oldObject, entry ) )
					{
						return false;
					}
				}
				return true;
			}
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:28,代码来源:Bag.cs

示例11: GetDeletes

		// For a one-to-many, a <bag> is not really a bag;
		// it is *really* a set, since it can't contain the
		// same element twice. It could be considered a bug
		// in the mapping dtd that <bag> allows <one-to-many>.

		// Anyway, here we implement <set> semantics for a
		// <one-to-many> <bag>!

		/// <summary>
		/// 
		/// </summary>
		/// <param name="elemType"></param>
		/// <returns></returns>
		public override ICollection GetDeletes( IType elemType )
		{
			ArrayList deletes = new ArrayList();
			IList sn = ( IList ) GetSnapshot();

			int i = 0;

			foreach( object oldObject in sn )
			{
				bool found = false;
				if( bag.Count > i && elemType.Equals( oldObject, bag[ i++ ] ) )
				{
					//a shortcut if its location didn't change!
					found = true;
				}
				else
				{
					//search for it
					foreach( object newObject in bag )
					{
						if( elemType.Equals( oldObject, newObject ) )
						{
							found = true;
							break;
						}
					}
				}
				if( !found )
				{
					deletes.Add( oldObject );
				}
			}

			return deletes;
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:48,代码来源:Bag.cs

示例12: CountOccurrences

		/// <summary>
		/// 
		/// </summary>
		/// <param name="element"></param>
		/// <param name="list"></param>
		/// <param name="elementType"></param>
		/// <returns></returns>
		private int CountOccurrences( object element, IList list, IType elementType )
		{
			int result = 0;
			foreach( object obj in list )
			{
				if( elementType.Equals( element, obj ) )
				{
					result++;
				}
			}

			return result;
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:20,代码来源:Bag.cs

示例13: CheckFunctionTypeApp

 private IType CheckFunctionTypeApp(
     IType parameterType,
     IType returnType,
     IType argumentType
 )
 {
     if (!argumentType.Equals(parameterType))
     {
         throw new ArgumentException(
             string.Format(
                 "unexpected {0}, expected {1}",
                 argumentType.Show(),
                 parameterType.Show()
             )
         );
     }
     return returnType;
 }
开发者ID:takuto-h,项目名称:omicron,代码行数:18,代码来源:VEApp.cs


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