Class CsPropertyExtensions
Extensions class that manage extensions that support CodeFactory models that implement the CsProperty model.
Inherited Members
Namespace: CodeFactory.Formatting.CSharp
Assembly: CodeFactory.Formatting.CSharp.dll
Syntax
public static class CsPropertyExtensions
Methods
| Improve this Doc View SourceCSharpFormatDefaultExpressionBodyPropertySignatureWithBackingField(CsProperty, string, NamespaceManager, bool, bool, CsSecurity, CsSecurity, CsSecurity)
Generates a default property definition with a backing field. Will determine security modifiers and append to get and set statements when needed.
Declaration
public static string CSharpFormatDefaultExpressionBodyPropertySignatureWithBackingField(this CsProperty source, string backingFieldName, NamespaceManager manager = null, bool includeKeyword = false, bool includeAbstractKeyword = false, CsSecurity propertySecurity = CsSecurity.Unknown, CsSecurity setSecurity = CsSecurity.Unknown, CsSecurity getSecurity = CsSecurity.Unknown)
Parameters
Type | Name | Description |
---|---|---|
CsProperty | source | Property model used for generation. |
string | backingFieldName | the name of the backing field to be managed by the property. |
NamespaceManager | manager | Namespace manager used to format type names. |
bool | includeKeyword | Optional parameter that determines if the keywords will be appended. Default is false. |
bool | includeAbstractKeyword | Will include the definition for the abstract keyword in the definition if it is defined. default is false. |
CsSecurity | propertySecurity | Optional parameter that overrides the models property security and sets a new security access level. |
CsSecurity | setSecurity | Optional parameter that overrides the models set security level with a new access level. Will also define a set statement even if it is not defined. |
CsSecurity | getSecurity | Optional parameter that overrides the models get security level with a new access level. Will also define a get statement even if it is not defined. |
Returns
Type | Description |
---|---|
string | Formatted property or null if model data was missing. |
Examples
With Keywords [security] [keywords] [property type] [property name] { [get when used] => [backingField]; [set when used] =>[backingField] = value; } Without Keywords [security] [property type] [property name] { [get when used] => [backingField]; [set when used] =>[backingField] = value; }
| Improve this Doc View SourceCSharpFormatDefaultPropertySignature(CsProperty, NamespaceManager, bool, bool, CsSecurity, CsSecurity, CsSecurity)
Generates a default property definition with no backing properties. Will determine security modifiers and append to get and set statements when needed.
Declaration
public static string CSharpFormatDefaultPropertySignature(this CsProperty source, NamespaceManager manager = null, bool includeKeyword = false, bool includeAbstractKeyword = false, CsSecurity propertySecurity = CsSecurity.Unknown, CsSecurity setSecurity = CsSecurity.Unknown, CsSecurity getSecurity = CsSecurity.Unknown)
Parameters
Type | Name | Description |
---|---|---|
CsProperty | source | Property model used for generation. |
NamespaceManager | manager | Namespace manager used to format type names.This is an optional parameter. |
bool | includeKeyword | Optional parameter that determines if the keywords will be appended. Default is false. |
bool | includeAbstractKeyword | Will include the definition for the abstract keyword in the definition if it is defined. default is false. |
CsSecurity | propertySecurity | Optional parameter that overrides the models property security and sets a new security access level. |
CsSecurity | setSecurity | Optional parameter that overrides the models set security level with a new access level. Will also define a set statement even if it is not defined. |
CsSecurity | getSecurity | Optional parameter that overrides the models get security level with a new access level. Will also define a get statement even if it is not defined. |
Returns
Type | Description |
---|---|
string | Formatted property or null if model data was missing. |
Examples
With Keywords [security] [keywords] [property type] [property name] { [get when used]; [set when used]; } No Keywords [security] [property type] [property name] { [get when used]; [set when used]; }
| Improve this Doc View SourceCSharpFormatDefaultPropertySignatureWithBackingField(CsProperty, string, NamespaceManager, bool, bool, CsSecurity, CsSecurity, CsSecurity)
Generates a default property definition with a backing properties. Will determine security modifiers and append to get and set statements when needed.
Declaration
public static string CSharpFormatDefaultPropertySignatureWithBackingField(this CsProperty source, string backingFieldName, NamespaceManager manager = null, bool includeKeyword = false, bool includeAbstractKeyword = false, CsSecurity propertySecurity = CsSecurity.Unknown, CsSecurity setSecurity = CsSecurity.Unknown, CsSecurity getSecurity = CsSecurity.Unknown)
Parameters
Type | Name | Description |
---|---|---|
CsProperty | source | Property model used for generation. |
string | backingFieldName | the name of the backing field to be managed by the property. |
NamespaceManager | manager | Namespace manager used to format type names. |
bool | includeKeyword | Optional parameter that determines if the keywords will be appended. Default is false. |
bool | includeAbstractKeyword | Will include the definition for the abstract keyword in the definition if it is defined. default is false. |
CsSecurity | propertySecurity | Optional parameter that overrides the models property security and sets a new security access level. |
CsSecurity | setSecurity | Optional parameter that overrides the models set security level with a new access level. Will also define a set statement even if it is not defined. |
CsSecurity | getSecurity | Optional parameter that overrides the models get security level with a new access level. Will also define a get statement even if it is not defined. |
Returns
Type | Description |
---|---|
string | Formatted property or null if model data was missing. |
Examples
With Keywords [security] [keywords] [property type] [property name] { [get when used]{return [backingField];} [set when used]{ [backingField] = value;} } Without Keywords [security] [property type] [property name] { [get when used]{return [backingField];} [set when used]{ [backingField] = value;} }
| Improve this Doc View SourceCSharpFormatGetStatement(CsProperty, CsSecurity, CsSecurity)
Extension method that formats the get statement of a property definition.
Declaration
public static string CSharpFormatGetStatement(this CsProperty source, CsSecurity propertySecurity = CsSecurity.Unknown, CsSecurity getSecurity = CsSecurity.Unknown)
Parameters
Type | Name | Description |
---|---|---|
CsProperty | source | the source property definition |
CsSecurity | propertySecurity | Optional parameter that defined the security used by the implementing property. |
CsSecurity | getSecurity | Optional parameter that allows you to set the get security level. |
Returns
Type | Description |
---|---|
string | Will return the formatted get statement or null if the property model is empty or the property does not support get. |
Examples
With the same security [get] will return example: get With different security [security] [get] will return example: public get
| Improve this Doc View SourceCSharpFormatInterfacePropertySignature(CsProperty, NamespaceManager)
Generates a default property definition for use in an interface definition.
Declaration
public static string CSharpFormatInterfacePropertySignature(this CsProperty source, NamespaceManager manager = null)
Parameters
Type | Name | Description |
---|---|---|
CsProperty | source | Property model used for generation. |
NamespaceManager | manager | Namespace manager used to format type names. |
Returns
Type | Description |
---|---|
string | Formatted property or null if model data was missing. |
Examples
[property type] [property name] { [get when used]; [set when used]; }
| Improve this Doc View SourceCSharpFormatPropertyDeclaration(CsProperty, NamespaceManager, bool, bool, bool, CsSecurity)
Generates the initial definition portion of a property.
Declaration
public static string CSharpFormatPropertyDeclaration(this CsProperty source, NamespaceManager manager = null, bool includeSecurity = true, bool includeKeyWords = false, bool includeAbstractKeyword = false, CsSecurity propertySecurity = CsSecurity.Unknown)
Parameters
Type | Name | Description |
---|---|---|
CsProperty | source | The source property to use for formatting. |
NamespaceManager | manager | Namespace manager used to format type names. |
bool | includeSecurity | Optional flag that determines if the security scope will be applied to the property definition. Default is true. |
bool | includeKeyWords | Optional flag that determines if keywords assigned to the property should be included in the signature. Default is false. |
bool | includeAbstractKeyword | Will include the definition for the abstract keyword in the definition if it is defined. default is false. |
CsSecurity | propertySecurity | Optional parameter to override the models security and set your own security. |
Returns
Type | Description |
---|---|
string | The formatted signature or null if the model data was not loaded. |
Examples
Format with Keywords [Security] [Keywords*] [ReturnType] [PropertyName] = public static string FirstName Format without Keywords [Security] [ReturnType] [PropertyName] = public string FirstName
| Improve this Doc View SourceCSharpFormatSetStatement(CsProperty, CsSecurity, CsSecurity)
Extension method that formats the set statement of a property definition.
Declaration
public static string CSharpFormatSetStatement(this CsProperty source, CsSecurity propertySecurity = CsSecurity.Unknown, CsSecurity setSecurity = CsSecurity.Unknown)
Parameters
Type | Name | Description |
---|---|---|
CsProperty | source | the source property definition |
CsSecurity | propertySecurity | Optional parameter that defined the security used by the implementing property. |
CsSecurity | setSecurity | Optional parameter that allows you to set the set security level. |
Returns
Type | Description |
---|---|
string | Will return the formatted set statement or null if the property model is empty or the property does not support set. |
Examples
With the same security [set] will return example: set With different security [security] [set] will return example: public set