From 417b595dd5e6278d8bd7aec182a9271d0e074bd2 Mon Sep 17 00:00:00 2001 From: Benedek Farkas Date: Fri, 31 Oct 2025 21:14:38 +0100 Subject: [PATCH] VS code cleanup: Apply auto property preferences --- .../Expressions/CollectionAccessExpression.cs | 6 +- .../Expressions/EntityExpression.cs | 21 +++---- .../Expressions/PropertyAccessExpression.cs | 16 ++--- .../Expressions/QuerySourceExpression.cs | 10 ++- .../NHibernate/NHibernate.Linq/Query.cs | 9 ++- .../LinqGroupingResultTransformer.cs | 5 +- .../Util/DetachedCriteriaAdapter.cs | 61 +++++++++---------- .../Visitors/MemberNameVisitor.cs | 24 ++++---- .../Visitors/SelectArgumentsVisitor.cs | 9 ++- .../Providers/CommonPartProviderTests.cs | 7 +-- src/Orchard.Specs/Bindings/WebAppHosting.cs | 22 +++---- src/Orchard.Tests/Stubs/StubAppDataFolder.cs | 29 +++++---- src/Orchard.Tests/Stubs/StubFileSystem.cs | 29 ++++----- .../Stubs/StubVirtualPathProvider.cs | 26 ++++---- .../Core/Common/Models/CommonPart.cs | 15 ++--- .../Containers/Services/ListViewService.cs | 6 +- .../Core/Navigation/Models/MenuPart.cs | 8 +-- .../Modules/Lucene/Models/LuceneSearchHit.cs | 5 +- .../Lucene/Models/LuceneSettingsPart.cs | 7 +-- .../Models/ArchiveLaterPart.cs | 3 +- .../Orchard.Blogs/Models/ArchiveData.cs | 4 +- .../Orchard.Comments/Models/CommentPart.cs | 15 ++--- .../Orchard.Comments/Models/CommentsPart.cs | 15 ++--- .../Orchard.Email/Models/SmtpSettingsPart.cs | 14 ++--- .../Models/LocalizationPart.cs | 15 ++--- .../Models/MediaFolder.cs | 10 +-- .../Services/FileBaseProjectSystem.cs | 5 +- .../Services/PackageBuilder.cs | 5 +- .../Models/PublishLaterPart.cs | 3 +- .../Providers/Executors/CommandStep.cs | 5 +- .../Orchard.Scripting/Ast/BinaryAstNode.cs | 20 +++--- .../Orchard.Scripting/Ast/ConstantAstNode.cs | 8 +-- .../Orchard.Scripting/Ast/ErrorAstNode.cs | 11 ++-- .../Ast/MethodCallAstNode.cs | 15 ++--- .../Orchard.Scripting/Ast/UnaryAstNode.cs | 15 ++--- .../Compiler/EvaluationResult.cs | 6 +- .../Orchard.Scripting/Compiler/Lexer.cs | 6 +- .../Services/UsernameValidationError.cs | 11 +--- src/Orchard/Caching/AcquireContext.cs | 6 +- .../Caching/DefaultCacheContextAccessor.cs | 10 +-- src/Orchard/Commands/CommandNameAttribute.cs | 6 +- .../Builders/ContentPartDefinitionBuilder.cs | 9 ++- src/Orchard/ContentManagement/QueryHints.cs | 3 +- src/Orchard/Data/MapAsRecordAttribute.cs | 6 +- .../Data/Migration/Schema/SchemaBuilder.cs | 40 ++++++------ src/Orchard/Data/Orderable.cs | 18 +++--- .../DisplayManagement/Shapes/Composite.cs | 24 +++----- .../Environment/DefaultOrchardShell.cs | 9 ++- .../Environment/WorkContextAccessor.cs | 16 +++-- src/Orchard/Localization/LocalizedString.cs | 35 +++++------ src/Orchard/Localization/Models/DateParts.cs | 24 +++----- .../Localization/Models/DateTimeParts.cs | 17 +++--- src/Orchard/Localization/Models/TimeParts.cs | 37 +++++------ src/Orchard/Localization/NullLocalizer.cs | 6 +- src/Orchard/Logging/NullLogger.cs | 4 +- .../AntiForgeryAuthorizationFilter.cs | 5 +- ...alidateAntiForgeryTokenOrchardAttribute.cs | 6 +- src/Orchard/Mvc/ViewPage.cs | 18 +++--- src/Orchard/Mvc/ViewUserControl.cs | 18 +++--- src/Orchard/Security/CreateUserParams.cs | 36 +++++------ .../Tasks/Locking/Services/DistributedLock.cs | 5 +- .../WebApi/AutofacWebApiDependencyResolver.cs | 7 +-- .../Orchard/Parameters/CommandLineParser.cs | 5 +- 63 files changed, 354 insertions(+), 517 deletions(-) diff --git a/src/Libraries/NHibernate/NHibernate.Linq/Expressions/CollectionAccessExpression.cs b/src/Libraries/NHibernate/NHibernate.Linq/Expressions/CollectionAccessExpression.cs index 931822488..7ecce2b09 100644 --- a/src/Libraries/NHibernate/NHibernate.Linq/Expressions/CollectionAccessExpression.cs +++ b/src/Libraries/NHibernate/NHibernate.Linq/Expressions/CollectionAccessExpression.cs @@ -4,15 +4,13 @@ namespace NHibernate.Linq.Expressions { public class CollectionAccessExpression : PropertyAccessExpression { - private readonly EntityExpression _elementExpression; - - public EntityExpression ElementExpression => _elementExpression; + public EntityExpression ElementExpression { get; } public CollectionAccessExpression(string name, System.Type type, IType nhibernateType, EntityExpression expression, EntityExpression elementExpression) : base(name, type, nhibernateType, expression, NHibernateExpressionType.CollectionAccess) { - _elementExpression = elementExpression; + ElementExpression = elementExpression; } } } diff --git a/src/Libraries/NHibernate/NHibernate.Linq/Expressions/EntityExpression.cs b/src/Libraries/NHibernate/NHibernate.Linq/Expressions/EntityExpression.cs index f400ef808..a020cfe6c 100644 --- a/src/Libraries/NHibernate/NHibernate.Linq/Expressions/EntityExpression.cs +++ b/src/Libraries/NHibernate/NHibernate.Linq/Expressions/EntityExpression.cs @@ -5,26 +5,21 @@ namespace NHibernate.Linq.Expressions { public class EntityExpression : NHibernateExpression { - private readonly string _alias; - private readonly string _associationPath; - private readonly IClassMetadata _metaData; - private readonly Expression _expression; + public string Alias { get; } - public string Alias => _alias; + public string AssociationPath { get; } - public string AssociationPath => _associationPath; + public IClassMetadata MetaData { get; } - public IClassMetadata MetaData => _metaData; - - public Expression Expression => _expression; + public Expression Expression { get; } public EntityExpression(string associationPath, string alias, System.Type type, IClassMetadata metaData, Expression expression) : base(IsRoot(expression) ? NHibernateExpressionType.RootEntity : NHibernateExpressionType.Entity, type) { - _associationPath = associationPath; - _alias = alias; - _metaData = metaData; - _expression = expression; + AssociationPath = associationPath; + Alias = alias; + MetaData = metaData; + Expression = expression; } private static bool IsRoot(Expression expr) diff --git a/src/Libraries/NHibernate/NHibernate.Linq/Expressions/PropertyAccessExpression.cs b/src/Libraries/NHibernate/NHibernate.Linq/Expressions/PropertyAccessExpression.cs index 862c55018..e36ab5d21 100644 --- a/src/Libraries/NHibernate/NHibernate.Linq/Expressions/PropertyAccessExpression.cs +++ b/src/Libraries/NHibernate/NHibernate.Linq/Expressions/PropertyAccessExpression.cs @@ -5,15 +5,11 @@ namespace NHibernate.Linq.Expressions { public class PropertyAccessExpression : NHibernateExpression { - private readonly string _name; - private readonly EntityExpression _expression; - private readonly IType _nhibernateType; + public string Name { get; } - public string Name => _name; + public EntityExpression Expression { get; } - public EntityExpression Expression => _expression; - - public IType NHibernateType => _nhibernateType; + public IType NHibernateType { get; } public PropertyAccessExpression(string name, System.Type type, IType nhibernateType, EntityExpression expression) : this(name, type, nhibernateType, expression, NHibernateExpressionType.PropertyAccess) { } @@ -26,9 +22,9 @@ namespace NHibernate.Linq.Expressions if (nhibernateType == null) throw new ArgumentNullException("nhibernateType"); if (expression == null) throw new ArgumentNullException("expression"); - _name = name; - _expression = expression; - _nhibernateType = nhibernateType; + Name = name; + Expression = expression; + NHibernateType = nhibernateType; } public override string ToString() diff --git a/src/Libraries/NHibernate/NHibernate.Linq/Expressions/QuerySourceExpression.cs b/src/Libraries/NHibernate/NHibernate.Linq/Expressions/QuerySourceExpression.cs index 0818df8f9..2697bf07b 100644 --- a/src/Libraries/NHibernate/NHibernate.Linq/Expressions/QuerySourceExpression.cs +++ b/src/Libraries/NHibernate/NHibernate.Linq/Expressions/QuerySourceExpression.cs @@ -4,13 +4,11 @@ namespace NHibernate.Linq.Expressions { public class QuerySourceExpression : NHibernateExpression { - private readonly string _alias; - private readonly IQueryable _query; private readonly System.Type _elementType; - public string Alias => _alias; + public string Alias { get; } - public IQueryable Query => _query; + public IQueryable Query { get; } public System.Type ElementType => _elementType ?? Query.ElementType; @@ -20,8 +18,8 @@ namespace NHibernate.Linq.Expressions public QuerySourceExpression(string alias, IQueryable query, System.Type elementType) : base(NHibernateExpressionType.QuerySource, query.GetType()) { - _alias = alias; - _query = query; + Alias = alias; + Query = query; _elementType = elementType; } diff --git a/src/Libraries/NHibernate/NHibernate.Linq/Query.cs b/src/Libraries/NHibernate/NHibernate.Linq/Query.cs index 3cdd69389..89f3a494d 100644 --- a/src/Libraries/NHibernate/NHibernate.Linq/Query.cs +++ b/src/Libraries/NHibernate/NHibernate.Linq/Query.cs @@ -13,14 +13,13 @@ namespace NHibernate.Linq { private readonly QueryProvider provider; private readonly Expression expression; - private readonly QueryOptions queryOptions; public Query(QueryProvider provider, QueryOptions queryOptions) { if (provider == null) throw new ArgumentNullException("provider"); this.provider = provider; - this.queryOptions = queryOptions; + this.QueryOptions = queryOptions; this.expression = Expression.Constant(this); } @@ -33,7 +32,7 @@ namespace NHibernate.Linq throw new ArgumentOutOfRangeException("expression"); this.provider = provider; - this.queryOptions = queryOptions; + this.QueryOptions = queryOptions; this.expression = expression; } @@ -43,11 +42,11 @@ namespace NHibernate.Linq IQueryProvider IQueryable.Provider => this.provider; - public QueryOptions QueryOptions => queryOptions; + public QueryOptions QueryOptions { get; } public IQueryable Expand(string path) { - queryOptions.AddExpansion(path); + QueryOptions.AddExpansion(path); return this; } diff --git a/src/Libraries/NHibernate/NHibernate.Linq/Transform/LinqGroupingResultTransformer.cs b/src/Libraries/NHibernate/NHibernate.Linq/Transform/LinqGroupingResultTransformer.cs index e232bf18d..2700adc88 100644 --- a/src/Libraries/NHibernate/NHibernate.Linq/Transform/LinqGroupingResultTransformer.cs +++ b/src/Libraries/NHibernate/NHibernate.Linq/Transform/LinqGroupingResultTransformer.cs @@ -98,7 +98,6 @@ namespace NHibernate.Linq.Transform /// internal class Grouping : IGrouping, IGrouping { - private readonly TKey key; private readonly IList list = new List(); /// @@ -107,7 +106,7 @@ namespace NHibernate.Linq.Transform /// public Grouping(TKey key) { - this.key = key; + this.Key = key; } #region IGrouping Members @@ -128,7 +127,7 @@ namespace NHibernate.Linq.Transform /// /// Gets the key of the . /// - public TKey Key => key; + public TKey Key { get; } /// /// Returns an enumerator that iterates through the collection. diff --git a/src/Libraries/NHibernate/NHibernate.Linq/Util/DetachedCriteriaAdapter.cs b/src/Libraries/NHibernate/NHibernate.Linq/Util/DetachedCriteriaAdapter.cs index d2d17c16f..b5f9a41bb 100644 --- a/src/Libraries/NHibernate/NHibernate.Linq/Util/DetachedCriteriaAdapter.cs +++ b/src/Libraries/NHibernate/NHibernate.Linq/Util/DetachedCriteriaAdapter.cs @@ -20,33 +20,30 @@ namespace NHibernate.Linq.Util public class DetachedCriteriaAdapter : ICriteria { - private readonly DetachedCriteria detachedCriteria; - private readonly ISession session; - public DetachedCriteriaAdapter(DetachedCriteria detachedCriteria, ISession session) { - this.detachedCriteria = detachedCriteria; - this.session = session; + this.DetachedCriteria = detachedCriteria; + this.Session = session; } - public DetachedCriteria DetachedCriteria => detachedCriteria; + public DetachedCriteria DetachedCriteria { get; } - public ISession Session => session; + public ISession Session { get; } #region ICriteria Members public IProjection Projection => null; public ICriteria Add(ICriterion expression) { - return detachedCriteria.Add(expression).Adapt(session); + return DetachedCriteria.Add(expression).Adapt(Session); } public ICriteria AddOrder(Order order) { - return detachedCriteria.AddOrder(order).Adapt(session); + return DetachedCriteria.AddOrder(order).Adapt(Session); } - public string Alias => detachedCriteria.Alias; + public string Alias => DetachedCriteria.Alias; public void ClearOrderds() { @@ -55,12 +52,12 @@ namespace NHibernate.Linq.Util public ICriteria CreateAlias(string associationPath, string alias, JoinType joinType) { - return detachedCriteria.CreateAlias(associationPath, alias, joinType).Adapt(session); + return DetachedCriteria.CreateAlias(associationPath, alias, joinType).Adapt(Session); } public ICriteria CreateAlias(string associationPath, string alias) { - return detachedCriteria.CreateAlias(associationPath, alias).Adapt(session); + return DetachedCriteria.CreateAlias(associationPath, alias).Adapt(Session); } public ICriteria CreateAlias(string associationPath, string alias, JoinType joinType, ICriterion withClause) @@ -70,17 +67,17 @@ namespace NHibernate.Linq.Util public ICriteria CreateCriteria(string associationPath, string alias, JoinType joinType) { - return detachedCriteria.CreateCriteria(associationPath, alias, joinType).Adapt(session); + return DetachedCriteria.CreateCriteria(associationPath, alias, joinType).Adapt(Session); } public ICriteria CreateCriteria(string associationPath, string alias) { - return detachedCriteria.CreateCriteria(associationPath, alias).Adapt(session); + return DetachedCriteria.CreateCriteria(associationPath, alias).Adapt(Session); } public ICriteria CreateCriteria(string associationPath, JoinType joinType) { - return detachedCriteria.CreateCriteria(associationPath, joinType).Adapt(session); + return DetachedCriteria.CreateCriteria(associationPath, joinType).Adapt(Session); } public ICriteria CreateCriteria(string associationPath, string alias, JoinType joinType, ICriterion withClause) @@ -90,17 +87,17 @@ namespace NHibernate.Linq.Util public ICriteria CreateCriteria(string associationPath) { - return detachedCriteria.CreateCriteria(associationPath).Adapt(session); + return DetachedCriteria.CreateCriteria(associationPath).Adapt(Session); } public ICriteria GetCriteriaByAlias(string alias) { - return detachedCriteria.GetCriteriaByAlias(alias).Adapt(session); + return DetachedCriteria.GetCriteriaByAlias(alias).Adapt(Session); } public ICriteria GetCriteriaByPath(string path) { - return detachedCriteria.GetCriteriaByPath(path).Adapt(session); + return DetachedCriteria.GetCriteriaByPath(path).Adapt(Session); } public IList List() @@ -120,7 +117,7 @@ namespace NHibernate.Linq.Util public ICriteria SetCacheMode(CacheMode cacheMode) { - return detachedCriteria.SetCacheMode(cacheMode).Adapt(session); + return DetachedCriteria.SetCacheMode(cacheMode).Adapt(Session); } public ICriteria SetCacheRegion(string cacheRegion) @@ -141,7 +138,7 @@ namespace NHibernate.Linq.Util [Obsolete("Use Fetch instead")] public ICriteria SetFetchMode(string associationPath, FetchMode mode) { - return detachedCriteria.SetFetchMode(associationPath, mode).Adapt(session); + return DetachedCriteria.SetFetchMode(associationPath, mode).Adapt(Session); } public ICriteria SetFetchSize(int fetchSize) @@ -151,7 +148,7 @@ namespace NHibernate.Linq.Util public ICriteria SetFirstResult(int firstResult) { - return detachedCriteria.SetFirstResult(firstResult).Adapt(session); + return DetachedCriteria.SetFirstResult(firstResult).Adapt(Session); } public ICriteria SetFlushMode(FlushMode flushMode) @@ -171,12 +168,12 @@ namespace NHibernate.Linq.Util public ICriteria SetMaxResults(int maxResults) { - return detachedCriteria.SetMaxResults(maxResults).Adapt(session); + return DetachedCriteria.SetMaxResults(maxResults).Adapt(Session); } public ICriteria SetProjection(IProjection projection) { - return detachedCriteria.SetProjection(projection).Adapt(session); + return DetachedCriteria.SetProjection(projection).Adapt(Session); } public ICriteria SetProjection(params IProjection[] projections) @@ -185,12 +182,12 @@ namespace NHibernate.Linq.Util foreach (var proj in projections) projectionList.Add(proj); - return detachedCriteria.SetProjection(projectionList).Adapt(session); + return DetachedCriteria.SetProjection(projectionList).Adapt(Session); } public ICriteria SetResultTransformer(IResultTransformer resultTransformer) { - return detachedCriteria.SetResultTransformer(resultTransformer).Adapt(session); + return DetachedCriteria.SetResultTransformer(resultTransformer).Adapt(Session); } public ICriteria SetTimeout(int timeout) @@ -210,12 +207,12 @@ namespace NHibernate.Linq.Util public System.Type GetRootEntityTypeIfAvailable() { - return detachedCriteria.GetRootEntityTypeIfAvailable(); + return DetachedCriteria.GetRootEntityTypeIfAvailable(); } public void ClearOrders() { - detachedCriteria.ClearOrders(); + DetachedCriteria.ClearOrders(); } public IEnumerable Future() @@ -269,17 +266,15 @@ namespace NHibernate.Linq.Util #endregion - private bool _readOnly; - private bool _readOnlyInitialized; - public bool IsReadOnly => _readOnly; + public bool IsReadOnly { get; private set; } - public bool IsReadOnlyInitialized => _readOnlyInitialized; + public bool IsReadOnlyInitialized { get; private set; } public ICriteria SetReadOnly(bool readOnly) { - _readOnly = readOnly; - _readOnlyInitialized = true; + IsReadOnly = readOnly; + IsReadOnlyInitialized = true; return this; } diff --git a/src/Libraries/NHibernate/NHibernate.Linq/Visitors/MemberNameVisitor.cs b/src/Libraries/NHibernate/NHibernate.Linq/Visitors/MemberNameVisitor.cs index d3dd36f96..f5ebd1604 100644 --- a/src/Libraries/NHibernate/NHibernate.Linq/Visitors/MemberNameVisitor.cs +++ b/src/Libraries/NHibernate/NHibernate.Linq/Visitors/MemberNameVisitor.cs @@ -16,8 +16,6 @@ namespace NHibernate.Linq.Visitors { private readonly ICriteria rootCriteria; private readonly bool createCriteriaForCollections; - private ICriteria currentCriteria; - private Expression currentExpression; private StringBuilder memberNameBuilder; private string currentAssociationPath; private bool isQueringEntity; @@ -33,16 +31,16 @@ namespace NHibernate.Linq.Visitors } } - public ICriteria CurrentCriteria => currentCriteria; + public ICriteria CurrentCriteria { get; private set; } - public Expression CurrentExpression => currentExpression; + public Expression CurrentExpression { get; private set; } public MemberNameVisitor(ICriteria criteria) : this(criteria, false) { } public MemberNameVisitor(ICriteria criteria, bool createCriteriaForCollections) { - this.rootCriteria = this.currentCriteria = criteria; + this.rootCriteria = this.CurrentCriteria = criteria; this.createCriteriaForCollections = createCriteriaForCollections; this.memberNameBuilder = new StringBuilder(); } @@ -56,9 +54,9 @@ namespace NHibernate.Linq.Visitors private ICriteria EnsureCriteria(string associationPath, string alias) { ICriteria criteria; - if ((criteria = currentCriteria.GetCriteriaByAlias(alias)) == null) + if ((criteria = CurrentCriteria.GetCriteriaByAlias(alias)) == null) { - criteria = currentCriteria.CreateCriteria(associationPath, alias, JoinType.LeftOuterJoin); + criteria = CurrentCriteria.CreateCriteria(associationPath, alias, JoinType.LeftOuterJoin); } return criteria; } @@ -80,15 +78,15 @@ namespace NHibernate.Linq.Visitors { expr = (EntityExpression)base.VisitEntity(expr); - if (currentCriteria.GetCriteriaByAlias(expr.Alias) != null || !IsRootEntity(expr)) + if (CurrentCriteria.GetCriteriaByAlias(expr.Alias) != null || !IsRootEntity(expr)) { if (!string.IsNullOrEmpty(expr.AssociationPath)) - currentCriteria = EnsureCriteria(expr.AssociationPath, expr.Alias); + CurrentCriteria = EnsureCriteria(expr.AssociationPath, expr.Alias); ResetMemberName(expr.Alias + "."); } currentAssociationPath = expr.AssociationPath; - currentExpression = expr; + CurrentExpression = expr; isQueringEntity = true; return expr; @@ -99,7 +97,7 @@ namespace NHibernate.Linq.Visitors expr = (PropertyAccessExpression)base.VisitPropertyAccess(expr); memberNameBuilder.Append(expr.Name + "."); - currentExpression = expr; + CurrentExpression = expr; isQueringEntity = false; return expr; @@ -110,13 +108,13 @@ namespace NHibernate.Linq.Visitors expr = (CollectionAccessExpression)base.VisitCollectionAccess(expr); //memberNameBuilder.Append(expr.Name + "."); ResetMemberName(expr.Name + "."); - currentExpression = expr; + CurrentExpression = expr; if (createCriteriaForCollections) { if (expr.ElementExpression != null) { - currentCriteria = EnsureCriteria(expr.Name, expr.ElementExpression.Alias); + CurrentCriteria = EnsureCriteria(expr.Name, expr.ElementExpression.Alias); } } diff --git a/src/Libraries/NHibernate/NHibernate.Linq/Visitors/SelectArgumentsVisitor.cs b/src/Libraries/NHibernate/NHibernate.Linq/Visitors/SelectArgumentsVisitor.cs index 52ad1658a..ea713d038 100644 --- a/src/Libraries/NHibernate/NHibernate.Linq/Visitors/SelectArgumentsVisitor.cs +++ b/src/Libraries/NHibernate/NHibernate.Linq/Visitors/SelectArgumentsVisitor.cs @@ -30,7 +30,6 @@ namespace NHibernate.Linq.Visitors private readonly ICriteria _rootCriteria; private readonly ISession _session; private readonly List _projections; - private IResultTransformer _transformer; private ICriteriaQuery _criteriaQuery; public IProjection Projection @@ -51,7 +50,7 @@ namespace NHibernate.Linq.Visitors } } - public IResultTransformer Transformer => _transformer; + public IResultTransformer Transformer { get; private set; } private ICriteriaQuery CriteriaQuery { @@ -153,7 +152,7 @@ namespace NHibernate.Linq.Visitors protected override NewExpression VisitNew(NewExpression expr) { NewExpression newExpr = base.VisitNew(expr); - _transformer = new TypeSafeConstructorMemberInitResultTransformer(expr); + Transformer = new TypeSafeConstructorMemberInitResultTransformer(expr); var aggregators = expr.Arguments.Where(arg => arg is MethodCallExpression && SupportsMethod(((MethodCallExpression)arg).Method.Name)); if (aggregators.Any()) @@ -174,7 +173,7 @@ namespace NHibernate.Linq.Visitors protected override Expression VisitMemberInit(MemberInitExpression expr) { Expression newExpr = base.VisitMemberInit(expr); - _transformer = new TypeSafeConstructorMemberInitResultTransformer(expr); + Transformer = new TypeSafeConstructorMemberInitResultTransformer(expr); return newExpr; } @@ -330,7 +329,7 @@ namespace NHibernate.Linq.Visitors { if (_rootCriteria.GetCriteriaByAlias(expr.Alias) != null) { - _transformer = new LinqJoinResultsTransformer(expr.Type); + Transformer = new LinqJoinResultsTransformer(expr.Type); } return expr; diff --git a/src/Orchard.Core.Tests/Common/Providers/CommonPartProviderTests.cs b/src/Orchard.Core.Tests/Common/Providers/CommonPartProviderTests.cs index 59038e7e7..47f85b107 100644 --- a/src/Orchard.Core.Tests/Common/Providers/CommonPartProviderTests.cs +++ b/src/Orchard.Core.Tests/Common/Providers/CommonPartProviderTests.cs @@ -193,10 +193,7 @@ namespace Orchard.Core.Tests.Common.Providers class UpdateModelStub : IUpdateModel { - - ModelStateDictionary _modelState = new ModelStateDictionary(); - - public ModelStateDictionary ModelErrors => _modelState; + public ModelStateDictionary ModelErrors { get; } = new ModelStateDictionary(); public string Owner { get; set; } @@ -208,7 +205,7 @@ namespace Orchard.Core.Tests.Common.Providers public void AddModelError(string key, LocalizedString errorMessage) { - _modelState.AddModelError(key, errorMessage.ToString()); + ModelErrors.AddModelError(key, errorMessage.ToString()); } } diff --git a/src/Orchard.Specs/Bindings/WebAppHosting.cs b/src/Orchard.Specs/Bindings/WebAppHosting.cs index d7b1a52c0..96af10251 100644 --- a/src/Orchard.Specs/Bindings/WebAppHosting.cs +++ b/src/Orchard.Specs/Bindings/WebAppHosting.cs @@ -19,21 +19,15 @@ namespace Orchard.Specs.Bindings [Binding] public class WebAppHosting { - private WebHost _webHost; - private RequestDetails _details; private HtmlDocument _doc; private MessageSink _messages; private static readonly Path _orchardTemp = Path.Get(System.IO.Path.GetTempPath()).Combine("Orchard.Specs"); private ExtensionDeploymentOptions _moduleDeploymentOptions = ExtensionDeploymentOptions.CompiledAssembly; private DynamicCompilationOption _dynamicCompilationOption = DynamicCompilationOption.Enabled; - public WebHost Host => _webHost; + public WebHost Host { get; private set; } - public RequestDetails Details - { - get { return _details; } - set { _details = value; } - } + public RequestDetails Details { get; set; } [BeforeTestRun] public static void BeforeTestRun() @@ -55,19 +49,19 @@ namespace Orchard.Specs.Bindings [BeforeScenario] public void CleanOutTheOldWebHost() { - if (_webHost != null) + if (Host != null) { - _webHost.Clean(); - _webHost = null; + Host.Clean(); + Host = null; } } [AfterScenario] public void AfterScenario() { - if (_webHost != null) + if (Host != null) { - _webHost.Dispose(); + Host.Dispose(); } } @@ -105,7 +99,7 @@ namespace Orchard.Specs.Bindings [Given(@"I have a clean site based on (.*) at ""(.*)""")] public void GivenIHaveACleanSiteBasedOn(string siteFolder, string virtualDirectory) { - _webHost = new WebHost(_orchardTemp); + Host = new WebHost(_orchardTemp); Host.Initialize(siteFolder, virtualDirectory ?? "/", _dynamicCompilationOption); var shuttle = new Shuttle(); Host.Execute(() => Executor(shuttle)); diff --git a/src/Orchard.Tests/Stubs/StubAppDataFolder.cs b/src/Orchard.Tests/Stubs/StubAppDataFolder.cs index 352fe4c5f..521fb6b1a 100644 --- a/src/Orchard.Tests/Stubs/StubAppDataFolder.cs +++ b/src/Orchard.Tests/Stubs/StubAppDataFolder.cs @@ -11,19 +11,18 @@ namespace Orchard.Tests.Stubs public class StubAppDataFolder : IAppDataFolder { private readonly IClock _clock; - private readonly StubFileSystem _fileSystem; public StubAppDataFolder(IClock clock) { _clock = clock; - _fileSystem = new StubFileSystem(_clock); + FileSystem = new StubFileSystem(_clock); } - public StubFileSystem FileSystem => _fileSystem; + public StubFileSystem FileSystem { get; } public IEnumerable ListFiles(string path) { - var entry = _fileSystem.GetDirectoryEntry(path); + var entry = FileSystem.GetDirectoryEntry(path); if (entry == null) throw new ArgumentException(); @@ -32,7 +31,7 @@ namespace Orchard.Tests.Stubs public IEnumerable ListDirectories(string path) { - var entry = _fileSystem.GetDirectoryEntry(path); + var entry = FileSystem.GetDirectoryEntry(path); if (entry == null) throw new ArgumentException(); @@ -41,7 +40,7 @@ namespace Orchard.Tests.Stubs public bool FileExists(string path) { - return _fileSystem.GetFileEntry(path) != null; + return FileSystem.GetFileEntry(path) != null; } public string Combine(params string[] paths) @@ -62,7 +61,7 @@ namespace Orchard.Tests.Stubs public Stream CreateFile(string path) { - return _fileSystem.CreateFile(path); + return FileSystem.CreateFile(path); } public string ReadFile(string path) @@ -78,14 +77,14 @@ namespace Orchard.Tests.Stubs public Stream OpenFile(string path) { - return _fileSystem.OpenFile(path); + return FileSystem.OpenFile(path); } public void StoreFile(string sourceFileName, string destinationPath) { using (var inputStream = File.OpenRead(sourceFileName)) { - using (var outputStream = _fileSystem.CreateFile(destinationPath)) + using (var outputStream = FileSystem.CreateFile(destinationPath)) { byte[] buffer = new byte[1024]; for (; ; ) @@ -101,12 +100,12 @@ namespace Orchard.Tests.Stubs public void DeleteFile(string path) { - _fileSystem.DeleteFile(path); + FileSystem.DeleteFile(path); } public DateTime GetFileLastWriteTimeUtc(string path) { - var entry = _fileSystem.GetFileEntry(path); + var entry = FileSystem.GetFileEntry(path); if (entry == null) throw new ArgumentException(); return entry.LastWriteTimeUtc; @@ -114,17 +113,17 @@ namespace Orchard.Tests.Stubs public void CreateDirectory(string path) { - _fileSystem.CreateDirectoryEntry(path); + FileSystem.CreateDirectoryEntry(path); } public bool DirectoryExists(string path) { - return _fileSystem.GetDirectoryEntry(path) != null; + return FileSystem.GetDirectoryEntry(path) != null; } public IVolatileToken WhenPathChanges(string path) { - return _fileSystem.WhenPathChanges(path); + return FileSystem.WhenPathChanges(path); } public string MapPath(string path) @@ -139,7 +138,7 @@ namespace Orchard.Tests.Stubs public DateTime GetLastWriteTimeUtc(string path) { - var entry = _fileSystem.GetFileEntry(path); + var entry = FileSystem.GetFileEntry(path); if (entry == null) throw new InvalidOperationException(); return entry.LastWriteTimeUtc; diff --git a/src/Orchard.Tests/Stubs/StubFileSystem.cs b/src/Orchard.Tests/Stubs/StubFileSystem.cs index fe245d397..a62bc7c61 100644 --- a/src/Orchard.Tests/Stubs/StubFileSystem.cs +++ b/src/Orchard.Tests/Stubs/StubFileSystem.cs @@ -98,20 +98,19 @@ namespace Orchard.Tests.Stubs { private readonly StubFileSystem _stubFileSystem; private readonly string _path; - private bool _isCurrent; public Token(StubFileSystem stubFileSystem, string path) { _stubFileSystem = stubFileSystem; _path = path; - _isCurrent = true; + IsCurrent = true; } - public bool IsCurrent => _isCurrent; + public bool IsCurrent { get; private set; } public void OnChange() { - _isCurrent = false; + IsCurrent = false; _stubFileSystem.DetachToken(_path); } } @@ -153,18 +152,17 @@ namespace Orchard.Tests.Stubs { private readonly T[] _buffer; private readonly int _offset; - private readonly int _count; public ArrayWrapper(T[] buffer, int offset, int count) { _buffer = buffer; _offset = offset; - _count = count; + Count = count; } public IEnumerator GetEnumerator() { - for (int i = _offset; i < _count; i++) + for (int i = _offset; i < Count; i++) yield return _buffer[i]; } @@ -190,7 +188,7 @@ namespace Orchard.Tests.Stubs public void CopyTo(T[] array, int arrayIndex) { - Array.Copy(_buffer, _offset, array, arrayIndex, _count); + Array.Copy(_buffer, _offset, array, arrayIndex, Count); } public bool Remove(T item) @@ -198,7 +196,7 @@ namespace Orchard.Tests.Stubs throw new NotImplementedException(); } - public int Count => _count; + public int Count { get; } public bool IsReadOnly => true; } @@ -234,17 +232,16 @@ namespace Orchard.Tests.Stubs public class FileEntryReadStream : Stream { - private readonly FileEntry _entry; private readonly IClock _clock; private int _position; public FileEntryReadStream(FileEntry entry, IClock clock) { - _entry = entry; + FileEntry = entry; _clock = clock; } - public FileEntry FileEntry => _entry; + public FileEntry FileEntry { get; } public override void Flush() { @@ -262,7 +259,7 @@ namespace Orchard.Tests.Stubs _position += (int)offset; break; case SeekOrigin.End: - _position = _entry.Content.Count - (int)offset; + _position = FileEntry.Content.Count - (int)offset; break; default: throw new ArgumentOutOfRangeException("origin"); @@ -277,10 +274,10 @@ namespace Orchard.Tests.Stubs public override int Read(byte[] buffer, int offset, int count) { - int remaingCount = _entry.Content.Count - _position; + int remaingCount = FileEntry.Content.Count - _position; count = Math.Min(count, remaingCount); - _entry.Content.CopyTo(_position, buffer, offset, count); + FileEntry.Content.CopyTo(_position, buffer, offset, count); _position += count; return count; @@ -297,7 +294,7 @@ namespace Orchard.Tests.Stubs public override bool CanWrite => false; - public override long Length => _entry.Content.Count; + public override long Length => FileEntry.Content.Count; public override long Position { diff --git a/src/Orchard.Tests/Stubs/StubVirtualPathProvider.cs b/src/Orchard.Tests/Stubs/StubVirtualPathProvider.cs index 621b2547f..92ca17f3e 100644 --- a/src/Orchard.Tests/Stubs/StubVirtualPathProvider.cs +++ b/src/Orchard.Tests/Stubs/StubVirtualPathProvider.cs @@ -8,14 +8,12 @@ namespace Orchard.Tests.Stubs { public class StubVirtualPathProvider : IVirtualPathProvider { - private readonly StubFileSystem _fileSystem; - public StubVirtualPathProvider(StubFileSystem fileSystem) { - _fileSystem = fileSystem; + FileSystem = fileSystem; } - public StubFileSystem FileSystem => _fileSystem; + public StubFileSystem FileSystem { get; } private string ToFileSystemPath(string path) { @@ -59,27 +57,27 @@ namespace Orchard.Tests.Stubs public bool FileExists(string virtualPath) { - return _fileSystem.GetFileEntry(ToFileSystemPath(virtualPath)) != null; + return FileSystem.GetFileEntry(ToFileSystemPath(virtualPath)) != null; } public Stream OpenFile(string virtualPath) { - return _fileSystem.OpenFile(ToFileSystemPath(virtualPath)); + return FileSystem.OpenFile(ToFileSystemPath(virtualPath)); } public StreamWriter CreateText(string virtualPath) { - return new StreamWriter(_fileSystem.CreateFile(ToFileSystemPath(virtualPath))); + return new StreamWriter(FileSystem.CreateFile(ToFileSystemPath(virtualPath))); } public Stream CreateFile(string virtualPath) { - return _fileSystem.CreateFile(ToFileSystemPath(virtualPath)); + return FileSystem.CreateFile(ToFileSystemPath(virtualPath)); } public DateTime GetFileLastWriteTimeUtc(string virtualPath) { - return _fileSystem.GetFileEntry(ToFileSystemPath(virtualPath)).LastWriteTimeUtc; + return FileSystem.GetFileEntry(ToFileSystemPath(virtualPath)).LastWriteTimeUtc; } public string GetFileHash(string virtualPath) @@ -94,17 +92,17 @@ namespace Orchard.Tests.Stubs public void DeleteFile(string virtualPath) { - _fileSystem.DeleteFile(ToFileSystemPath(virtualPath)); + FileSystem.DeleteFile(ToFileSystemPath(virtualPath)); } public bool DirectoryExists(string virtualPath) { - return _fileSystem.GetDirectoryEntry(ToFileSystemPath(virtualPath)) != null; + return FileSystem.GetDirectoryEntry(ToFileSystemPath(virtualPath)) != null; } public void CreateDirectory(string virtualPath) { - _fileSystem.CreateDirectoryEntry(ToFileSystemPath(virtualPath)); + FileSystem.CreateDirectoryEntry(ToFileSystemPath(virtualPath)); } public void DeleteDirectory(string virtualPath) @@ -119,14 +117,14 @@ namespace Orchard.Tests.Stubs public IEnumerable ListFiles(string path) { - return _fileSystem.GetDirectoryEntry(ToFileSystemPath(path)) + return FileSystem.GetDirectoryEntry(ToFileSystemPath(path)) .Files .Select(f => Combine(path, f.Name)); } public IEnumerable ListDirectories(string path) { - return _fileSystem.GetDirectoryEntry(ToFileSystemPath(path)) + return FileSystem.GetDirectoryEntry(ToFileSystemPath(path)) .Directories .Select(f => Combine(path, f.Name)); } diff --git a/src/Orchard.Web/Core/Common/Models/CommonPart.cs b/src/Orchard.Web/Core/Common/Models/CommonPart.cs index 4ffdcbf5d..f3d925b9c 100644 --- a/src/Orchard.Web/Core/Common/Models/CommonPart.cs +++ b/src/Orchard.Web/Core/Common/Models/CommonPart.cs @@ -8,23 +8,20 @@ namespace Orchard.Core.Common.Models { public class CommonPart : ContentPart, ICommonPart { - private readonly LazyField _owner = new LazyField(); - private readonly LazyField _container = new LazyField(); + public LazyField OwnerField { get; } = new LazyField(); - public LazyField OwnerField => _owner; - - public LazyField ContainerField => _container; + public LazyField ContainerField { get; } = new LazyField(); public IUser Owner { - get { return _owner.Value; } - set { _owner.Value = value; } + get { return OwnerField.Value; } + set { OwnerField.Value = value; } } public IContent Container { - get { return _container.Value; } - set { _container.Value = value; } + get { return ContainerField.Value; } + set { ContainerField.Value = value; } } public DateTime? CreatedUtc diff --git a/src/Orchard.Web/Core/Containers/Services/ListViewService.cs b/src/Orchard.Web/Core/Containers/Services/ListViewService.cs index 60a5bddfb..4cb6e02e9 100644 --- a/src/Orchard.Web/Core/Containers/Services/ListViewService.cs +++ b/src/Orchard.Web/Core/Containers/Services/ListViewService.cs @@ -15,14 +15,12 @@ namespace Orchard.Core.Containers.Services public class ListViewService : IListViewService { - private readonly IEnumerable _providers; - public ListViewService(IEnumerable providers) { - _providers = providers.OrderBy(x => x.Priority); + Providers = providers.OrderBy(x => x.Priority); } - public IEnumerable Providers => _providers; + public IEnumerable Providers { get; } public IListViewProvider GetProvider(string name) { diff --git a/src/Orchard.Web/Core/Navigation/Models/MenuPart.cs b/src/Orchard.Web/Core/Navigation/Models/MenuPart.cs index a2b6006a7..f84f8261f 100644 --- a/src/Orchard.Web/Core/Navigation/Models/MenuPart.cs +++ b/src/Orchard.Web/Core/Navigation/Models/MenuPart.cs @@ -6,14 +6,12 @@ namespace Orchard.Core.Navigation.Models { public class MenuPart : ContentPart { - - private readonly LazyField _menu = new LazyField(); - public LazyField MenuField => _menu; + public LazyField MenuField { get; } = new LazyField(); public IContent Menu { - get { return _menu.Value; } - set { _menu.Value = value; } + get { return MenuField.Value; } + set { MenuField.Value = value; } } [StringLength(MenuPartRecord.DefaultMenuTextLength)] diff --git a/src/Orchard.Web/Modules/Lucene/Models/LuceneSearchHit.cs b/src/Orchard.Web/Modules/Lucene/Models/LuceneSearchHit.cs index dd81046f3..ccbb0d5ee 100644 --- a/src/Orchard.Web/Modules/Lucene/Models/LuceneSearchHit.cs +++ b/src/Orchard.Web/Modules/Lucene/Models/LuceneSearchHit.cs @@ -7,14 +7,13 @@ namespace Lucene.Models public class LuceneSearchHit : ISearchHit { private readonly Document _doc; - private readonly float _score; - public float Score => _score; + public float Score { get; } public LuceneSearchHit(Document document, float score) { _doc = document; - _score = score; + Score = score; } public int ContentItemId => GetInt("id"); diff --git a/src/Orchard.Web/Modules/Lucene/Models/LuceneSettingsPart.cs b/src/Orchard.Web/Modules/Lucene/Models/LuceneSettingsPart.cs index 7e5acb901..7cff366bc 100644 --- a/src/Orchard.Web/Modules/Lucene/Models/LuceneSettingsPart.cs +++ b/src/Orchard.Web/Modules/Lucene/Models/LuceneSettingsPart.cs @@ -12,12 +12,11 @@ namespace Lucene.Models set { this.Store(x => x.LuceneAnalyzerSelectorMappingsSerialized, value); } } - private readonly LazyField> _luceneAnalyzerSelectorMappings = new LazyField>(); - internal LazyField> LuceneAnalyzerSelectorMappingsField => _luceneAnalyzerSelectorMappings; + internal LazyField> LuceneAnalyzerSelectorMappingsField { get; } = new LazyField>(); public IEnumerable LuceneAnalyzerSelectorMappings { - get { return _luceneAnalyzerSelectorMappings.Value; } - set { _luceneAnalyzerSelectorMappings.Value = value; } + get { return LuceneAnalyzerSelectorMappingsField.Value; } + set { LuceneAnalyzerSelectorMappingsField.Value = value; } } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ArchiveLater/Models/ArchiveLaterPart.cs b/src/Orchard.Web/Modules/Orchard.ArchiveLater/Models/ArchiveLaterPart.cs index 70ec7be6b..ac7850981 100644 --- a/src/Orchard.Web/Modules/Orchard.ArchiveLater/Models/ArchiveLaterPart.cs +++ b/src/Orchard.Web/Modules/Orchard.ArchiveLater/Models/ArchiveLaterPart.cs @@ -6,7 +6,6 @@ namespace Orchard.ArchiveLater.Models { public class ArchiveLaterPart : ContentPart { - private readonly LazyField _scheduledArchiveUtc = new LazyField(); - public LazyField ScheduledArchiveUtc => _scheduledArchiveUtc; + public LazyField ScheduledArchiveUtc { get; } = new LazyField(); } } diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Models/ArchiveData.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Models/ArchiveData.cs index 08ad26cf5..7b187e9a4 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Models/ArchiveData.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Models/ArchiveData.cs @@ -6,8 +6,6 @@ namespace Orchard.Blogs.Models { public class ArchiveData : IEquatable, IComparable { - private static readonly string _defaultString = DateTime.Now.Year.ToString(); - private static readonly Regex archiveDataRegex = new Regex(@"^(?\d{4})(?:/(?\d{1,2})?(?:/(?\d{1,2})?)?)?(?:/(?:page(?\d+))?)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); @@ -57,7 +55,7 @@ namespace Orchard.Blogs.Models public int Month { get; private set; } public int Day { get; private set; } - public static string DefaultString => _defaultString; + public static string DefaultString { get; } = DateTime.Now.Year.ToString(); #region IComparable Members diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentPart.cs b/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentPart.cs index 47f0833ff..5584c16ef 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentPart.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentPart.cs @@ -8,11 +8,8 @@ namespace Orchard.Comments.Models { public class CommentPart : ContentPart { - private readonly LazyField _commentedOnContentItem = new LazyField(); - private readonly LazyField _commentedOnContentItemMetadata = new LazyField(); - - public LazyField CommentedOnContentItemField => _commentedOnContentItem; - public LazyField CommentedOnContentItemMetadataField => _commentedOnContentItemMetadata; + public LazyField CommentedOnContentItemField { get; } = new LazyField(); + public LazyField CommentedOnContentItemMetadataField { get; } = new LazyField(); [StringLength(255)] public string Author @@ -82,14 +79,14 @@ namespace Orchard.Comments.Models public ContentItem CommentedOnContentItem { - get { return _commentedOnContentItem.Value; } - set { _commentedOnContentItem.Value = value; } + get { return CommentedOnContentItemField.Value; } + set { CommentedOnContentItemField.Value = value; } } public ContentItemMetadata CommentedOnContentItemMetadata { - get { return _commentedOnContentItemMetadata.Value; } - set { _commentedOnContentItemMetadata.Value = value; } + get { return CommentedOnContentItemMetadataField.Value; } + set { CommentedOnContentItemMetadataField.Value = value; } } public int CommentedOnContainer diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentsPart.cs b/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentsPart.cs index 6adc4fc67..78a4b1313 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentsPart.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentsPart.cs @@ -6,22 +6,19 @@ namespace Orchard.Comments.Models { public class CommentsPart : ContentPart { - private readonly LazyField> _comments = new LazyField>(); - private readonly LazyField> _pendingComments = new LazyField>(); - - public LazyField> CommentsField => _comments; - public LazyField> PendingCommentsField => _pendingComments; + public LazyField> CommentsField { get; } = new LazyField>(); + public LazyField> PendingCommentsField { get; } = new LazyField>(); public IList Comments { - get { return _comments.Value; } - set { _comments.Value = value; } + get { return CommentsField.Value; } + set { CommentsField.Value = value; } } public IList PendingComments { - get { return _pendingComments.Value; } - set { _pendingComments.Value = value; } + get { return PendingCommentsField.Value; } + set { PendingCommentsField.Value = value; } } public bool CommentsShown diff --git a/src/Orchard.Web/Modules/Orchard.Email/Models/SmtpSettingsPart.cs b/src/Orchard.Web/Modules/Orchard.Email/Models/SmtpSettingsPart.cs index 3368047c1..598346d25 100644 --- a/src/Orchard.Web/Modules/Orchard.Email/Models/SmtpSettingsPart.cs +++ b/src/Orchard.Web/Modules/Orchard.Email/Models/SmtpSettingsPart.cs @@ -8,9 +8,7 @@ namespace Orchard.Email.Models { public class SmtpSettingsPart : ContentPart { - private readonly ComputedField _password = new ComputedField(); - - public ComputedField PasswordField => _password; + public ComputedField PasswordField { get; } = new ComputedField(); public string FromAddress { @@ -29,10 +27,8 @@ namespace Orchard.Email.Models get => this.Retrieve(x => x.ReplyTo); set => this.Store(x => x.ReplyTo, value); } - - private readonly LazyField _addressPlaceholder = new LazyField(); - internal LazyField AddressPlaceholderField => _addressPlaceholder; - public string AddressPlaceholder => _addressPlaceholder.Value; + internal LazyField AddressPlaceholderField { get; } = new LazyField(); + public string AddressPlaceholder => AddressPlaceholderField.Value; public string Host { @@ -81,8 +77,8 @@ namespace Orchard.Email.Models public string Password { - get => _password.Value; - set => _password.Value = value; + get => PasswordField.Value; + set => PasswordField.Value = value; } // Hotmail only supports the mailto:link. When a user clicks on the 'unsubscribe' option in Hotmail. diff --git a/src/Orchard.Web/Modules/Orchard.Localization/Models/LocalizationPart.cs b/src/Orchard.Web/Modules/Orchard.Localization/Models/LocalizationPart.cs index fdc6929f5..356933796 100644 --- a/src/Orchard.Web/Modules/Orchard.Localization/Models/LocalizationPart.cs +++ b/src/Orchard.Web/Modules/Orchard.Localization/Models/LocalizationPart.cs @@ -7,22 +7,19 @@ namespace Orchard.Localization.Models { public sealed class LocalizationPart : ContentPart, ILocalizableAspect { - private readonly LazyField _culture = new LazyField(); - private readonly LazyField _masterContentItem = new LazyField(); - - public LazyField CultureField => _culture; - public LazyField MasterContentItemField => _masterContentItem; + public LazyField CultureField { get; } = new LazyField(); + public LazyField MasterContentItemField { get; } = new LazyField(); public CultureRecord Culture { - get { return _culture.Value; } - set { _culture.Value = value; } + get { return CultureField.Value; } + set { CultureField.Value = value; } } public IContent MasterContentItem { - get { return _masterContentItem.Value; } - set { _masterContentItem.Value = value; } + get { return MasterContentItemField.Value; } + set { MasterContentItemField.Value = value; } } public bool HasTranslationGroup => Record.MasterContentItemId != 0; diff --git a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Models/MediaFolder.cs b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Models/MediaFolder.cs index 5d0d9ee3f..1c1d8bda5 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Models/MediaFolder.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Models/MediaFolder.cs @@ -8,14 +8,8 @@ namespace Orchard.MediaLibrary.Models public string MediaPath { get; set; } public string User { get; set; } public DateTime LastUpdated { get; set; } + internal Lazy SizeField { get; set; } - private Lazy _size; - internal Lazy SizeField - { - get { return _size; } - set { _size = value; } - } - - public long Size => _size.Value; + public long Size => SizeField.Value; } } diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Services/FileBaseProjectSystem.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Services/FileBaseProjectSystem.cs index 21731a92e..e276f77b5 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Services/FileBaseProjectSystem.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Services/FileBaseProjectSystem.cs @@ -11,7 +11,6 @@ namespace Orchard.Packaging.Services { private const string NetFrameworkIdentifier = ".NETFramework"; private const string BinDir = "bin"; - private readonly string _root; private DateTime? _writeTimeUtcForAddedFiles; public FileBasedProjectSystem(string root) @@ -20,10 +19,10 @@ namespace Orchard.Packaging.Services { throw new ArgumentException("root"); } - _root = root; + Root = root; } - public string Root => _root; + public string Root { get; } public virtual string ProjectName => Root; diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageBuilder.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageBuilder.cs index ecfde0d8c..740495d1b 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageBuilder.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Services/PackageBuilder.cs @@ -243,16 +243,15 @@ namespace Orchard.Packaging.Services { private readonly IWebSiteFolder _webSiteFolder; private readonly string _virtualPath; - private readonly string _packagePath; public VirtualPackageFile(IWebSiteFolder webSiteFolder, string virtualPath, string packagePath) { _webSiteFolder = webSiteFolder; _virtualPath = virtualPath; - _packagePath = packagePath; + Path = packagePath; } - public string Path => _packagePath; + public string Path { get; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Supposed to return an open stream.")] public Stream GetStream() diff --git a/src/Orchard.Web/Modules/Orchard.PublishLater/Models/PublishLaterPart.cs b/src/Orchard.Web/Modules/Orchard.PublishLater/Models/PublishLaterPart.cs index 68101985d..3c60f8f03 100644 --- a/src/Orchard.Web/Modules/Orchard.PublishLater/Models/PublishLaterPart.cs +++ b/src/Orchard.Web/Modules/Orchard.PublishLater/Models/PublishLaterPart.cs @@ -7,7 +7,6 @@ namespace Orchard.PublishLater.Models { public class PublishLaterPart : ContentPart, IPublishingControlAspect { - private readonly LazyField _scheduledPublishUtc = new LazyField(); - public LazyField ScheduledPublishUtc => _scheduledPublishUtc; + public LazyField ScheduledPublishUtc { get; } = new LazyField(); } } diff --git a/src/Orchard.Web/Modules/Orchard.Recipes/Providers/Executors/CommandStep.cs b/src/Orchard.Web/Modules/Orchard.Recipes/Providers/Executors/CommandStep.cs index 5a7bcbda4..79bde84cb 100644 --- a/src/Orchard.Web/Modules/Orchard.Recipes/Providers/Executors/CommandStep.cs +++ b/src/Orchard.Web/Modules/Orchard.Recipes/Providers/Executors/CommandStep.cs @@ -106,18 +106,17 @@ namespace Orchard.Recipes.Providers.Executors class State { private readonly string _commandLine; - private readonly StringBuilder _stringBuilder; private readonly List _arguments; private int _index; public State(string commandLine) { _commandLine = commandLine; - _stringBuilder = new StringBuilder(); + StringBuilder = new StringBuilder(); _arguments = new List(); } - public StringBuilder StringBuilder => _stringBuilder; + public StringBuilder StringBuilder { get; } public bool EOF => _index >= _commandLine.Length; public char Current => _commandLine[_index]; public IEnumerable Arguments => _arguments; diff --git a/src/Orchard.Web/Modules/Orchard.Scripting/Ast/BinaryAstNode.cs b/src/Orchard.Web/Modules/Orchard.Scripting/Ast/BinaryAstNode.cs index 50776d7ea..2d30b18cc 100644 --- a/src/Orchard.Web/Modules/Orchard.Scripting/Ast/BinaryAstNode.cs +++ b/src/Orchard.Web/Modules/Orchard.Scripting/Ast/BinaryAstNode.cs @@ -5,30 +5,26 @@ namespace Orchard.Scripting.Ast { public class BinaryAstNode : AstNode, IAstNodeWithToken { - private readonly AstNode _left; - private readonly Token _token; - private readonly AstNode _right; - public BinaryAstNode(AstNode left, Token token, AstNode right) { - _left = left; - _token = token; - _right = right; + Left = left; + Operator = token; + Right = right; } - public Token Token => _token; + public Token Token => Operator; - public Token Operator => _token; + public Token Operator { get; } public override object Accept(AstVisitor visitor) { return visitor.VisitBinary(this); } - public override IEnumerable Children => new List(2) { _left, _right }; + public override IEnumerable Children => new List(2) { Left, Right }; - public AstNode Left => _left; + public AstNode Left { get; } - public AstNode Right => _right; + public AstNode Right { get; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Scripting/Ast/ConstantAstNode.cs b/src/Orchard.Web/Modules/Orchard.Scripting/Ast/ConstantAstNode.cs index 58ddc9a49..3c3693625 100644 --- a/src/Orchard.Web/Modules/Orchard.Scripting/Ast/ConstantAstNode.cs +++ b/src/Orchard.Web/Modules/Orchard.Scripting/Ast/ConstantAstNode.cs @@ -4,16 +4,14 @@ namespace Orchard.Scripting.Ast { public class ConstantAstNode : AstNode, IAstNodeWithToken { - private readonly Token _token; - public ConstantAstNode(Token token) { - _token = token; + Token = token; } - public Token Token => _token; + public Token Token { get; } - public object Value => _token.Value; + public object Value => Token.Value; public override object Accept(AstVisitor visitor) { diff --git a/src/Orchard.Web/Modules/Orchard.Scripting/Ast/ErrorAstNode.cs b/src/Orchard.Web/Modules/Orchard.Scripting/Ast/ErrorAstNode.cs index 032124ceb..924e1dfca 100644 --- a/src/Orchard.Web/Modules/Orchard.Scripting/Ast/ErrorAstNode.cs +++ b/src/Orchard.Web/Modules/Orchard.Scripting/Ast/ErrorAstNode.cs @@ -4,18 +4,15 @@ namespace Orchard.Scripting.Ast { public class ErrorAstNode : AstNode, IAstNodeWithToken { - private readonly Token _token; - private readonly string _message; - public ErrorAstNode(Token token, string message) { - _token = token; - _message = message; + Token = token; + Message = message; } - public Token Token => _token; + public Token Token { get; } - public string Message => _message; + public string Message { get; } public override string ToString() { diff --git a/src/Orchard.Web/Modules/Orchard.Scripting/Ast/MethodCallAstNode.cs b/src/Orchard.Web/Modules/Orchard.Scripting/Ast/MethodCallAstNode.cs index 7b9ff31ae..bd9e0847f 100644 --- a/src/Orchard.Web/Modules/Orchard.Scripting/Ast/MethodCallAstNode.cs +++ b/src/Orchard.Web/Modules/Orchard.Scripting/Ast/MethodCallAstNode.cs @@ -5,21 +5,18 @@ namespace Orchard.Scripting.Ast { public class MethodCallAstNode : AstNode, IAstNodeWithToken { - private readonly Token _token; - private readonly IList _arguments; - public MethodCallAstNode(Token token, IList arguments) { - _token = token; - _arguments = arguments; + Token = token; + Arguments = arguments; } - public Token Target => _token; - public IList Arguments => _arguments; + public Token Target => Token; + public IList Arguments { get; } - public Token Token => _token; + public Token Token { get; } - public override IEnumerable Children => _arguments; + public override IEnumerable Children => Arguments; public override object Accept(AstVisitor visitor) { diff --git a/src/Orchard.Web/Modules/Orchard.Scripting/Ast/UnaryAstNode.cs b/src/Orchard.Web/Modules/Orchard.Scripting/Ast/UnaryAstNode.cs index 0ff73f2e5..d5979171f 100644 --- a/src/Orchard.Web/Modules/Orchard.Scripting/Ast/UnaryAstNode.cs +++ b/src/Orchard.Web/Modules/Orchard.Scripting/Ast/UnaryAstNode.cs @@ -5,20 +5,17 @@ namespace Orchard.Scripting.Ast { public class UnaryAstNode : AstNode, IAstNodeWithToken { - private readonly AstNode _operand; - private readonly Token _token; - public UnaryAstNode(Token token, AstNode operand) { - _operand = operand; - _token = token; + Operand = operand; + Operator = token; } - public Token Token => _token; - public Token Operator => _token; - public AstNode Operand => _operand; + public Token Token => Operator; + public Token Operator { get; } + public AstNode Operand { get; } - public override IEnumerable Children => new List(1) { _operand }; + public override IEnumerable Children => new List(1) { Operand }; public override object Accept(AstVisitor visitor) { diff --git a/src/Orchard.Web/Modules/Orchard.Scripting/Compiler/EvaluationResult.cs b/src/Orchard.Web/Modules/Orchard.Scripting/Compiler/EvaluationResult.cs index 94eb51011..4448bfc80 100644 --- a/src/Orchard.Web/Modules/Orchard.Scripting/Compiler/EvaluationResult.cs +++ b/src/Orchard.Web/Modules/Orchard.Scripting/Compiler/EvaluationResult.cs @@ -4,11 +4,9 @@ namespace Orchard.Scripting.Compiler { public class EvaluationResult { - private readonly object _value; - public EvaluationResult(object value) { - _value = value; + Value = value; } public static EvaluationResult Result(object value) @@ -23,7 +21,7 @@ namespace Orchard.Scripting.Compiler return new EvaluationResult(new Error { Message = message }); } - public object Value => _value; + public object Value { get; } public bool IsError => Value is Error; public bool IsNil => IsNull; diff --git a/src/Orchard.Web/Modules/Orchard.Scripting/Compiler/Lexer.cs b/src/Orchard.Web/Modules/Orchard.Scripting/Compiler/Lexer.cs index d8f96741c..4e9a3fa6d 100644 --- a/src/Orchard.Web/Modules/Orchard.Scripting/Compiler/Lexer.cs +++ b/src/Orchard.Web/Modules/Orchard.Scripting/Compiler/Lexer.cs @@ -39,14 +39,12 @@ namespace Orchard.Scripting.Compiler public struct Marker { - private readonly int _tokenIndex; - public Marker(int tokenIndex) { - _tokenIndex = tokenIndex; + TokenIndex = tokenIndex; } - public int TokenIndex => _tokenIndex; + public int TokenIndex { get; } } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Users/Services/UsernameValidationError.cs b/src/Orchard.Web/Modules/Orchard.Users/Services/UsernameValidationError.cs index 7ad19b39b..c2f870fc2 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Services/UsernameValidationError.cs +++ b/src/Orchard.Web/Modules/Orchard.Users/Services/UsernameValidationError.cs @@ -11,11 +11,6 @@ namespace Orchard.Users.Services public class UsernameValidationError { - - private Severity _severity; - private string _key; - private LocalizedString _errorMessage; - public UsernameValidationError(Severity severity, string key, LocalizedString errorMessage) { Severity = severity; @@ -23,9 +18,9 @@ namespace Orchard.Users.Services ErrorMessage = errorMessage; } - public Severity Severity { get => _severity; set => _severity = value; } - public string Key { get => _key; set => _key = value; } - public LocalizedString ErrorMessage { get => _errorMessage; set => _errorMessage = value; } + public Severity Severity { get; set; } + public string Key { get; set; } + public LocalizedString ErrorMessage { get; set; } diff --git a/src/Orchard/Caching/AcquireContext.cs b/src/Orchard/Caching/AcquireContext.cs index bd4d98c9b..8d92da69d 100644 --- a/src/Orchard/Caching/AcquireContext.cs +++ b/src/Orchard/Caching/AcquireContext.cs @@ -24,13 +24,11 @@ namespace Orchard.Caching /// public class SimpleAcquireContext : IAcquireContext { - private readonly Action _monitor; - public SimpleAcquireContext(Action monitor) { - _monitor = monitor; + Monitor = monitor; } - public Action Monitor => _monitor; + public Action Monitor { get; } } } diff --git a/src/Orchard/Caching/DefaultCacheContextAccessor.cs b/src/Orchard/Caching/DefaultCacheContextAccessor.cs index 6383774dc..09cdeaf58 100644 --- a/src/Orchard/Caching/DefaultCacheContextAccessor.cs +++ b/src/Orchard/Caching/DefaultCacheContextAccessor.cs @@ -4,14 +4,8 @@ namespace Orchard.Caching { public class DefaultCacheContextAccessor : ICacheContextAccessor { - [ThreadStatic] - private static IAcquireContext _threadInstance; - - public static IAcquireContext ThreadInstance - { - get { return _threadInstance; } - set { _threadInstance = value; } - } + [field: ThreadStatic] + public static IAcquireContext ThreadInstance { get; set; } public IAcquireContext Current { diff --git a/src/Orchard/Commands/CommandNameAttribute.cs b/src/Orchard/Commands/CommandNameAttribute.cs index ebff0d789..97c5ce0dc 100644 --- a/src/Orchard/Commands/CommandNameAttribute.cs +++ b/src/Orchard/Commands/CommandNameAttribute.cs @@ -5,14 +5,12 @@ namespace Orchard.Commands [AttributeUsage(AttributeTargets.Method)] public class CommandNameAttribute : Attribute { - private readonly string _commandAlias; - public CommandNameAttribute(string commandAlias) { - _commandAlias = commandAlias; + Command = commandAlias; } - public string Command => _commandAlias; + public string Command { get; } } [AttributeUsage(AttributeTargets.Method)] diff --git a/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs b/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs index 7b18f0bfa..0d13f38b1 100644 --- a/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs +++ b/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs @@ -9,7 +9,6 @@ namespace Orchard.ContentManagement.MetaData.Builders public class ContentPartDefinitionBuilder { private readonly ContentPartDefinition _part; - private string _name; private readonly IList _fields; private readonly SettingsDictionary _settings; @@ -31,22 +30,22 @@ namespace Orchard.ContentManagement.MetaData.Builders } else { - _name = existing.Name; + Name = existing.Name; _fields = existing.Fields.ToList(); _settings = new SettingsDictionary(existing.Settings.ToDictionary(kv => kv.Key, kv => kv.Value)); } } - public string Name => _name; + public string Name { get; private set; } public ContentPartDefinition Build() { - return new ContentPartDefinition(_name, _fields, _settings); + return new ContentPartDefinition(Name, _fields, _settings); } public ContentPartDefinitionBuilder Named(string name) { - _name = name; + Name = name; return this; } diff --git a/src/Orchard/ContentManagement/QueryHints.cs b/src/Orchard/ContentManagement/QueryHints.cs index 57746ded8..29ac77029 100644 --- a/src/Orchard/ContentManagement/QueryHints.cs +++ b/src/Orchard/ContentManagement/QueryHints.cs @@ -8,11 +8,10 @@ namespace Orchard.ContentManagement public class QueryHints { private readonly List _records = new List(); - private static readonly QueryHints _empty = new QueryHints(); public IEnumerable Records => _records; - public static QueryHints Empty => _empty; + public static QueryHints Empty { get; } = new QueryHints(); public QueryHints ExpandRecords(IEnumerable records) { diff --git a/src/Orchard/Data/MapAsRecordAttribute.cs b/src/Orchard/Data/MapAsRecordAttribute.cs index aa6904c3c..9484e403f 100644 --- a/src/Orchard/Data/MapAsRecordAttribute.cs +++ b/src/Orchard/Data/MapAsRecordAttribute.cs @@ -7,15 +7,13 @@ namespace Orchard.Data /// public class MapAsRecordAttribute : Attribute { - private readonly bool _enabled; - public MapAsRecordAttribute() : this(true) { } public MapAsRecordAttribute(bool enabled) { - _enabled = enabled; + Enabled = enabled; } - public bool Enabled => _enabled; + public bool Enabled { get; } } } \ No newline at end of file diff --git a/src/Orchard/Data/Migration/Schema/SchemaBuilder.cs b/src/Orchard/Data/Migration/Schema/SchemaBuilder.cs index bca989990..76a1a321a 100644 --- a/src/Orchard/Data/Migration/Schema/SchemaBuilder.cs +++ b/src/Orchard/Data/Migration/Schema/SchemaBuilder.cs @@ -7,32 +7,28 @@ namespace Orchard.Data.Migration.Schema { public class SchemaBuilder { - private readonly IDataMigrationInterpreter _interpreter; - private readonly string _featurePrefix; - private readonly Func _formatPrefix; - public Localizer T { get; set; } public SchemaBuilder(IDataMigrationInterpreter interpreter, string featurePrefix = null, Func formatPrefix = null) { - _interpreter = interpreter; - _featurePrefix = featurePrefix ?? string.Empty; - _formatPrefix = formatPrefix ?? (s => s ?? string.Empty); + Interpreter = interpreter; + FeaturePrefix = featurePrefix ?? string.Empty; + FormatPrefix = formatPrefix ?? (s => s ?? string.Empty); T = NullLocalizer.Instance; } - public IDataMigrationInterpreter Interpreter => _interpreter; + public IDataMigrationInterpreter Interpreter { get; } - public string FeaturePrefix => _featurePrefix; + public string FeaturePrefix { get; } - public Func FormatPrefix => _formatPrefix; + public Func FormatPrefix { get; } /// /// Translate Table name into database table name - including prefixes. /// public virtual string TableDbName(string srcTable, string featurePrefixOverride = null) { - return _interpreter.PrefixTableName(FormatPrefix(featurePrefixOverride ?? FeaturePrefix) + srcTable); + return Interpreter.PrefixTableName(FormatPrefix(featurePrefixOverride ?? FeaturePrefix) + srcTable); } /// @@ -40,12 +36,12 @@ namespace Orchard.Data.Migration.Schema /// public virtual string RemoveDataTablePrefix(string prefixedTableName) { - return _interpreter.RemovePrefixFromTableName(prefixedTableName); + return Interpreter.RemovePrefixFromTableName(prefixedTableName); } public SchemaBuilder CreateTable(string name, Action table) { - var createTable = new CreateTableCommand(string.Concat(_formatPrefix(_featurePrefix), name)); + var createTable = new CreateTableCommand(string.Concat(FormatPrefix(FeaturePrefix), name)); table(createTable); Run(createTable); return this; @@ -53,7 +49,7 @@ namespace Orchard.Data.Migration.Schema public SchemaBuilder AlterTable(string name, Action table) { - var alterTable = new AlterTableCommand(string.Concat(_formatPrefix(_featurePrefix), name)); + var alterTable = new AlterTableCommand(string.Concat(FormatPrefix(FeaturePrefix), name)); table(alterTable); Run(alterTable); return this; @@ -61,7 +57,7 @@ namespace Orchard.Data.Migration.Schema public SchemaBuilder DropTable(string name) { - var deleteTable = new DropTableCommand(string.Concat(_formatPrefix(_featurePrefix), name)); + var deleteTable = new DropTableCommand(string.Concat(FormatPrefix(FeaturePrefix), name)); Run(deleteTable); return this; } @@ -90,47 +86,47 @@ namespace Orchard.Data.Migration.Schema private void Run(ISchemaBuilderCommand command) { - _interpreter.Visit(command); + Interpreter.Visit(command); } public SchemaBuilder CreateForeignKey(string name, string srcTable, string[] srcColumns, string destTable, string[] destColumns) { - var command = new CreateForeignKeyCommand(name, string.Concat(_formatPrefix(_featurePrefix), srcTable), srcColumns, string.Concat(_formatPrefix(_featurePrefix), destTable), destColumns); + var command = new CreateForeignKeyCommand(name, string.Concat(FormatPrefix(FeaturePrefix), srcTable), srcColumns, string.Concat(FormatPrefix(FeaturePrefix), destTable), destColumns); Run(command); return this; } public SchemaBuilder CreateForeignKey(string name, string srcModule, string srcTable, string[] srcColumns, string destTable, string[] destColumns) { - var command = new CreateForeignKeyCommand(name, string.Concat(_formatPrefix(srcModule), srcTable), srcColumns, string.Concat(_formatPrefix(_featurePrefix), destTable), destColumns); + var command = new CreateForeignKeyCommand(name, string.Concat(FormatPrefix(srcModule), srcTable), srcColumns, string.Concat(FormatPrefix(FeaturePrefix), destTable), destColumns); Run(command); return this; } public SchemaBuilder CreateForeignKey(string name, string srcTable, string[] srcColumns, string destModule, string destTable, string[] destColumns) { - var command = new CreateForeignKeyCommand(name, string.Concat(_formatPrefix(_featurePrefix), srcTable), srcColumns, string.Concat(_formatPrefix(destModule), destTable), destColumns); + var command = new CreateForeignKeyCommand(name, string.Concat(FormatPrefix(FeaturePrefix), srcTable), srcColumns, string.Concat(FormatPrefix(destModule), destTable), destColumns); Run(command); return this; } public SchemaBuilder CreateForeignKey(string name, string srcModule, string srcTable, string[] srcColumns, string destModule, string destTable, string[] destColumns) { - var command = new CreateForeignKeyCommand(name, string.Concat(_formatPrefix(srcModule), srcTable), srcColumns, string.Concat(_formatPrefix(destModule), destTable), destColumns); + var command = new CreateForeignKeyCommand(name, string.Concat(FormatPrefix(srcModule), srcTable), srcColumns, string.Concat(FormatPrefix(destModule), destTable), destColumns); Run(command); return this; } public SchemaBuilder DropForeignKey(string srcTable, string name) { - var command = new DropForeignKeyCommand(string.Concat(_formatPrefix(_featurePrefix), srcTable), name); + var command = new DropForeignKeyCommand(string.Concat(FormatPrefix(FeaturePrefix), srcTable), name); Run(command); return this; } public SchemaBuilder DropForeignKey(string srcModule, string srcTable, string name) { - var command = new DropForeignKeyCommand(string.Concat(_formatPrefix(srcModule), srcTable), name); + var command = new DropForeignKeyCommand(string.Concat(FormatPrefix(srcModule), srcTable), name); Run(command); return this; } diff --git a/src/Orchard/Data/Orderable.cs b/src/Orchard/Data/Orderable.cs index ecdfa170f..1600a71f9 100644 --- a/src/Orchard/Data/Orderable.cs +++ b/src/Orchard/Data/Orderable.cs @@ -6,18 +6,16 @@ namespace Orchard.Data { public class Orderable { - private IQueryable _queryable; - public Orderable(IQueryable enumerable) { - _queryable = enumerable; + Queryable = enumerable; } - public IQueryable Queryable => _queryable; + public IQueryable Queryable { get; private set; } public Orderable Asc(Expression> keySelector) { - _queryable = _queryable + Queryable = Queryable .OrderBy(keySelector); return this; } @@ -25,7 +23,7 @@ namespace Orchard.Data public Orderable Asc(Expression> keySelector1, Expression> keySelector2) { - _queryable = _queryable + Queryable = Queryable .OrderBy(keySelector1) .OrderBy(keySelector2); return this; @@ -35,7 +33,7 @@ namespace Orchard.Data Expression> keySelector2, Expression> keySelector3) { - _queryable = _queryable + Queryable = Queryable .OrderBy(keySelector1) .OrderBy(keySelector2) .OrderBy(keySelector3); @@ -44,7 +42,7 @@ namespace Orchard.Data public Orderable Desc(Expression> keySelector) { - _queryable = _queryable + Queryable = Queryable .OrderByDescending(keySelector); return this; } @@ -52,7 +50,7 @@ namespace Orchard.Data public Orderable Desc(Expression> keySelector1, Expression> keySelector2) { - _queryable = _queryable + Queryable = Queryable .OrderByDescending(keySelector1) .OrderByDescending(keySelector2); return this; @@ -62,7 +60,7 @@ namespace Orchard.Data Expression> keySelector2, Expression> keySelector3) { - _queryable = _queryable + Queryable = Queryable .OrderByDescending(keySelector1) .OrderByDescending(keySelector2) .OrderByDescending(keySelector3); diff --git a/src/Orchard/DisplayManagement/Shapes/Composite.cs b/src/Orchard/DisplayManagement/Shapes/Composite.cs index 0e03b8ff6..bab47d562 100644 --- a/src/Orchard/DisplayManagement/Shapes/Composite.cs +++ b/src/Orchard/DisplayManagement/Shapes/Composite.cs @@ -15,9 +15,6 @@ namespace Orchard.DisplayManagement.Shapes { public class Composite : DynamicObject { - - private readonly IDictionary _props = new HybridDictionary(); - public override bool TryGetMember(GetMemberBinder binder, out object result) { return TryGetMemberImpl(binder.Name, out result); @@ -25,9 +22,9 @@ namespace Orchard.DisplayManagement.Shapes protected virtual bool TryGetMemberImpl(string name, out object result) { - if (_props.Contains(name)) + if (Properties.Contains(name)) { - result = _props[name]; + result = Properties[name]; return true; } @@ -42,7 +39,7 @@ namespace Orchard.DisplayManagement.Shapes protected bool TrySetMemberImpl(string name, object value) { - _props[name] = value; + Properties[name] = value; return true; } @@ -83,9 +80,9 @@ namespace Orchard.DisplayManagement.Shapes var index = indexes.Single(); - if (_props.Contains(index)) + if (Properties.Contains(index)) { - result = _props[index]; + result = Properties[index]; return true; } @@ -117,11 +114,11 @@ namespace Orchard.DisplayManagement.Shapes return true; } - _props[indexes.Single()] = value; + Properties[indexes.Single()] = value; return true; } - public IDictionary Properties => _props; + public IDictionary Properties { get; } = new HybridDictionary(); public static bool operator ==(Composite a, Nil b) => null == a; @@ -129,7 +126,7 @@ namespace Orchard.DisplayManagement.Shapes protected bool Equals(Composite other) { - return Equals(_props, other._props); + return Equals(Properties, other.Properties); } public override bool Equals(object obj) @@ -151,7 +148,7 @@ namespace Orchard.DisplayManagement.Shapes public override int GetHashCode() { - return (_props != null ? _props.GetHashCode() : 0); + return (Properties != null ? Properties.GetHashCode() : 0); } #region InterfaceProxyBehavior @@ -459,8 +456,7 @@ namespace Orchard.DisplayManagement.Shapes public class Nil : DynamicObject { - static readonly Nil Singleton = new Nil(); - public static Nil Instance => Singleton; + public static Nil Instance { get; } = new Nil(); private Nil() { diff --git a/src/Orchard/Environment/DefaultOrchardShell.cs b/src/Orchard/Environment/DefaultOrchardShell.cs index 3c5a482e4..bb4f0977d 100644 --- a/src/Orchard/Environment/DefaultOrchardShell.cs +++ b/src/Orchard/Environment/DefaultOrchardShell.cs @@ -24,7 +24,6 @@ namespace Orchard.Environment private readonly IRoutePublisher _routePublisher; private readonly IEnumerable _modelBinderProviders; private readonly IModelBinderPublisher _modelBinderPublisher; - private readonly ISweepGenerator _sweepGenerator; private readonly IEnumerable _owinMiddlewareProviders; private readonly ShellSettings _shellSettings; @@ -45,7 +44,7 @@ namespace Orchard.Environment _routePublisher = routePublisher; _modelBinderProviders = modelBinderProviders; _modelBinderPublisher = modelBinderPublisher; - _sweepGenerator = sweepGenerator; + Sweep = sweepGenerator; _owinMiddlewareProviders = owinMiddlewareProviders; _shellSettings = shellSettings; @@ -53,7 +52,7 @@ namespace Orchard.Environment } public ILogger Logger { get; set; } - public ISweepGenerator Sweep => _sweepGenerator; + public ISweepGenerator Sweep { get; } public void Activate() { @@ -94,7 +93,7 @@ namespace Orchard.Environment } } - _sweepGenerator.Activate(); + Sweep.Activate(); } public void Terminate() @@ -110,7 +109,7 @@ namespace Orchard.Environment } }); - SafelyTerminate(() => _sweepGenerator.Terminate()); + SafelyTerminate(() => Sweep.Terminate()); } private void SafelyTerminate(Action action) diff --git a/src/Orchard/Environment/WorkContextAccessor.cs b/src/Orchard/Environment/WorkContextAccessor.cs index 99c1e3023..233cd60a1 100644 --- a/src/Orchard/Environment/WorkContextAccessor.cs +++ b/src/Orchard/Environment/WorkContextAccessor.cs @@ -70,13 +70,12 @@ namespace Orchard.Environment class HttpContextScopeImplementation : IWorkContextScope { - readonly WorkContext _workContext; readonly Action _disposer; public HttpContextScopeImplementation(IEnumerable events, ILifetimeScope lifetimeScope, HttpContextBase httpContext, object workContextKey) { - _workContext = lifetimeScope.Resolve(); - httpContext.Items[workContextKey] = _workContext; + WorkContext = lifetimeScope.Resolve(); + httpContext.Items[workContextKey] = WorkContext; _disposer = () => { @@ -91,7 +90,7 @@ namespace Orchard.Environment _disposer(); } - public WorkContext WorkContext => _workContext; + public WorkContext WorkContext { get; } public TService Resolve() { @@ -106,7 +105,6 @@ namespace Orchard.Environment class CallContextScopeImplementation : IWorkContextScope { - readonly WorkContext _workContext; readonly Action _disposer; public CallContextScopeImplementation(IEnumerable events, ILifetimeScope lifetimeScope, string workContextSlot) @@ -114,11 +112,11 @@ namespace Orchard.Environment CallContext.LogicalSetData(workContextSlot, null); - _workContext = lifetimeScope.Resolve(); + WorkContext = lifetimeScope.Resolve(); var httpContext = lifetimeScope.Resolve(); - _workContext.HttpContext = httpContext; + WorkContext.HttpContext = httpContext; - CallContext.LogicalSetData(workContextSlot, new ObjectHandle(_workContext)); + CallContext.LogicalSetData(workContextSlot, new ObjectHandle(WorkContext)); _disposer = () => { @@ -133,7 +131,7 @@ namespace Orchard.Environment _disposer(); } - public WorkContext WorkContext => _workContext; + public WorkContext WorkContext { get; } public TService Resolve() { diff --git a/src/Orchard/Localization/LocalizedString.cs b/src/Orchard/Localization/LocalizedString.cs index f40175180..5411f5a17 100644 --- a/src/Orchard/Localization/LocalizedString.cs +++ b/src/Orchard/Localization/LocalizedString.cs @@ -9,23 +9,18 @@ namespace Orchard.Localization /// public class LocalizedString : MarshalByRefObject, IHtmlString { - private readonly string _localized; - private readonly string _scope; - private readonly string _textHint; - private readonly object[] _args; - public LocalizedString(string languageNeutral) { - _localized = languageNeutral; - _textHint = languageNeutral; + Text = languageNeutral; + TextHint = languageNeutral; } public LocalizedString(string localized, string scope, string textHint, object[] args) { - _localized = localized; - _scope = scope; - _textHint = textHint; - _args = args; + Text = localized; + Scope = scope; + TextHint = textHint; + Args = args; } public static LocalizedString TextOrDefault(string text, LocalizedString defaultValue) @@ -35,38 +30,38 @@ namespace Orchard.Localization return new LocalizedString(text); } - public string Scope => _scope; + public string Scope { get; } /// /// The HTML-Encoded original text /// - public string TextHint => _textHint; + public string TextHint { get; } - public object[] Args => _args; + public object[] Args { get; } /// /// The HTML-encoded localized text /// - public string Text => _localized; + public string Text { get; } /// /// The HTML-encoded localized text /// public override string ToString() { - return _localized; + return Text; } string IHtmlString.ToHtmlString() { - return _localized; + return Text; } public override int GetHashCode() { var hashCode = 0; - if (_localized != null) - hashCode ^= _localized.GetHashCode(); + if (Text != null) + hashCode ^= Text.GetHashCode(); return hashCode; } @@ -76,7 +71,7 @@ namespace Orchard.Localization return false; var that = (LocalizedString)obj; - return string.Equals(_localized, that._localized); + return string.Equals(Text, that.Text); } public override object InitializeLifetimeService() diff --git a/src/Orchard/Localization/Models/DateParts.cs b/src/Orchard/Localization/Models/DateParts.cs index 1873c053f..8d077d4e5 100644 --- a/src/Orchard/Localization/Models/DateParts.cs +++ b/src/Orchard/Localization/Models/DateParts.cs @@ -10,25 +10,21 @@ namespace Orchard.Localization.Models public DateParts(int year, int month, int day) { - _year = year; - _month = month; - _day = day; + Year = year; + Month = month; + Day = day; } - private readonly int _day; - private readonly int _month; - private readonly int _year; - - public int Year => _year; - public int Month => _month; - public int Day => _day; + public int Year { get; } + public int Month { get; } + public int Day { get; } public DateTime ToDateTime(Calendar calendar) { return new DateTime( - _year > 0 ? _year : DateTime.MinValue.Year, - _month > 0 ? _month : DateTime.MinValue.Month, - _day > 0 ? _day : DateTime.MinValue.Day, + Year > 0 ? Year : DateTime.MinValue.Year, + Month > 0 ? Month : DateTime.MinValue.Month, + Day > 0 ? Day : DateTime.MinValue.Day, DateTime.MinValue.Hour, DateTime.MinValue.Minute, DateTime.MinValue.Second, @@ -39,7 +35,7 @@ namespace Orchard.Localization.Models public override string ToString() { - return string.Format("{0}-{1}-{2}", _year, _month, _day); + return string.Format("{0}-{1}-{2}", Year, Month, Day); } } } diff --git a/src/Orchard/Localization/Models/DateTimeParts.cs b/src/Orchard/Localization/Models/DateTimeParts.cs index 9357d0ab1..a80c4d16c 100644 --- a/src/Orchard/Localization/Models/DateTimeParts.cs +++ b/src/Orchard/Localization/Models/DateTimeParts.cs @@ -18,22 +18,19 @@ namespace Orchard.Localization.Models public DateTimeParts(int year, int month, int day, int hour, int minute, int second, int millisecond, DateTimeKind kind, TimeSpan offset) { - _date = new DateParts(year, month, day); - _time = new TimeParts(hour, minute, second, millisecond, kind, offset); + Date = new DateParts(year, month, day); + Time = new TimeParts(hour, minute, second, millisecond, kind, offset); } public DateTimeParts(DateParts dateParts, TimeParts timeParts) { - _date = dateParts; - _time = timeParts; + Date = dateParts; + Time = timeParts; } - private readonly DateParts _date; - private readonly TimeParts _time; + public DateParts Date { get; } - public DateParts Date => _date; - - public TimeParts Time => _time; + public TimeParts Time { get; } public DateTime ToDateTime(Calendar calendar) { @@ -52,7 +49,7 @@ namespace Orchard.Localization.Models public override string ToString() { - return string.Format("{0} {1}", _date, _time); + return string.Format("{0} {1}", Date, Time); } } } diff --git a/src/Orchard/Localization/Models/TimeParts.cs b/src/Orchard/Localization/Models/TimeParts.cs index 89310bbe0..5337c414c 100644 --- a/src/Orchard/Localization/Models/TimeParts.cs +++ b/src/Orchard/Localization/Models/TimeParts.cs @@ -13,30 +13,25 @@ namespace Orchard.Localization.Models { throw new ArgumentOutOfRangeException(string.Format("The specified offset {0} does not match the specified kind {1}.", offset, kind)); } - _hour = hour; - _minute = minute; - _second = second; - _millisecond = millisecond; - _kind = kind; + Hour = hour; + Minute = minute; + Second = second; + Millisecond = millisecond; + Kind = kind; _offset = offset; } - private readonly int _hour; - private readonly int _minute; - private readonly int _second; - private readonly int _millisecond; - private readonly DateTimeKind _kind; private readonly TimeSpan _offset; - public int Hour => _hour; + public int Hour { get; } - public int Minute => _minute; + public int Minute { get; } - public int Second => _second; + public int Second { get; } - public int Millisecond => _millisecond; + public int Millisecond { get; } - public DateTimeKind Kind => _kind; + public DateTimeKind Kind { get; } public TimeSpan? Offset => _offset; @@ -46,17 +41,17 @@ namespace Orchard.Localization.Models DateTime.MinValue.Year, DateTime.MinValue.Month, DateTime.MinValue.Day, - _hour > 0 ? _hour : DateTime.MinValue.Hour, - _minute > 0 ? _minute : DateTime.MinValue.Minute, - _second > 0 ? _second : DateTime.MinValue.Second, - _millisecond > 0 ? _millisecond : DateTime.MinValue.Millisecond, - _kind + Hour > 0 ? Hour : DateTime.MinValue.Hour, + Minute > 0 ? Minute : DateTime.MinValue.Minute, + Second > 0 ? Second : DateTime.MinValue.Second, + Millisecond > 0 ? Millisecond : DateTime.MinValue.Millisecond, + Kind ); } public override string ToString() { - return string.Format("{0}:{1}:{2}.{3}-{4}-{5}", _hour, _minute, _second, _millisecond, _kind, _offset); + return string.Format("{0}:{1}:{2}.{3}-{4}-{5}", Hour, Minute, Second, Millisecond, Kind, _offset); } } } diff --git a/src/Orchard/Localization/NullLocalizer.cs b/src/Orchard/Localization/NullLocalizer.cs index a0d9061bb..c9a324400 100644 --- a/src/Orchard/Localization/NullLocalizer.cs +++ b/src/Orchard/Localization/NullLocalizer.cs @@ -5,11 +5,9 @@ namespace Orchard.Localization static NullLocalizer() { - _instance = (format, args) => new LocalizedString((args == null || args.Length == 0) ? format : string.Format(format, args)); + Instance = (format, args) => new LocalizedString((args == null || args.Length == 0) ? format : string.Format(format, args)); } - static readonly Localizer _instance; - - public static Localizer Instance => _instance; + public static Localizer Instance { get; private set; } } } \ No newline at end of file diff --git a/src/Orchard/Logging/NullLogger.cs b/src/Orchard/Logging/NullLogger.cs index e0287a660..8d7fe3d03 100644 --- a/src/Orchard/Logging/NullLogger.cs +++ b/src/Orchard/Logging/NullLogger.cs @@ -4,9 +4,7 @@ namespace Orchard.Logging { public class NullLogger : ILogger { - private static readonly ILogger _instance = new NullLogger(); - - public static ILogger Instance => _instance; + public static ILogger Instance { get; } = new NullLogger(); public bool IsEnabled(LogLevel level) { diff --git a/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs b/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs index 4a03b69e9..7146c9da4 100644 --- a/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs +++ b/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs @@ -95,18 +95,17 @@ namespace Orchard.Mvc.AntiForgery private class HackHttpContext : HttpContextWrapper { - private readonly HttpContextBase _originalHttpContextBase; private readonly HttpContext _originalHttpContext; private HttpRequestWrapper _request; public HackHttpContext(HttpContextBase httpContextBase, HttpContext httpContext) : base(httpContext) { - _originalHttpContextBase = httpContextBase; + OriginalHttpContextBase = httpContextBase; _originalHttpContext = httpContext; } - public HttpContextBase OriginalHttpContextBase => _originalHttpContextBase; + public HttpContextBase OriginalHttpContextBase { get; } public override HttpRequestBase Request { diff --git a/src/Orchard/Mvc/AntiForgery/ValidateAntiForgeryTokenOrchardAttribute.cs b/src/Orchard/Mvc/AntiForgery/ValidateAntiForgeryTokenOrchardAttribute.cs index 88c9cf5f8..f9675c21b 100644 --- a/src/Orchard/Mvc/AntiForgery/ValidateAntiForgeryTokenOrchardAttribute.cs +++ b/src/Orchard/Mvc/AntiForgery/ValidateAntiForgeryTokenOrchardAttribute.cs @@ -6,15 +6,13 @@ namespace Orchard.Mvc.AntiForgery [AttributeUsage(AttributeTargets.Method)] public class ValidateAntiForgeryTokenOrchardAttribute : FilterAttribute { - private readonly bool _enabled = true; - public ValidateAntiForgeryTokenOrchardAttribute() : this(true) { } public ValidateAntiForgeryTokenOrchardAttribute(bool enabled) { - _enabled = enabled; + Enabled = enabled; } - public bool Enabled => _enabled; + public bool Enabled { get; } = true; } } \ No newline at end of file diff --git a/src/Orchard/Mvc/ViewPage.cs b/src/Orchard/Mvc/ViewPage.cs index df21ce74c..c261d37ee 100644 --- a/src/Orchard/Mvc/ViewPage.cs +++ b/src/Orchard/Mvc/ViewPage.cs @@ -20,11 +20,9 @@ namespace Orchard.Mvc private ResourceRegister _stylesheetRegister; private object _display; - private Localizer _localizer = NullLocalizer.Instance; private object _layout; - private WorkContext _workContext; - public Localizer T => _localizer; + public Localizer T { get; private set; } = NullLocalizer.Instance; public dynamic Display => _display; public ScriptRegister Script { @@ -36,16 +34,16 @@ namespace Orchard.Mvc } public dynamic Layout => _layout; - public WorkContext WorkContext => _workContext; + public WorkContext WorkContext { get; private set; } private IDisplayHelperFactory _displayHelperFactory; - public IDisplayHelperFactory DisplayHelperFactory => _displayHelperFactory ?? (_displayHelperFactory = _workContext.Resolve()); + public IDisplayHelperFactory DisplayHelperFactory => _displayHelperFactory ?? (_displayHelperFactory = WorkContext.Resolve()); private IShapeFactory _shapeFactory; - public IShapeFactory ShapeFactory => _shapeFactory ?? (_shapeFactory = _workContext.Resolve()); + public IShapeFactory ShapeFactory => _shapeFactory ?? (_shapeFactory = WorkContext.Resolve()); private IAuthorizer _authorizer; - public IAuthorizer Authorizer => _authorizer ?? (_authorizer = _workContext.Resolve()); + public IAuthorizer Authorizer => _authorizer ?? (_authorizer = WorkContext.Resolve()); public ResourceRegister Style { @@ -60,11 +58,11 @@ namespace Orchard.Mvc { base.InitHelpers(); - _workContext = ViewContext.GetWorkContext(); + WorkContext = ViewContext.GetWorkContext(); - _localizer = LocalizationUtilities.Resolve(ViewContext, AppRelativeVirtualPath); + T = LocalizationUtilities.Resolve(ViewContext, AppRelativeVirtualPath); _display = DisplayHelperFactory.CreateHelper(ViewContext, this); - _layout = _workContext.Layout; + _layout = WorkContext.Layout; } public virtual void RegisterLink(LinkEntry link) diff --git a/src/Orchard/Mvc/ViewUserControl.cs b/src/Orchard/Mvc/ViewUserControl.cs index 5846d0cad..110494717 100644 --- a/src/Orchard/Mvc/ViewUserControl.cs +++ b/src/Orchard/Mvc/ViewUserControl.cs @@ -18,24 +18,22 @@ namespace Orchard.Mvc private ResourceRegister _stylesheetRegister; private object _display; - private Localizer _localizer = NullLocalizer.Instance; private object _layout; - private WorkContext _workContext; - public Localizer T => _localizer; + public Localizer T { get; private set; } = NullLocalizer.Instance; public dynamic Display => _display; public dynamic New => ShapeFactory; public dynamic Layout => _layout; - public WorkContext WorkContext => _workContext; + public WorkContext WorkContext { get; private set; } private IDisplayHelperFactory _displayHelperFactory; - public IDisplayHelperFactory DisplayHelperFactory => _displayHelperFactory ?? (_displayHelperFactory = _workContext.Resolve()); + public IDisplayHelperFactory DisplayHelperFactory => _displayHelperFactory ?? (_displayHelperFactory = WorkContext.Resolve()); private IShapeFactory _shapeFactory; - public IShapeFactory ShapeFactory => _shapeFactory ?? (_shapeFactory = _workContext.Resolve()); + public IShapeFactory ShapeFactory => _shapeFactory ?? (_shapeFactory = WorkContext.Resolve()); private IAuthorizer _authorizer; - public IAuthorizer Authorizer => _authorizer ?? (_authorizer = _workContext.Resolve()); + public IAuthorizer Authorizer => _authorizer ?? (_authorizer = WorkContext.Resolve()); public ScriptRegister Script { @@ -83,11 +81,11 @@ namespace Orchard.Mvc public override void RenderView(ViewContext viewContext) { - _workContext = viewContext.GetWorkContext(); + WorkContext = viewContext.GetWorkContext(); - _localizer = LocalizationUtilities.Resolve(viewContext, AppRelativeVirtualPath); + T = LocalizationUtilities.Resolve(viewContext, AppRelativeVirtualPath); _display = DisplayHelperFactory.CreateHelper(viewContext, this); - _layout = _workContext.Layout; + _layout = WorkContext.Layout; base.RenderView(viewContext); } diff --git a/src/Orchard/Security/CreateUserParams.cs b/src/Orchard/Security/CreateUserParams.cs index 983a7e3db..70d34b315 100644 --- a/src/Orchard/Security/CreateUserParams.cs +++ b/src/Orchard/Security/CreateUserParams.cs @@ -3,14 +3,6 @@ namespace Orchard.Security //TEMP: Add setters, provide default constructor and remove parameterized constructor public class CreateUserParams { - private readonly string _username; - private readonly string _password; - private readonly string _email; - private readonly string _passwordQuestion; - private readonly string _passwordAnswer; - private readonly bool _isApproved; - private readonly bool _forcePasswordChange; - public CreateUserParams(string username, string password, string email) : this(username, password, email, string.Empty, string.Empty, true, false) { } @@ -19,27 +11,27 @@ namespace Orchard.Security public CreateUserParams(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, bool forcePasswordChange) { - _username = username; - _password = password; - _email = email; - _passwordQuestion = passwordQuestion; - _passwordAnswer = passwordAnswer; - _isApproved = isApproved; - _forcePasswordChange = forcePasswordChange; + Username = username; + Password = password; + Email = email; + PasswordQuestion = passwordQuestion; + PasswordAnswer = passwordAnswer; + IsApproved = isApproved; + ForcePasswordChange = forcePasswordChange; } - public string Username => _username; + public string Username { get; } - public string Password => _password; + public string Password { get; } - public string Email => _email; + public string Email { get; } - public string PasswordQuestion => _passwordQuestion; + public string PasswordQuestion { get; } - public string PasswordAnswer => _passwordAnswer; + public string PasswordAnswer { get; } - public bool IsApproved => _isApproved; + public bool IsApproved { get; } - public bool ForcePasswordChange => _forcePasswordChange; + public bool ForcePasswordChange { get; } } } \ No newline at end of file diff --git a/src/Orchard/Tasks/Locking/Services/DistributedLock.cs b/src/Orchard/Tasks/Locking/Services/DistributedLock.cs index b72e9603d..9568be03a 100644 --- a/src/Orchard/Tasks/Locking/Services/DistributedLock.cs +++ b/src/Orchard/Tasks/Locking/Services/DistributedLock.cs @@ -7,21 +7,20 @@ namespace Orchard.Tasks.Locking.Services { private readonly string _name; - private readonly string _internalName; private readonly Action _releaseLockAction; private int _count; internal DistributedLock(string name, string internalName, Action releaseLockAction) { _name = name; - _internalName = internalName; + InternalName = internalName; _releaseLockAction = releaseLockAction; _count = 1; } string IDistributedLock.Name => _name; - internal string InternalName => _internalName; + internal string InternalName { get; } internal void Increment() { diff --git a/src/Orchard/WebApi/AutofacWebApiDependencyResolver.cs b/src/Orchard/WebApi/AutofacWebApiDependencyResolver.cs index 53618eed4..0d39ff10c 100644 --- a/src/Orchard/WebApi/AutofacWebApiDependencyResolver.cs +++ b/src/Orchard/WebApi/AutofacWebApiDependencyResolver.cs @@ -7,7 +7,6 @@ namespace Orchard.WebApi { public class AutofacWebApiDependencyResolver : IDependencyResolver { - readonly ILifetimeScope _container; readonly IDependencyScope _rootDependencyScope; //internal static readonly string ApiRequestTag = "AutofacWebRequest"; @@ -16,11 +15,11 @@ namespace Orchard.WebApi { if (container == null) throw new ArgumentNullException("container"); - _container = container; + Container = container; _rootDependencyScope = new AutofacWebApiDependencyScope(container); } - public ILifetimeScope Container => _container; + public ILifetimeScope Container { get; } public object GetService(Type serviceType) { @@ -34,7 +33,7 @@ namespace Orchard.WebApi public IDependencyScope BeginScope() { - ILifetimeScope lifetimeScope = _container.BeginLifetimeScope(); + ILifetimeScope lifetimeScope = Container.BeginLifetimeScope(); return new AutofacWebApiDependencyScope(lifetimeScope); } diff --git a/src/Tools/Orchard/Parameters/CommandLineParser.cs b/src/Tools/Orchard/Parameters/CommandLineParser.cs index 7f40b609e..445978663 100644 --- a/src/Tools/Orchard/Parameters/CommandLineParser.cs +++ b/src/Tools/Orchard/Parameters/CommandLineParser.cs @@ -20,18 +20,17 @@ namespace Orchard.Parameters public class State { private readonly string _commandLine; - private readonly StringBuilder _stringBuilder; private readonly List _arguments; private int _index; public State(string commandLine) { _commandLine = commandLine; - _stringBuilder = new StringBuilder(); + StringBuilder = new StringBuilder(); _arguments = new List(); } - public StringBuilder StringBuilder => _stringBuilder; + public StringBuilder StringBuilder { get; } public bool EOF => _index >= _commandLine.Length; public char Current => _commandLine[_index]; public IEnumerable Arguments => _arguments;