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


C# Type.IsEquivalentTo方法代码示例

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


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

示例1: AreEquivalent

 internal static bool AreEquivalent(Type t1, Type t2)
 {
     if (!(t1 == t2))
     {
         return t1.IsEquivalentTo(t2);
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:TypeUtils.cs

示例2: AreEquivalent

 internal static bool AreEquivalent(Type t1, Type t2)
 {
     #if CLR2 || SILVERLIGHT
     return t1 == t2;
     #else
     return t1 == t2 || t1.IsEquivalentTo(t2);
     #endif
 }
开发者ID:dayanruben,项目名称:TigerConverters,代码行数:8,代码来源:TypeUtils.cs

示例3: ConvertTo

        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType.IsEquivalentTo(typeof(string)))
            {
                return ((BuildAction)value).Name;
            }

            return null;
        }
开发者ID:zooba,项目名称:wix3,代码行数:9,代码来源:typeconverters.cs

示例4: ReadJson

        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (objectType.IsEquivalentTo(typeof(SemanticVersion)) && reader.Value is string)
            {
                SemanticVersion value;
                if (SemanticVersion.TryParse((string)reader.Value, out value))
                {
                    return value;
                }
            }

            throw new NotSupportedException();
        }
开发者ID:jthelin,项目名称:Nerdbank.GitVersioning,代码行数:13,代码来源:SemanticVersionJsonConverter.cs

示例5: CheckType

 public override bool CheckType(Type propertyType)
 {
     if (propertyType.IsEquivalentTo(typeof(int))
         || propertyType.Equals(ExpectedType())
         || (propertyType.IsGenericType
            && typeof(int) == propertyType.GetGenericArguments().FirstOrDefault()))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
开发者ID:Sitecore,项目名称:sitecore-itemadapter,代码行数:14,代码来源:ItemAdapterIntegerFieldAttribute.cs

示例6: ConvertTo

        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
            if (destinationType.IsEquivalentTo(typeof(string)))
            {
                string result = null;
                // In some cases if multiple nodes are selected the windows form engine
                // calls us with a null value if the selected node's property values are not equal
                if (value != null)
                {
                    result = SR.GetString(((OutputType)value).ToString(), culture);
                }
                else
                {
                    result = SR.GetString(OutputType.Library.ToString(), culture);
                }

                if (result != null) return result;
            }

            return base.ConvertTo(context, culture, value, destinationType);
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:20,代码来源:typeconverters.cs

示例7: ReadJson

        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (objectType.IsEquivalentTo(typeof(VersionOptions.AssemblyVersionOptions)))
            {
                if (reader.Value is string)
                {
                    Version value;
                    if (Version.TryParse((string)reader.Value, out value))
                    {
                        return new VersionOptions.AssemblyVersionOptions(value);
                    }
                }
                else if (reader.TokenType == JsonToken.StartObject)
                {
                    // Temporarily remove ourselves from the serializer so we don't recurse infinitely.
                    serializer.Converters.Remove(this);
                    var result = serializer.Deserialize<VersionOptions.AssemblyVersionOptions>(reader);
                    serializer.Converters.Add(this);
                    return result;
                }
            }

            throw new NotSupportedException();
        }
开发者ID:azeno,项目名称:Nerdbank.GitVersioning,代码行数:24,代码来源:AssemblyVersionOptionsConverter.cs

示例8: GetPreDefinedConversionNotVoid

 /// <summary>
 /// 返回的将对象从 <paramref name="inputType"/> 类型转换为 <paramref name="outputType"/> 
 /// 类型的预定义类型转换。
 /// </summary>
 /// <param name="inputType">要转换的对象的类型,不能是 <see cref="Void"/>。</param>
 /// <param name="outputType">要将输入对象转换到的类型,不能是 <see cref="Void"/>。</param>
 /// <returns>将对象从 <paramref name="inputType"/> 类型转换为 <paramref name="outputType"/> 
 /// 类型的预定义类型转换,如果不存在则为 <c>null</c>。</returns>
 public static Conversion GetPreDefinedConversionNotVoid(Type inputType, Type outputType)
 {
     Contract.Requires(inputType != null && outputType != null &&
         inputType != typeof(void) && outputType != typeof(void));
     // 测试相等转换。
     if (inputType.IsEquivalentTo(outputType))
     {
         return IdentityConversion.Default;
     }
     if (inputType.IsValueType)
     {
         if (outputType.IsValueType)
         {
             // 值类型间转换。
             return GetBetweenValueTypeConversion(inputType, outputType);
         }
         // 装箱转换。
         if (outputType.IsAssignableFrom(inputType))
         {
             return BoxConversion.Default;
         }
         Type inputUnderlyingType = Nullable.GetUnderlyingType(inputType);
         if (inputUnderlyingType != null && outputType.IsAssignableFrom(inputUnderlyingType))
         {
             // 装箱为可空类型的内部类型实现的接口。
             return BoxConversion.Default;
         }
         return null;
     }
     if (outputType.IsValueType)
     {
         // 拆箱转换。
         if (inputType.IsAssignableFrom(outputType))
         {
             return UnboxConversion.Default;
         }
         Type outputUnderlyingType = Nullable.GetUnderlyingType(outputType);
         if (outputUnderlyingType != null && inputType.IsAssignableFrom(outputUnderlyingType))
         {
             return UnboxConversion.Default;
         }
         return null;
     }
     // 隐式引用转换。
     if (outputType.IsAssignableFrom(inputType))
     {
         return IdentityConversion.ImplicitReference;
     }
     // 显式引用转换。
     return GetExplicitRefConversion(inputType, outputType);
 }
