Class Recipe
A recipe contains instructions how to generate tags etc. which can contain multiple resized images
[InternalApi_DoNotUse_MayChangeWithoutNotice("Still Beta / WIP")]
public class Recipe : ICanDump
- Inheritance
-
Recipe
- Implements
Remarks
All the properties are read-only. If you need to override anything, copy it and set the modified values, then use the copy.
Constructors
Recipe(string, string, string, string, int, bool?, bool?, string, IDictionary<string, object>, IEnumerable<Recipe>)
Lighter constructor for json, without parameter Recipe.
Important If you call this from your code, always use named parameters, as the parameter order can change in future.
[JsonConstructor]
public Recipe(string name = null, string forTag = null, string forFactor = null, string forCss = null, int width = 0, bool? setWidth = null, bool? setHeight = null, string variants = null, IDictionary<string, object> attributes = null, IEnumerable<Recipe> recipes = null)
Parameters
name
stringAn optional name
forTag
stringRestricts the rule to only apply to specific tags - ATM
img
andsource
forFactor
stringRestricts the rule to only apply to resizes for a specified factor
forCss
stringRestricts the rule to only apply to pages which have the specified CSS Framework
width
intInitial width to use when resizing
setWidth
bool?Set the
width
attribute if the img width is knownsetHeight
bool?Set the
height
attribute if the img-height is knownvariants
stringSpecial string containing variants to generate
attributes
IDictionary<string, object>List of attributes to set on the
img
tagrecipes
IEnumerable<Recipe>List of additional recipes which will all inherit values from this master after creation
Recipe(Recipe, string, string, string, string, int, bool?, bool?, string, IDictionary<string, object>, IEnumerable<Recipe>)
Important
If you call this from your code, always use named parameters, as the parameter order can change in future.
public Recipe(Recipe original, string name = null, string forTag = null, string forFactor = null, string forCss = null, int width = 0, bool? setWidth = null, bool? setHeight = null, string variants = null, IDictionary<string, object> attributes = null, IEnumerable<Recipe> recipes = null)
Parameters
original
RecipeAn original recipe to copy if we want to get a modified recipe based on one which already existed.
name
stringAn optional name
forTag
stringRestricts the rule to only apply to specific tags - ATM
img
andsource
forFactor
stringRestricts the rule to only apply to resizes for a specified factor
forCss
stringRestricts the rule to only apply to pages which have the specified CSS Framework
width
intInitial width to use when resizing
setWidth
bool?Set the
width
attribute if the img width is knownsetHeight
bool?Set the
height
attribute if the img-height is knownvariants
stringSpecial string containing variants to generate
attributes
IDictionary<string, object>List of attributes to set on the
img
tagrecipes
IEnumerable<Recipe>List of additional recipes which will all inherit values from this master after creation
Properties
Attributes
Attributes to add to the img tag
public IDictionary<string, object> Attributes { get; }
Property Value
Remarks
System.Text.Json requires that the case-insensitive property name and type match the parameter in the constructor. We are using string/object because a value could also be { "name": true, "other-name": 5 } in the json configuration
ForCss
WIP, not implemented yet
public string ForCss { get; set; }
Property Value
ForFactor
Determines which factors this recipe should be applied to. Null means any factor.
public string ForFactor { get; }
Property Value
ForTag
TODO: DOC
img
,source
public string ForTag { get; }
Property Value
Name
Just an identifier - no technical use
public string Name { get; }
Property Value
Recipes
wip TODO: DOC
public IEnumerable<Recipe> Recipes { get; }
Property Value
Remarks
System.Text.Json requires that the case-insensitive property name and type match the parameter in the constructor.
SetHeight
Determines if the img tag will receive a height-attribute
public bool? SetHeight { get; }
Property Value
- bool?
SetWidth
Determines if the img tag will receive a width-attribute
public bool? SetWidth { get; }
Property Value
- bool?
Variants
Source-Set rules (comma separated) which will determine what will be generated.
Examples:
1x,1.5x,2x
- screen resolutions200w,400w,600w,800w,1000w
- pixel sizes0.5*,1*,1.5*,2*
- multipliers of the originally specified pixel size
Important: According to the HTML standard you can mix pixel-sizes and multipliers, but not resolutions with any of the other types.
public string Variants { get; }
Property Value
Width
The initial width to assume in this resize, from which other sizes would be calculated.
If set to 0, it will be ignored.
public int Width { get; }
Property Value
Methods
Dump()
Create a string dump of the current objects state/contents.
public string Dump()