Umbraco.Community.GunsNPrices 0.1.0

dotnet add package Umbraco.Community.GunsNPrices --version 0.1.0
                    
NuGet\Install-Package Umbraco.Community.GunsNPrices -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Umbraco.Community.GunsNPrices" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Umbraco.Community.GunsNPrices" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Umbraco.Community.GunsNPrices" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Umbraco.Community.GunsNPrices --version 0.1.0
                    
#r "nuget: Umbraco.Community.GunsNPrices, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Umbraco.Community.GunsNPrices@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Umbraco.Community.GunsNPrices&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Umbraco.Community.GunsNPrices&version=0.1.0
                    
Install as a Cake Tool

GunsNPrices for Umbraco

NuGet Umbraco Marketplace

Read firearm and ammunition product titles in Umbraco: brand, model, caliber, magazine capacity, barrel length, rounds per box and cost per round, for gun shops, ammo stores, ranges and review sites built on Umbraco.

@Html.GunsNPricesSpecs(Model.ProductTitle)
<dl class="gunsnprices-specs">
  <dt>Brand</dt><dd>Glock</dd>
  <dt>Model</dt><dd>Glock 19 Gen 5 MOS</dd>
  <dt>Caliber</dt><dd>9×19mm Parabellum</dd>
  <dt>Capacity</dt><dd>15 rounds</dd>
  <dt>Barrel length</dt><dd>4.02 in</dd>
</dl>

It is built on GunsNPrices, the title parser behind gunsnprices.com, a price comparison site for 40+ US gun and ammo stores: 50 brands of model dictionaries ("G19 GEN5 MOS" is the Glock 19 Gen 5 MOS) and 293 calibers with the spellings stores use ("300 BLK", "6.5 CM", "12ga"). Server-side only: no backoffice UI, no database tables, no configuration needed to start.

Umbraco 17 (LTS) and 18, .NET 10.

Install

dotnet add package Umbraco.Community.GunsNPrices

The package registers itself (an IComposer); there is nothing to add to Program.cs.

Use it in views

Parse any property or the node name, wherever the title comes from:

@using Umbraco.Community.GunsNPrices
@{
    var info = Model.ParseTitle("productTitle", brand: Model.Value<string>("brand"));
    // or: var info = Model.ParseName();
}
@if (info?.Model != null)
{
    <p>@info.Model.Model, @info.Caliber?.Name, @info.Capacity rounds</p>
}
@Html.GunsNPricesSpecs(info)
  • ParseTitle(alias, culture, brand, mpn, price) on any IPublishedElement (content and blocks) parses the property value; ParseName(brand, mpn, price) on IPublishedContent parses the node name. Both return null when there is nothing to parse.
  • @Html.GunsNPricesSpecs(result or title, linkCalibers: false, cssClass: "gunsnprices-specs") renders a <dl> with the rows that have a value (Brand, Model, Caliber(s), Capacity, Barrel length, Rounds per box, Cost per round). Everything is HTML-encoded. With linkCalibers: true each caliber links to its ammo price comparison page on gunsnprices.com.
  • The result is a GunsNPrices.ParseResult: Kind, Brand, Model (Family, Model, Generation, Configs, Features), Caliber, Calibers, Capacity, BarrelLength, Rounds, CostPerRound. TitleParser.Parse(...) is available directly too.

Or convert the property itself

List the text properties that hold product titles in appsettings.json:

{
  "GunsNPrices": {
    "TitlePropertyAliases": [ "productTitle" ]
  }
}

After a restart, those properties (Text box or Textarea editors only) return a ParseResult instead of a string. With ModelsBuilder the generated property is typed accordingly:

@Model.ProductTitle?.Title               @* the text the editor typed *@
@Model.ProductTitle?.Model?.Model        @* "Glock 19 Gen 5 MOS" *@
@Html.GunsNPricesSpecs(Model.ProductTitle)

In the Delivery API (headless) the property becomes an object:

"productTitle": {
  "title": "Glock 19 Gen 5 MOS 9mm 4.02in 15rd Pistol",
  "kind": "firearm",
  "brand": "Glock",
  "family": "Glock 19",
  "model": "Glock 19 Gen 5 MOS",
  "calibers": [ { "id": "9x19mmparabellum", "name": "9×19mm Parabellum", "type": "handgun", "url": "https://gunsnprices.com/ammo/handgun-ammo/9-19mm-parabellum" } ],
  "capacity": 15,
  "barrelLength": 4.02,
  "rounds": null
}

Only the listed aliases are converted; every other text property stays a string. Remove an alias to switch back.

Settings

Key Default
GunsNPrices:TitlePropertyAliases [] text box / textarea properties to convert to ParseResult
GunsNPrices:WarmupOnStartup true load the parser data in the background at startup (about 0.4 s once), so the first page doesn't wait

What it recognizes

Field Example in a title Result
Firearm or ammo ... 150gr ... 20rds Kind == ProductKind.Ammo
Brand and model (50 brands) G19 Gen5 MOS, part number PA195S203 Glock 19 Gen 5 MOS
Calibers (293) .357 Mag / .38 Spl, 6.5 CM, 12ga, 300 BLK .357 Magnum, .38 S&W Special, ...
Magazine capacity 15+1, 17RD, 13rd/15rd, 10-shot 15, 17, 15, 10
Barrel length, inches 4.02in, 16 1/2", 22 BBL, O/U 12/28 4.02, 16.5, 22, 28
Rounds per box 50/Box, Box of 20, 1,000 Rounds 50, 20, 1000
Cost per round price 449.99 + 1000 Rounds 0.45

Titles from US retailers, in English. More in the GunsNPrices package README.

License

The code is under the MIT License. The model and caliber data inside the GunsNPrices package are under CC BY 4.0: credit GunsNPrices (gunsnprices.com) with a link. Source: https://github.com/gunsnprices/gunsnprices-dotnet. Questions and missing models: app@gunsnprices.com.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 48 11/11/2026