开发者ID:GISwilson,项目名称:Cyjb,代码行数:59,代码来源:ConversionFactory.cs

示例9: AreEquivalent

        // keep in sync with System.Core version
        internal static bool AreEquivalent(Type t1, Type t2) {
#if CLR2 || SILVERLIGHT // type equivalence not implemented on Silverlight
            return t1 == t2;
#else
            return t1 == t2 || t1.IsEquivalentTo(t2);
#endif
        }
开发者ID:jschementi,项目名称:iron,代码行数:8,代码来源:TypeUtils.cs

示例10: return

        object System.IServiceProvider.GetService(Type serviceType)
        {
            if (serviceType.IsEquivalentTo(typeof(IOleCommandTarget)))
                return ((IOleCommandTarget)menuService);
            else if (serviceType.IsEquivalentTo(typeof(System.ComponentModel.Design.IMenuCommandService)))
                return ((System.ComponentModel.Design.IMenuCommandService)menuService);
            else 
                return this.serviceProvider.GetService(serviceType);

        }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:10,代码来源:Project.cs

示例11: ParameterTypeMatches

        private static bool ParameterTypeMatches(Type type, ParameterInfo param)
        {
            if (!type.IsEquivalentTo(param.ParameterType))
            {
                return false;
            }

            // TODO (tomat): how expensive is GetOptional/GetRequiredCustomModifiers?
            ModifiedType modified = type as ModifiedType;
            return IsEquivalentTo(modified != null ? modified.OptionalModifiers : null, param.GetOptionalCustomModifiers())
                && IsEquivalentTo(modified != null ? modified.RequiredModifiers : null, param.GetRequiredCustomModifiers());
        }
开发者ID:furesoft,项目名称:roslyn,代码行数:12,代码来源:ReflectionEmitter.cs

示例12: AreEquivalent

 protected bool AreEquivalent( Type lhs, Type rhs )
 {
     return lhs == rhs || lhs.IsEquivalentTo( rhs );
 }
开发者ID:idavis,项目名称:Archetype,代码行数:4,代码来源:DelegatingMetaObject.cs

示例13: GetService

 /// <devdoc>
 ///     Override to GetService so we can route requests
 ///     to the package's service provider.
 /// </devdoc>
 protected override object GetService(Type serviceType)
 {
     if (serviceType == null) {
         throw new ArgumentNullException("serviceType");
     }
     if (serviceType.IsEquivalentTo(typeof(AmbientProperties))) {
         if (_ambientProperties == null) {
             IUIService uis = GetService(typeof(IUIService)) as IUIService;
             _ambientProperties = new AmbientProperties();
             _ambientProperties.Font = (Font)uis.Styles["DialogFont"];
         }
         return _ambientProperties;
     }
     if (_provider != null) {
         object service = _provider.GetService(serviceType);
         if (service != null) {
             return service;
         }
     }
     return base.GetService(serviceType);
 }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:25,代码来源:DialogPage.cs

示例14: CanConvertFrom

        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
            if (sourceType.IsEquivalentTo(typeof(string))) return true;

            return base.CanConvertFrom(context, sourceType);
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:5,代码来源:typeconverters.cs

示例15: CreateService

 public static object CreateService(IServiceContainer container, Type serviceType) {
     if (serviceType.IsEquivalentTo(typeof(IPythonToolsOptionsService))) {
         return new PythonToolsOptionsService(container);
     }
     return null;
 }
开发者ID:jsschultz,项目名称:PTVS,代码行数:6,代码来源:PythonToolsOptionsService.cs


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