本文整理汇总了C#中Func.DynamicInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# Func.DynamicInvoke方法的具体用法?C# Func.DynamicInvoke怎么用?C# Func.DynamicInvoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Func
的用法示例。
在下文中一共展示了Func.DynamicInvoke方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Header
public MvcHtmlString Header(Func<dynamic, Object> markup)
{
var output = "<div class=\"panel-heading\">";
output += markup.DynamicInvoke(ViewContext);
output += "</div>";
return MvcHtmlString.Create(output);
}
示例2: JsMinify
public static IHtmlString JsMinify(this HtmlHelper helper, Func<object, object> markup)
{
if (helper == null || markup == null)
{
return MvcHtmlString.Empty;
}
string sourceJs = (markup.DynamicInvoke(helper.ViewContext) ?? String.Empty).ToString();
return !BundleTable.EnableOptimizations ?
new MvcHtmlString(sourceJs) :
new MvcHtmlString(SpaApp.MinifyJavaScript(sourceJs));
}
示例3: JsMinify
/// <summary>
/// Jses the minify.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="markup">The markup.</param>
/// <returns></returns>
public static MvcHtmlString JsMinify(this HtmlHelper helper, Func<object, object> markup)
{
if (helper == null || markup == null)
{
return MvcHtmlString.Empty;
}
var sourceJs = (markup.DynamicInvoke(helper.ViewContext) ?? String.Empty).ToString();
if (!IsJsMinify)
{
return new MvcHtmlString(sourceJs);
}
var minifier = new Minifier();
var minifiedJs = minifier.MinifyJavaScript(sourceJs, new CodeSettings
{
EvalTreatment = EvalTreatment.MakeImmediateSafe,
PreserveImportantComments = false
});
return new MvcHtmlString(minifiedJs);
}
示例4: CssMinify
/// <summary>
/// CSSs the minify.
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="markup">The markup.</param>
/// <returns></returns>
public static MvcHtmlString CssMinify(this HtmlHelper helper, Func<object, object> markup)
{
if (helper == null || markup == null)
{
return MvcHtmlString.Empty;
}
var sourceCss = (markup.DynamicInvoke(helper.ViewContext) ?? String.Empty).ToString();
if (!IsJsMinify)
{
return new MvcHtmlString(sourceCss);
}
var minifier = new Minifier();
var minifiedCss = minifier.MinifyStyleSheet(sourceCss, new CssSettings
{
CommentMode = CssComment.None
});
return new MvcHtmlString(minifiedCss);
}
示例5: HandleFunction
/// <summary>
/// De-serializes and runs a compiled linq func expression.
/// </summary>
/// <param name="function">The function.</param>
/// <param name="receivedMessage">The received message.</param>
/// <param name="workerNotification">The worker notification.</param>
private void HandleFunction(Func<IReceivedMessage<MessageExpression>, IWorkerNotification, object> function, IReceivedMessage<MessageExpression> receivedMessage, IWorkerNotification workerNotification)
{
var result = function.DynamicInvoke(receivedMessage, workerNotification);
if (result == null) return;
//if we have a connection, this is an rpc request
var connection =
receivedMessage.GetHeader(workerNotification.HeaderNames.StandardHeaders.RpcConnectionInfo);
//if no connection, then this was not RPC
if (connection == null) return;
var timeOut =
receivedMessage.GetHeader(workerNotification.HeaderNames.StandardHeaders.RpcTimeout).Timeout;
//if we don't have an RPC queue for this queue, create one
CreateRpcModuleIfNeeded(connection);
//send the response
var response =
_rpcQueues[connection].Send(
result,
_rpcQueues[connection].CreateResponse(receivedMessage.MessageId, timeOut));
if (response.HasError)
{
_log.ErrorException("Failed to send a response for message {0}", response.SendingException, receivedMessage.MessageId.Id.Value);
}
}
示例6: parseData
// Usage: parseData("{x:10,y:20}", MethodName);
public static void parseData(string data, Func<Dictionary<string, string>, bool> func)
{
string[] d = data.Trim().Replace("\r", "").Replace("}", "\n}").Replace("{", "{\n").Replace("\n", "\n\n").Split('\n');
var vals = new Dictionary<string, string>();
for (int row = 0; row < d.Length; row++) {
var line = d[row].Trim();
if (line.Length == 0) continue;
if (line.Substring(0, 1) == "}") {
func.DynamicInvoke(vals);
vals = new Dictionary<string, string>();
} else {
var keyval = line.Split(new char[] { ':' }, 2);
string key = keyval[0].Trim().ToLower();
if (keyval.Length == 2 && !vals.ContainsKey(key)) vals.Add(key, keyval[1].Trim());
}
}
}