mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-09 11:21:04 +08:00
VS code cleanup: Apply object/collection initializer preferences
This commit is contained in:
@@ -375,8 +375,10 @@ namespace Orchard.Tests.Modules.Users.Controllers
|
||||
{
|
||||
get
|
||||
{
|
||||
var nv = new NameValueCollection();
|
||||
nv["Host"] = "orchardproject.net";
|
||||
var nv = new NameValueCollection
|
||||
{
|
||||
["Host"] = "orchardproject.net"
|
||||
};
|
||||
return nv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,8 +126,11 @@ namespace Orchard.Tests.Environment.Configuration
|
||||
public void SettingsDontLoseTenantState()
|
||||
{
|
||||
IShellSettingsManager loader = new ShellSettingsManager(_appDataFolder, new Mock<IShellSettingsManagerEventHandler>().Object);
|
||||
var foo = new ShellSettings { Name = "Default" };
|
||||
foo.State = TenantState.Disabled;
|
||||
var foo = new ShellSettings
|
||||
{
|
||||
Name = "Default",
|
||||
State = TenantState.Disabled
|
||||
};
|
||||
|
||||
loader.SaveSettings(foo);
|
||||
var settings = loader.LoadSettings().First();
|
||||
|
||||
@@ -49,9 +49,11 @@ namespace Orchard.Tests.Events
|
||||
public void EventParametersAreCorrectlyPassedToEventHandlers()
|
||||
{
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 5200;
|
||||
arguments["b"] = 2600;
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>
|
||||
{
|
||||
["a"] = 5200,
|
||||
["b"] = 2600
|
||||
};
|
||||
_eventBus.Notify("ITestEventHandler.Substract", arguments);
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(2600));
|
||||
}
|
||||
@@ -60,9 +62,11 @@ namespace Orchard.Tests.Events
|
||||
public void EventParametersArePassedInCorrectOrderToEventHandlers()
|
||||
{
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 2600;
|
||||
arguments["b"] = 5200;
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>
|
||||
{
|
||||
["a"] = 2600,
|
||||
["b"] = 5200
|
||||
};
|
||||
_eventBus.Notify("ITestEventHandler.Substract", arguments);
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(-2600));
|
||||
}
|
||||
@@ -71,10 +75,12 @@ namespace Orchard.Tests.Events
|
||||
public void EventParametersAreCorrectlyPassedToMatchingMethod()
|
||||
{
|
||||
Assert.That(_eventHandler.Summary, Is.Null);
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = "a";
|
||||
arguments["b"] = "b";
|
||||
arguments["c"] = "c";
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>
|
||||
{
|
||||
["a"] = "a",
|
||||
["b"] = "b",
|
||||
["c"] = "c"
|
||||
};
|
||||
_eventBus.Notify("ITestEventHandler.Concat", arguments);
|
||||
Assert.That(_eventHandler.Summary, Is.EqualTo("abc"));
|
||||
}
|
||||
@@ -83,10 +89,12 @@ namespace Orchard.Tests.Events
|
||||
public void EventParametersAreCorrectlyPassedToExactlyMatchingMethod()
|
||||
{
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
arguments["b"] = 100;
|
||||
arguments["c"] = 10;
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>
|
||||
{
|
||||
["a"] = 1000,
|
||||
["b"] = 100,
|
||||
["c"] = 10
|
||||
};
|
||||
_eventBus.Notify("ITestEventHandler.Sum", arguments);
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(1110));
|
||||
}
|
||||
@@ -95,11 +103,13 @@ namespace Orchard.Tests.Events
|
||||
public void EventParametersAreCorrectlyPassedToBestMatchingMethodAndExtraParametersAreIgnored()
|
||||
{
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
arguments["b"] = 100;
|
||||
arguments["c"] = 10;
|
||||
arguments["e"] = 1;
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>
|
||||
{
|
||||
["a"] = 1000,
|
||||
["b"] = 100,
|
||||
["c"] = 10,
|
||||
["e"] = 1
|
||||
};
|
||||
_eventBus.Notify("ITestEventHandler.Sum", arguments);
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(1110));
|
||||
}
|
||||
@@ -108,9 +118,11 @@ namespace Orchard.Tests.Events
|
||||
public void EventParametersAreCorrectlyPassedToBestMatchingMethodAndExtraParametersAreIgnored2()
|
||||
{
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
arguments["e"] = 1;
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>
|
||||
{
|
||||
["a"] = 1000,
|
||||
["e"] = 1
|
||||
};
|
||||
_eventBus.Notify("ITestEventHandler.Sum", arguments);
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(3000));
|
||||
}
|
||||
@@ -119,9 +131,11 @@ namespace Orchard.Tests.Events
|
||||
public void EventParametersAreCorrectlyPassedToExactlyMatchingMethodWhenThereIsOne()
|
||||
{
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
arguments["b"] = 100;
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>
|
||||
{
|
||||
["a"] = 1000,
|
||||
["b"] = 100
|
||||
};
|
||||
_eventBus.Notify("ITestEventHandler.Sum", arguments);
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(2200));
|
||||
}
|
||||
@@ -130,8 +144,10 @@ namespace Orchard.Tests.Events
|
||||
public void EventParametersAreCorrectlyPassedToExactlyMatchingMethodWhenThereIsOne2()
|
||||
{
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>
|
||||
{
|
||||
["a"] = 1000
|
||||
};
|
||||
_eventBus.Notify("ITestEventHandler.Sum", arguments);
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(3000));
|
||||
}
|
||||
@@ -140,8 +156,10 @@ namespace Orchard.Tests.Events
|
||||
public void EventHandlerWontBeCalledWhenNoParameterMatchExists()
|
||||
{
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["e"] = 1;
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>
|
||||
{
|
||||
["e"] = 1
|
||||
};
|
||||
_eventBus.Notify("ITestEventHandler.Sum", arguments);
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
@@ -733,8 +733,10 @@ namespace Orchard.Core.Shapes
|
||||
[Shape]
|
||||
public IHtmlString Pager_CurrentPage(HtmlHelper Html, dynamic Display, object Value)
|
||||
{
|
||||
var tagBuilder = new TagBuilder("span");
|
||||
tagBuilder.InnerHtml = EncodeOrDisplay(Value, Display, Html).ToString();
|
||||
var tagBuilder = new TagBuilder("span")
|
||||
{
|
||||
InnerHtml = EncodeOrDisplay(Value, Display, Html).ToString()
|
||||
};
|
||||
|
||||
return MvcHtmlString.Create(tagBuilder.ToString());
|
||||
}
|
||||
@@ -792,8 +794,10 @@ namespace Orchard.Core.Shapes
|
||||
[Shape]
|
||||
public IHtmlString Pager_Gap(HtmlHelper Html, dynamic Display, object Value)
|
||||
{
|
||||
var tagBuilder = new TagBuilder("span");
|
||||
tagBuilder.InnerHtml = EncodeOrDisplay(Value, Display, Html).ToString();
|
||||
var tagBuilder = new TagBuilder("span")
|
||||
{
|
||||
InnerHtml = EncodeOrDisplay(Value, Display, Html).ToString()
|
||||
};
|
||||
|
||||
return MvcHtmlString.Create(tagBuilder.ToString());
|
||||
}
|
||||
|
||||
@@ -66,8 +66,10 @@ namespace Orchard.Autoroute.Providers.ContentDefinition
|
||||
var SiteCultures = _cultureManager.ListCultures().ToList();
|
||||
|
||||
// Adding a null culture for the culture neutral pattern
|
||||
List<string> cultures = new List<string>();
|
||||
cultures.Add(null);
|
||||
List<string> cultures = new List<string>
|
||||
{
|
||||
null
|
||||
};
|
||||
cultures.AddRange(SiteCultures);
|
||||
|
||||
// Create Patterns and DefaultPatterns
|
||||
|
||||
@@ -41,8 +41,10 @@ namespace Orchard.Autoroute.Settings
|
||||
List<RoutePattern> newPatterns = new List<RoutePattern>();
|
||||
|
||||
// Adding a null culture for the culture neutral pattern
|
||||
var cultures = new List<string>();
|
||||
cultures.Add(null);
|
||||
var cultures = new List<string>
|
||||
{
|
||||
null
|
||||
};
|
||||
cultures.AddRange(settings.SiteCultures);
|
||||
|
||||
foreach (string culture in cultures)
|
||||
@@ -62,12 +64,9 @@ namespace Orchard.Autoroute.Settings
|
||||
newPatterns.Add(new RoutePattern { Culture = culture, Name = null, Description = null, Pattern = null });
|
||||
|
||||
// If the content type has no defaultPattern for autoroute, assign one
|
||||
var defaultPatternExists = false;
|
||||
if (string.IsNullOrEmpty(culture))
|
||||
defaultPatternExists = settings.DefaultPatterns.Any(x => string.IsNullOrEmpty(x.Culture));
|
||||
else
|
||||
defaultPatternExists = settings.DefaultPatterns.Any(x => string.Equals(x.Culture, culture, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
var defaultPatternExists = string.IsNullOrEmpty(culture)
|
||||
? settings.DefaultPatterns.Any(x => string.IsNullOrEmpty(x.Culture))
|
||||
: settings.DefaultPatterns.Any(x => string.Equals(x.Culture, culture, StringComparison.OrdinalIgnoreCase));
|
||||
if (!defaultPatternExists)
|
||||
{
|
||||
// If in the default culture check the old setting
|
||||
@@ -103,12 +102,11 @@ namespace Orchard.Autoroute.Settings
|
||||
|
||||
var settings = new AutorouteSettings
|
||||
{
|
||||
Patterns = new List<RoutePattern>()
|
||||
Patterns = new List<RoutePattern>(),
|
||||
// Get cultures
|
||||
SiteCultures = _cultureManager.ListCultures().ToList()
|
||||
};
|
||||
|
||||
// Get cultures
|
||||
settings.SiteCultures = _cultureManager.ListCultures().ToList();
|
||||
|
||||
if (updateModel.TryUpdateModel(settings, "AutorouteSettings", null, null))
|
||||
{
|
||||
//TODO need to add validations client and/or server side here
|
||||
@@ -118,13 +116,9 @@ namespace Orchard.Autoroute.Settings
|
||||
|
||||
foreach (var defaultPattern in settings.DefaultPatterns)
|
||||
{
|
||||
RoutePattern correspondingPattern = null;
|
||||
|
||||
if (string.IsNullOrEmpty(defaultPattern.Culture))
|
||||
correspondingPattern = settings.Patterns.Where(x => string.IsNullOrEmpty(x.Culture)).ElementAt(Convert.ToInt32(defaultPattern.PatternIndex));
|
||||
else
|
||||
correspondingPattern = settings.Patterns.Where(x => string.Equals(x.Culture, defaultPattern.Culture, StringComparison.OrdinalIgnoreCase)).ElementAt(Convert.ToInt32(defaultPattern.PatternIndex));
|
||||
|
||||
var correspondingPattern = string.IsNullOrEmpty(defaultPattern.Culture)
|
||||
? settings.Patterns.Where(x => string.IsNullOrEmpty(x.Culture)).ElementAt(Convert.ToInt32(defaultPattern.PatternIndex))
|
||||
: settings.Patterns.Where(x => string.Equals(x.Culture, defaultPattern.Culture, StringComparison.OrdinalIgnoreCase)).ElementAt(Convert.ToInt32(defaultPattern.PatternIndex));
|
||||
if (string.IsNullOrWhiteSpace(correspondingPattern.Name) && string.IsNullOrWhiteSpace(correspondingPattern.Pattern) && string.IsNullOrWhiteSpace(correspondingPattern.Description))
|
||||
newDefaultPatterns.Add(new DefaultPattern { Culture = defaultPattern.Culture, PatternIndex = "0" });
|
||||
else
|
||||
@@ -138,8 +132,10 @@ namespace Orchard.Autoroute.Settings
|
||||
patterns.RemoveAll(p => string.IsNullOrWhiteSpace(p.Name) && string.IsNullOrWhiteSpace(p.Pattern) && string.IsNullOrWhiteSpace(p.Description));
|
||||
|
||||
// Adding a null culture for the culture neutral pattern
|
||||
var cultures = new List<string>();
|
||||
cultures.Add(null);
|
||||
var cultures = new List<string>
|
||||
{
|
||||
null
|
||||
};
|
||||
cultures.AddRange(settings.SiteCultures);
|
||||
|
||||
//If there is no pattern for some culture create a default one
|
||||
|
||||
@@ -65,11 +65,10 @@ namespace Orchard.ContentPicker.Drivers
|
||||
Field = field,
|
||||
Part = part,
|
||||
ContentItems = _contentManager
|
||||
.GetMany<ContentItem>(ids, VersionOptions.Latest, QueryHints.Empty).ToList()
|
||||
.GetMany<ContentItem>(ids, VersionOptions.Latest, QueryHints.Empty).ToList(),
|
||||
SelectedIds = string.Join(",", ids)
|
||||
};
|
||||
|
||||
model.SelectedIds = string.Join(",", ids);
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Fields/ContentPicker.Edit", Model: model, Prefix: GetPrefix(field, part));
|
||||
});
|
||||
}
|
||||
@@ -101,14 +100,9 @@ namespace Orchard.ContentPicker.Drivers
|
||||
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<ContentPickerFieldSettings>();
|
||||
|
||||
if (string.IsNullOrEmpty(model.SelectedIds))
|
||||
{
|
||||
field.Ids = new int[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
field.Ids = model.SelectedIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
|
||||
}
|
||||
field.Ids = string.IsNullOrEmpty(model.SelectedIds)
|
||||
? (new int[0])
|
||||
: model.SelectedIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
|
||||
|
||||
if (settings.Required && field.Ids.Length == 0)
|
||||
{
|
||||
@@ -126,16 +120,11 @@ namespace Orchard.ContentPicker.Drivers
|
||||
if (element != null)
|
||||
{
|
||||
var contentItemIds = context.Attribute(field.FieldDefinition.Name + "." + field.Name, "ContentItems");
|
||||
if (contentItemIds != null)
|
||||
{
|
||||
field.Ids = contentItemIds.Split(',')
|
||||
field.Ids = contentItemIds != null
|
||||
? contentItemIds.Split(',')
|
||||
.Select(context.GetItemFromSession)
|
||||
.Select(contentItem => contentItem.Id).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
field.Ids = new int[0];
|
||||
}
|
||||
.Select(contentItem => contentItem.Id).ToArray()
|
||||
: (new int[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,8 +149,7 @@ namespace Orchard.ContentPicker.Drivers
|
||||
|
||||
protected override void Describe(DescribeMembersContext context)
|
||||
{
|
||||
context
|
||||
.Member(null, typeof(string), T("Ids"), T("A formatted list of the ids, e.g., {1},{42}"));
|
||||
context.Member(null, typeof(string), T("Ids"), T("A formatted list of the ids, e.g., {1},{42}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,11 +36,10 @@ namespace Orchard.ContentPicker.Drivers
|
||||
{
|
||||
Field = field,
|
||||
Part = part,
|
||||
ContentItems = _contentManager.GetMany<ContentItem>(field.Ids, VersionOptions.Latest, QueryHints.Empty).ToList()
|
||||
ContentItems = _contentManager.GetMany<ContentItem>(field.Ids, VersionOptions.Latest, QueryHints.Empty).ToList(),
|
||||
SelectedIds = string.Join(",", field.Ids)
|
||||
};
|
||||
|
||||
model.SelectedIds = string.Join(",", field.Ids);
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Fields/ContentPickerLocalization.Edit", Model: model, Prefix: GetPrefix(field, part));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -361,8 +361,10 @@ namespace Orchard.Forms.Shapes
|
||||
|
||||
private static string ListItemToOption(SelectListItem item)
|
||||
{
|
||||
var option = new TagBuilder("option");
|
||||
option.InnerHtml = HttpUtility.HtmlEncode(item.Text);
|
||||
var option = new TagBuilder("option")
|
||||
{
|
||||
InnerHtml = HttpUtility.HtmlEncode(item.Text)
|
||||
};
|
||||
|
||||
if (item.Value != null)
|
||||
{
|
||||
|
||||
@@ -92,8 +92,10 @@ namespace Orchard.Localization.Handlers
|
||||
//use cloning
|
||||
foreach (var target in lSet.Select(lp => lp.ContentItem))
|
||||
{
|
||||
var context = new CloneContentContext(localizationPart.ContentItem, target);
|
||||
context.FieldName = field.Name;
|
||||
var context = new CloneContentContext(localizationPart.ContentItem, target)
|
||||
{
|
||||
FieldName = field.Name
|
||||
};
|
||||
fieldDrivers.Invoke(driver => driver.Cloning(context), context.Logger);
|
||||
fieldDrivers.Invoke(driver => driver.Cloned(context), context.Logger);
|
||||
}
|
||||
|
||||
@@ -52,10 +52,9 @@ namespace Orchard.MediaLibrary.Drivers
|
||||
Field = field,
|
||||
Part = part,
|
||||
ContentItems = _contentManager.GetMany<ContentItem>(field.Ids, VersionOptions.Published, QueryHints.Empty).ToList(),
|
||||
SelectedIds = string.Join(",", field.Ids)
|
||||
};
|
||||
|
||||
model.SelectedIds = string.Join(",", field.Ids);
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Fields/MediaLibraryPicker.Edit", Model: model, Prefix: GetPrefix(field, part));
|
||||
});
|
||||
}
|
||||
@@ -68,14 +67,9 @@ namespace Orchard.MediaLibrary.Drivers
|
||||
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<MediaLibraryPickerFieldSettings>();
|
||||
|
||||
if (string.IsNullOrEmpty(model.SelectedIds))
|
||||
{
|
||||
field.Ids = new int[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
field.Ids = model.SelectedIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
|
||||
}
|
||||
field.Ids = string.IsNullOrEmpty(model.SelectedIds)
|
||||
? (new int[0])
|
||||
: model.SelectedIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
|
||||
|
||||
if (settings.Required && field.Ids.Length == 0)
|
||||
{
|
||||
|
||||
@@ -188,10 +188,12 @@ namespace Orchard.MessageBus.Brokers.SqlServer
|
||||
{
|
||||
SqlCommand command = new SqlCommand(commandText, connection);
|
||||
|
||||
SqlParameter param = new SqlParameter("@Id", SqlDbType.Int);
|
||||
param.Direction = ParameterDirection.Input;
|
||||
param.DbType = DbType.Int32;
|
||||
param.Value = lastMessageId;
|
||||
SqlParameter param = new SqlParameter("@Id", SqlDbType.Int)
|
||||
{
|
||||
Direction = ParameterDirection.Input,
|
||||
DbType = DbType.Int32,
|
||||
Value = lastMessageId
|
||||
};
|
||||
command.Parameters.Add(param);
|
||||
|
||||
return command;
|
||||
|
||||
@@ -48,11 +48,12 @@ namespace Orchard.MultiTenancy.Controllers
|
||||
if (!IsExecutingInDefaultTenant())
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var viewModel = new TenantAddViewModel();
|
||||
|
||||
// Fetches all available themes and modules.
|
||||
viewModel.Themes = _tenantService.GetInstalledThemes().Select(x => new ThemeEntry { ThemeId = x.Id, ThemeName = x.Name }).ToList();
|
||||
viewModel.Modules = _tenantService.GetInstalledModules().Select(x => new ModuleEntry { ModuleId = x.Id, ModuleName = x.Name }).ToList();
|
||||
var viewModel = new TenantAddViewModel
|
||||
{
|
||||
// Fetches all available themes and modules.
|
||||
Themes = _tenantService.GetInstalledThemes().Select(x => new ThemeEntry { ThemeId = x.Id, ThemeName = x.Name }).ToList(),
|
||||
Modules = _tenantService.GetInstalledModules().Select(x => new ModuleEntry { ModuleId = x.Id, ModuleName = x.Name }).ToList()
|
||||
};
|
||||
|
||||
return View(viewModel);
|
||||
}
|
||||
@@ -132,10 +133,9 @@ namespace Orchard.MultiTenancy.Controllers
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var tenant = _tenantService.GetTenants().FirstOrDefault(ss => ss.Name == name);
|
||||
if (tenant == null)
|
||||
return HttpNotFound();
|
||||
|
||||
return View(new TenantEditViewModel
|
||||
return tenant == null
|
||||
? HttpNotFound()
|
||||
: (ActionResult)View(new TenantEditViewModel
|
||||
{
|
||||
Name = tenant.Name,
|
||||
RequestUrlHost = tenant.RequestUrlHost,
|
||||
@@ -262,10 +262,9 @@ namespace Orchard.MultiTenancy.Controllers
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var tenant = _tenantService.GetTenants().FirstOrDefault(ss => ss.Name == name);
|
||||
if (tenant == null)
|
||||
return HttpNotFound();
|
||||
|
||||
return View(new TenantResetViewModel()
|
||||
return tenant == null
|
||||
? HttpNotFound()
|
||||
: (ActionResult)View(new TenantResetViewModel()
|
||||
{
|
||||
Name = name,
|
||||
DatabaseTableNames = _tenantService.GetTenantDatabaseTableNames(tenant)
|
||||
|
||||
@@ -61,25 +61,21 @@ namespace Orchard.OutputCache.Services
|
||||
record.Url = cacheItem.Url;
|
||||
}
|
||||
|
||||
private CacheItem Convert(CacheItemRecord record)
|
||||
private CacheItem Convert(CacheItemRecord record) => new CacheItem
|
||||
{
|
||||
var cacheItem = new CacheItem();
|
||||
|
||||
cacheItem.CacheKey = record.CacheKey;
|
||||
cacheItem.CachedOnUtc = record.CachedOnUtc;
|
||||
cacheItem.Duration = record.Duration;
|
||||
cacheItem.GraceTime = record.GraceTime;
|
||||
cacheItem.ContentType = record.ContentType;
|
||||
cacheItem.InvariantCacheKey = record.InvariantCacheKey;
|
||||
cacheItem.Output = record.Output;
|
||||
cacheItem.QueryString = record.QueryString;
|
||||
cacheItem.StatusCode = record.StatusCode;
|
||||
cacheItem.Tags = record.Tags.Split(';');
|
||||
cacheItem.Tenant = record.Tenant;
|
||||
cacheItem.Url = record.Url;
|
||||
|
||||
return cacheItem;
|
||||
}
|
||||
CacheKey = record.CacheKey,
|
||||
CachedOnUtc = record.CachedOnUtc,
|
||||
Duration = record.Duration,
|
||||
GraceTime = record.GraceTime,
|
||||
ContentType = record.ContentType,
|
||||
InvariantCacheKey = record.InvariantCacheKey,
|
||||
Output = record.Output,
|
||||
QueryString = record.QueryString,
|
||||
StatusCode = record.StatusCode,
|
||||
Tags = record.Tags.Split(';'),
|
||||
Tenant = record.Tenant,
|
||||
Url = record.Url
|
||||
};
|
||||
|
||||
public void Remove(string key)
|
||||
{
|
||||
|
||||
@@ -65,8 +65,10 @@ namespace Orchard.Projections.Settings
|
||||
yield break;
|
||||
}
|
||||
|
||||
var model = new ProjectionPartSettings();
|
||||
model.QueryRecordEntries = GetQueriesRecordEntry();
|
||||
var model = new ProjectionPartSettings
|
||||
{
|
||||
QueryRecordEntries = GetQueriesRecordEntry()
|
||||
};
|
||||
|
||||
|
||||
if (updateModel.TryUpdateModel(model, "ProjectionPartSettings", null, null))
|
||||
@@ -287,13 +289,15 @@ namespace Orchard.Projections.Settings
|
||||
// populating the list of queries and layouts
|
||||
var layouts = _projectionManager.DescribeLayouts().SelectMany(x => x.Descriptors).ToList();
|
||||
|
||||
List<QueryRecordEntry> records = new List<QueryRecordEntry>();
|
||||
records.Add(new QueryRecordEntry
|
||||
List<QueryRecordEntry> records = new List<QueryRecordEntry>
|
||||
{
|
||||
Id = -1,
|
||||
Name = T("No default").Text,
|
||||
LayoutRecordEntries = new List<LayoutRecordEntry>()
|
||||
});
|
||||
new QueryRecordEntry
|
||||
{
|
||||
Id = -1,
|
||||
Name = T("No default").Text,
|
||||
LayoutRecordEntries = new List<LayoutRecordEntry>()
|
||||
}
|
||||
};
|
||||
|
||||
records.AddRange(Services.ContentManager.Query<QueryPart, QueryPartRecord>().Join<TitlePartRecord>().OrderBy(x => x.Title).List()
|
||||
.Select(x => new QueryRecordEntry
|
||||
|
||||
@@ -77,10 +77,12 @@ namespace Orchard.Search.Controllers
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(searchText))
|
||||
{
|
||||
var searchableTypes = new List<string>();
|
||||
// add the type to the list of types we will filter for
|
||||
// BlogPost for now but we would add more types in the future (i.e. "Article")
|
||||
searchableTypes.Add("BlogPost");
|
||||
var searchableTypes = new List<string>
|
||||
{
|
||||
// add the type to the list of types we will filter for
|
||||
// BlogPost for now but we would add more types in the future (i.e. "Article")
|
||||
"BlogPost"
|
||||
};
|
||||
var searchBuilder = _indexManager.HasIndexProvider()
|
||||
? _indexManager
|
||||
.GetSearchIndexProvider()
|
||||
|
||||
@@ -160,10 +160,9 @@ namespace Orchard.Taxonomies.Controllers
|
||||
[HttpPost]
|
||||
public ActionResult SelectTerm(int taxonomyId, int selectedTermId)
|
||||
{
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateTerm, T("Not allowed to select terms")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
return RedirectToAction("Create", new { taxonomyId, parentTermId = selectedTermId, ReturnUrl = Url.Action("Index", new { taxonomyId = taxonomyId }) });
|
||||
return !Services.Authorizer.Authorize(Permissions.CreateTerm, T("Not allowed to select terms"))
|
||||
? new HttpUnauthorizedResult()
|
||||
: (ActionResult)RedirectToAction("Create", new { taxonomyId, parentTermId = selectedTermId, ReturnUrl = Url.Action("Index", new { taxonomyId = taxonomyId }) });
|
||||
}
|
||||
|
||||
public ActionResult MoveTerm(int taxonomyId, string termIds)
|
||||
@@ -195,9 +194,11 @@ namespace Orchard.Taxonomies.Controllers
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditTerm, T("Not allowed to move terms")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
MoveTermsContext context = new MoveTermsContext();
|
||||
context.Terms = ResolveTermIds(termIds);
|
||||
context.ParentTerm = _taxonomyService.GetTerm(selectedTermId);
|
||||
MoveTermsContext context = new MoveTermsContext
|
||||
{
|
||||
Terms = ResolveTermIds(termIds),
|
||||
ParentTerm = _taxonomyService.GetTerm(selectedTermId)
|
||||
};
|
||||
_termLocalizationEventHandler.MovingTerms(context);
|
||||
|
||||
var taxonomy = _taxonomyService.GetTaxonomy(taxonomyId);
|
||||
|
||||
@@ -21,11 +21,13 @@ namespace Orchard.Taxonomies.Drivers
|
||||
|
||||
protected override DriverResult Editor(TaxonomyPart part, dynamic shapeHelper)
|
||||
{
|
||||
AssociateTermTypeViewModel model = new AssociateTermTypeViewModel();
|
||||
model.TermTypes = _taxonomyExtensionsService.GetAllTermTypes();
|
||||
model.TermCreationAction = TermCreationOptions.CreateLocalized;
|
||||
model.SelectedTermTypeId = part.TermTypeName;
|
||||
model.ContentItem = part;
|
||||
AssociateTermTypeViewModel model = new AssociateTermTypeViewModel
|
||||
{
|
||||
TermTypes = _taxonomyExtensionsService.GetAllTermTypes(),
|
||||
TermCreationAction = TermCreationOptions.CreateLocalized,
|
||||
SelectedTermTypeId = part.TermTypeName,
|
||||
ContentItem = part
|
||||
};
|
||||
|
||||
return ContentShape("Parts_TaxonomyTermSelector",
|
||||
() => shapeHelper.EditorTemplate(
|
||||
|
||||
@@ -76,8 +76,10 @@ namespace Orchard.ContentManagement
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<int, string> TermsRecordFieldDictionary = new Dictionary<int, string>();
|
||||
TermsRecordFieldDictionary.Add(termRecordId, (string)keyValue[2]);
|
||||
Dictionary<int, string> TermsRecordFieldDictionary = new Dictionary<int, string>
|
||||
{
|
||||
{ termRecordId, (string)keyValue[2] }
|
||||
};
|
||||
termsTermRecordIdsDictionary.Add((int)keyValue[0], TermsRecordFieldDictionary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +119,10 @@ namespace Orchard.ContentManagement
|
||||
// adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit
|
||||
((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType);
|
||||
|
||||
var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable, GetPath());
|
||||
context.Layout = workContext.Layout;
|
||||
var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable, GetPath())
|
||||
{
|
||||
Layout = workContext.Layout
|
||||
};
|
||||
BindPlacement(context, null, stereotype);
|
||||
|
||||
_handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger);
|
||||
|
||||
@@ -210,8 +210,10 @@ namespace Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy
|
||||
if (!routeData.Values.ContainsKey("controller") && !routeData.Values.ContainsKey("Controller"))
|
||||
routeData.Values.Add("controller", controller.GetType().Name.ToLower().Replace("controller", ""));
|
||||
|
||||
controller.ControllerContext = new ControllerContext(httpContext, routeData, controller);
|
||||
controller.ControllerContext.RequestContext = requestContext;
|
||||
controller.ControllerContext = new ControllerContext(httpContext, routeData, controller)
|
||||
{
|
||||
RequestContext = requestContext
|
||||
};
|
||||
return controller.ControllerContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -295,8 +295,10 @@ namespace Orchard.Security.Providers
|
||||
|
||||
private Dictionary<string, string> ComputeUserDataDictionary(IUser user)
|
||||
{
|
||||
var userDataDictionary = new Dictionary<string, string>();
|
||||
userDataDictionary.Add("UserName", user.UserName);
|
||||
var userDataDictionary = new Dictionary<string, string>
|
||||
{
|
||||
{ "UserName", user.UserName }
|
||||
};
|
||||
foreach (var userDataProvider in _userDataProviders)
|
||||
{
|
||||
var key = userDataProvider.Key;
|
||||
|
||||
Reference in New Issue
Block a user