Home » .NET » BrowseDotNET: Manage your .NET Solutions and code snippets

About Christos Sakellarios

Christos Sakellarios
Senior Software Engineer, Blogger

BrowseDotNET: Manage your .NET Solutions and code snippets

BrowseDotNET is an open source ASP.NET MVC Web Application   I created, that can help you manage your computer’s .NET solutions and code samples (programming language indepented) in one place. What does it solve? It’s common sense for developers to have dosens or hundrends of solutions projects in their personal computers with each of them providing a single solution to a specific problem. The thing is, that when the time comes to solve the same problem it’s quite difficult to find the respective solution among dosens and hence you are forced to seek over and over again the same solution on the internet. More over, you might have noticed that there are code snippets which you often use in your applications, but still you always have to get them from the internet.

BrowseDotNET features

BrowseDotNET came to solve these two important problems by providing three main features:

browsedotnet-01

This post’s objective is to show how to host and use BrowseDotNET in your personal computer. First let’s see the technologies, frameworks and techniques used for this application.

  1. ASP.NET MVC 5
  2. Entity Framework Code First development
  3. Code First Migrations
  4. Generic Repository pattern
  5. Dependency Injection using Autofac framework
  6. ASP.NET Identity
  7. Automapper
  8. FluentValidation API

Installation

Download BrowseDotNET source code from my Github account. You will find link at the bottom of this post. Build the application to restore packages. Rebuild. Open BrowseDotNET.Data and BrowseDotNET.Web and change the connection strings in their configuration files to reflect your development environment. Next, Open Package Manager Console and enter the following command while having BrowseDotNET.Data as the default project.

update-database -verbose

browsedotnet-02

That’s all you need to start BrowseDotNET. Fire the application and you will reach the starting page.

browsedotnet-03

First thing you need to do is create an account. You won’t be able to register solutions and code snippets unless you are an authorized user.

browsedotnet-04

Register single .NET Solution

From the top menu, select Register/Solution and fill all the relative fields. You will be asked to give information for solution’s to be registered file path, name and description and of course search term keys. On the right side, you will always have some hints to help you register either a solution or a code snippet.

browsedotnet-05

Open, Edit or Remove a registered solution

By the time you register a .NET solution, you will be able to open it from BrowseDotNET. From the top menu, select Open/Solution and view all your registered solutions. Of course you can filter your solution by typing into the table’s textbox.

browsedotnet-06

Multiple .NET Solutions registration (scan)

We all have more than one solution in our pc so I decided to create a scanning process to automate registration for you. All you have to do is enter a root directory and then check it’s subdirectories you want to be scanned for .net solutions. BrowseDotNET will search in these folders for .sln files and register them automatically. It will use solution’s file name as solution name and description but you can always edit them later. To start, select from the top menu Register/Scan Solutions and enter a valid root directory path.

browsedotnet-07

If the directory path is valid, you will be redirected to check child folders you want to be scanned.

browsedotnet-08

BrowseDotNET will do it’s magic and when finished it will show you registered solutions page.

browsedotnet-09

Code snippet registration

Select Register/Code Snippet from the top menu and fill the relative code snippet’s information. There are two tabs, one for snippet’s information and another to paste the code. You can paste code of any language you wish. One thing I want to point is the field Group. Use the same group name to group many code snippets together. For example you can register a C# code snippet and a jQuery code snippet under the same group. Later, you will be able to view them together by selecting this group. This is why I have used an autocomplete textbox for this field. It will help you find group names you have used before.

browsedotnet-10

As soon as you register the snippet you will be able to view it whenever you want. View all of your snippets by selecting Open/Snippets from the top menu.

browsedotnet-11

On the left menu you can select settings and set the available Solution Types for your solutions and the available programming languages for you Code Snippets.

browsedotnet-12

Type key terms on the top menu and search .NET Solutions or Code snippets by keys. You will be able to open directly the matched solutions and view the source of your snippets. You can type multiple key terms by comma separating them.

browsedotnet-13

