Skip to content

Commit 6bbc551

Browse files
committed
Fix obsolete "As".
1 parent 493e491 commit 6bbc551

8 files changed

Lines changed: 25 additions & 25 deletions

File tree

Lombiq.HelpfulExtensions.Tests.UI/Lombiq.HelpfulExtensions.Tests.UI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</ItemGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="OrchardCore.ContentManagement.Abstractions" Version="3.0.0-preview-18971">
30+
<PackageReference Include="OrchardCore.ContentManagement.Abstractions" Version="3.0.0-preview-18973">
3131
<Aliases>OCCMA</Aliases>
3232
</PackageReference>
3333
</ItemGroup>

Lombiq.HelpfulExtensions/Extensions/Flows/Drivers/AdditionalStylingPartDisplay.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public override IDisplayResult Edit(ContentItem model, BuildEditorContext contex
1717

1818
public override async Task<IDisplayResult> UpdateAsync(ContentItem model, UpdateEditorContext context)
1919
{
20-
var additionalStylingPart = model.As<AdditionalStylingPart>();
20+
var additionalStylingPart = model.GetOrCreate<AdditionalStylingPart>();
2121

2222
if (additionalStylingPart == null)
2323
{
@@ -31,7 +31,7 @@ public override async Task<IDisplayResult> UpdateAsync(ContentItem model, Update
3131

3232
private static void PopulateViewModel(ContentItem model, AdditionalStylingPart viewModel)
3333
{
34-
var additionalStylingPart = model.As<AdditionalStylingPart>();
34+
var additionalStylingPart = model.GetOrCreate<AdditionalStylingPart>();
3535

3636
if (additionalStylingPart != null)
3737
{

Lombiq.HelpfulExtensions/Extensions/OrchardRecipeMigration/Services/ListPartOrchardExportConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ public class ListPartOrchardExportConverter : IOrchardExportConverter
1818
public Task UpdateContentItemsAsync(XDocument document, IList<ContentItem> contentItems)
1919
{
2020
var itemsById = contentItems
21-
.Where(item => !string.IsNullOrEmpty(item.As<OrchardIds>()?.ExportId))
22-
.ToDictionary(item => item.As<OrchardIds>().ExportId);
21+
.Where(item => !string.IsNullOrEmpty(item.GetOrCreate<OrchardIds>()?.ExportId))
22+
.ToDictionary(item => item.GetOrCreate<OrchardIds>().ExportId);
2323

24-
foreach (var item in itemsById.Values.Where(item => !string.IsNullOrEmpty(item.As<OrchardIds>().Parent)))
24+
foreach (var item in itemsById.Values.Where(item => !string.IsNullOrEmpty(item.GetOrCreate<OrchardIds>().Parent)))
2525
{
26-
var parentId = item.As<OrchardIds>().Parent;
26+
var parentId = item.GetOrCreate<OrchardIds>().Parent;
2727
if (!itemsById.TryGetValue(parentId, out var parent) || !parent.Has<ListPart>()) continue;
2828

2929
item.Alter<ContainedPart>(part =>

Lombiq.HelpfulExtensions/Extensions/SiteTexts/Services/ContentLocalizationSiteTextService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public override async Task<HtmlString> RenderHtmlByIdAsync(string contentItemId)
2525
var part = await GetSiteTextMarkdownBodyPartByIdAsync(contentItemId);
2626
var culture = CultureInfo.CurrentCulture.Name;
2727

28-
if (part.As<LocalizationPart>() is { Culture: { } partCulture, LocalizationSet: { } localizationSet } &&
28+
if (part.GetOrCreate<LocalizationPart>() is { Culture: { } partCulture, LocalizationSet: { } localizationSet } &&
2929
partCulture != culture &&
3030
await _contentLocalizationManager.GetContentItemAsync(localizationSet, culture) is { } contentItem &&
31-
contentItem.As<MarkdownBodyPart>() is { } localizedPart)
31+
contentItem.GetOrCreate<MarkdownBodyPart>() is { } localizedPart)
3232
{
3333
part = localizedPart;
3434
}

Lombiq.HelpfulExtensions/Extensions/SiteTexts/Services/SiteTextServiceBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private async Task<MarkdownBodyPart> GetSiteTextMarkdownBodyPartByIdInnerAsync(s
5151
throw new InvalidOperationException($"A content with the ID \"{contentItemId}\" does not exist.");
5252
}
5353

54-
if (contentItem.As<MarkdownBodyPart>() is not { } part)
54+
if (contentItem.GetOrCreate<MarkdownBodyPart>() is not { } part)
5555
{
5656
throw new InvalidOperationException(
5757
$"A content with the ID \"{contentItemId}\" does not have a {nameof(MarkdownBodyPart)}.");

Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@
3232

3333
<ItemGroup>
3434
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="3.0.71" />
35-
<PackageReference Include="OrchardCore.Autoroute" Version="3.0.0-preview-18971" />
36-
<PackageReference Include="OrchardCore.ContentFields" Version="3.0.0-preview-18971" />
37-
<PackageReference Include="OrchardCore.Contents" Version="3.0.0-preview-18971" />
38-
<PackageReference Include="OrchardCore.Flows" Version="3.0.0-preview-18971" />
39-
<PackageReference Include="OrchardCore.Html" Version="3.0.0-preview-18971" />
40-
<PackageReference Include="OrchardCore.Lists" Version="3.0.0-preview-18971" />
41-
<PackageReference Include="OrchardCore.Liquid" Version="3.0.0-preview-18971" />
42-
<PackageReference Include="OrchardCore.Markdown" Version="3.0.0-preview-18971" />
43-
<PackageReference Include="OrchardCore.MetaWeblog.Abstractions" Version="3.0.0-preview-18971" />
44-
<PackageReference Include="OrchardCore.Module.Targets" Version="3.0.0-preview-18971" GeneratePathProperty="true" />
45-
<PackageReference Include="OrchardCore.Rules.Abstractions" Version="3.0.0-preview-18971" />
46-
<PackageReference Include="OrchardCore.Workflows" Version="3.0.0-preview-18971" />
35+
<PackageReference Include="OrchardCore.Autoroute" Version="3.0.0-preview-18973" />
36+
<PackageReference Include="OrchardCore.ContentFields" Version="3.0.0-preview-18973" />
37+
<PackageReference Include="OrchardCore.Contents" Version="3.0.0-preview-18973" />
38+
<PackageReference Include="OrchardCore.Flows" Version="3.0.0-preview-18973" />
39+
<PackageReference Include="OrchardCore.Html" Version="3.0.0-preview-18973" />
40+
<PackageReference Include="OrchardCore.Lists" Version="3.0.0-preview-18973" />
41+
<PackageReference Include="OrchardCore.Liquid" Version="3.0.0-preview-18973" />
42+
<PackageReference Include="OrchardCore.Markdown" Version="3.0.0-preview-18973" />
43+
<PackageReference Include="OrchardCore.MetaWeblog.Abstractions" Version="3.0.0-preview-18973" />
44+
<PackageReference Include="OrchardCore.Module.Targets" Version="3.0.0-preview-18973" GeneratePathProperty="true" />
45+
<PackageReference Include="OrchardCore.Rules.Abstractions" Version="3.0.0-preview-18973" />
46+
<PackageReference Include="OrchardCore.Workflows" Version="3.0.0-preview-18973" />
4747
<PackageReference Include="Scrutor" Version="7.0.0" />
4848
</ItemGroup>
4949

Lombiq.HelpfulExtensions/Views/ContentItemWidget.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@inject IUpdateModelAccessor UpdateModelAccessor
99

1010
@{
11-
if ((Model.ContentItem as ContentItem)?.As<ContentItemWidget>() is not { } part) { return; }
11+
if ((Model.ContentItem as ContentItem)?.GetOrCreate<ContentItemWidget>() is not { } part) { return; }
1212

1313
var ids = part.ContentToDisplay?.ContentItemIds ?? Array.Empty<string>();
1414
var contentItems = await ContentManager.GetAsync(ids);

Lombiq.HelpfulExtensions/Views/Lombiq.HelpfulExtensions.Flows.FlowPart.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
{
1212
var widgetContent = await ContentItemDisplayManager.BuildDisplayAsync(
1313
widget, Model.BuildPartDisplayContext.Updater, Model.BuildPartDisplayContext.DisplayType, Model.BuildPartDisplayContext.GroupId);
14-
var flowMetadata = widget.As<FlowMetadata>();
14+
var flowMetadata = widget.GetOrCreate<FlowMetadata>();
1515

1616
if (flowMetadata != null)
1717
{
18-
var additionalStyling = widget.As<AdditionalStylingPart>();
18+
var additionalStyling = widget.GetOrCreate<AdditionalStylingPart>();
1919

2020
bool removeGridExtensionClasses = false;
2121
if (additionalStyling != null)

0 commit comments

Comments
 (0)