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


C# Type.IsSubclassOf方法代码示例

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


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

示例1: GetWriteJsonMethod

 internal static WriteJsonValue GetWriteJsonMethod(Type type)
 {
     var t = Reflection.GetJsonDataType (type);
     if (t == JsonDataType.Primitive) {
         return typeof (decimal).Equals (type) ? WriteDecimal
                 : typeof (byte).Equals (type) ? WriteByte
                 : typeof (sbyte).Equals (type) ? WriteSByte
                 : typeof (short).Equals (type) ? WriteInt16
                 : typeof (ushort).Equals (type) ? WriteUInt16
                 : typeof (uint).Equals (type) ? WriteUInt32
                 : typeof (ulong).Equals (type) ? WriteUInt64
                 : typeof (char).Equals (type) ? WriteChar
                 : (WriteJsonValue)WriteUnknown;
     }
     else if (t == JsonDataType.Undefined) {
         return type.IsSubclassOf (typeof (Array)) && type.GetArrayRank () > 1 ? WriteMultiDimensionalArray
             : type.IsSubclassOf (typeof (Array)) && typeof (byte[]).Equals (type) == false ? WriteArray
             : typeof (KeyValuePair<string,object>).Equals (type) ? WriteKeyObjectPair
             : typeof (KeyValuePair<string,string>).Equals (type) ? WriteKeyValuePair
             : (WriteJsonValue)WriteObject;
     }
     else {
         return _convertMethods[(int)t];
     }
 }
开发者ID:qyezzard,项目名称:PowerJSON,代码行数:25,代码来源:JsonSerializer.cs

示例2: IsEcommerceType

 private static bool IsEcommerceType(Type entityType)
 {
     return MrCMSApp.AllAppTypes.ContainsKey(entityType) &&
            MrCMSApp.AllAppTypes[entityType] == EcommerceApp.EcommerceAppName &&
            (!entityType.IsSubclassOf(typeof (Document)) &&
             !entityType.IsSubclassOf(typeof (UserProfileData)) && !entityType.IsSubclassOf(typeof (Widget)));
 }
开发者ID:neozhu,项目名称:Ecommerce,代码行数:7,代码来源:TableNameConvention.cs

示例3: CreateTest

        static ILockTest CreateTest( Type testType, Type lockType, object[] parameters )
        {
            if ( ! testType.IsSubclassOf(typeof(ILockTest)) )
            {
                throw new InvalidCastException("Test type must be derived from ILockTest");
            }

            if ( null != lockType )
            {
                if ( ! testType.IsSubclassOf(typeof(ISyncLock)) )
                {
                    throw new InvalidCastException("Lock type must be derived from ISyncLock");
                }
            }

            ISyncLock syncLock = (ISyncLock) CreateTypeInstance(lockType);

            if ( null == syncLock )
            {
                throw new ArgumentException("Unable to construct an ISyncLock instance with specified parameters");
            }

            ILockTest test = (ILockTest) CreateTypeInstance(testType, new object[] {syncLock});

            if ( null == test )
            {
                throw new ArgumentException("Unable to construct an ILockTest instance with specified ISyncLock");
            }

            return test;
        }
开发者ID:adamedx,项目名称:locktest,代码行数:31,代码来源:Program.cs

示例4: Classify

		public static BulkGenericType Classify( BODType deedType, Type itemType )
		{
			if ( deedType == BODType.Tailor )
			{
				if ( itemType == null || itemType.IsSubclassOf( typeof( BaseArmor ) ) || itemType.IsSubclassOf( typeof( BaseShoes ) ) )
					return BulkGenericType.Leather;

				return BulkGenericType.Cloth;
			}
			//else if ( deedType == BODType.Fletcher )
//////////////////////////////////
//  Cap & Fletch BOD Addon 2/2  //
//////////////////////////////////
            else if ( deedType == BODType.Fletcher )
			{
				if ( itemType == null || itemType.IsSubclassOf( typeof( BaseRanged ) ) )
					return BulkGenericType.Wood;

				return BulkGenericType.Wood;
			}
            else if ( deedType == BODType.Carpenter )
			{
				if ( itemType == null || itemType.IsSubclassOf( typeof( BaseStaff ) ) || itemType.IsSubclassOf( typeof( BaseShield ) ) )
					return BulkGenericType.Wood;

				return BulkGenericType.Wood;
			}
//////////////////////////////////
//  End of Edit            2/2  //
//////////////////////////////////
				//return BulkGenericType.Wood;

			return BulkGenericType.Iron;
		}
