本文整理汇总了C#中System.IsSubclassOf方法的典型用法代码示例。如果您正苦于以下问题:C# System.IsSubclassOf方法的具体用法?C# System.IsSubclassOf怎么用?C# System.IsSubclassOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System.IsSubclassOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFiltered
public static UnityEngine.Object[] GetFiltered(System.Type type, UnityEditor.SelectionMode mode)
{
ArrayList list = new ArrayList();
if ((type == typeof(Component)) || type.IsSubclassOf(typeof(Component)))
{
foreach (Transform transform in GetTransforms(mode))
{
Component component = transform.GetComponent(type);
if (component != null)
{
list.Add(component);
}
}
}
else if ((type == typeof(GameObject)) || type.IsSubclassOf(typeof(GameObject)))
{
foreach (Transform transform2 in GetTransforms(mode))
{
list.Add(transform2.gameObject);
}
}
else
{
foreach (UnityEngine.Object obj2 in GetObjectsMode(mode))
{
if ((obj2 != null) && ((obj2.GetType() == type) || obj2.GetType().IsSubclassOf(type)))
{
list.Add(obj2);
}
}
}
return (UnityEngine.Object[]) list.ToArray(typeof(UnityEngine.Object));
}
示例2: AddAbility
/// <summary>
/// Add an ability from the ability store to the ability HUD as they are purchased
/// </summary>
/// <param name="AbilityType"></param>
public void AddAbility(System.Type AbilityType)
{
//If the ability type is valid
if (AbilityType.IsSubclassOf(typeof(Ability)))
{
bool AbilityExists = (Abilities.Where(a => a.GetType() == AbilityType).Count() > 0);
//If the ability is already in the list
if (AbilityExists)
{
Ability ability = Abilities.Where(a => a.GetType() == AbilityType).Select(a => a).Single();
ability.Quantity++;
}
//If it is not
else {
Ability newa = System.Activator.CreateInstance(AbilityType) as Ability;
newa.Quantity = 1;
Abilities.Add(newa);
}
UpdateButtons();
}
else
{
Debug.Log("Error: Invalid Ability type");
}
}
示例3: Create
public static OpCode Create(System.Type t)
{
if(t.IsSubclassOf(typeof(OpCode)))
{
return Activator.CreateInstance(t) as OpCode;
}
throw new ParseException("Type derived from HVM.OpCode", t.ToString());
}
示例4: HasType
/// <summary>
/// Returns True if the value has the supplied type; False otherwise.
/// <param name="type">The field type to check.</param>
/// <returns>True if the value has the supplied type; False otherwise.</returns>
/// <summary>
public bool HasType (System.Type type) {
switch (m_FieldType) {
case FieldType.Int:
return type == typeof(int);
case FieldType.String:
return type == typeof(string);
case FieldType.Float:
return type == typeof(float);
case FieldType.Enum:
return type.IsEnum;
case FieldType.Bool:
return type == typeof(bool);
case FieldType.Vector2:
return type == typeof(Vector2);
case FieldType.Vector3:
return type == typeof(Vector3);
case FieldType.Vector4:
return type == typeof(Vector4);
case FieldType.Quaternion:
return type == typeof(Quaternion);
case FieldType.Rect:
return type == typeof(Rect);
case FieldType.Color:
return type == typeof(Color);
case FieldType.LayerMask:
return type == typeof(LayerMask);
case FieldType.AnimationCurve:
return type == typeof(AnimationCurve);
case FieldType.Array:
return type.IsArray;
case FieldType.Constant:
return type.IsSubclassOf(typeof(Variable));
case FieldType.None:
return type.IsSubclassOf(typeof(Variable));
case FieldType.UnityObject:
return type.IsSubclassOf(typeof(UnityEngine.Object)) || type == typeof(UnityEngine.Object);
case FieldType.State:
return type == typeof(InternalStateBehaviour);
case FieldType.Generic:
return !type.IsValueType && !typeof(Variable).IsAssignableFrom(type) && !typeof(UnityEngine.Object).IsAssignableFrom(type);
}
return false;
}
示例5: GetHelpURL
/// <summary>
/// Get the URL pointing to the documentation for the specified component.
/// </summary>
static public string GetHelpURL (System.Type type)
{
if (type == typeof(UITexture)) return "http://www.tasharen.com/forum/index.php?topic=6703";
if (type == typeof(UISprite)) return "http://www.tasharen.com/forum/index.php?topic=6704";
if (type == typeof(UIPanel)) return "http://www.tasharen.com/forum/index.php?topic=6705";
if (type == typeof(UILabel)) return "http://www.tasharen.com/forum/index.php?topic=6706";
if (type == typeof(UIButton)) return "http://www.tasharen.com/forum/index.php?topic=6708";
if (type == typeof(UIToggle)) return "http://www.tasharen.com/forum/index.php?topic=6709";
if (type == typeof(UIRoot)) return "http://www.tasharen.com/forum/index.php?topic=6710";
if (type == typeof(UICamera)) return "http://www.tasharen.com/forum/index.php?topic=6711";
if (type == typeof(UIAnchor)) return "http://www.tasharen.com/forum/index.php?topic=6712";
if (type == typeof(UIStretch)) return "http://www.tasharen.com/forum/index.php?topic=6713";
if (type == typeof(UISlider)) return "http://www.tasharen.com/forum/index.php?topic=6715";
#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_1 && !UNITY_4_2
if (type == typeof(UI2DSprite)) return "http://www.tasharen.com/forum/index.php?topic=6729";
#endif
if (type == typeof(UIScrollBar)) return "http://www.tasharen.com/forum/index.php?topic=6733";
if (type == typeof(UIProgressBar)) return "http://www.tasharen.com/forum/index.php?topic=6738";
if (type == typeof(UIPopupList)) return "http://www.tasharen.com/forum/index.php?topic=6751";
if (type == typeof(UIInput)) return "http://www.tasharen.com/forum/index.php?topic=6752";
if (type == typeof(UIKeyBinding)) return "http://www.tasharen.com/forum/index.php?topic=6753";
if (type == typeof(UIGrid)) return "http://www.tasharen.com/forum/index.php?topic=6756";
if (type == typeof(UITable)) return "http://www.tasharen.com/forum/index.php?topic=6758";
if (type == typeof(ActiveAnimation) || type == typeof(UIPlayAnimation))
return "http://www.tasharen.com/forum/index.php?topic=6762";
if (type == typeof(UIScrollView) || type == typeof(UIDragScrollView))
return "http://www.tasharen.com/forum/index.php?topic=6763";
if (type == typeof(UIWidget) || type.IsSubclassOf(typeof(UIWidget)))
return "http://www.tasharen.com/forum/index.php?topic=6702";
if (type == typeof(UIPlayTween) || type.IsSubclassOf(typeof(UITweener)))
return "http://www.tasharen.com/forum/index.php?topic=6760";
if (type == typeof(UILocalize) || type == typeof(Localization))
return "http://www.tasharen.com/forum/index.php?topic=8092.0";
return null;
}
示例6: SubDrawerAttribute
public SubDrawerAttribute( System.Type type, params object[] objects )
{
if ( !type.IsSubclassOf( typeof( PropertyAttribute ) ) ) return;
System.Type[] paramTypes = objects == null ? Type.EmptyTypes : new Type[ objects.Length];
for ( int i = 0; i < objects.Length; i++ ) {
paramTypes[ i ] = objects[ i ].GetType();
}
ConstructorInfo ci = type.GetConstructor( paramTypes );
if( ci == null ){
Debug.Log( "GetConstructor Error" );
}
else{
SecondAttribute = ci.Invoke( objects ) as PropertyAttribute;
}
}
示例7: Drop
// called after the object has been created, and it is being dropped
public void Drop(Pawn dropper, System.Type itemType)
{
if(!itemType.IsSubclassOf(typeof(Item))) {
Debug.Log("WARNING! "+dropper.name+" tried to drop a "+itemType.ToString()+". Must extend Item!");
return;
}
bHasLanded = false;
startDropSpeed = Random.Range(0.0f, maxVelocity);
velocity = Random.insideUnitCircle * startDropSpeed;
velocity.y = Mathf.Abs(velocity.y);
groundHeight = (dropper.transform.position - dropper.GetBaseOffset()).y;
item = (Item)System.Activator.CreateInstance(itemType);
droppedBy = dropper;
}
示例8: WriteToStreamAsync
public override System.Threading.Tasks.Task WriteToStreamAsync(System.Type type, object value, System.IO.Stream writeStream, System.Net.Http.HttpContent content, System.Net.TransportContext transportContext)
{
var obj = new ExpandoObject() as IDictionary<string, Object>;
if (type.IsSubclassOf(typeof(BaseMetaResponseModel)) && type.IsGenericType)
{
Type innerType = type.GetGenericArguments()[0];
var genericValue = (value as BaseMetaResponseModel);
value = genericValue.Content;
type = innerType;
obj["meta"] = genericValue.Meta;
}
var root = GetRootFieldName(type, value);
obj[root] = value;
return base.WriteToStreamAsync(type, obj as object, writeStream, content, transportContext);
}
示例9: GetFactory
private static System.Data.Common.DbProviderFactory GetFactory(System.Type type)
{
if (type != null && type.IsSubclassOf(typeof(System.Data.Common.DbProviderFactory)))
{
// Provider factories are singletons with Instance field having
// the sole instance
System.Reflection.FieldInfo field = type.GetField("Instance"
, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static
);
if (field != null)
{
return (System.Data.Common.DbProviderFactory)field.GetValue(null);
//return field.GetValue(null) as DbProviderFactory;
} // End if (field != null)
} // End if (type != null && type.IsSubclassOf(typeof(System.Data.Common.DbProviderFactory)))
throw new System.Configuration.ConfigurationErrorsException("DataProvider is missing!");
//throw new System.Configuration.ConfigurationException("DataProvider is missing!");
}
示例10: AddNode
/// <summary>
/// Adds a new node to the action state, automatically handles undo, dirty flag and save node.
/// <param name="actionState">The action state to add a new node.</param>
/// <param name="nodeType">The type of the new node.</param>
/// <returns>The new node.</returns>
/// </summary>
public static ActionNode AddNode (InternalActionState actionState, System.Type nodeType) {
// Validate parameters
if (actionState != null && nodeType != null && nodeType.IsSubclassOf(typeof(ActionNode)) && !nodeType.IsAbstract) {
// Register Undo
#if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2
Undo.RegisterUndo(actionState,"Add New Node");
#else
Undo.RecordObject(actionState,"Add New Node");
#endif
// Create new node
var newNode = actionState.AddNode(nodeType);
if (newNode != null) {
// Saves node and sets dirty flag
StateUtility.SetDirty(actionState);
return newNode;
}
}
return null;
}
示例11: GetMethod
public Delegate GetMethod(string name, System.Type delegShape)
{
if (_wrappedObject == null) throw new InvalidOperationException("Can only access static members.");
if (!delegShape.IsSubclassOf(typeof(Delegate))) throw new ArgumentException("Type must inherit from Delegate.", "delegShape");
var binding = PUBLIC_MEMBERS;
if (_includeNonPublic) binding |= BindingFlags.NonPublic;
var invokeMeth = delegShape.GetMethod("Invoke");
var paramTypes = (from p in invokeMeth.GetParameters() select p.ParameterType).ToArray();
MethodInfo meth = null;
try
{
meth = _wrappedType.GetMethod(name, binding, null, paramTypes, null);
}
catch
{
try
{
meth = _wrappedType.GetMethod(name, binding);
}
catch
{
}
}
if (meth != null)
{
try
{
return Delegate.CreateDelegate(delegShape, _wrappedObject, meth);
}
catch (Exception ex)
{
throw new InvalidOperationException("A method matching the name and shape requested could not be found.", ex);
}
}
else
{
throw new InvalidOperationException("A method matching the name and shape requested could not be found.");
}
}
示例12: GetExtender
internal static Skybound.VisualTips.IVisualTipExtender GetExtender(System.Type controlOrComponentType)
{
Skybound.VisualTips.IVisualTipExtender ivisualTipExtender2;
Skybound.VisualTips.IVisualTipExtender ivisualTipExtender1 = Skybound.VisualTips.VisualTipProvider.Extenders[controlOrComponentType] as Skybound.VisualTips.IVisualTipExtender;
if (ivisualTipExtender1 == null)
{
System.Collections.IDictionaryEnumerator idictionaryEnumerator = Skybound.VisualTips.VisualTipProvider.Extenders.GetEnumerator();
try
{
while (idictionaryEnumerator.MoveNext())
{
System.Collections.DictionaryEntry dictionaryEntry = (System.Collections.DictionaryEntry)idictionaryEnumerator.Current;
if (controlOrComponentType.IsSubclassOf(dictionaryEntry.Key as System.Type))
{
ivisualTipExtender2 = dictionaryEntry.Value as Skybound.VisualTips.IVisualTipExtender;
return ivisualTipExtender2;
}
}
}
finally
{
System.IDisposable idisposable = idictionaryEnumerator as System.IDisposable;
if (idisposable != null)
idisposable.Dispose();
}
}
return ivisualTipExtender1;
}
示例13: TestNonDesignerFormEndSuccessor
public void TestNonDesignerFormEndSuccessor(System.Type type, System.Type baseForm)
{
Assert.IsTrue(type.IsSubclassOf(baseForm), string.Format("{0} does not inherit from {1}!", type.Name, baseForm.Name));
var attributes = type.GetCustomAttributes(typeof(System.ComponentModel.DesignerCategoryAttribute), false);
Assert.GreaterOrEqual(attributes.Length, 1, string.Format("No DesignerCategoryAttribute for {0}!", type.Name));
foreach (var a in attributes)
{
Assert.AreEqual(((System.ComponentModel.DesignerCategoryAttribute)a).Category, "Form", type.Name + " does not marked as DesignerCategoryAttribute - Form");
}
}
示例14: IsProtectedVisibleTo
internal static bool IsProtectedVisibleTo(MethodInfo method, System.Type derivedType, XamlSchemaContext schemaContext)
{
if (derivedType == null)
{
return false;
}
if (!derivedType.Equals(method.DeclaringType) && !derivedType.IsSubclassOf(method.DeclaringType))
{
return false;
}
if (method.IsFamily || method.IsFamilyOrAssembly)
{
return true;
}
if (!method.IsFamilyAndAssembly)
{
return false;
}
return (TypeReflector.IsInternal(method.DeclaringType) || schemaContext.AreInternalsVisibleTo(method.DeclaringType.Assembly, derivedType.Assembly));
}
示例15: HelperWindowMenuItem
// We pass in a type of the form to create rather than encode it as a generic parameter
// so that we can have an array of the HelperWindowMenuItem.
public HelperWindowMenuItem(MainForm mainForm, string name, System.Type tForm)
{
Debug.Assert(tForm.IsSubclassOf(typeof(gui.DebuggerToolWindow)));
this.m_mainForm = mainForm;
this.m_typeHelperForm = tForm;
EventHandler handler = new EventHandler(this.OnClick);
MenuItem item = new MenuItem(name, handler);
this.m_mainForm.AddToViewMenu(item);
}