本文整理汇总了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];
}
}
示例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)));
}
示例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;
}
示例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;
}
示例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;
}
示例6: AssemblyPredicate
static bool AssemblyPredicate( Type t )
{
return
!t.IsAbstract &&
t.IsSubclassOf( typeof(ScriptableObject) ) &&
!t.IsSubclassOf( typeof(Editor) );
}
示例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));
}
示例8: IsTypeCompatible
private static bool IsTypeCompatible(Type type)
{
if ((type == null) || (!type.IsSubclassOf(typeof(MonoBehaviour)) && !type.IsSubclassOf(typeof(ScriptableObject))))
{
return false;
}
return true;
}
示例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;
}
示例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;
}
示例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);
}
}
示例12: IsDiscriminated
public override bool IsDiscriminated(Type type)
{
//return true;
if (type.IsSubclassOf(typeof(BillingTransaction)) || type.IsSubclassOf(typeof(AccountMeta)))
{
return true;
}
return false;
}
示例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;
}
示例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;
}
示例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);
}
}