开发者ID:greeduomacro,项目名称:cov-shard-svn-1,代码行数:34,代码来源:BulkMaterialType.cs

示例5: GetFormatter

 public virtual ICauterizeTypeFormatter GetFormatter(Type t)
 {
     ICauterizeTypeFormatter formatter;
     if (t.IsSubclassOf(typeof (CauterizeComposite)))
     {
         formatter = new CauterizeCompositeFormatter(this);
     }
     else if (t.IsSubclassOf(typeof (CauterizeGroup)))
     {
         formatter = new CauterizeGroupFormatter(this);
     }
     else if (t.IsSubclassOf(typeof (CauterizeFixedArray)))
     {
         formatter = new CauterizeFixedArrayFormatter(this);
     }
     else if (t.IsSubclassOf(typeof (CauterizeVariableArray)))
     {
         formatter = new CauterizeVariableArrayFormatter(this);
     }
     else if (t.IsSubclassOf(typeof (Enum)))
     {
         formatter = new CauterizeEnumFormatter();
     }
     else
     {
         formatter = new CauterizePrimitiveFormatter();
     }
     return formatter;
 }
开发者ID:sw17ch,项目名称:Z-ARCHIVED-legacy-cauterize,代码行数:29,代码来源:CauterizeTypeFormatterFactory.cs

示例6: AssemblyPredicate

 static bool AssemblyPredicate( Type t )
 {
     return
         !t.IsAbstract &&
         t.IsSubclassOf( typeof(ScriptableObject) ) &&
         !t.IsSubclassOf( typeof(Editor) );
 }
开发者ID:sarkahn,项目名称:unitygamelooptesting,代码行数:7,代码来源:SUtilReflection.cs