Keys are really important to the search engine so try to be carefull when registering solutions or code snippets. For example if you register a .NET solution with a key mvc and use the same key for registering a code snippet, searching with that term will fetch you both results. Instead, if you use the key term mvc snippet for the snippet registration, BrowseDotNET would fetch again both results but the inner search engine will use two different key records from the database while only one record used on the first case.

browsedotnet-17

As soon as you start registering and opening .NET solutions from BrowseDotNET you will find the most recently used solutions on the first page.

browsedotnet-14

Host BrowseDotNET in your local IIS and you will never loose time searching for the same code samples or finding a .NET solution.

Source Code

There is a lot of source code to study in BrowseDotNET and I totally recommend you read ASP.NET MVC Solution Architecture – Best Practices and Web API powerful Custom Model Validation with FluentValidation in case you aren’t familiar with those concepts. FluentValidation is used particularly for validating ViewModels. Let’s see the example for validating the FilePath in SolutiongViewModel, the model which is posted back to server when the user registers a solution.

SolutionViewModel.cs

public class SolutionViewModel : IValidatableObject
    {
        public int ID { get; set; }

        [MaxLength(50)]
        public string Author { get; set; }

        [Required]
        [MaxLength(100)]
        [Display(Name = "Application")]
        public string Name { get; set; }

        [Required]
        [MaxLength(250)]
        [Display(Name = "Full Path (.sln)")]
        [RegularExpression(@"^(?:[\w]\:|\\)(\\[a-zA-Z_\-\s0-9\.]+)+\.(sln)$", ErrorMessage = "Invalid file path format.")]
        public string FilePath { get; set; }

        [Required]
        [MaxLength(300)]
        [DataType(DataType.MultilineText)]
        public string Description { get; set; }

        [MaxLength(200)]
        [DataType(DataType.Url)]
        public string Website { get; set; }

        [Required]
        [Display(Name = "Type")]
        public int SolutionTypeID { get; set; }

        [Display(Name = "Type")]
        public string SolutionTypeType { get; set; }

        [Required]
        [MaxLength(200)]
        [DataType(DataType.MultilineText)]
        public string Keys { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            var validator = new SolutionViewModelValidator();
            var result = validator.Validate(this);
            return result.Errors.Select(item => new ValidationResult(item.ErrorMessage, new[] { item.PropertyName }));
        }
    }

And it’s Validator..

SolutionViewModelValidator

public class SolutionViewModelValidator : AbstractValidator<SolutionViewModel>
    {
        public SolutionViewModelValidator()
        {
            RuleFor(s => s.FilePath)
                .Must(IsValidPath)
                .WithMessage("Enter solution's full file path.");
        }

        private bool IsValidPath(string filePath)
        {
            bool _isValidSolutionPath = new bool();

            try
            {

                if (File.Exists(filePath) && Path.GetExtension(filePath).EndsWith(".sln"))
                    _isValidSolutionPath = true;
            }
            catch
            {
                _isValidSolutionPath = false;
            }

            return _isValidSolutionPath;
        }
    }

Data annotations used for SolutionViewModel in conjuction with jQuery Validation will prevent the user post a string that doesn’t represent a file path ending in .sln.

browsedotnet-15

But even if he does enter a file path that ends with .sln, the ModelState.IsValid will return false if the path posted doesn’t exist in user’s pc. That’s the magic of FluentValidation.

browsedotnet-16

Conclusion

BrowseDotNET is certainly a powerfull tool for .NET developers. The more solutions you have on your pc and the more code snippets you want to easily access, the most you will benefit from BrowseDotNET. Download the source code from here. I’ m certain that you ‘ll enjoy working with it. Happy coding!

Update

Some folks asked me to add a Run as admin button cause they needed to open Visual Studio solutions with administrator rights, so I added that to.

browsedotnet-18

(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a sysadmin Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. Introduction to NGINX
2. Apache HTTP Server Cookbook
3. VirtualBox Essentials
4. Nagios Monitoring Cookbook
5. Linux BASH Programming Cookbook
6. Postgresql Database Tutorial
and many more ....
I agree to the Terms and Privacy Policy

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of