Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use expressions based properties #4583

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ public void SetClientContext(IContextDictionary? clientContext, ApplicationConte
/// <exception cref="InvalidOperationException">The underlying <see cref="HttpContext"/> is <see langword="null"/>.</exception>
public virtual ApplicationContext? ApplicationContext
{
get
{
return (ApplicationContext?)HttpContext?.Items[_applicationContextName];
}
get => (ApplicationContext?)HttpContext?.Items[_applicationContextName];
set
{
ThrowIfHttpContextIsNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ private void AuthenticationStateProvider_AuthenticationStateChanged(Task<Authent
/// context manager is valid for use in
/// the current environment.
/// </summary>
public bool IsValid
{
get { return ActiveCircuitState.CircuitExists; }
}
public bool IsValid => ActiveCircuitState.CircuitExists;

/// <summary>
/// Gets a value indicating whether the context manager
Expand Down
5 changes: 1 addition & 4 deletions Source/Csla.Blazor.WebAssembly/ApplicationContextManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ private void AuthenticationStateProvider_AuthenticationStateChanged(Task<Authent
/// context manager is valid for use in
/// the current environment.
/// </summary>
public bool IsValid
{
get { return true; }
}
public bool IsValid => true;

/// <summary>
/// Gets a value indicating whether the current runtime
Expand Down
15 changes: 3 additions & 12 deletions Source/Csla.Web.Mvc.Shared/ApplicationContextManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public class ApplicationContextManager : IContextManager
/// context manager is valid for use in
/// the current environment.
/// </summary>
public bool IsValid
{
get { return HttpContext.Current != null; }
}
public bool IsValid => HttpContext.Current != null;

/// <summary>
/// Gets a value indicating whether the current runtime
Expand Down Expand Up @@ -98,14 +95,8 @@ public void SetClientContext(IContextDictionary? clientContext, ApplicationConte
/// </summary>
public virtual ApplicationContext? ApplicationContext
{
get
{
return (ApplicationContext?)HttpContext.Current.Items[_applicationContextName];
}
set
{
HttpContext.Current.Items[_applicationContextName] = value;
}
get => (ApplicationContext?)HttpContext.Current.Items[_applicationContextName];
set => HttpContext.Current.Items[_applicationContextName] = value;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public HttpPortal Portal
_portal = _applicationContext.CreateInstanceDI<HttpPortal>();
return _portal;
}
set { _portal = value; }
set => _portal = value;
}

#if NETSTANDARD2_0 || NET8_0_OR_GREATER
Expand Down
4 changes: 2 additions & 2 deletions Source/Csla.Web.Mvc.Shared/ViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public abstract class ViewModelBase<T> : IViewModel where T : class
{
object? IViewModel.ModelObject
{
get { return ModelObject; }
set { ModelObject = (T?)value; }
get => ModelObject;
set => ModelObject = (T?)value;
}

/// <summary>
Expand Down
15 changes: 3 additions & 12 deletions Source/Csla.Web/ApplicationContextManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public ApplicationContextManager()
/// context manager is valid for use in
/// the current environment.
/// </summary>
public bool IsValid
{
get { return HttpContext.Current != null; }
}
public bool IsValid => HttpContext.Current != null;

/// <summary>
/// Gets a value indicating whether the current runtime
Expand Down Expand Up @@ -104,14 +101,8 @@ public void SetClientContext(IContextDictionary clientContext, ApplicationContex
/// </summary>
public ApplicationContext ApplicationContext
{
get
{
return (ApplicationContext)HttpContext.Current.Items[_applicationContextName];
}
set
{
HttpContext.Current.Items[_applicationContextName] = value;
}
get => (ApplicationContext)HttpContext.Current.Items[_applicationContextName];
set => HttpContext.Current.Items[_applicationContextName] = value;
}
}
}
16 changes: 8 additions & 8 deletions Source/Csla.Web/CslaDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ protected override DataSourceView GetView(string viewName)
/// <value>Obsolete - do not use.</value>
public string TypeAssemblyName
{
get { return ((CslaDataSourceView)GetView("Default")).TypeAssemblyName; }
set { ((CslaDataSourceView)GetView("Default")).TypeAssemblyName = value; }
get => ((CslaDataSourceView)GetView("Default")).TypeAssemblyName;
set => ((CslaDataSourceView)GetView("Default")).TypeAssemblyName = value;
}

/// <summary>
Expand All @@ -90,8 +90,8 @@ public string TypeAssemblyName
/// including assembly name.</value>
public string TypeName
{
get { return ((CslaDataSourceView)GetView("Default")).TypeName; }
set { ((CslaDataSourceView)GetView("Default")).TypeName = value; }
get => ((CslaDataSourceView)GetView("Default")).TypeName;
set => ((CslaDataSourceView)GetView("Default")).TypeName = value;
}

/// <summary>
Expand All @@ -105,8 +105,8 @@ public string TypeName
/// </remarks>
public bool TypeSupportsPaging
{
get { return ((CslaDataSourceView)GetView("Default")).TypeSupportsPaging; }
set { ((CslaDataSourceView)GetView("Default")).TypeSupportsPaging = value; }
get => ((CslaDataSourceView)GetView("Default")).TypeSupportsPaging;
set => ((CslaDataSourceView)GetView("Default")).TypeSupportsPaging = value;
}

/// <summary>
Expand All @@ -115,8 +115,8 @@ public bool TypeSupportsPaging
/// </summary>
public bool TypeSupportsSorting
{
get { return ((CslaDataSourceView)GetView("Default")).TypeSupportsSorting; }
set { ((CslaDataSourceView)GetView("Default")).TypeSupportsSorting = value; }
get => ((CslaDataSourceView)GetView("Default")).TypeSupportsSorting;
set => ((CslaDataSourceView)GetView("Default")).TypeSupportsSorting = value;
}

private static Dictionary<string,Type> _typeCache = [];
Expand Down
21 changes: 3 additions & 18 deletions Source/Csla.Web/CslaDataSourceView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,35 +240,20 @@ protected override int ExecuteUpdate(IDictionary keys, IDictionary values, IDict
/// Gets a value indicating whether the data source supports
/// paging of the data.
/// </summary>
public override bool CanPage
{
get
{
return TypeSupportsPaging;
}
}
public override bool CanPage => TypeSupportsPaging;

/// <summary>
/// Gets a value indicating whether the data source can
/// retrieve the total number of rows of data. Always
/// returns true.
/// </summary>
public override bool CanRetrieveTotalRowCount
{
get { return true; }
}
public override bool CanRetrieveTotalRowCount => true;

/// <summary>
/// Gets a alue indicating whether the data source supports
/// sorting of the data. Always returns false.
/// </summary>
public override bool CanSort
{
get
{
return TypeSupportsSorting;
}
}
public override bool CanSort => TypeSupportsSorting;

#endregion

Expand Down
5 changes: 1 addition & 4 deletions Source/Csla.Web/Design/CslaDataSourceConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ public CslaDataSourceConfiguration(DataSourceControl control, string oldTypeName
/// <summary>
/// Gets the type name entered by the user.
/// </summary>
public string TypeName
{
get { return TypeComboBox.Text; }
}
public string TypeName => TypeComboBox.Text;

private void DiscoverTypes()
{
Expand Down
41 changes: 6 additions & 35 deletions Source/Csla.Web/Design/CslaDataSourceDesigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ public override void Initialize(IComponent component)
_control = (DataSourceControl)component;
}

internal ISite Site
{
get
{
return _control.Site;
}
}
internal ISite Site => _control.Site;

/// <summary>
/// Returns the default view for this designer.
/// </summary>
Expand Down Expand Up @@ -81,13 +76,7 @@ public override void RefreshSchema(bool preferSilent)
/// Get a value indicating whether the control can
/// refresh its schema.
/// </summary>
public override bool CanRefreshSchema
{
get
{
return true;
}
}
public override bool CanRefreshSchema => true;

/// <summary>
/// Invoke the design time configuration
Expand Down Expand Up @@ -133,36 +122,18 @@ private bool ConfigureCallback(object context)
/// Get a value indicating whether this control
/// supports design time configuration.
/// </summary>
public override bool CanConfigure
{
get
{
return true;
}
}
public override bool CanConfigure => true;

/// <summary>
/// Get a value indicating whether the control can
/// be resized.
/// </summary>
public override bool AllowResize
{
get
{
return false;
}
}
public override bool AllowResize => false;

/// <summary>
/// Get a reference to the CslaDataSource control being
/// designed.
/// </summary>
internal CslaDataSource DataSourceControl
{
get
{
return (CslaDataSource)_control;
}
}
internal CslaDataSource DataSourceControl => (CslaDataSource)_control;
}
}
37 changes: 7 additions & 30 deletions Source/Csla.Web/Design/CslaDesignerDataSourceView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,16 @@ public override IEnumerable GetDesignTimeData(int minimumRows, out bool isSample
/// with the <see cref="BrowsableAttribute">Browsable attribute</see>
/// as False.
/// </remarks>
public override IDataSourceViewSchema Schema
{
get
{
return new ObjectSchema(
_owner,
_owner.DataSourceControl.TypeName).GetViews()[0];
}
}
public override IDataSourceViewSchema Schema =>
new ObjectSchema(
_owner,
_owner.DataSourceControl.TypeName).GetViews()[0];

/// <summary>
/// Get a value indicating whether data binding can retrieve
/// the total number of rows of data.
/// </summary>
public override bool CanRetrieveTotalRowCount
{
get
{
return true;
}
}
public override bool CanRetrieveTotalRowCount => true;

private Type GetObjectType()
{
Expand Down Expand Up @@ -213,24 +202,12 @@ public override bool CanUpdate
/// Gets a value indicating whether the data source supports
/// paging.
/// </summary>
public override bool CanPage
{
get
{
return _owner.DataSourceControl.TypeSupportsPaging;
}
}
public override bool CanPage => _owner.DataSourceControl.TypeSupportsPaging;

/// <summary>
/// Gets a value indicating whether the data source supports
/// sorting.
/// </summary>
public override bool CanSort
{
get
{
return _owner.DataSourceControl.TypeSupportsSorting;
}
}
public override bool CanSort => _owner.DataSourceControl.TypeSupportsSorting;
}
}
15 changes: 3 additions & 12 deletions Source/Csla.Web/Design/ObjectFieldInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ public ObjectFieldInfo(PropertyDescriptor field)
/// Gets the property's numeric precision.
/// </summary>
/// <returns>Always returns -1.</returns>
public int Precision
{
get { return -1; }
}
public int Precision => -1;

/// <summary>
/// Gets a value indicating whether the property
Expand All @@ -133,18 +130,12 @@ public int Precision
/// the <see cref="DataObjectFieldAttribute">DataObjectField</see>
/// attribute on the property.
/// </remarks>
public bool PrimaryKey
{
get { return IsUnique; }
}
public bool PrimaryKey => IsUnique;

/// <summary>
/// Gets the property's scale.
/// </summary>
/// <returns>Always returns -1.</returns>
public int Scale
{
get { return -1; }
}
public int Scale => -1;
}
}
8 changes: 1 addition & 7 deletions Source/Csla.Web/Design/ObjectViewSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ public IDataSourceFieldSchema[] GetFields()
/// <summary>
/// Returns the name of the schema.
/// </summary>
public string Name
{
get
{
return "Default";
}
}
public string Name => "Default";
}
}
4 changes: 2 additions & 2 deletions Source/Csla.Web/SelectObjectArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public class SelectObjectArgs : EventArgs
/// <value>A reference to a CSLA .NET business object.</value>
public object BusinessObject
{
get { return _businessObject; }
set { _businessObject = value; }
get => _businessObject;
set => _businessObject = value;
}

/// <summary>
Expand Down
Loading
Loading