Skip to main content

Posts

How to merge cells with equal values in the GridView

My solution is not the first; however, I think, it is rather universal and very short - less than 20 lines of the code.

The algorithm is simple: to bypass all the rows, starting from the second at the bottom, to the top. If a cell value is the same as a value in the previous (lower) row, then increase RowSpan and make the lower cell invisible, and so forth.

The code that merges the cells is very short:
public class GridDecorator { public static void MergeRows(GridView gridView) { for (int rowIndex = gridView.Rows.Count - 2; rowIndex >= 0; rowIndex--) { GridViewRow row = gridView.Rows[rowIndex]; GridViewRow previousRow = gridView.Rows[rowIndex + 1]; for (int i = 0; i < row.Cells.Count; i++) { if (row.Cells[i].Text == previousRow.Cells[i].Text) { row.Cells[i].RowSpan = previousRow.Cells[i].RowSpan < 2 ? 2 : prev…
Recent posts

JSON Viewer: JSONPath Expressions Evaluation

Added a new feature to JSON Viewer extension: evaluation of JSONPath expressions.



The source code: https://github.com/marss19/json-viewer-visual-studio-extension
The latest release in Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=MykolaTarasyuk.JSONViewer

Reference Conflicts Analyzer - Visual Studio Extension

This is an extension to Visual Studio for easy visual analysis of the "Could not load file or assembly or one of its dependencies" problem and issues related to referenced assemblies. The tool allows selecting a .Net assembly (.dll or .exe file) and get a graph of all referenced assemblies with hightlighted conflicting references.

Source code: https://github.com/marss19/reference-conflicts-analyzer
Download: https://marketplace.visualstudio.com/vsgallery/051172f3-4b30-4bbc-8da6-d55f70402734

Documentation After installation, it is available in the main menu: Tools -> Analyze Assembly Dependencies.

Screenshot 1. Tool settings

Assembly to analyse: .Net DLL or EXE file which dependencies should be analysed.
Related config file: .exe.config for EXE file or web.config in case a web application DLL is selected. The extension inserts the related config automatically after the assembly is selected but it is also possible to select it manually.
Ignore system assemblies: by default…

Search for Movies and TV-series from the Chrome Context Menu

I noticed that sometimes, having a free evening and wishing to spend it watching a movie, I spent a lot of time selecting this movie, checking online movie databases for ratings, reviews, etc. As it was rather unproductive wasting of the time I created a simple Chrome extension helping to do the search easier and faster.

The extension adds context menu items executing search for a selected text (movie name).

There are also lots of sites which web masters overcomplicated them with scripts and CSS and made a simple selection of text quite a tricky thing. For these particular cases it is also possible to search without selection; for a focused text at cursor.

The extension is configurable: you can select preferable online movies databases.

Link:  https://chrome.google.com/webstore/detail/movies-tv-series-search/miploifkaagebhdlcdaaomgnenchiocf?hl=en&gl=PL

Preview:

Caching HTTP Handlers

There comes a time in an ASP.Net developer's life when he must write own HTTP handler. Quite often the handler has to return a static or a rarely changable content and the developer should implement caching of it. Step 1. Specify how long data should retain cached. Someone does it this way: context.Response.Cache.SetExpires(DateTime.Now.AddDay(1)); Someone likes this approach: context.Response.Cache.SetMaxAge(86400); //1 day in seconds The most careful developers use both: context.Response.Cache.SetExpires(DateTime.Now.AddDay(1)); context.Response.Cache.SetMaxAge(86400); All the above are correct in their own way. The first example sets an absolute expiration date. In the list of headers it looks like this: Expires: Mon, 25 Jul 2016 19:50:09 GMT This header was introduced in the HTTP/1.0 specification but it is supported by HTTP/1.1 too. A small pitfall related to this header is that the expiration date and time are set explicitly and it may cause issues if time…

JIRA REST API: Cookie-based Authentication

Three authentication methods are proposed by the JIRA REST API documentation: Basic Authentication is a simple but not very safe approach. Credentials are sent in the header on every request and encoding to Base64 is not a proper protection in this case; HTTPS connection is required. OAuth authentication - looks a bit complex and requires additional configuration at the JIRA server that is not always possible. Cookie-based Authentication - this approach seems to be the most convinient one: credentials are checked once, then the authentication cookie only is sent on subsequent requests. However, trying to use the cookie-based authentication I encountered an issue. The approach described in the documentation worked partially: I was able to create a new session and get the response containing the session cookie but all subsequent requests using this session cookie were rejected as unauthorized. Spending some time investigating this I found the cause of the issue: JSESSIONID is not th…

JSON Viewer. Part 2

JSON Viewer extension has now a few new features:
ability to print formatted dataability to format input data keeping JSON markup
ability to compare 2 JSON data
Source code and binaries to download are here: https://github.com/marss19/json-viewer-visual-studio-extension
After installation the viewer appears in the main menu: Tools -> JSON Viewer. Applicable to VS 2012 and 2013.

UPDATE
The source code has been migrated to GitHub: https://github.com/marss19/json-viewer-visual-studio-extension
The latest release is available for download in Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=MykolaTarasyuk.JSONViewer

JSON Viewer

Made a simple extension to Visual Studio to view JSON data in a more user-friendly format.
Source code and binaries to download are here: https://github.com/marss19/json-viewer-visual-studio-extension.
After installation the viewer is available in the main menu: Tools -> JSON Viewer.
Applicable to VS 2012 and 2013. Please note that custom VS extensions cannot be installed into Express editions of Visual Studio due to a Microsoft policy.

UPDATE
The source code has been migrated to GitHub: https://github.com/marss19/json-viewer-visual-studio-extension
The latest release is available for download in Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=MykolaTarasyuk.JSONViewer