mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 21:13:35 +08:00
Cleanup & Refactoring
--HG-- branch : dev
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Orchard.Core.Common {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
ChangeOwner,
|
ChangeOwner,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ namespace Orchard.Core.Settings {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
ManageSettings,
|
ManageSettings,
|
||||||
ChangeSuperuser,
|
ChangeSuperuser,
|
||||||
};
|
};
|
||||||
|
@@ -19,7 +19,7 @@ namespace Orchard.Blogs {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
ManageBlogs,
|
ManageBlogs,
|
||||||
EditBlogPost,
|
EditBlogPost,
|
||||||
EditOthersBlogPost,
|
EditOthersBlogPost,
|
||||||
|
@@ -14,7 +14,7 @@ namespace Orchard.Comments {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
AddComment,
|
AddComment,
|
||||||
EnableComment,
|
EnableComment,
|
||||||
CloseComment,
|
CloseComment,
|
||||||
|
@@ -10,7 +10,7 @@ namespace Orchard.Experimental {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
DebugShowAllMenuItems,
|
DebugShowAllMenuItems,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -99,7 +99,7 @@ namespace Orchard.Localization.Controllers {
|
|||||||
var model = new AddLocalizationViewModel();
|
var model = new AddLocalizationViewModel();
|
||||||
TryUpdateModel(model);
|
TryUpdateModel(model);
|
||||||
|
|
||||||
ContentItem contentItemTranslation = null;
|
ContentItem contentItemTranslation;
|
||||||
var existingTranslation = _localizationService.GetLocalizedContentItem(contentItem, model.SelectedCulture);
|
var existingTranslation = _localizationService.GetLocalizedContentItem(contentItem, model.SelectedCulture);
|
||||||
if (existingTranslation != null) {
|
if (existingTranslation != null) {
|
||||||
// edit existing
|
// edit existing
|
||||||
|
@@ -10,7 +10,7 @@ namespace Orchard.Media {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
ManageMediaFiles,
|
ManageMediaFiles,
|
||||||
UploadMediaFiles,
|
UploadMediaFiles,
|
||||||
};
|
};
|
||||||
|
@@ -12,7 +12,7 @@ namespace Orchard.Roles {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
ManageRoles,
|
ManageRoles,
|
||||||
ApplyRoles,
|
ApplyRoles,
|
||||||
};
|
};
|
||||||
|
@@ -59,10 +59,10 @@ namespace Orchard.Scripting.Compiler {
|
|||||||
if (IsDigitCharacter(ch)) {
|
if (IsDigitCharacter(ch)) {
|
||||||
return LexInteger();
|
return LexInteger();
|
||||||
}
|
}
|
||||||
else if (IsIdentifierCharacter(ch)) {
|
if (IsIdentifierCharacter(ch)) {
|
||||||
return LexIdentifierOrKeyword();
|
return LexIdentifierOrKeyword();
|
||||||
}
|
}
|
||||||
else if (IsWhitespaceCharacter(ch)) {
|
if (IsWhitespaceCharacter(ch)) {
|
||||||
NextCharacter();
|
NextCharacter();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -163,18 +163,18 @@ namespace Orchard.Scripting.Compiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsWhitespaceCharacter(char character) {
|
private static bool IsWhitespaceCharacter(char character) {
|
||||||
return char.IsWhiteSpace(character);
|
return char.IsWhiteSpace(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsIdentifierCharacter(char ch) {
|
private static bool IsIdentifierCharacter(char ch) {
|
||||||
return
|
return
|
||||||
(ch >= 'a' && ch <= 'z') ||
|
(ch >= 'a' && ch <= 'z') ||
|
||||||
(ch >= 'A' && ch <= 'Z') ||
|
(ch >= 'A' && ch <= 'Z') ||
|
||||||
(ch == '_');
|
(ch == '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsDigitCharacter(char ch) {
|
private static bool IsDigitCharacter(char ch) {
|
||||||
return ch >= '0' && ch <= '9';
|
return ch >= '0' && ch <= '9';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ namespace Orchard.Scripting.Compiler {
|
|||||||
return CreateToken(TokenKind.SingleQuotedStringLiteral, _stringBuilder.ToString());
|
return CreateToken(TokenKind.SingleQuotedStringLiteral, _stringBuilder.ToString());
|
||||||
}
|
}
|
||||||
// backslash notation
|
// backslash notation
|
||||||
else if (Character() == '\\') {
|
if (Character() == '\\') {
|
||||||
NextCharacter();
|
NextCharacter();
|
||||||
|
|
||||||
if (Eof())
|
if (Eof())
|
||||||
@@ -232,7 +232,7 @@ namespace Orchard.Scripting.Compiler {
|
|||||||
return CreateToken(TokenKind.StringLiteral, _stringBuilder.ToString());
|
return CreateToken(TokenKind.StringLiteral, _stringBuilder.ToString());
|
||||||
}
|
}
|
||||||
// backslash notation
|
// backslash notation
|
||||||
else if (Character() == '\\') {
|
if (Character() == '\\') {
|
||||||
NextCharacter();
|
NextCharacter();
|
||||||
|
|
||||||
if (Eof())
|
if (Eof())
|
||||||
|
@@ -11,7 +11,7 @@ namespace Orchard.Tags {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
ManageTags,
|
ManageTags,
|
||||||
CreateTag,
|
CreateTag,
|
||||||
ApplyTag,
|
ApplyTag,
|
||||||
|
@@ -10,7 +10,7 @@ namespace Orchard.Themes {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
ManageThemes,
|
ManageThemes,
|
||||||
ApplyTheme,
|
ApplyTheme,
|
||||||
};
|
};
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using Orchard.Commands;
|
using Orchard.Commands;
|
||||||
using Orchard.ContentManagement;
|
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
using Orchard.Users.Services;
|
using Orchard.Users.Services;
|
||||||
|
|
||||||
@@ -9,7 +8,6 @@ namespace Orchard.Users.Commands {
|
|||||||
private readonly IUserService _userService;
|
private readonly IUserService _userService;
|
||||||
|
|
||||||
public UserCommands(
|
public UserCommands(
|
||||||
IContentManager contentManager,
|
|
||||||
IMembershipService membershipService,
|
IMembershipService membershipService,
|
||||||
IUserService userService) {
|
IUserService userService) {
|
||||||
_membershipService = membershipService;
|
_membershipService = membershipService;
|
||||||
@@ -43,7 +41,7 @@ namespace Orchard.Users.Commands {
|
|||||||
var user = _membershipService.CreateUser(new CreateUserParams(UserName, Password, Email, null, null, true));
|
var user = _membershipService.CreateUser(new CreateUserParams(UserName, Password, Email, null, null, true));
|
||||||
if (user != null)
|
if (user != null)
|
||||||
return T("User created successfully").ToString();
|
return T("User created successfully").ToString();
|
||||||
else
|
|
||||||
return T("The authentication provider returned an error").ToString();
|
return T("The authentication provider returned an error").ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -132,10 +132,9 @@ namespace Orchard.Users.Controllers {
|
|||||||
_authenticationService.SignIn(user, false /* createPersistentCookie */);
|
_authenticationService.SignIn(user, false /* createPersistentCookie */);
|
||||||
return Redirect("~/");
|
return Redirect("~/");
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
ModelState.AddModelError("_FORM", T(ErrorCodeToString(/*createStatus*/MembershipCreateStatus.ProviderError)));
|
ModelState.AddModelError("_FORM", T(ErrorCodeToString(/*createStatus*/MembershipCreateStatus.ProviderError)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If we got this far, something failed, redisplay form
|
// If we got this far, something failed, redisplay form
|
||||||
return Register();
|
return Register();
|
||||||
@@ -196,12 +195,11 @@ namespace Orchard.Users.Controllers {
|
|||||||
_membershipService.SetPassword(validated, newPassword);
|
_membershipService.SetPassword(validated, newPassword);
|
||||||
return RedirectToAction("ChangePasswordSuccess");
|
return RedirectToAction("ChangePasswordSuccess");
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
ModelState.AddModelError("_FORM",
|
ModelState.AddModelError("_FORM",
|
||||||
T("The current password is incorrect or the new password is invalid."));
|
T("The current password is incorrect or the new password is invalid."));
|
||||||
return ChangePassword();
|
return ChangePassword();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch {
|
catch {
|
||||||
ModelState.AddModelError("_FORM", T("The current password is incorrect or the new password is invalid."));
|
ModelState.AddModelError("_FORM", T("The current password is incorrect or the new password is invalid."));
|
||||||
return ChangePassword();
|
return ChangePassword();
|
||||||
|
@@ -11,7 +11,7 @@ namespace Orchard.Users {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
ManageUsers,
|
ManageUsers,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ namespace Orchard.Widgets {
|
|||||||
public virtual Feature Feature { get; set; }
|
public virtual Feature Feature { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
ManageWidgets,
|
ManageWidgets,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -33,12 +33,10 @@ namespace Orchard.Commands {
|
|||||||
throw new OrchardCoreException(T("Multiple commands found matching arguments \"{0}\". Commands available: {1}.",
|
throw new OrchardCoreException(T("Multiple commands found matching arguments \"{0}\". Commands available: {1}.",
|
||||||
commandMatch, commandList));
|
commandMatch, commandList));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
throw new OrchardCoreException(T("No command found matching arguments \"{0}\". Commands available: {1}.",
|
throw new OrchardCoreException(T("No command found matching arguments \"{0}\". Commands available: {1}.",
|
||||||
commandMatch, commandList));
|
commandMatch, commandList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<CommandDescriptor> GetCommandDescriptors() {
|
public IEnumerable<CommandDescriptor> GetCommandDescriptors() {
|
||||||
return _handlers.SelectMany(h => GetDescriptor(h.Metadata).Commands);
|
return _handlers.SelectMany(h => GetDescriptor(h.Metadata).Commands);
|
||||||
|
@@ -166,7 +166,7 @@ namespace Orchard.Data.Migration {
|
|||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
foreach (var migration in migrations.OfType<DataMigrationImpl>()) {
|
foreach (var migration in migrations.OfType<DataMigrationImpl>()) {
|
||||||
migration.SchemaBuilder = new SchemaBuilder(_interpreter, migration.Feature.Descriptor.Id, (s) => s.Replace(".", "_") + "_");
|
migration.SchemaBuilder = new SchemaBuilder(_interpreter, migration.Feature.Descriptor.Id, s => s.Replace(".", "_") + "_");
|
||||||
migration.ContentDefinitionManager = _contentDefinitionManager;
|
migration.ContentDefinitionManager = _contentDefinitionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -107,7 +107,7 @@ namespace Orchard.Data.Migration.Generator {
|
|||||||
|
|
||||||
|
|
||||||
if ( columnCopy.IsLengthDefined()
|
if ( columnCopy.IsLengthDefined()
|
||||||
&& new DbType[] { DbType.StringFixedLength, DbType.String, DbType.AnsiString, DbType.AnsiStringFixedLength }.Contains(sqlType.DbType)
|
&& new[] { DbType.StringFixedLength, DbType.String, DbType.AnsiString, DbType.AnsiStringFixedLength }.Contains(sqlType.DbType)
|
||||||
&& columnCopy.Length != Column.DefaultLength) {
|
&& columnCopy.Length != Column.DefaultLength) {
|
||||||
action.WithLength(columnCopy.Length);
|
action.WithLength(columnCopy.Length);
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ namespace Orchard.Data.Migration.Schema {
|
|||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "System.Enum.TryParse<System.Data.DbType>(System.String,System.Boolean,System.Data.DbType@)")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "System.Enum.TryParse<System.Data.DbType>(System.String,System.Boolean,System.Data.DbType@)")]
|
||||||
public static DbType ToDbType(Type type) {
|
public static DbType ToDbType(Type type) {
|
||||||
DbType dbType;
|
DbType dbType;
|
||||||
switch ( System.Type.GetTypeCode(type) ) {
|
switch ( Type.GetTypeCode(type) ) {
|
||||||
case TypeCode.String:
|
case TypeCode.String:
|
||||||
dbType = DbType.String;
|
dbType = DbType.String;
|
||||||
break;
|
break;
|
||||||
|
@@ -20,9 +20,7 @@ namespace Orchard.Data.Providers {
|
|||||||
if (string.IsNullOrEmpty(_connectionString)) {
|
if (string.IsNullOrEmpty(_connectionString)) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
persistence = persistence.ConnectionString(_connectionString);
|
persistence = persistence.ConnectionString(_connectionString);
|
||||||
}
|
|
||||||
return persistence;
|
return persistence;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,6 @@ namespace Orchard.Localization {
|
|||||||
public static LocalizedString TextOrDefault(string text, LocalizedString defaultValue) {
|
public static LocalizedString TextOrDefault(string text, LocalizedString defaultValue) {
|
||||||
if (string.IsNullOrEmpty(text))
|
if (string.IsNullOrEmpty(text))
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
else
|
|
||||||
return new LocalizedString(text);
|
return new LocalizedString(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -295,7 +295,7 @@ namespace Orchard.Mvc.Html {
|
|||||||
try {
|
try {
|
||||||
return htmlHelper.AntiForgeryToken(siteSalt);
|
return htmlHelper.AntiForgeryToken(siteSalt);
|
||||||
}
|
}
|
||||||
catch(System.Web.Mvc.HttpAntiForgeryException) {
|
catch(HttpAntiForgeryException) {
|
||||||
// Work-around an issue in MVC 2: If the browser sends a cookie that is not
|
// Work-around an issue in MVC 2: If the browser sends a cookie that is not
|
||||||
// coming from this server (this can happen if the user didn't close their browser
|
// coming from this server (this can happen if the user didn't close their browser
|
||||||
// while the application server configuration changed), clear it up
|
// while the application server configuration changed), clear it up
|
||||||
|
@@ -45,7 +45,7 @@ namespace Orchard.Mvc {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IController GetControllerInstance(RequestContext requestContext, System.Type controllerType) {
|
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) {
|
||||||
IController controller;
|
IController controller;
|
||||||
var workContext = requestContext.GetWorkContext();
|
var workContext = requestContext.GetWorkContext();
|
||||||
if (TryResolve(workContext, controllerType, out controller)) {
|
if (TryResolve(workContext, controllerType, out controller)) {
|
||||||
|
@@ -28,7 +28,7 @@ namespace Orchard.Security {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Permission> GetPermissions() {
|
public IEnumerable<Permission> GetPermissions() {
|
||||||
return new Permission[] {
|
return new[] {
|
||||||
AccessAdminPanel,
|
AccessAdminPanel,
|
||||||
AccessFrontEnd,
|
AccessFrontEnd,
|
||||||
};
|
};
|
||||||
|
@@ -52,7 +52,7 @@ namespace Orchard {
|
|||||||
if (controllerContext == null)
|
if (controllerContext == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return WorkContextExtensions.GetWorkContext(controllerContext.RequestContext);
|
return GetWorkContext(controllerContext.RequestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IWorkContextScope CreateWorkContextScope(this ILifetimeScope lifetimeScope, HttpContextBase httpContext) {
|
public static IWorkContextScope CreateWorkContextScope(this ILifetimeScope lifetimeScope, HttpContextBase httpContext) {
|
||||||
|
Reference in New Issue
Block a user