當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。