示例7: CanConvert

		public override bool CanConvert(Type objectType)
		{
		    return objectType == typeof (RavenJToken) ||
		           objectType == typeof (DynamicJsonObject) ||
		           objectType == typeof (DynamicNullObject) ||
		           objectType.IsSubclassOf(typeof (RavenJToken)) ||
		           objectType.IsSubclassOf(typeof (DynamicJsonObject));
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:8,代码来源:JsonToJsonConverter.cs

示例8: IsTypeCompatible

 private static bool IsTypeCompatible(Type type)
 {
     if ((type == null) || (!type.IsSubclassOf(typeof(MonoBehaviour)) && !type.IsSubclassOf(typeof(ScriptableObject))))
     {
         return false;
     }
     return true;
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:8,代码来源:MonoScriptImporterInspector.cs

示例9: GetService

 public object GetService(Type serviceType)
 {
     return serviceType.IsSubclassOf(typeof (ControllerBase))
         ? Activator.CreateInstance(serviceType, new ServiceManager())
         : serviceType.IsSubclassOf(typeof (ApiController))
             ? Activator.CreateInstance(serviceType)
             : null;
 }
开发者ID:Apozhidaev,项目名称:GetSso,代码行数:8,代码来源:WebApiDependencyResolver.cs

示例10: GetSerializer

 public IBsonSerializer GetSerializer(Type type)
 {
     if (type == typeof(IGameObject) || type.IsSubclassOf(typeof(IGameObject)) || type.GetInterface(typeof(IGameObject).Name) != null)
         return new GameObjectSerializer();
     if (type == typeof(IDataObject) || type.IsSubclassOf(typeof(IDataObject)) || type.GetInterface(typeof(IDataObject).Name) != null)
         return new DataObjectSerializer<IDataObject>();
     return null;
 }
开发者ID:mobytoby,项目名称:beastmud,代码行数:8,代码来源:DataObjectSerializationProvider.cs

示例11: BuildPropertySet

        protected void BuildPropertySet(Type p, StringCollection propertySet)
        {
            if (TypeToLdapPropListMap[this.MappingTableIndex].ContainsKey(p))
            {
                Debug.Assert(TypeToLdapPropListMap[this.MappingTableIndex].ContainsKey(p));
                string[] props = new string[TypeToLdapPropListMap[this.MappingTableIndex][p].Count];
                TypeToLdapPropListMap[this.MappingTableIndex][p].CopyTo(props, 0);
                propertySet.AddRange(props);
            }
            else
            {
                Type baseType;

                if (p.IsSubclassOf(typeof(UserPrincipal)))
                {
                    baseType = typeof(UserPrincipal);
                }
                else if (p.IsSubclassOf(typeof(GroupPrincipal)))
                {
                    baseType = typeof(GroupPrincipal);
                }
                else if (p.IsSubclassOf(typeof(ComputerPrincipal)))
                {
                    baseType = typeof(ComputerPrincipal);
                }
                else if (p.IsSubclassOf(typeof(AuthenticablePrincipal)))
                {
                    baseType = typeof(AuthenticablePrincipal);
                }
                else
                {
                    baseType = typeof(Principal);
                }

                Hashtable propertyList = new Hashtable();

                // Load the properties for the base types...
                foreach (string s in TypeToLdapPropListMap[this.MappingTableIndex][baseType])
                {
                    if (!propertyList.Contains(s))
                    {
                        propertyList.Add(s, s);
                    }
                }

                // Reflect the properties off the extension class and add them to the list.                
                BuildExtensionPropertyList(propertyList, p);

                foreach (string property in propertyList.Values)
                {
                    propertySet.Add(property);
                }

                // Cache the list for this property type so we don't need to reflect again in the future.                                
                this.AddPropertySetToTypePropListMap(p, propertySet);
            }
        }
开发者ID:chcosta,项目名称:corefx,代码行数:57,代码来源:ADStoreCtx_Query.cs

示例12: IsDiscriminated

        public override bool IsDiscriminated(Type type)
        {
            //return true;
            if (type.IsSubclassOf(typeof(BillingTransaction)) || type.IsSubclassOf(typeof(AccountMeta)))
            {
                return true;
            }

            return false;
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:10,代码来源:AutoPersistenceModelConfiguration.cs

示例13: UniqueAttribute

        //TODO: If placed in your domain, uncomment and replace MyDbContext with your domain's DbContext/ObjectContext class.
        //public UniqueAttribute() : this(typeof(MyDbContext)) { }
        /// <summary>
        /// Initializes a new instance of <see cref="UniqueAttribute"/>.
        /// </summary>
        /// <param name="contextType">The type of <see cref="DbContext"/> or <see cref="ObjectContext"/> subclass that will be used to search for duplicates.</param>
        public UniqueAttribute(Type contextType)
        {
            if (contextType == null)
                throw new ArgumentNullException("contextType");
            if (!contextType.IsSubclassOf(typeof(DbContext)) && !contextType.IsSubclassOf(typeof(ObjectContext)))
                throw new ArgumentException("The contextType Type must be a subclass of DbContext or ObjectContext.", "contextType");
            if (contextType.GetConstructor(Type.EmptyTypes) == null)
                throw new ArgumentException("The contextType type must declare a public parameterless consructor.");

            _ContextType = contextType;
        }
开发者ID:carlaoforti,项目名称:MeetingRoom,代码行数:17,代码来源:DbValidation.cs

示例14: Classify

		public static BulkGenericType Classify( BODType deedType, Type itemType )
		{
			if ( deedType == BODType.Tailor )
			{
				if ( itemType == null || itemType.IsSubclassOf( typeof( BaseArmor ) ) || itemType.IsSubclassOf( typeof( BaseShoes ) ) )
					return BulkGenericType.Leather;

				return BulkGenericType.Cloth;
			}

			return BulkGenericType.Iron;
		}
开发者ID:FreeReign,项目名称:imaginenation,代码行数:12,代码来源:BulkMaterialType.cs

示例15: GenerateCodeFor

        protected override void GenerateCodeFor(Type type)
        {
            var codeNamespace = GetNamespace(type);

            Action<Action<Type>> run = action =>
            {
                AppendUsings(UsingNamespaces);
                sb.AppendLine();

                cw.Indented("namespace ");
                sb.AppendLine(codeNamespace);
                cw.InBrace(delegate {
                    action(type);
                });
            };

            if (type.GetIsEnum())
                run(GenerateEnum);
            else if (type.IsSubclassOf(typeof(Controller)))
                run(GenerateService);
            else
            {
                var formScriptAttr = type.GetCustomAttribute<FormScriptAttribute>();
                if (formScriptAttr != null)
                {
                    run(t => GenerateForm(t, formScriptAttr));
                    EnqueueTypeMembers(type);

                    if (type.IsSubclassOf(typeof(ServiceRequest)))
                    {
                        AddFile(RemoveRootNamespace(codeNamespace,
                            this.fileIdentifier + (IsTS() ? ".ts" : ".cs")));

                        this.fileIdentifier = type.Name;
                        run(GenerateBasicType);
                    }

                    return;
                }
                else if (type.GetCustomAttribute<ColumnsScriptAttribute>() != null)
                {
                    //GenerateColumns(type);
                    run(EnqueueTypeMembers);
                    return;
                }
                else
                    run(GenerateBasicType);
            }
        }
开发者ID:volkanceylan,项目名称:Serenity,代码行数:49,代码来源:ServerImportsGenerator.cs


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