本文整理汇总了C#中XObject.FindGlobal方法的典型用法代码示例。如果您正苦于以下问题:C# XObject.FindGlobal方法的具体用法?C# XObject.FindGlobal怎么用?C# XObject.FindGlobal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XObject
的用法示例。
在下文中一共展示了XObject.FindGlobal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMethod
public static Expression CreateMethod(XObject currentObject, string objectId, string actionId, List<Expression> parameters)
{
XObject target;
if (objectId == null)
{
target = currentObject.Parent;
objectId = target.Id;
}
else
target = currentObject.FindGlobal(objectId);
if (target == null)
throw new InvalidOperationException(string.Format("Could not find object with Id: [{0}]", objectId));
var method = target.GetType().GetMethod(actionId);
if (method == null)
throw new InvalidOperationException(string.Format("Could not find method [{0}] on object [{1}]", actionId, objectId));
var returnType = method.ReturnType;
if (returnType == typeof(string))
{
Func<List<Expression>, string> func;
target.GetMethod(actionId, out func);
return new Method<string>(currentObject, objectId, actionId, func, parameters);
}
else if (returnType == typeof(bool))
{
Func<List<Expression>, bool> func;
target.GetMethod(actionId, out func);
return new Method<bool>(currentObject, objectId, actionId, func, parameters);
}
else if (returnType == typeof(void))
{
Action<List<Expression>> func;
target.GetMethod(actionId, out func);
return new Method<object>(currentObject, objectId, actionId, (ps) => { func(ps); return null; }, parameters);
}
else
{
Func<List<Expression>, double> func;
target.GetMethod(actionId, out func);
return new Method<double>(currentObject, objectId, actionId, func, parameters);
}
}