Automatic Type Inference
Use Type Inference to automatically select the desired type from a given component name.
Automatic Type Inference
Automatic Type Inference allows you to enter the desired name of a component and MFractor will guess the desired type. This dramatically simplifies and speeds up the process of creating new bindable properties, value converters or any component where the name often represents its given type.
Once you adjust to type inference, you can simply enter the name of a new component and MFractor automatically sets up the type information based on known conventions. This makes it fast and intuitive to create new components and not need to worry about provide the type information.
Rules
Here is a full list of the rules the type inference engine uses when deducing types:
- Bool:
- Name starts with:
is
,can
,has
,should
allow
,show
,include
,accepts
. - Name ends with:
boolean
,bool
,enabled
.
- Name starts with:
- String:
- Name ends with:
text
,label
,string
,title
,message
,name
,character
.
- Name ends with:
- Int:
- Name ends with:
number
,id
,int
,integer
,count
,size
,width
,height
,spacing
,length
.
- Name ends with:
- Double:
- Name starts with:
double
. - Name ends with:
decimal
.
- Name starts with:
- Char:
- Name starts with:
char
.
- Name starts with:
- Enum:
- Name starts with:
enum
.
- Name starts with:
- Xamarin.Forms.ImageSource:
- Input value ends with:
.png
,.gif
,.jpg
,.jpeg
. - Name ends with:
image
,icon
,picture
,photo
.
- Input value ends with:
- EventHandler:
- Name ends with:
callback
,handler
,event
.
- Name ends with:
- System.IO.FileInfo:
- Name ends with:
file
.
- Name ends with:
- System.Windows.Input.ICommand:
- Name ends with:
command
.
- Name ends with:
- System.DateTime:
- Name starts with:
date
,time
. - Name ends with:
date
,time
.
- Name starts with:
- System.TimeSpan:
- Name ends with:
timespan
.
- Name ends with:
- Xamarin.Forms.Color:
- Name ends with:
color
,colour
.
- Name ends with:
- List
: - When the input name ends with
s
(IE: Is pluralised) and the name can be matched to a known type in the project, returnsList<Name>
.
- When the input name ends with