protected object Json(Antlr.Runtime.Misc.Func <object> action, string error = null) { try { return(action()); } catch (Exception e) { LogHelper.Error(error, e); return(new ServiceResult(ServiceResultCode.Error, string.IsNullOrEmpty(error) ? e.Message : error + ":" + e.Message)); } }
protected T Get <T>(string cacheId, Antlr.Runtime.Misc.Func <T> getItemcallback) where T : class { var item = HttpRuntime.Cache.Get(cacheId) as T; if (item == null) { item = getItemcallback(); HttpContext.Current.Cache.Insert(cacheId, item, null, DateTime.Now.AddMinutes(5), TimeSpan.Zero); return(item); } return(item); }
public ApplicationOAuthProvider(string publicClientId, Antlr.Runtime.Misc.Func <UserManager <IdentityUser> > userManagerFactory) { if (publicClientId == null) { throw new ArgumentNullException("publicClientId"); } if (userManagerFactory == null) { throw new ArgumentNullException("userManagerFactory"); } _publicClientId = publicClientId; _userManagerFactory = userManagerFactory; }
protected HttpResponseMessage CreateHttpResponse(HttpRequestMessage request, Antlr.Runtime.Misc.Func <HttpResponseMessage> function) { HttpResponseMessage response = null; try { response = function(); } catch (Exception exception) { response = request.CreateResponse(HttpStatusCode.InternalServerError, new { message = exception.Message }); } return(response); }
public ApplicationOAuthProvider(string publicClientId, Antlr.Runtime.Misc.Func<UserManager<IdentityUser>> userManagerFactory) { if (publicClientId == null) { throw new ArgumentNullException("publicClientId"); } if (userManagerFactory == null) { throw new ArgumentNullException("userManagerFactory"); } _publicClientId = publicClientId; _userManagerFactory = userManagerFactory; }
/** Find and replace * ID*[','] with ID (',' ID)* * ID+[','] with ID (',' ID)+ * (x {action} y)+[','] with x {action} y (',' x {action} y)+ * * Parameter must be a token. * todo: do we want? */ public virtual void ExpandParameterizedLoops(GrammarAST root) { TreeVisitor v = new TreeVisitor(new GrammarASTAdaptor()); Antlr.Runtime.Misc.Func <object, object> preAction = t => { if (((GrammarAST)t).Type == 3) { return(ExpandParameterizedLoop((GrammarAST)t)); } return(t); }; Antlr.Runtime.Misc.Func <object, object> postAction = t => t; v.Visit(root, new TreeVisitorAction(preAction, postAction)); }
/** Utility visitor that sets grammar ptr in each node */ public static void SetGrammarPtr(Grammar g, GrammarAST tree) { if (tree == null) { return; } // ensure each node has pointer to surrounding grammar Antlr.Runtime.Misc.Func <object, object> preAction = t => { ((GrammarAST)t).g = g; return(t); }; Antlr.Runtime.Misc.Func <object, object> postAction = t => t; TreeVisitor v = new TreeVisitor(new GrammarASTAdaptor()); v.Visit(tree, new TreeVisitorAction(preAction, postAction)); }
public static LinkedListNode <Tag> FirstNodeReverse(this LinkedListNode <Tag> startNode, Antlr.Runtime.Misc.Func <LinkedListNode <Tag>, bool> condition) { while (startNode != null) { if (condition(startNode)) { return(startNode); } startNode = startNode.Previous; } return(null); }
public static LinkedListNode <Tag> TranslateWhile(this LinkedListNode <Tag> startNode, TranslateContext context, Antlr.Runtime.Misc.Func <LinkedListNode <Tag>, bool> condition) { var n = startNode; while (n != null && condition(n)) { n = n.Value.Translate(context, n); } return(n); }
public static string GetOriginalContentWhileCondition(this LinkedListNode <Tag> node, Antlr.Runtime.Misc.Func <LinkedListNode <Tag>, bool> whileCondition) { var sb = new StringBuilder(); while (node != null && whileCondition(node)) { sb.Append(node.Value.Text); node = node.Next; } return(sb.ToString()); }
public static MvcHtmlString PageLinks(this HtmlHelper html, Paginacao paginacao, Antlr.Runtime.Misc.Func <int, string> paginaUrl) { var builder = new StringBuilder(); for (int pagina = 0; pagina <= paginacao.TotalPaginas; pagina++) { var tagBuilder = new TagBuilder("a"); tagBuilder.MergeAttribute("href", paginaUrl(pagina)); tagBuilder.InnerHtml = pagina.ToString(); if (pagina == paginacao.PaginaAtual) { tagBuilder.AddCssClass("selected"); tagBuilder.AddCssClass("btn-primary"); } tagBuilder.AddCssClass("btn btn-default"); builder.Append(tagBuilder); } return(MvcHtmlString.Create(builder.ToString())); }
public MoviesController(Antlr.Runtime.Misc.Func <Owned <ISession> > sessionFactory) { _sessionFactory = sessionFactory; }