Skip to content

Commit 7ed6bb0

Browse files
Merge pull request #48 from umbraco/v9/feature/port-from-net-framework
Updated to v9/net 5.
2 parents a6d8238 + 8e2430e commit 7ed6bb0

File tree

9 files changed

+92
-96
lines changed

9 files changed

+92
-96
lines changed

src/Umbraco.Deploy.Contrib.Connectors/Properties/VersionInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
[assembly: System.Reflection.AssemblyInformationalVersion("4.0.0")]
12-
[assembly: System.Reflection.AssemblyVersion("4.0.0")]
11+
[assembly: System.Reflection.AssemblyInformationalVersion("9.0.0-beta001")]
12+
[assembly: System.Reflection.AssemblyVersion("9.0.0")]
1313

1414

src/Umbraco.Deploy.Contrib.Connectors/Umbraco.Deploy.Contrib.Connectors.csproj

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@
33
<AssemblyName>Umbraco.Deploy.Contrib.Connectors</AssemblyName>
44
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
55
<RootNamespace>Umbraco.Deploy.Contrib.Connectors</RootNamespace>
6-
<TargetFramework>net472</TargetFramework>
6+
<TargetFramework>net5.0</TargetFramework>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<Content Include="GridCellValueConnectors\dummy.txt" />
11-
</ItemGroup>
12-
13-
<ItemGroup>
14-
<PackageReference Include="UmbracoDeploy.Core">
15-
<Version>4.1.2</Version>
16-
</PackageReference>
10+
<PackageReference Include="Umbraco.Deploy.Core" Version="9.0.0-beta001" />
1711
</ItemGroup>
1812
</Project>

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/BlockEditorValueConnector.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
1+
using Microsoft.Extensions.Logging;
42
using Newtonsoft.Json;
53
using Newtonsoft.Json.Linq;
6-
using Umbraco.Core;
7-
using Umbraco.Core.Deploy;
8-
using Umbraco.Core.Logging;
9-
using Umbraco.Core.Models;
10-
using Umbraco.Core.Services;
11-
using Umbraco.Deploy.Connectors.ValueConnectors.Services;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using Umbraco.Cms.Core.Deploy;
8+
using Umbraco.Cms.Core.Models;
9+
using Umbraco.Cms.Core.Services;
10+
using Umbraco.Deploy.Core.Connectors.ValueConnectors.Services;
11+
using Umbraco.Extensions;
1212

