Skip to content

Commit 898f4ce

Browse files
use expressions based properties (#4583)
Co-authored-by: Rockford Lhotka <[email protected]>
1 parent 7eab515 commit 898f4ce

File tree

84 files changed

+454
-1228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+454
-1228
lines changed

Source/Csla.AspNetCore/ApplicationContextManagerHttpContext.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,7 @@ public void SetClientContext(IContextDictionary? clientContext, ApplicationConte
175175
/// <exception cref="InvalidOperationException">The underlying <see cref="HttpContext"/> is <see langword="null"/>.</exception>
176176
public virtual ApplicationContext? ApplicationContext
177177
{
178-
get
179-
{
180-
return (ApplicationContext?)HttpContext?.Items[_applicationContextName];
181-
}
178+
get => (ApplicationContext?)HttpContext?.Items[_applicationContextName];
182179
set
183180
{
184181
ThrowIfHttpContextIsNull();

Source/Csla.AspNetCore/Blazor/ApplicationContextManagerInMemory.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ private void AuthenticationStateProvider_AuthenticationStateChanged(Task<Authent
110110
/// context manager is valid for use in
111111
/// the current environment.
112112
/// </summary>
113-
public bool IsValid
114-
{
115-
get { return ActiveCircuitState.CircuitExists; }
116-
}
113+
public bool IsValid => ActiveCircuitState.CircuitExists;
117114

118115
/// <summary>
119116
/// Gets a value indicating whether the context manager

Source/Csla.Blazor.WebAssembly/ApplicationContextManager.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ private void AuthenticationStateProvider_AuthenticationStateChanged(Task<Authent
6161
/// context manager is valid for use in
6262
/// the current environment.
6363
/// </summary>
64-
public bool IsValid
65-
{
66-
get { return true; }
67-
}
64+
public bool IsValid => true;
6865

6966
/// <summary>
7067
/// Gets a value indicating whether the current runtime

Source/Csla.Web.Mvc.Shared/ApplicationContextManager.cs

+3-12
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ public class ApplicationContextManager : IContextManager
2525
/// context manager is valid for use in
2626
/// the current environment.
2727
/// </summary>
28-
public bool IsValid
29-
{
30-
get { return HttpContext.Current != null; }
31-
}
28+
public bool IsValid => HttpContext.Current != null;
3229

3330
/// <summary>
3431
/// Gets a value indicating whether the current runtime
@@ -98,14 +95,8 @@ public void SetClientContext(IContextDictionary? clientContext, ApplicationConte
9895
/// </summary>
9996
public virtual ApplicationContext? ApplicationContext
10097
{
101-
get
102-
{
103-
return (ApplicationContext?)HttpContext.Current.Items[_applicationContextName];
104-
}
105-
set
106-
{
107-
HttpContext.Current.Items[_applicationContextName] = value;
108-
}
98+
get => (ApplicationContext?)HttpContext.Current.Items[_applicationContextName];
99+
set => HttpContext.Current.Items[_applicationContextName] = value;
109100
}
110101

111102
/// <summary>

Source/Csla.Web.Mvc.Shared/Server/Hosts/HttpPortalController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public HttpPortal Portal
169169
_portal = _applicationContext.CreateInstanceDI<HttpPortal>();
170170
return _portal;
171171
}
172-
set { _portal = value; }
172+
set => _portal = value;
173173
}
174174

175175
#if NETSTANDARD2_0 || NET8_0_OR_GREATER

Source/Csla.Web.Mvc.Shared/ViewModelBase.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public abstract class ViewModelBase<T> : IViewModel where T : class
2020
{
2121
object? IViewModel.ModelObject
2222
{
23-
get { return ModelObject; }
24-
set { ModelObject = (T?)value; }
23+
get => ModelObject;
24+
set => ModelObject = (T?)value;
2525
}
2626

2727
/// <summary>

Source/Csla.Web/ApplicationContextManager.cs

+3-12
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ public ApplicationContextManager()
3030
/// context manager is valid for use in
3131
/// the current environment.
3232
/// </summary>
33-
public bool IsValid
34-
{
35-
get { return HttpContext.Current != null; }
36-
}
33+
public bool IsValid => HttpContext.Current != null;
3734

3835
/// <summary>
3936
/// Gets a value indicating whether the current runtime
@@ -104,14 +101,8 @@ public void SetClientContext(IContextDictionary clientContext, ApplicationContex
104101
/// </summary>
105102
public ApplicationContext ApplicationContext
106103
{
107-
get
108-
{
109-
return (ApplicationContext)HttpContext.Current.Items[_applicationContextName];
110-
}
111-
set
112-
{
113-
HttpContext.Current.Items[_applicationContextName] = value;
114-
}
104+
get => (ApplicationContext)HttpContext.Current.Items[_applicationContextName];
105+
set => HttpContext.Current.Items[_applicationContextName] = value;
115106
}
116107
}
117108
}

Source/Csla.Web/CslaDataSource.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ protected override DataSourceView GetView(string viewName)
7878
/// <value>Obsolete - do not use.</value>
7979
public string TypeAssemblyName
8080
{
81-
get { return ((CslaDataSourceView)GetView("Default")).TypeAssemblyName; }
82-
set { ((CslaDataSourceView)GetView("Default")).TypeAssemblyName = value; }
81+
get => ((CslaDataSourceView)GetView("Default")).TypeAssemblyName;
82+
set => ((CslaDataSourceView)GetView("Default")).TypeAssemblyName = value;
8383
}
8484

8585
/// <summary>
@@ -90,8 +90,8 @@ public string TypeAssemblyName
9090
/// including assembly name.</value>
9191
public string TypeName
9292
{
93-
get { return ((CslaDataSourceView)GetView("Default")).TypeName; }
94-
set { ((CslaDataSourceView)GetView("Default")).TypeName = value; }
93+
get => ((CslaDataSourceView)GetView("Default")).TypeName;
94+
set => ((CslaDataSourceView)GetView("Default")).TypeName = value;
9595
}
9696

9797
/// <summary>
@@ -105,8 +105,8 @@ public string TypeName
105105
/// </remarks>
106106
public bool TypeSupportsPaging
107107
{
108-
get { return ((CslaDataSourceView)GetView("Default")).TypeSupportsPaging; }
109-
set { ((CslaDataSourceView)GetView("Default")).TypeSupportsPaging = value; }
108+
get => ((CslaDataSourceView)GetView("Default")).TypeSupportsPaging;
109+
set => ((CslaDataSourceView)GetView("Default")).TypeSupportsPaging = value;
110110
}
111111

112112
/// <summary>
@@ -115,8 +115,8 @@ public bool TypeSupportsPaging
115115
/// </summary>
116116
public bool TypeSupportsSorting
117117
{
118-
get { return ((CslaDataSourceView)GetView("Default")).TypeSupportsSorting; }
119-
set { ((CslaDataSourceView)GetView("Default")).TypeSupportsSorting = value; }
118+
get => ((CslaDataSourceView)GetView("Default")).TypeSupportsSorting;
119+
set => ((CslaDataSourceView)GetView("Default")).TypeSupportsSorting = value;
120120
}
121121

122122
private static Dictionary<string,Type> _typeCache = [];

Source/Csla.Web/CslaDataSourceView.cs

+3-18
Original file line numberDiff line numberDiff line change
@@ -240,35 +240,20 @@ protected override int ExecuteUpdate(IDictionary keys, IDictionary values, IDict
240240
/// Gets a value indicating whether the data source supports
241241
/// paging of the data.
242242
/// </summary>
243-
public override bool CanPage
244-
{
245-
get
246-
{
247-
return TypeSupportsPaging;
248-
}
249-
}
243+
public override bool CanPage => TypeSupportsPaging;
250244

251245
/// <summary>
252246
/// Gets a value indicating whether the data source can
253247
/// retrieve the total number of rows of data. Always
254248
/// returns true.
255249
/// </summary>
256-
public override bool CanRetrieveTotalRowCount
257-
{
258-
get { return true; }
259-
}
250+
public override bool CanRetrieveTotalRowCount => true;
260251

261252
/// <summary>
262253
/// Gets a alue indicating whether the data source supports
263254
/// sorting of the data. Always returns false.
264255
/// </summary>
265-
public override bool CanSort
266-
{
267-
get
268-
{
269-
return TypeSupportsSorting;
270-
}
271-
}
256+
public override bool CanSort => TypeSupportsSorting;
272257

273258
#endregion
274259

Source/Csla.Web/Design/CslaDataSourceConfiguration.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ public CslaDataSourceConfiguration(DataSourceControl control, string oldTypeName
4444
/// <summary>
4545
/// Gets the type name entered by the user.
4646
/// </summary>
47-
public string TypeName
48-
{
49-
get { return TypeComboBox.Text; }
50-
}
47+
public string TypeName => TypeComboBox.Text;
5148

5249
private void DiscoverTypes()
5350
{

Source/Csla.Web/Design/CslaDataSourceDesigner.cs

+6-35
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,8 @@ public override void Initialize(IComponent component)
3333
_control = (DataSourceControl)component;
3434
}
3535

36-
internal ISite Site
37-
{
38-
get
39-
{
40-
return _control.Site;
41-
}
42-
}
36+
internal ISite Site => _control.Site;
37+
4338
/// <summary>
4439
/// Returns the default view for this designer.
4540
/// </summary>
@@ -81,13 +76,7 @@ public override void RefreshSchema(bool preferSilent)
8176
/// Get a value indicating whether the control can
8277
/// refresh its schema.
8378
/// </summary>
84-
public override bool CanRefreshSchema
85-
{
86-
get
87-
{
88-
return true;
89-
}
90-
}
79+
public override bool CanRefreshSchema => true;
9180

9281
/// <summary>
9382
/// Invoke the design time configuration
@@ -133,36 +122,18 @@ private bool ConfigureCallback(object context)
133122
/// Get a value indicating whether this control
134123
/// supports design time configuration.
135124
/// </summary>
136-
public override bool CanConfigure
137-
{
138-
get
139-
{
140-
return true;
141-
}
142-
}
125+
public override bool CanConfigure => true;
143126

144127
/// <summary>
145128
/// Get a value indicating whether the control can
146129
/// be resized.
147130
/// </summary>
148-
public override bool AllowResize
149-
{
150-
get
151-
{
152-
return false;
153-
}
154-
}
131+
public override bool AllowResize => false;
155132

156133
/// <summary>
157134
/// Get a reference to the CslaDataSource control being
158135
/// designed.
159136
/// </summary>
160-
internal CslaDataSource DataSourceControl
161-
{
162-
get
163-
{
164-
return (CslaDataSource)_control;
165-
}
166-
}
137+
internal CslaDataSource DataSourceControl => (CslaDataSource)_control;
167138
}
168139
}

Source/Csla.Web/Design/CslaDesignerDataSourceView.cs

+7-30
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,16 @@ public override IEnumerable GetDesignTimeData(int minimumRows, out bool isSample
9292
/// with the <see cref="BrowsableAttribute">Browsable attribute</see>
9393
/// as False.
9494
/// </remarks>
95-
public override IDataSourceViewSchema Schema
96-
{
97-
get
98-
{
99-
return new ObjectSchema(
100-
_owner,
101-
_owner.DataSourceControl.TypeName).GetViews()[0];
102-
}
103-
}
95+
public override IDataSourceViewSchema Schema =>
96+
new ObjectSchema(
97+
_owner,
98+
_owner.DataSourceControl.TypeName).GetViews()[0];
10499

105100
/// <summary>
106101
/// Get a value indicating whether data binding can retrieve
107102
/// the total number of rows of data.
108103
/// </summary>
109-
public override bool CanRetrieveTotalRowCount
110-
{
111-
get
112-
{
113-
return true;
114-
}
115-
}
104+
public override bool CanRetrieveTotalRowCount => true;
116105

117106
private Type GetObjectType()
118107
{
@@ -213,24 +202,12 @@ public override bool CanUpdate
213202
/// Gets a value indicating whether the data source supports
214203
/// paging.
215204
/// </summary>
216-
public override bool CanPage
217-
{
218-
get
219-
{
220-
return _owner.DataSourceControl.TypeSupportsPaging;
221-
}
222-
}
205+
public override bool CanPage => _owner.DataSourceControl.TypeSupportsPaging;
223206

224207
/// <summary>
225208
/// Gets a value indicating whether the data source supports
226209
/// sorting.
227210
/// </summary>
228-
public override bool CanSort
229-
{
230-
get
231-
{
232-
return _owner.DataSourceControl.TypeSupportsSorting;
233-
}
234-
}
211+
public override bool CanSort => _owner.DataSourceControl.TypeSupportsSorting;
235212
}
236213
}

Source/Csla.Web/Design/ObjectFieldInfo.cs

+3-12
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ public ObjectFieldInfo(PropertyDescriptor field)
119119
/// Gets the property's numeric precision.
120120
/// </summary>
121121
/// <returns>Always returns -1.</returns>
122-
public int Precision
123-
{
124-
get { return -1; }
125-
}
122+
public int Precision => -1;
126123

127124
/// <summary>
128125
/// Gets a value indicating whether the property
@@ -133,18 +130,12 @@ public int Precision
133130
/// the <see cref="DataObjectFieldAttribute">DataObjectField</see>
134131
/// attribute on the property.
135132
/// </remarks>
136-
public bool PrimaryKey
137-
{
138-
get { return IsUnique; }
139-
}
133+
public bool PrimaryKey => IsUnique;
140134

141135
/// <summary>
142136
/// Gets the property's scale.
143137
/// </summary>
144138
/// <returns>Always returns -1.</returns>
145-
public int Scale
146-
{
147-
get { return -1; }
148-
}
139+
public int Scale => -1;
149140
}
150141
}

Source/Csla.Web/Design/ObjectViewSchema.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ public IDataSourceFieldSchema[] GetFields()
9595
/// <summary>
9696
/// Returns the name of the schema.
9797
/// </summary>
98-
public string Name
99-
{
100-
get
101-
{
102-
return "Default";
103-
}
104-
}
98+
public string Name => "Default";
10599
}
106100
}

Source/Csla.Web/SelectObjectArgs.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public class SelectObjectArgs : EventArgs
2727
/// <value>A reference to a CSLA .NET business object.</value>
2828
public object BusinessObject
2929
{
30-
get { return _businessObject; }
31-
set { _businessObject = value; }
30+
get => _businessObject;
31+
set => _businessObject = value;
3232
}
3333

3434
/// <summary>

0 commit comments

Comments
 (0)