Make your resources type safe and IntelliSense friendly
.NETFramework v4.5+
Just copy ums.exe
to a folder in your path
-t
or-target
or first argument: the output file name or location (e.g. MyResources.cs). If not specified, the console stdout is used.-s
or-source
: the base directory to scan for files. If not specified, the current working directory is used.-n
or-namespace
: the namespace for the resources class.-i
or-include
: the patterns of files and folders to should be included relative to the base directory.-e
or-exclude
: the patterns of files and folders to should be excluded relative to the base directory.
The pattern matching style can be exact or partial, using *
syntax (e.g. file.ext
, folder*
, folder\subfolder*
, *file*
, *.ext
)
Sample folder structure:
- description.txt
- images
- image.bmp
- image.gif
- styles
- main.css
- colors.css
- headers.css
- scripts
- main.js
Scan all files and folders in the current location:
C:\demo>ums.exe
public partial class Resources
{
public const string description_txt = @"description.txt";
public const string imagesFolder = @"images\";
public partial class images
{
public const string image_bmp = @"images\image.bmp";
public const string image_gif = @"images\image.gif";
}
public const string scriptsFolder = @"scripts\";
public partial class scripts
{
public const string main_js = @"scripts\main.js";
}
public const string stylesFolder = @"styles\";
public partial class styles
{
public const string colors_css = @"styles\colors.css";
public const string headers_css = @"styles\headers.css";
public const string main_css = @"styles\main.css";
}
}
Specify target
, namespace
, include
and exclude
patterns:
C:\demo>ums.exe MyResources -namespace MyNamespace -include images* -exclude *.gif
namespace MyNamespace
{
public partial class Resources
{
public const string imagesFolder = @"images\";
public partial class images
{
public const string image_bmp = @"images\image.bmp";
}
}
}
- Have a question? Ask at Stackoverflow
- Found a problem? Create an issue
- Want to contribute? Send a pull request
This project is licensed under the MIT License - see the LICENSE.md file for details
- Hat tip to anyone who's code was used
- Vapour in the Alley for the command line arguments parser
- Adriano Repetti for the PathAddBackslash method