1313
namespace Umbraco.Deploy.Contrib.Connectors.ValueConnectors
1414
{
@@ -19,15 +19,15 @@ public abstract class BlockEditorValueConnector : IValueConnector
1919
{
2020
private readonly IContentTypeService _contentTypeService;
2121
private readonly Lazy<ValueConnectorCollection> _valueConnectorsLazy;
22-
private readonly ILogger _logger;
22+
private readonly ILogger<BlockEditorValueConnector> _logger;
2323

2424
public virtual IEnumerable<string> PropertyEditorAliases => new[] { "Umbraco.BlockEditor" };
2525

2626
// cannot inject ValueConnectorCollection directly as it would cause a circular (recursive) dependency,
2727
// so we have to inject it lazily and use the lazy value when actually needing it
2828
private ValueConnectorCollection ValueConnectors => _valueConnectorsLazy.Value;
2929

30-
public BlockEditorValueConnector(IContentTypeService contentTypeService, Lazy<ValueConnectorCollection> valueConnectors, ILogger logger)
30+
public BlockEditorValueConnector(IContentTypeService contentTypeService, Lazy<ValueConnectorCollection> valueConnectors, ILogger<BlockEditorValueConnector> logger)
3131
{
3232
if (contentTypeService == null) throw new ArgumentNullException(nameof(contentTypeService));
3333
if (valueConnectors == null) throw new ArgumentNullException(nameof(valueConnectors));
@@ -37,35 +37,35 @@ public BlockEditorValueConnector(IContentTypeService contentTypeService, Lazy<Va
3737
_logger = logger;
3838
}
3939

40-
public virtual string ToArtifact(object value, PropertyType propertyType, ICollection<ArtifactDependency> dependencies)
40+
public virtual string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies)
4141
{
42-
_logger.Debug<BlockEditorValueConnector>("Converting {PropertyType} to artifact.", propertyType.Alias);
42+
_logger.LogDebug("Converting {PropertyType} to artifact.", propertyType.Alias);
4343
var svalue = value as string;
4444

4545
// nested values will arrive here as JObject - convert to string to enable reuse of same code as when non-nested.
4646
if (value is JObject)
4747
{
48-
_logger.Debug<BlockListValueConnector>("Value is a JObject - converting to string.");
48+
_logger.LogDebug("Value is a JObject - converting to string.");
4949
svalue = value.ToString();
5050
}
5151

5252
if (string.IsNullOrWhiteSpace(svalue))
5353
{
54-
_logger.Debug<BlockEditorValueConnector>($"Value is null or whitespace. Skipping conversion to artifact.");
54+
_logger.LogDebug($"Value is null or whitespace. Skipping conversion to artifact.");
5555
return null;
5656
}
5757

5858
if (svalue.DetectIsJson() == false)
5959
{
60-
_logger.Warn<BlockListValueConnector>("Value '{Value}' is not a json string. Skipping conversion to artifact.", svalue);
60+
_logger.LogWarning("Value '{Value}' is not a json string. Skipping conversion to artifact.", svalue);
6161
return null;
6262
}
6363

6464
var blockEditorValue = JsonConvert.DeserializeObject<BlockEditorValue>(svalue);
6565

6666
if (blockEditorValue == null)
6767
{
68-
_logger.Warn<BlockEditorValueConnector>("Deserialized value is null. Skipping conversion to artifact.");
68+
_logger.LogWarning("Deserialized value is null. Skipping conversion to artifact.");
6969
return null;
7070
}
7171

@@ -90,7 +90,7 @@ public virtual string ToArtifact(object value, PropertyType propertyType, IColle
9090
//Ensure that these content types have dependencies added
9191
foreach (var contentType in allContentTypes.Values)
9292
{
93-
_logger.Debug<BlockEditorValueConnector>("Adding dependency for content type {ContentType}.", contentType.Alias);
93+
_logger.LogDebug("Adding dependency for content type {ContentType}.", contentType.Alias);
9494
dependencies.Add(new ArtifactDependency(contentType.GetUdi(), false, ArtifactDependencyMode.Match));
9595
}
9696

@@ -106,7 +106,7 @@ public virtual string ToArtifact(object value, PropertyType propertyType, IColle
106106

107107
if (innerPropertyType == null)
108108
{
109-
_logger.Warn<BlockEditorValueConnector>("No property type found with alias {PropertyType} on content type {ContentType}.", key, contentType.Alias);
109+
_logger.LogWarning("No property type found with alias {PropertyType} on content type {ContentType}.", key, contentType.Alias);
110110
continue;
111111
}
112112

@@ -118,7 +118,7 @@ public virtual string ToArtifact(object value, PropertyType propertyType, IColle
118118
var innerValue = block.PropertyValues[key];
119119
object parsedValue = propertyValueConnector.ToArtifact(innerValue, innerPropertyType, dependencies);
120120

121-
_logger.Debug<BlockEditorValueConnector>("Mapped {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropertyValueConnectorType} for {PropertyType}.", key, block.PropertyValues[key], parsedValue, propertyValueConnector.GetType(), innerPropertyType.Alias);
121+
_logger.LogDebug("Mapped {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropertyValueConnectorType} for {PropertyType}.", key, block.PropertyValues[key], parsedValue, propertyValueConnector.GetType(), innerPropertyType.Alias);
122122

123123
parsedValue = parsedValue?.ToString();
124124

@@ -128,13 +128,13 @@ public virtual string ToArtifact(object value, PropertyType propertyType, IColle
128128
}
129129

130130
value = JsonConvert.SerializeObject(blockEditorValue);
131-
_logger.Debug<BlockEditorValueConnector>("Finished converting {PropertyType} to artifact.", propertyType.Alias);
131+
_logger.LogDebug("Finished converting {PropertyType} to artifact.", propertyType.Alias);
132132
return (string) value;
133133
}
134134

135-
public virtual object FromArtifact(string value, PropertyType propertyType, object currentValue)
135+
public virtual object FromArtifact(string value, IPropertyType propertyType, object currentValue)
136136
{
137-
_logger.Debug<BlockEditorValueConnector>("Converting {PropertyType} from artifact.", propertyType.Alias);
137+
_logger.LogDebug("Converting {PropertyType} from artifact.", propertyType.Alias);
138138
if (string.IsNullOrWhiteSpace(value))
139139
{
140140
return value;
@@ -177,7 +177,7 @@ public virtual object FromArtifact(string value, PropertyType propertyType, obje
177177

178178
if (innerPropertyType == null)
179179
{
180-
_logger.Warn<BlockEditorValueConnector>("No property type found with alias {Key} on content type {ContentType}.", key, contentType.Alias);
180+
_logger.LogWarning("No property type found with alias {Key} on content type {ContentType}.", key, contentType.Alias);
181181
continue;
182182
}
183183

@@ -200,18 +200,18 @@ public virtual object FromArtifact(string value, PropertyType propertyType, obje
200200
{
201201
block.PropertyValues[key] = convertedValue;
202202
}
203-
_logger.Debug<BlockEditorValueConnector>("Mapped {Key} value '{PropertyValue}' to '{ConvertedValue}' using {PropertyValueConnectorType} for {PropertyType}.", key, innerValue, convertedValue, propertyValueConnector.GetType(), innerPropertyType.Alias);
203+
_logger.LogDebug("Mapped {Key} value '{PropertyValue}' to '{ConvertedValue}' using {PropertyValueConnectorType} for {PropertyType}.", key, innerValue, convertedValue, propertyValueConnector.GetType(), innerPropertyType.Alias);
204204
}
205205
else
206206
{
207207
block.PropertyValues[key] = innerValue;
208-
_logger.Debug<BlockEditorValueConnector>("{Key} value was null. Setting value as null without conversion.", key);
208+
_logger.LogDebug("{Key} value was null. Setting value as null without conversion.", key);
209209
}
210210
}
211211
}
212212
}
213213

214-
_logger.Debug<BlockEditorValueConnector>("Finished converting {PropertyType} from artifact.", propertyType.Alias);
214+
_logger.LogDebug("Finished converting {PropertyType} from artifact.", propertyType.Alias);
215215

216216
return JObject.FromObject(blockEditorValue);
217217
}

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/BlockListValueConnector.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System;
1+
using Microsoft.Extensions.Logging;
2+
using System;
23
using System.Collections.Generic;
3-
using Umbraco.Core.Logging;
4-
using Umbraco.Core.Services;
5-
using Umbraco.Deploy.Connectors.ValueConnectors.Services;
4+
using Umbraco.Cms.Core.Services;
5+
using Umbraco.Deploy.Core.Connectors.ValueConnectors.Services;
66

77
namespace Umbraco.Deploy.Contrib.Connectors.ValueConnectors
88
{
@@ -13,7 +13,7 @@ public class BlockListValueConnector : BlockEditorValueConnector
1313
{
1414
public override IEnumerable<string> PropertyEditorAliases => new[] { "Umbraco.BlockList" };
1515

16-
public BlockListValueConnector(IContentTypeService contentTypeService, Lazy<ValueConnectorCollection> valueConnectors, ILogger logger)
16+
public BlockListValueConnector(IContentTypeService contentTypeService, Lazy<ValueConnectorCollection> valueConnectors, ILogger<BlockListValueConnector> logger)
1717
: base(contentTypeService, valueConnectors, logger)
1818
{ }
1919
}

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/MultiUrlPickerValueConnector.cs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text.RegularExpressions;
4+
using Microsoft.Extensions.Logging;
45
using Newtonsoft.Json;
56
using Newtonsoft.Json.Linq;
6-
using Umbraco.Core;
7-
using Umbraco.Core.Deploy;
8-
using Umbraco.Core.Logging;
9-
using Umbraco.Core.Models;
10-
using Umbraco.Core.Services;
7+
using Umbraco.Cms.Core;
8+
using Umbraco.Cms.Core.Deploy;
9+
using Umbraco.Cms.Core.Models;
10+
using Umbraco.Cms.Core.PropertyEditors;
11+
using Umbraco.Cms.Core.Services;
12+
using Umbraco.Extensions;
1113

1214
namespace Umbraco.Deploy.Contrib.Connectors.ValueConnectors
1315
{
1416
public class MultiUrlPickerValueConnector : IValueConnector
1517
{
1618
private readonly IEntityService _entityService;
1719
private readonly IMediaService _mediaService;
18-
private readonly ILogger _logger;
20+
private readonly ILogger<MultiUrlPickerValueConnector> _logger;
21+
private readonly MediaUrlGeneratorCollection _mediaUrlGenerators;
1922

2023
// Used to fetch the udi from a umb://-based url
2124
private static readonly Regex MediaUdiSrcRegex = new Regex(@"(?<udi>umb://media/[A-z0-9]+)", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
@@ -40,16 +43,21 @@ public class MultiUrlPickerValueConnector : IValueConnector
4043
/// <param name="entityService">An <see cref="IEntityService"/> implementation.</param>
4144
/// <param name="mediaService"></param>
4245
/// <param name="logger"></param>
43-
public MultiUrlPickerValueConnector(IEntityService entityService, IMediaService mediaService, ILogger logger)
46+
public MultiUrlPickerValueConnector(
47+
IEntityService entityService,
48+
IMediaService mediaService,
49+
ILogger<MultiUrlPickerValueConnector> logger,
50+
MediaUrlGeneratorCollection mediaUrlGenerators)
4451
{
4552
if (entityService == null) throw new ArgumentNullException(nameof(entityService));
4653
if (mediaService == null) throw new ArgumentNullException(nameof(mediaService));
4754
_entityService = entityService;
4855
_mediaService = mediaService;
4956
_logger = logger;
57+
_mediaUrlGenerators = mediaUrlGenerators;
5058
}
5159

52-
public string ToArtifact(object value, PropertyType propertyType, ICollection<ArtifactDependency> dependencies)
60+
public string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies)
5361
{
5462
var svalue = value as string;
5563
if (string.IsNullOrWhiteSpace(svalue))
@@ -92,7 +100,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
92100
}
93101
else if (TryParseJTokenAttr(link, "udi", out guidUdi))
94102
{
95-
var entity = _entityService.Get(guidUdi.Guid, Constants.UdiEntityType.ToUmbracoObjectType(guidUdi.EntityType));
103+
var entity = _entityService.Get(guidUdi.Guid, UdiEntityTypeHelper.ToUmbracoObjectType(guidUdi.EntityType));
96104
if (entity == null)
97105
continue;
98106

@@ -153,7 +161,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
153161
}
154162
else if (TryParseJTokenAttr(link, "udi", out guidUdi))
155163
{
156-
var entity = _entityService.Get(guidUdi.Guid, Constants.UdiEntityType.ToUmbracoObjectType(guidUdi.EntityType));
164+
var entity = _entityService.Get(guidUdi.Guid, UdiEntityTypeHelper.ToUmbracoObjectType(guidUdi.EntityType));
157165
if (entity != null)
158166
{
159167
// Add the artifact dependency
@@ -184,7 +192,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
184192
return string.Empty;
185193
}
186194

187-
public object FromArtifact(string value, PropertyType propertyType, object currentValue)
195+
public object FromArtifact(string value, IPropertyType propertyType, object currentValue)
188196
{
189197
if (string.IsNullOrWhiteSpace(value))
190198
{
@@ -226,12 +234,12 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
226234
{
227235
var udiString = match.Groups["udi"].ToString();
228236
GuidUdi foundUdi;
229-
if (GuidUdi.TryParse(udiString, out foundUdi) && foundUdi.EntityType == Constants.UdiEntityType.Media)
237+
if (UdiParser.TryParse(udiString, out foundUdi) && foundUdi.EntityType == Constants.UdiEntityType.Media)
230238
{
231239
// (take care of nulls)
232240
var media = _mediaService.GetById(foundUdi.Guid);
233241
if (media != null)
234-
return media.GetUrl("umbracoFile", _logger);
242+
return media.GetUrl("umbracoFile", _mediaUrlGenerators);
235243
}
236244
return string.Empty;
237245
});
@@ -271,13 +279,13 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
271279
{
272280
var udiString = match.Groups["udi"].ToString();
273281
GuidUdi foundUdi;
274-
if (GuidUdi.TryParse(udiString, out foundUdi) &&
282+
if (UdiParser.TryParse(udiString, out foundUdi) &&
275283
foundUdi.EntityType == Constants.UdiEntityType.Media)
276284
{
277285
// (take care of nulls)
278286
var media = _mediaService.GetById(foundUdi.Guid);
279287
if (media != null)
280-
return media.GetUrl("umbracoFile", _logger);
288+
return media.GetUrl("umbracoFile", _mediaUrlGenerators);
281289
}
282290

283291
return string.Empty;
@@ -310,7 +318,7 @@ private bool TryParseJTokenAttr(JToken link, string attrName, out GuidUdi attrVa
310318
if (link[attrName] != null)
311319
{
312320
var val = link[attrName].ToString();
313-
return GuidUdi.TryParse(val, out attrValue);
321+
return UdiParser.TryParse(val, out attrValue);
314322
}
315323
attrValue = null;
316324
return false;

0 commit comments

Comments
 (0)