The Ignition framework has as a standard for using a constants file as opposed to having constants randomly assigned to variables throughout the application. When a new Ignition project is created, an IgnitionConstants.cs file is added to the Ignition.Sc project within the Presentation folder of the Ignition solution.
Example of the type of constants oriented information which can be stored in the IgnitionConstants.cs file include
- Placeholder Names
- Folder Names
- Item Names
- Tag Names
- Item GUIDs (when needed)
- View Paths (when needed)
This is not an exhaustive list of string options for constants but keeping these constants in one file makes it easier to re-use and to update this information through-out the application when necessary.
Code Structure of IgnitionConstants.cs File
The code structure used to define these constants appear like the following…
namespace Ignition.Sc { public struct IgnitionConstants { public struct Placeholders { public struct Layout { public const string LayoutContent = "layoutContent"; public const string LayoutHead = "layoutHead"; } public struct Content { public const string BlurbList = "blurb"; } } public struct News { public const string NewsDetailBranchId = "{4713D2A4-6E63-4FDB-B463-6C6DA154725E}"; public const string InTheNewsDetailBranchId = "{4CB843CE-3868-4CAE-B86F-DBDA7217E4A4}"; public const string InTheNewsTypeTag = "InTheNews"; } public struct CardTagType { public const string ContentType = "Content"; public const string TaxonomyTag = "Tag"; } } }
Within the IgnitionConstants class, a bunch of C# structs are used to define the level of constants needed to support the application. An example of this reference is shown below.
using Ignition.Core.Mvc; namespace Ignition.Sc.Components.Content { public class ContentBlurbListViewAgent : Agent<ContentBlurbListViewModel> { public override void PopulateModel() { ViewModel.CurrentTag = IgnitionConstants.CardTagType.ContentType; } } }
In this example, the current tag property of the view model is set by pulling a constant from the IgnitionConstants.cs file used to manage those constants where this value is defined.
For more information about using the Ignition framework please click the following link. This on-line documentation is still in progress and will be updated with the latest information when available.