本文整理汇总了C#中DefaultObject.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# DefaultObject.GetType方法的具体用法?C# DefaultObject.GetType怎么用?C# DefaultObject.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DefaultObject
的用法示例。
在下文中一共展示了DefaultObject.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: parseConstVar
protected VariableDef parseConstVar(List<Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, string str)
{
Debug.Check(str.StartsWith("const"));
//const Int32 1
object propertyMemberDepended = null;
Type objType = node.GetType();
if (this.DependedProperty != "") {
System.Reflection.PropertyInfo pi = objType.GetProperty(this.DependedProperty);
if (pi != null) {
propertyMemberDepended = pi.GetValue(node, null);
} else if (pi == null && parentObject != null) {
Type parentType = parentObject.GetType();
pi = parentType.GetProperty(this.DependedProperty);
propertyMemberDepended = pi.GetValue(parentObject, null);
}
}
Type valueType = null;
VariableDef variableDepended = propertyMemberDepended as VariableDef;
if (variableDepended != null) {
valueType = variableDepended.GetValueType();
} else if (propertyMemberDepended != null) {
MethodDef methodDepended = propertyMemberDepended as MethodDef;
if (methodDepended != null) {
valueType = methodDepended.ReturnType;
} else {
RightValueDef varRV = propertyMemberDepended as RightValueDef;
if (varRV != null) {
valueType = varRV.ValueType;
}
}
} else {
string[] tokens = str.Split(' ');
Debug.Check(tokens.Length >= 3);
valueType = Plugin.GetTypeFromName(tokens[1]);
}
if (valueType != null) {
VariableDef variable = new VariableDef(null);
//string[] tokens = str.Split(' ');
//Debug.Check(tokens.Length == 3);
Debug.Check(str.StartsWith("const"));
//skip 'const '
int pos = str.IndexOf(' ');
Debug.Check(pos != -1);
pos = str.IndexOf(' ', pos + 1);
string token = str.Substring(pos + 1);
Plugin.InvokeTypeParser(result, valueType, token,
(object value) => variable.Value = value,
node);
return variable;
}
return null;
}
示例2: GetObjectsBySelfPropertyMethod
public static void GetObjectsBySelfPropertyMethod(Nodes.Node root, DefaultObject obj, string propertyName, bool matchCase, bool matchWholeWord, ref List<ObjectPair> objects)
{
if (root == null || string.IsNullOrEmpty(propertyName))
{ return; }
if (!ContainObjectPair(objects, root, obj)) {
bool found = false;
// search from its members
Type type = obj.GetType();
foreach(System.Reflection.PropertyInfo property in type.GetProperties()) {
Attribute[] attributes = (Attribute[])property.GetCustomAttributes(typeof(Behaviac.Design.Attributes.DesignerProperty), false);
if (attributes == null || attributes.Length == 0) {
continue;
}
try {
object value = property.GetValue(obj, null);
if (value != null) {
if (property.PropertyType == typeof(MethodDef)) {
MethodDef method = value as MethodDef;
Debug.Check(method != null);
if (CompareTwoTypes(method.Name, propertyName, matchCase, matchWholeWord) ||
CompareTwoTypes(method.DisplayName, propertyName, matchCase, matchWholeWord) ||
CompareTwoTypes(method.GetDisplayValue(), propertyName, matchCase, matchWholeWord) ||
CompareTwoTypes(method.GetExportValue(), propertyName, matchCase, matchWholeWord)) {
found = true;
break;
}
} else if (property.PropertyType == typeof(VariableDef)) {
VariableDef var = value as VariableDef;
Debug.Check(var != null);
if (CompareTwoTypes(var.GetDisplayValue(), propertyName, matchCase, matchWholeWord) ||
CompareTwoTypes(var.GetExportValue(), propertyName, matchCase, matchWholeWord)) {
found = true;
break;
}
} else if (property.PropertyType == typeof(RightValueDef)) {
RightValueDef rv = value as RightValueDef;
Debug.Check(rv != null);
if (CompareTwoTypes(rv.GetDisplayValue(), propertyName, matchCase, matchWholeWord) ||
CompareTwoTypes(rv.GetExportValue(), propertyName, matchCase, matchWholeWord)) {
found = true;
break;
}
} else if (CompareTwoTypes(value.ToString(), propertyName, matchCase, matchWholeWord)) {
found = true;
break;
}
}
} catch (Exception) {
}
}
// search from its pars
if (!found) {
if (obj is Behavior) {
foreach(ParInfo par in((Behavior)obj).LocalVars) {
if (CompareTwoTypes(par.Name, propertyName, matchCase, matchWholeWord)) {
found = true;
break;
}
}
}
}
if (found) {
objects.Add(new ObjectPair(root, obj));
}
}
}
示例3: checkPar
private static void checkPar(DefaultObject obj, ParInfo par, ref List<Node.ErrorCheck> result)
{
Node node = getNode(obj);
if (node != null && par != null) {
Type type = obj.GetType();
foreach(PropertyInfo property in type.GetProperties()) {
try {
object value = property.GetValue(obj, null);
if (value != null) {
if (property.PropertyType == typeof(MethodDef)) {
MethodDef method = value as MethodDef;
Debug.Check(method != null);
if (method.CheckPar(par))
{ result.Add(new Node.ErrorCheck(node, ErrorCheckLevel.Error, "Par as a parameter of the method.")); }
} else if (property.PropertyType == typeof(VariableDef)) {
VariableDef var = value as VariableDef;
Debug.Check(var != null);
if (var.CheckPar(par))
{ result.Add(new Node.ErrorCheck(node, ErrorCheckLevel.Error, "Par as a value.")); }
} else if (property.PropertyType == typeof(RightValueDef)) {
RightValueDef rv = value as RightValueDef;
Debug.Check(rv != null);
if (rv.CheckPar(par))
{ result.Add(new Node.ErrorCheck(node, ErrorCheckLevel.Error, "Par as a right value.")); }
}
}
} catch {
}
}
}
}
示例4: AcceptsAttachment
public override bool AcceptsAttachment(DefaultObject obj)
{
Type type = (obj != null) ? obj.GetType() : null;
return type != null && ((this.IsFSM && Plugin.IsClassDerived(type, typeof(Behaviac.Design.Attachments.AttachAction))) || //if fsm, only accept effectors
(!Plugin.IsClassDerived(type, typeof(Behaviac.Design.Attachments.AttachAction)) &&
!Plugin.IsClassDerived(type, typeof(Behaviac.Design.Attachments.Event)) &&
!Plugin.IsClassDerived(type, typeof(Behaviac.Design.Nodes.Behavior))));
}