Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a54cdb583 | |||
| d580153c9a |
@@ -39,8 +39,6 @@
|
||||
<dependency id="Serilog.Formatting.Compact.Reader" version="[1.0.3,1.999999)" />
|
||||
<dependency id="Serilog.Settings.AppSettings" version="[2.2.2,2.999999)" />
|
||||
<dependency id="Serilog.Sinks.File" version="[4.0.0,4.999999)" />
|
||||
<dependency id="Serilog.Sinks.Map" version="[1.0.0,1.999999)" />
|
||||
<dependency id="Serilog.Sinks.Async" version="[1.3.0,1.999999)" />
|
||||
<dependency id="Umbraco.SqlServerCE" version="[4.0.0.1,4.999999)" />
|
||||
<dependency id="NPoco" version="[3.9.4,3.999999)" />
|
||||
</group>
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
$uenv=build/build.ps1 -get
|
||||
|
||||
$src = "$($uenv.SolutionRoot)\src"
|
||||
$tmp = $uenv.BuildTemp
|
||||
$out = $uenv.BuildOutput
|
||||
$DocFxJson = "$src\ApiDocs\docfx.json"
|
||||
$DocFxSiteOutput = "$tmp\_site\*.*"
|
||||
|
||||
################ Do the UI docs
|
||||
$uenv.CompileBelle()
|
||||
|
||||
"Moving to Umbraco.Web.UI.Client folder"
|
||||
cd .\src\Umbraco.Web.UI.Client
|
||||
|
||||
"Generating the docs and waiting before executing the next commands"
|
||||
& gulp docs | Out-Null
|
||||
|
||||
# change baseUrl
|
||||
$BaseUrl = "https://our.umbraco.com/apidocs/v8/ui/"
|
||||
$IndexPath = "./docs/api/index.html"
|
||||
(Get-Content $IndexPath).replace('location.href.replace(rUrl, indexFile)', "`'" + $BaseUrl + "`'") | Set-Content $IndexPath
|
||||
|
||||
# zip it
|
||||
& $uenv.BuildEnv.Zip a -tzip -r "$out\ui-docs.zip" "$src\Umbraco.Web.UI.Client\docs\api\*.*"
|
||||
|
||||
|
||||
################ Do the c# docs
|
||||
|
||||
# Build the solution in debug mode
|
||||
$SolutionPath = Join-Path -Path $src -ChildPath "umbraco.sln"
|
||||
#$uenv.CompileUmbraco()
|
||||
|
||||
#restore nuget packages
|
||||
$uenv.RestoreNuGet()
|
||||
|
||||
# run DocFx
|
||||
$DocFx = $uenv.BuildEnv.DocFx
|
||||
|
||||
Write-Host "$DocFxJson"
|
||||
& $DocFx metadata $DocFxJson
|
||||
& $DocFx build $DocFxJson
|
||||
|
||||
# zip it
|
||||
& $uenv.BuildEnv.Zip a -tzip -r "$out\csharp-docs.zip" $DocFxSiteOutput
|
||||
+13
-14
@@ -430,19 +430,16 @@
|
||||
$this.CopyFile("$($this.SolutionRoot)\build\Azure\azuregalleryrelease.ps1", $this.BuildOutput)
|
||||
})
|
||||
|
||||
$ubuild.DefineMethod("PrepareCSharpDocs",
|
||||
$ubuild.DefineMethod("BuildCSharpDocs",
|
||||
{
|
||||
Write-Host "Prepare C# Documentation"
|
||||
Write-Host "Building C# Documentation"
|
||||
|
||||
$src = "$($this.SolutionRoot)\src"
|
||||
$tmp = $this.BuildTemp
|
||||
$out = $this.BuildOutput
|
||||
$tmp = $this.BuildTemp
|
||||
$out = $this.BuildOutput
|
||||
$DocFxJson = Join-Path -Path $src "\ApiDocs\docfx.json"
|
||||
$DocFxSiteOutput = Join-Path -Path $tmp "\_site\*.*"
|
||||
|
||||
|
||||
#restore nuget packages
|
||||
$this.RestoreNuGet()
|
||||
# run DocFx
|
||||
$DocFx = $this.BuildEnv.DocFx
|
||||
|
||||
@@ -453,24 +450,26 @@
|
||||
& $this.BuildEnv.Zip a -tzip -r "$out\csharp-docs.zip" $DocFxSiteOutput
|
||||
})
|
||||
|
||||
$ubuild.DefineMethod("PrepareAngularDocs",
|
||||
$ubuild.DefineMethod("BuildAngularDocs",
|
||||
{
|
||||
Write-Host "Prepare Angular Documentation"
|
||||
Write-Host "Building Angular Documentation"
|
||||
|
||||
$src = "$($this.SolutionRoot)\src"
|
||||
$out = $this.BuildOutput
|
||||
$out = $this.BuildOutput
|
||||
|
||||
$this.CompileBelle()
|
||||
# Check if the solution has been built
|
||||
if (!(Test-Path "$src\Umbraco.Web.UI.Client\node_modules")) {throw "Umbraco needs to be built before generating the Angular Docs"}
|
||||
|
||||
"Moving to Umbraco.Web.UI.Client folder"
|
||||
cd .\src\Umbraco.Web.UI.Client
|
||||
Push-Location "$src\Umbraco.Web.UI.Client"
|
||||
|
||||
"Generating the docs and waiting before executing the next commands"
|
||||
& gulp docs | Out-Null
|
||||
|
||||
Pop-Location
|
||||
|
||||
# change baseUrl
|
||||
$BaseUrl = "https://our.umbraco.com/apidocs/v8/ui/"
|
||||
$IndexPath = "./docs/api/index.html"
|
||||
$IndexPath = "$src\Umbraco.Web.UI.Client\docs\api\index.html"
|
||||
(Get-Content $IndexPath).replace('location.href.replace(rUrl, indexFile)', "`'" + $BaseUrl + "`'") | Set-Content $IndexPath
|
||||
|
||||
# zip it
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Umbraco configuration section which can be used to pass to UmbracoConfiguration.For{T}
|
||||
/// </summary>
|
||||
public interface IUmbracoConfigurationSection
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
public class DatabaseCreationEventArgs : System.ComponentModel.CancelEventArgs{}
|
||||
}
|
||||
@@ -1,761 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Collections;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides object extension methods.
|
||||
/// </summary>
|
||||
public static class ObjectExtensions
|
||||
{
|
||||
|
||||
private static readonly ConcurrentDictionary<Type, Type> NullableGenericCache = new ConcurrentDictionary<Type, Type>();
|
||||
private static readonly ConcurrentDictionary<CompositeTypeTypeKey, TypeConverter> InputTypeConverterCache = new ConcurrentDictionary<CompositeTypeTypeKey, TypeConverter>();
|
||||
private static readonly ConcurrentDictionary<CompositeTypeTypeKey, TypeConverter> DestinationTypeConverterCache = new ConcurrentDictionary<CompositeTypeTypeKey, TypeConverter>();
|
||||
private static readonly ConcurrentDictionary<CompositeTypeTypeKey, bool> AssignableTypeCache = new ConcurrentDictionary<CompositeTypeTypeKey, bool>();
|
||||
private static readonly ConcurrentDictionary<Type, bool> BoolConvertCache = new ConcurrentDictionary<Type, bool>();
|
||||
|
||||
private static readonly char[] NumberDecimalSeparatorsToNormalize = { '.', ',' };
|
||||
private static readonly CustomBooleanTypeConverter CustomBooleanTypeConverter = new CustomBooleanTypeConverter();
|
||||
|
||||
//private static readonly ConcurrentDictionary<Type, Func<object>> ObjectFactoryCache = new ConcurrentDictionary<Type, Func<object>>();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> AsEnumerableOfOne<T>(this T input)
|
||||
{
|
||||
return Enumerable.Repeat(input, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
public static void DisposeIfDisposable(this object input)
|
||||
{
|
||||
if (input is IDisposable disposable)
|
||||
disposable.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a shortcut way of safely casting an input when you cannot guarantee the <typeparamref name="T"/> is
|
||||
/// an instance type (i.e., when the C# AS keyword is not applicable).
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="input">The input.</param>
|
||||
/// <returns></returns>
|
||||
public static T SafeCast<T>(this object input)
|
||||
{
|
||||
if (ReferenceEquals(null, input) || ReferenceEquals(default(T), input)) return default;
|
||||
if (input is T variable) return variable;
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to convert the input object to the output type.
|
||||
/// </summary>
|
||||
/// <remarks>This code is an optimized version of the original Umbraco method</remarks>
|
||||
/// <typeparam name="T">The type to convert to</typeparam>
|
||||
/// <param name="input">The input.</param>
|
||||
/// <returns>The <see cref="Attempt{T}"/></returns>
|
||||
public static Attempt<T> TryConvertTo<T>(this object input)
|
||||
{
|
||||
var result = TryConvertTo(input, typeof(T));
|
||||
|
||||
if (result.Success)
|
||||
return Attempt<T>.Succeed((T)result.Result);
|
||||
|
||||
// just try to cast
|
||||
try
|
||||
{
|
||||
return Attempt<T>.Succeed((T)input);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return Attempt<T>.Fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to convert the input object to the output type.
|
||||
/// </summary>
|
||||
/// <remarks>This code is an optimized version of the original Umbraco method</remarks>
|
||||
/// <param name="input">The input.</param>
|
||||
/// <param name="target">The type to convert to</param>
|
||||
/// <returns>The <see cref="Attempt{Object}"/></returns>
|
||||
public static Attempt<object> TryConvertTo(this object input, Type target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
return Attempt<object>.Fail();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
// Nullable is ok
|
||||
if (target.IsGenericType && GetCachedGenericNullableType(target) != null)
|
||||
{
|
||||
return Attempt<object>.Succeed(null);
|
||||
}
|
||||
|
||||
// Reference types are ok
|
||||
return Attempt<object>.If(target.IsValueType == false, null);
|
||||
}
|
||||
|
||||
var inputType = input.GetType();
|
||||
|
||||
// Easy
|
||||
if (target == typeof(object) || inputType == target)
|
||||
{
|
||||
return Attempt.Succeed(input);
|
||||
}
|
||||
|
||||
// Check for string so that overloaders of ToString() can take advantage of the conversion.
|
||||
if (target == typeof(string))
|
||||
{
|
||||
return Attempt<object>.Succeed(input.ToString());
|
||||
}
|
||||
|
||||
// If we've got a nullable of something, we try to convert directly to that thing.
|
||||
// We cache the destination type and underlying nullable types
|
||||
// Any other generic types need to fall through
|
||||
if (target.IsGenericType)
|
||||
{
|
||||
var underlying = GetCachedGenericNullableType(target);
|
||||
if (underlying != null)
|
||||
{
|
||||
// Special case for empty strings for bools/dates which should return null if an empty string.
|
||||
if (input is string inputString)
|
||||
{
|
||||
// TODO: Why the check against only bool/date when a string is null/empty? In what scenario can we convert to another type when the string is null or empty other than just being null?
|
||||
if (string.IsNullOrEmpty(inputString) && (underlying == typeof(DateTime) || underlying == typeof(bool)))
|
||||
{
|
||||
return Attempt<object>.Succeed(null);
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively call into this method with the inner (not-nullable) type and handle the outcome
|
||||
var inner = input.TryConvertTo(underlying);
|
||||
|
||||
// And if successful, fall on through to rewrap in a nullable; if failed, pass on the exception
|
||||
if (inner.Success)
|
||||
{
|
||||
input = inner.Result; // Now fall on through...
|
||||
}
|
||||
else
|
||||
{
|
||||
return Attempt<object>.Fail(inner.Exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// target is not a generic type
|
||||
|
||||
if (input is string inputString)
|
||||
{
|
||||
// Try convert from string, returns an Attempt if the string could be
|
||||
// processed (either succeeded or failed), else null if we need to try
|
||||
// other methods
|
||||
var result = TryConvertToFromString(inputString, target);
|
||||
if (result.HasValue)
|
||||
{
|
||||
return result.Value;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Do a check for destination type being IEnumerable<T> and source type implementing IEnumerable<T> with
|
||||
// the same 'T', then we'd have to find the extension method for the type AsEnumerable() and execute it.
|
||||
if (GetCachedCanAssign(input, inputType, target))
|
||||
{
|
||||
return Attempt.Succeed(Convert.ChangeType(input, target));
|
||||
}
|
||||
}
|
||||
|
||||
if (target == typeof(bool))
|
||||
{
|
||||
if (GetCachedCanConvertToBoolean(inputType))
|
||||
{
|
||||
return Attempt.Succeed(CustomBooleanTypeConverter.ConvertFrom(input));
|
||||
}
|
||||
}
|
||||
|
||||
var inputConverter = GetCachedSourceTypeConverter(inputType, target);
|
||||
if (inputConverter != null)
|
||||
{
|
||||
return Attempt.Succeed(inputConverter.ConvertTo(input, target));
|
||||
}
|
||||
|
||||
var outputConverter = GetCachedTargetTypeConverter(inputType, target);
|
||||
if (outputConverter != null)
|
||||
{
|
||||
return Attempt.Succeed(outputConverter.ConvertFrom(input));
|
||||
}
|
||||
|
||||
if (target.IsGenericType && GetCachedGenericNullableType(target) != null)
|
||||
{
|
||||
// cannot Convert.ChangeType as that does not work with nullable
|
||||
// input has already been converted to the underlying type - just
|
||||
// return input, there's an implicit conversion from T to T? anyways
|
||||
return Attempt.Succeed(input);
|
||||
}
|
||||
|
||||
// Re-check convertibles since we altered the input through recursion
|
||||
if (input is IConvertible convertible2)
|
||||
{
|
||||
return Attempt.Succeed(Convert.ChangeType(convertible2, target));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return Attempt<object>.Fail(e);
|
||||
}
|
||||
|
||||
return Attempt<object>.Fail();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to convert the input string to the output type.
|
||||
/// </summary>
|
||||
/// <remarks>This code is an optimized version of the original Umbraco method</remarks>
|
||||
/// <param name="input">The input.</param>
|
||||
/// <param name="target">The type to convert to</param>
|
||||
/// <returns>The <see cref="Nullable{Attempt}"/></returns>
|
||||
private static Attempt<object>? TryConvertToFromString(this string input, Type target)
|
||||
{
|
||||
// Easy
|
||||
if (target == typeof(string))
|
||||
{
|
||||
return Attempt<object>.Succeed(input);
|
||||
}
|
||||
|
||||
// Null, empty, whitespaces
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
{
|
||||
if (target == typeof(bool))
|
||||
{
|
||||
// null/empty = bool false
|
||||
return Attempt<object>.Succeed(false);
|
||||
}
|
||||
|
||||
if (target == typeof(DateTime))
|
||||
{
|
||||
// null/empty = min DateTime value
|
||||
return Attempt<object>.Succeed(DateTime.MinValue);
|
||||
}
|
||||
|
||||
// Cannot decide here,
|
||||
// Any of the types below will fail parsing and will return a failed attempt
|
||||
// but anything else will not be processed and will return null
|
||||
// so even though the string is null/empty we have to proceed.
|
||||
}
|
||||
|
||||
// Look for type conversions in the expected order of frequency of use.
|
||||
//
|
||||
// By using a mixture of ordered if statements and switches we can optimize both for
|
||||
// fast conditional checking for most frequently used types and the branching
|
||||
// that does not depend on previous values available to switch statements.
|
||||
if (target.IsPrimitive)
|
||||
{
|
||||
if (target == typeof(int))
|
||||
{
|
||||
if (int.TryParse(input, out var value))
|
||||
{
|
||||
return Attempt<object>.Succeed(value);
|
||||
}
|
||||
|
||||
// Because decimal 100.01m will happily convert to integer 100, it
|
||||
// makes sense that string "100.01" *also* converts to integer 100.
|
||||
var input2 = NormalizeNumberDecimalSeparator(input);
|
||||
return Attempt<object>.If(decimal.TryParse(input2, out var value2), Convert.ToInt32(value2));
|
||||
}
|
||||
|
||||
if (target == typeof(long))
|
||||
{
|
||||
if (long.TryParse(input, out var value))
|
||||
{
|
||||
return Attempt<object>.Succeed(value);
|
||||
}
|
||||
|
||||
// Same as int
|
||||
var input2 = NormalizeNumberDecimalSeparator(input);
|
||||
return Attempt<object>.If(decimal.TryParse(input2, out var value2), Convert.ToInt64(value2));
|
||||
}
|
||||
|
||||
// TODO: Should we do the decimal trick for short, byte, unsigned?
|
||||
|
||||
if (target == typeof(bool))
|
||||
{
|
||||
if (bool.TryParse(input, out var value))
|
||||
{
|
||||
return Attempt<object>.Succeed(value);
|
||||
}
|
||||
|
||||
// Don't declare failure so the CustomBooleanTypeConverter can try
|
||||
return null;
|
||||
}
|
||||
|
||||
// Calling this method directly is faster than any attempt to cache it.
|
||||
switch (Type.GetTypeCode(target))
|
||||
{
|
||||
case TypeCode.Int16:
|
||||
return Attempt<object>.If(short.TryParse(input, out var value), value);
|
||||
|
||||
case TypeCode.Double:
|
||||
var input2 = NormalizeNumberDecimalSeparator(input);
|
||||
return Attempt<object>.If(double.TryParse(input2, out var valueD), valueD);
|
||||
|
||||
case TypeCode.Single:
|
||||
var input3 = NormalizeNumberDecimalSeparator(input);
|
||||
return Attempt<object>.If(float.TryParse(input3, out var valueF), valueF);
|
||||
|
||||
case TypeCode.Char:
|
||||
return Attempt<object>.If(char.TryParse(input, out var valueC), valueC);
|
||||
|
||||
case TypeCode.Byte:
|
||||
return Attempt<object>.If(byte.TryParse(input, out var valueB), valueB);
|
||||
|
||||
case TypeCode.SByte:
|
||||
return Attempt<object>.If(sbyte.TryParse(input, out var valueSb), valueSb);
|
||||
|
||||
case TypeCode.UInt32:
|
||||
return Attempt<object>.If(uint.TryParse(input, out var valueU), valueU);
|
||||
|
||||
case TypeCode.UInt16:
|
||||
return Attempt<object>.If(ushort.TryParse(input, out var valueUs), valueUs);
|
||||
|
||||
case TypeCode.UInt64:
|
||||
return Attempt<object>.If(ulong.TryParse(input, out var valueUl), valueUl);
|
||||
}
|
||||
}
|
||||
else if (target == typeof(Guid))
|
||||
{
|
||||
return Attempt<object>.If(Guid.TryParse(input, out var value), value);
|
||||
}
|
||||
else if (target == typeof(DateTime))
|
||||
{
|
||||
if (DateTime.TryParse(input, out var value))
|
||||
{
|
||||
switch (value.Kind)
|
||||
{
|
||||
case DateTimeKind.Unspecified:
|
||||
case DateTimeKind.Utc:
|
||||
return Attempt<object>.Succeed(value);
|
||||
|
||||
case DateTimeKind.Local:
|
||||
return Attempt<object>.Succeed(value.ToUniversalTime());
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
return Attempt<object>.Fail();
|
||||
}
|
||||
else if (target == typeof(DateTimeOffset))
|
||||
{
|
||||
return Attempt<object>.If(DateTimeOffset.TryParse(input, out var value), value);
|
||||
}
|
||||
else if (target == typeof(TimeSpan))
|
||||
{
|
||||
return Attempt<object>.If(TimeSpan.TryParse(input, out var value), value);
|
||||
}
|
||||
else if (target == typeof(decimal))
|
||||
{
|
||||
var input2 = NormalizeNumberDecimalSeparator(input);
|
||||
return Attempt<object>.If(decimal.TryParse(input2, out var value), value);
|
||||
}
|
||||
else if (input != null && target == typeof(Version))
|
||||
{
|
||||
return Attempt<object>.If(Version.TryParse(input, out var value), value);
|
||||
}
|
||||
|
||||
// E_NOTIMPL IPAddress, BigInteger
|
||||
return null; // we can't decide...
|
||||
}
|
||||
internal static void CheckThrowObjectDisposed(this IDisposable disposable, bool isDisposed, string objectname)
|
||||
{
|
||||
// TODO: Localize this exception
|
||||
if (isDisposed)
|
||||
throw new ObjectDisposedException(objectname);
|
||||
}
|
||||
|
||||
//public enum PropertyNamesCaseType
|
||||
//{
|
||||
// CamelCase,
|
||||
// CaseInsensitive
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Convert an object to a JSON string with camelCase formatting
|
||||
///// </summary>
|
||||
///// <param name="obj"></param>
|
||||
///// <returns></returns>
|
||||
//public static string ToJsonString(this object obj)
|
||||
//{
|
||||
// return obj.ToJsonString(PropertyNamesCaseType.CamelCase);
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Convert an object to a JSON string with the specified formatting
|
||||
///// </summary>
|
||||
///// <param name="obj">The obj.</param>
|
||||
///// <param name="propertyNamesCaseType">Type of the property names case.</param>
|
||||
///// <returns></returns>
|
||||
//public static string ToJsonString(this object obj, PropertyNamesCaseType propertyNamesCaseType)
|
||||
//{
|
||||
// var type = obj.GetType();
|
||||
// var dateTimeStyle = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
// if (type.IsPrimitive || typeof(string).IsAssignableFrom(type))
|
||||
// {
|
||||
// return obj.ToString();
|
||||
// }
|
||||
|
||||
// if (typeof(DateTime).IsAssignableFrom(type) || typeof(DateTimeOffset).IsAssignableFrom(type))
|
||||
// {
|
||||
// return Convert.ToDateTime(obj).ToString(dateTimeStyle);
|
||||
// }
|
||||
|
||||
// var serializer = new JsonSerializer();
|
||||
|
||||
// switch (propertyNamesCaseType)
|
||||
// {
|
||||
// case PropertyNamesCaseType.CamelCase:
|
||||
// serializer.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
// break;
|
||||
// }
|
||||
|
||||
// var dateTimeConverter = new IsoDateTimeConverter
|
||||
// {
|
||||
// DateTimeStyles = System.Globalization.DateTimeStyles.None,
|
||||
// DateTimeFormat = dateTimeStyle
|
||||
// };
|
||||
|
||||
// if (typeof(IDictionary).IsAssignableFrom(type))
|
||||
// {
|
||||
// return JObject.FromObject(obj, serializer).ToString(Formatting.None, dateTimeConverter);
|
||||
// }
|
||||
|
||||
// if (type.IsArray || (typeof(IEnumerable).IsAssignableFrom(type)))
|
||||
// {
|
||||
// return JArray.FromObject(obj, serializer).ToString(Formatting.None, dateTimeConverter);
|
||||
// }
|
||||
|
||||
// return JObject.FromObject(obj, serializer).ToString(Formatting.None, dateTimeConverter);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Converts an object into a dictionary
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="TProperty"></typeparam>
|
||||
/// <typeparam name="TVal"> </typeparam>
|
||||
/// <param name="o"></param>
|
||||
/// <param name="ignoreProperties"></param>
|
||||
/// <returns></returns>
|
||||
public static IDictionary<string, TVal> ToDictionary<T, TProperty, TVal>(this T o, params Expression<Func<T, TProperty>>[] ignoreProperties)
|
||||
{
|
||||
return o.ToDictionary<TVal>(ignoreProperties.Select(e => o.GetPropertyInfo(e)).Select(propInfo => propInfo.Name).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns object into dictionary
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
/// <param name="ignoreProperties">Properties to ignore</param>
|
||||
/// <returns></returns>
|
||||
public static IDictionary<string, TVal> ToDictionary<TVal>(this object o, params string[] ignoreProperties)
|
||||
{
|
||||
if (o != null)
|
||||
{
|
||||
var props = TypeDescriptor.GetProperties(o);
|
||||
var d = new Dictionary<string, TVal>();
|
||||
foreach (var prop in props.Cast<PropertyDescriptor>().Where(x => ignoreProperties.Contains(x.Name) == false))
|
||||
{
|
||||
var val = prop.GetValue(o);
|
||||
if (val != null)
|
||||
{
|
||||
d.Add(prop.Name, (TVal)val);
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
return new Dictionary<string, TVal>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal static string ToDebugString(this object obj, int levels = 0)
|
||||
{
|
||||
if (obj == null) return "{null}";
|
||||
try
|
||||
{
|
||||
if (obj is string)
|
||||
{
|
||||
return "\"{0}\"".InvariantFormat(obj);
|
||||
}
|
||||
if (obj is int || obj is short || obj is long || obj is float || obj is double || obj is bool || obj is int? || obj is short? || obj is long? || obj is float? || obj is double? || obj is bool?)
|
||||
{
|
||||
return "{0}".InvariantFormat(obj);
|
||||
}
|
||||
if (obj is Enum)
|
||||
{
|
||||
return "[{0}]".InvariantFormat(obj);
|
||||
}
|
||||
if (obj is IEnumerable)
|
||||
{
|
||||
var enumerable = (obj as IEnumerable);
|
||||
|
||||
var items = (from object enumItem in enumerable let value = GetEnumPropertyDebugString(enumItem, levels) where value != null select value).Take(10).ToList();
|
||||
|
||||
return items.Any()
|
||||
? "{{ {0} }}".InvariantFormat(string.Join(", ", items))
|
||||
: null;
|
||||
}
|
||||
|
||||
var props = obj.GetType().GetProperties();
|
||||
if ((props.Length == 2) && props[0].Name == "Key" && props[1].Name == "Value" && levels > -2)
|
||||
{
|
||||
try
|
||||
{
|
||||
var key = props[0].GetValue(obj, null) as string;
|
||||
var value = props[1].GetValue(obj, null).ToDebugString(levels - 1);
|
||||
return "{0}={1}".InvariantFormat(key, value);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return "[KeyValuePropertyException]";
|
||||
}
|
||||
}
|
||||
if (levels > -1)
|
||||
{
|
||||
var items =
|
||||
(from propertyInfo in props
|
||||
let value = GetPropertyDebugString(propertyInfo, obj, levels)
|
||||
where value != null
|
||||
select "{0}={1}".InvariantFormat(propertyInfo.Name, value)).ToArray();
|
||||
|
||||
return items.Any()
|
||||
? "[{0}]:{{ {1} }}".InvariantFormat(obj.GetType().Name, String.Join(", ", items))
|
||||
: null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "[Exception:{0}]".InvariantFormat(ex.Message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to serialize the value to an XmlString using ToXmlString
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
internal static Attempt<string> TryConvertToXmlString(this object value, Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
var output = value.ToXmlString(type);
|
||||
return Attempt.Succeed(output);
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
return Attempt<string>.Fail(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an XmlSerialized safe string representation for the value
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="type">The Type can only be a primitive type or Guid and byte[] otherwise an exception is thrown</param>
|
||||
/// <returns></returns>
|
||||
public static string ToXmlString(this object value, Type type)
|
||||
{
|
||||
if (value == null) return string.Empty;
|
||||
if (type == typeof(string)) return (value.ToString().IsNullOrWhiteSpace() ? "" : value.ToString());
|
||||
if (type == typeof(bool)) return XmlConvert.ToString((bool)value);
|
||||
if (type == typeof(byte)) return XmlConvert.ToString((byte)value);
|
||||
if (type == typeof(char)) return XmlConvert.ToString((char)value);
|
||||
if (type == typeof(DateTime)) return XmlConvert.ToString((DateTime)value, XmlDateTimeSerializationMode.Unspecified);
|
||||
if (type == typeof(DateTimeOffset)) return XmlConvert.ToString((DateTimeOffset)value);
|
||||
if (type == typeof(decimal)) return XmlConvert.ToString((decimal)value);
|
||||
if (type == typeof(double)) return XmlConvert.ToString((double)value);
|
||||
if (type == typeof(float)) return XmlConvert.ToString((float)value);
|
||||
if (type == typeof(Guid)) return XmlConvert.ToString((Guid)value);
|
||||
if (type == typeof(int)) return XmlConvert.ToString((int)value);
|
||||
if (type == typeof(long)) return XmlConvert.ToString((long)value);
|
||||
if (type == typeof(sbyte)) return XmlConvert.ToString((sbyte)value);
|
||||
if (type == typeof(short)) return XmlConvert.ToString((short)value);
|
||||
if (type == typeof(TimeSpan)) return XmlConvert.ToString((TimeSpan)value);
|
||||
if (type == typeof(bool)) return XmlConvert.ToString((bool)value);
|
||||
if (type == typeof(uint)) return XmlConvert.ToString((uint)value);
|
||||
if (type == typeof(ulong)) return XmlConvert.ToString((ulong)value);
|
||||
if (type == typeof(ushort)) return XmlConvert.ToString((ushort)value);
|
||||
|
||||
throw new NotSupportedException("Cannot convert type " + type.FullName + " to a string using ToXmlString as it is not supported by XmlConvert");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an XmlSerialized safe string representation for the value and type
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToXmlString<T>(this object value)
|
||||
{
|
||||
return value.ToXmlString(typeof (T));
|
||||
}
|
||||
|
||||
private static string GetEnumPropertyDebugString(object enumItem, int levels)
|
||||
{
|
||||
try
|
||||
{
|
||||
return enumItem.ToDebugString(levels - 1);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return "[GetEnumPartException]";
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetPropertyDebugString(PropertyInfo propertyInfo, object obj, int levels)
|
||||
{
|
||||
try
|
||||
{
|
||||
return propertyInfo.GetValue(obj, null).ToDebugString(levels - 1);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return "[GetPropertyValueException]";
|
||||
}
|
||||
}
|
||||
|
||||
public static Guid AsGuid(this object value)
|
||||
{
|
||||
return value is Guid guid ? guid : Guid.Empty;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static string NormalizeNumberDecimalSeparator(string s)
|
||||
{
|
||||
var normalized = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator[0];
|
||||
return s.ReplaceMany(NumberDecimalSeparatorsToNormalize, normalized);
|
||||
}
|
||||
|
||||
// gets a converter for source, that can convert to target, or null if none exists
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static TypeConverter GetCachedSourceTypeConverter(Type source, Type target)
|
||||
{
|
||||
var key = new CompositeTypeTypeKey(source, target);
|
||||
|
||||
if (InputTypeConverterCache.TryGetValue(key, out var typeConverter))
|
||||
{
|
||||
return typeConverter;
|
||||
}
|
||||
|
||||
var converter = TypeDescriptor.GetConverter(source);
|
||||
if (converter.CanConvertTo(target))
|
||||
{
|
||||
return InputTypeConverterCache[key] = converter;
|
||||
}
|
||||
|
||||
return InputTypeConverterCache[key] = null;
|
||||
}
|
||||
|
||||
// gets a converter for target, that can convert from source, or null if none exists
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static TypeConverter GetCachedTargetTypeConverter(Type source, Type target)
|
||||
{
|
||||
var key = new CompositeTypeTypeKey(source, target);
|
||||
|
||||
if (DestinationTypeConverterCache.TryGetValue(key, out var typeConverter))
|
||||
{
|
||||
return typeConverter;
|
||||
}
|
||||
|
||||
var converter = TypeDescriptor.GetConverter(target);
|
||||
if (converter.CanConvertFrom(source))
|
||||
{
|
||||
return DestinationTypeConverterCache[key] = converter;
|
||||
}
|
||||
|
||||
return DestinationTypeConverterCache[key] = null;
|
||||
}
|
||||
|
||||
// gets the underlying type of a nullable type, or null if the type is not nullable
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static Type GetCachedGenericNullableType(Type type)
|
||||
{
|
||||
if (NullableGenericCache.TryGetValue(type, out var underlyingType))
|
||||
{
|
||||
return underlyingType;
|
||||
}
|
||||
|
||||
if (type.GetGenericTypeDefinition() == typeof(Nullable<>))
|
||||
{
|
||||
Type underlying = Nullable.GetUnderlyingType(type);
|
||||
return NullableGenericCache[type] = underlying;
|
||||
}
|
||||
|
||||
return NullableGenericCache[type] = null;
|
||||
}
|
||||
|
||||
// gets an IConvertible from source to target type, or null if none exists
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static bool GetCachedCanAssign(object input, Type source, Type target)
|
||||
{
|
||||
var key = new CompositeTypeTypeKey(source, target);
|
||||
if (AssignableTypeCache.TryGetValue(key, out var canConvert))
|
||||
{
|
||||
return canConvert;
|
||||
}
|
||||
|
||||
// "object is" is faster than "Type.IsAssignableFrom.
|
||||
// We can use it to very quickly determine whether true/false
|
||||
if (input is IConvertible && target.IsAssignableFrom(source))
|
||||
{
|
||||
return AssignableTypeCache[key] = true;
|
||||
}
|
||||
|
||||
return AssignableTypeCache[key] = false;
|
||||
}
|
||||
|
||||
// determines whether a type can be converted to boolean
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static bool GetCachedCanConvertToBoolean(Type type)
|
||||
{
|
||||
if (BoolConvertCache.TryGetValue(type, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (CustomBooleanTypeConverter.CanConvertFrom(type))
|
||||
{
|
||||
return BoolConvertCache[type] = true;
|
||||
}
|
||||
|
||||
return BoolConvertCache[type] = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core.Persistence
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a mean to express aliases in SELECT Sql statements.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>First register with <c>using static Umbraco.Core.Persistence.NPocoSqlExtensions.Aliaser</c>,
|
||||
/// then use eg <c>Sql{Foo}(x => Alias(x.Id, "id"))</c>.</para>
|
||||
/// </remarks>
|
||||
public static class SqlExtensionsStatics
|
||||
{
|
||||
/// <summary>
|
||||
/// Aliases a field.
|
||||
/// </summary>
|
||||
/// <param name="field">The field to alias.</param>
|
||||
/// <param name="alias">The alias.</param>
|
||||
public static object Alias(object field, string alias) => field;
|
||||
|
||||
/// <summary>
|
||||
/// Produces Sql text.
|
||||
/// </summary>
|
||||
/// <param name="field">The name of the field.</param>
|
||||
/// <param name="expr">A function producing Sql text.</param>
|
||||
public static T SqlText<T>(string field, Func<string, string> expr) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Produces Sql text.
|
||||
/// </summary>
|
||||
/// <param name="field1">The name of the first field.</param>
|
||||
/// <param name="field2">The name of the second field.</param>
|
||||
/// <param name="expr">A function producing Sql text.</param>
|
||||
public static T SqlText<T>(string field1, string field2, Func<string, string, string> expr) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Produces Sql text.
|
||||
/// </summary>
|
||||
/// <param name="field1">The name of the first field.</param>
|
||||
/// <param name="field2">The name of the second field.</param>
|
||||
/// <param name="field3">The name of the third field.</param>
|
||||
/// <param name="expr">A function producing Sql text.</param>
|
||||
public static T SqlText<T>(string field1, string field2, string field3, Func<string, string, string, string> expr) => default;
|
||||
}
|
||||
}
|
||||
@@ -1,558 +0,0 @@
|
||||
using System;
|
||||
#if !NETSTANDARD
|
||||
using System.Globalization;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Permissions;
|
||||
#endif
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
/*
|
||||
Copyright (c) 2013 Max Hauser
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
namespace Semver
|
||||
{
|
||||
/// <summary>
|
||||
/// A semantic version implementation.
|
||||
/// Conforms to v2.0.0 of http://semver.org/
|
||||
/// </summary>
|
||||
#if NETSTANDARD
|
||||
public sealed class SemVersion : IComparable<SemVersion>, IComparable
|
||||
#else
|
||||
[Serializable]
|
||||
public sealed class SemVersion : IComparable<SemVersion>, IComparable, ISerializable
|
||||
#endif
|
||||
{
|
||||
static Regex parseEx =
|
||||
new Regex(@"^(?<major>\d+)" +
|
||||
@"(\.(?<minor>\d+))?" +
|
||||
@"(\.(?<patch>\d+))?" +
|
||||
@"(\-(?<pre>[0-9A-Za-z\-\.]+))?" +
|
||||
@"(\+(?<build>[0-9A-Za-z\-\.]+))?$",
|
||||
#if NETSTANDARD
|
||||
RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture);
|
||||
#else
|
||||
RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.ExplicitCapture);
|
||||
#endif
|
||||
|
||||
#if !NETSTANDARD
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SemVersion" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
private SemVersion(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if (info == null) throw new ArgumentNullException("info");
|
||||
var semVersion = Parse(info.GetString("SemVersion"));
|
||||
Major = semVersion.Major;
|
||||
Minor = semVersion.Minor;
|
||||
Patch = semVersion.Patch;
|
||||
Prerelease = semVersion.Prerelease;
|
||||
Build = semVersion.Build;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SemVersion" /> class.
|
||||
/// </summary>
|
||||
/// <param name="major">The major version.</param>
|
||||
/// <param name="minor">The minor version.</param>
|
||||
/// <param name="patch">The patch version.</param>
|
||||
/// <param name="prerelease">The prerelease version (eg. "alpha").</param>
|
||||
/// <param name="build">The build eg ("nightly.232").</param>
|
||||
public SemVersion(int major, int minor = 0, int patch = 0, string prerelease = "", string build = "")
|
||||
{
|
||||
this.Major = major;
|
||||
this.Minor = minor;
|
||||
this.Patch = patch;
|
||||
|
||||
this.Prerelease = prerelease ?? "";
|
||||
this.Build = build ?? "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SemVersion"/> class.
|
||||
/// </summary>
|
||||
/// <param name="version">The <see cref="System.Version"/> that is used to initialize
|
||||
/// the Major, Minor, Patch and Build properties.</param>
|
||||
public SemVersion(Version version)
|
||||
{
|
||||
if (version == null)
|
||||
throw new ArgumentNullException("version");
|
||||
|
||||
this.Major = version.Major;
|
||||
this.Minor = version.Minor;
|
||||
|
||||
if (version.Revision >= 0)
|
||||
{
|
||||
this.Patch = version.Revision;
|
||||
}
|
||||
|
||||
this.Prerelease = String.Empty;
|
||||
|
||||
if (version.Build > 0)
|
||||
{
|
||||
this.Build = version.Build.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Build = String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the specified string to a semantic version.
|
||||
/// </summary>
|
||||
/// <param name="version">The version string.</param>
|
||||
/// <param name="strict">If set to <c>true</c> minor and patch version are required, else they default to 0.</param>
|
||||
/// <returns>The SemVersion object.</returns>
|
||||
/// <exception cref="System.InvalidOperationException">When a invalid version string is passed.</exception>
|
||||
public static SemVersion Parse(string version, bool strict = false)
|
||||
{
|
||||
var match = parseEx.Match(version);
|
||||
if (!match.Success)
|
||||
throw new ArgumentException("Invalid version.", "version");
|
||||
|
||||
#if NETSTANDARD
|
||||
var major = int.Parse(match.Groups["major"].Value);
|
||||
#else
|
||||
var major = int.Parse(match.Groups["major"].Value, CultureInfo.InvariantCulture);
|
||||
#endif
|
||||
|
||||
var minorMatch = match.Groups["minor"];
|
||||
int minor = 0;
|
||||
if (minorMatch.Success)
|
||||
{
|
||||
#if NETSTANDARD
|
||||
minor = int.Parse(minorMatch.Value);
|
||||
#else
|
||||
minor = int.Parse(minorMatch.Value, CultureInfo.InvariantCulture);
|
||||
#endif
|
||||
}
|
||||
else if (strict)
|
||||
{
|
||||
throw new InvalidOperationException("Invalid version (no minor version given in strict mode)");
|
||||
}
|
||||
|
||||
var patchMatch = match.Groups["patch"];
|
||||
int patch = 0;
|
||||
if (patchMatch.Success)
|
||||
{
|
||||
#if NETSTANDARD
|
||||
patch = int.Parse(patchMatch.Value);
|
||||
#else
|
||||
patch = int.Parse(patchMatch.Value, CultureInfo.InvariantCulture);
|
||||
#endif
|
||||
}
|
||||
else if (strict)
|
||||
{
|
||||
throw new InvalidOperationException("Invalid version (no patch version given in strict mode)");
|
||||
}
|
||||
|
||||
var prerelease = match.Groups["pre"].Value;
|
||||
var build = match.Groups["build"].Value;
|
||||
|
||||
return new SemVersion(major, minor, patch, prerelease, build);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the specified string to a semantic version.
|
||||
/// </summary>
|
||||
/// <param name="version">The version string.</param>
|
||||
/// <param name="semver">When the method returns, contains a SemVersion instance equivalent
|
||||
/// to the version string passed in, if the version string was valid, or <c>null</c> if the
|
||||
/// version string was not valid.</param>
|
||||
/// <param name="strict">If set to <c>true</c> minor and patch version are required, else they default to 0.</param>
|
||||
/// <returns><c>False</c> when a invalid version string is passed, otherwise <c>true</c>.</returns>
|
||||
public static bool TryParse(string version, out SemVersion semver, bool strict = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
semver = Parse(version, strict);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
semver = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the specified versions for equality.
|
||||
/// </summary>
|
||||
/// <param name="versionA">The first version.</param>
|
||||
/// <param name="versionB">The second version.</param>
|
||||
/// <returns>If versionA is equal to versionB <c>true</c>, else <c>false</c>.</returns>
|
||||
public static bool Equals(SemVersion versionA, SemVersion versionB)
|
||||
{
|
||||
if (ReferenceEquals(versionA, null))
|
||||
return ReferenceEquals(versionB, null);
|
||||
return versionA.Equals(versionB);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares the specified versions.
|
||||
/// </summary>
|
||||
/// <param name="versionA">The version to compare to.</param>
|
||||
/// <param name="versionB">The version to compare against.</param>
|
||||
/// <returns>If versionA < versionB <c>< 0</c>, if versionA > versionB <c>> 0</c>,
|
||||
/// if versionA is equal to versionB <c>0</c>.</returns>
|
||||
public static int Compare(SemVersion versionA, SemVersion versionB)
|
||||
{
|
||||
if (ReferenceEquals(versionA, null))
|
||||
return ReferenceEquals(versionB, null) ? 0 : -1;
|
||||
return versionA.CompareTo(versionB);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make a copy of the current instance with optional altered fields.
|
||||
/// </summary>
|
||||
/// <param name="major">The major version.</param>
|
||||
/// <param name="minor">The minor version.</param>
|
||||
/// <param name="patch">The patch version.</param>
|
||||
/// <param name="prerelease">The prerelease text.</param>
|
||||
/// <param name="build">The build text.</param>
|
||||
/// <returns>The new version object.</returns>
|
||||
public SemVersion Change(int? major = null, int? minor = null, int? patch = null,
|
||||
string prerelease = null, string build = null)
|
||||
{
|
||||
return new SemVersion(
|
||||
major ?? this.Major,
|
||||
minor ?? this.Minor,
|
||||
patch ?? this.Patch,
|
||||
prerelease ?? this.Prerelease,
|
||||
build ?? this.Build);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the major version.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The major version.
|
||||
/// </value>
|
||||
public int Major { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minor version.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The minor version.
|
||||
/// </value>
|
||||
public int Minor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the patch version.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The patch version.
|
||||
/// </value>
|
||||
public int Patch { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pre-release version.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The pre-release version.
|
||||
/// </value>
|
||||
public string Prerelease { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the build version.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The build version.
|
||||
/// </value>
|
||||
public string Build { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String" /> that represents this instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="System.String" /> that represents this instance.
|
||||
/// </returns>
|
||||
public override string ToString()
|
||||
{
|
||||
var version = "" + Major + "." + Minor + "." + Patch;
|
||||
if (!String.IsNullOrEmpty(Prerelease))
|
||||
version += "-" + Prerelease;
|
||||
if (!String.IsNullOrEmpty(Build))
|
||||
version += "+" + Build;
|
||||
return version;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares the current instance with another object of the same type and returns an integer that indicates
|
||||
/// whether the current instance precedes, follows, or occurs in the same position in the sort order as the
|
||||
/// other object.
|
||||
/// </summary>
|
||||
/// <param name="obj">An object to compare with this instance.</param>
|
||||
/// <returns>
|
||||
/// A value that indicates the relative order of the objects being compared.
|
||||
/// The return value has these meanings: Value Meaning Less than zero
|
||||
/// This instance precedes <paramref name="obj" /> in the sort order.
|
||||
/// Zero This instance occurs in the same position in the sort order as <paramref name="obj" />. i
|
||||
/// Greater than zero This instance follows <paramref name="obj" /> in the sort order.
|
||||
/// </returns>
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
return CompareTo((SemVersion)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares the current instance with another object of the same type and returns an integer that indicates
|
||||
/// whether the current instance precedes, follows, or occurs in the same position in the sort order as the
|
||||
/// other object.
|
||||
/// </summary>
|
||||
/// <param name="other">An object to compare with this instance.</param>
|
||||
/// <returns>
|
||||
/// A value that indicates the relative order of the objects being compared.
|
||||
/// The return value has these meanings: Value Meaning Less than zero
|
||||
/// This instance precedes <paramref name="other" /> in the sort order.
|
||||
/// Zero This instance occurs in the same position in the sort order as <paramref name="other" />. i
|
||||
/// Greater than zero This instance follows <paramref name="other" /> in the sort order.
|
||||
/// </returns>
|
||||
public int CompareTo(SemVersion other)
|
||||
{
|
||||
if (ReferenceEquals(other, null))
|
||||
return 1;
|
||||
|
||||
var r = this.CompareByPrecedence(other);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = CompareComponent(this.Build, other.Build);
|
||||
return r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information.
|
||||
/// </summary>
|
||||
/// <param name="other">The semantic version.</param>
|
||||
/// <returns><c>true</c> if the version precedence matches.</returns>
|
||||
public bool PrecedenceMatches(SemVersion other)
|
||||
{
|
||||
return CompareByPrecedence(other) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information.
|
||||
/// </summary>
|
||||
/// <param name="other">The semantic version.</param>
|
||||
/// <returns>
|
||||
/// A value that indicates the relative order of the objects being compared.
|
||||
/// The return value has these meanings: Value Meaning Less than zero
|
||||
/// This instance precedes <paramref name="other" /> in the version precedence.
|
||||
/// Zero This instance has the same precedence as <paramref name="other" />. i
|
||||
/// Greater than zero This instance has creater precedence as <paramref name="other" />.
|
||||
/// </returns>
|
||||
public int CompareByPrecedence(SemVersion other)
|
||||
{
|
||||
if (ReferenceEquals(other, null))
|
||||
return 1;
|
||||
|
||||
var r = this.Major.CompareTo(other.Major);
|
||||
if (r != 0) return r;
|
||||
|
||||
r = this.Minor.CompareTo(other.Minor);
|
||||
if (r != 0) return r;
|
||||
|
||||
r = this.Patch.CompareTo(other.Patch);
|
||||
if (r != 0) return r;
|
||||
|
||||
r = CompareComponent(this.Prerelease, other.Prerelease, true);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int CompareComponent(string a, string b, bool lower = false)
|
||||
{
|
||||
var aEmpty = String.IsNullOrEmpty(a);
|
||||
var bEmpty = String.IsNullOrEmpty(b);
|
||||
if (aEmpty && bEmpty)
|
||||
return 0;
|
||||
|
||||
if (aEmpty)
|
||||
return lower ? 1 : -1;
|
||||
if (bEmpty)
|
||||
return lower ? -1 : 1;
|
||||
|
||||
var aComps = a.Split('.');
|
||||
var bComps = b.Split('.');
|
||||
|
||||
var minLen = Math.Min(aComps.Length, bComps.Length);
|
||||
for (int i = 0; i < minLen; i++)
|
||||
{
|
||||
var ac = aComps[i];
|
||||
var bc = bComps[i];
|
||||
int anum, bnum;
|
||||
var isanum = Int32.TryParse(ac, out anum);
|
||||
var isbnum = Int32.TryParse(bc, out bnum);
|
||||
int r;
|
||||
if (isanum && isbnum)
|
||||
{
|
||||
r = anum.CompareTo(bnum);
|
||||
if (r != 0) return anum.CompareTo(bnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isanum)
|
||||
return -1;
|
||||
if (isbnum)
|
||||
return 1;
|
||||
r = String.CompareOrdinal(ac, bc);
|
||||
if (r != 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return aComps.Length.CompareTo(bComps.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="System.Object" /> is equal to this instance.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(obj, null))
|
||||
return false;
|
||||
|
||||
if (ReferenceEquals(this, obj))
|
||||
return true;
|
||||
|
||||
var other = (SemVersion)obj;
|
||||
|
||||
return this.Major == other.Major &&
|
||||
this.Minor == other.Minor &&
|
||||
this.Patch == other.Patch &&
|
||||
string.Equals(this.Prerelease, other.Prerelease, StringComparison.Ordinal) &&
|
||||
string.Equals(this.Build, other.Build, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hash code for this instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
|
||||
/// </returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
int result = this.Major.GetHashCode();
|
||||
result = result * 31 + this.Minor.GetHashCode();
|
||||
result = result * 31 + this.Patch.GetHashCode();
|
||||
result = result * 31 + this.Prerelease.GetHashCode();
|
||||
result = result * 31 + this.Build.GetHashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#if !NETSTANDARD
|
||||
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if (info == null) throw new ArgumentNullException("info");
|
||||
info.AddValue("SemVersion", ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Implicit conversion from string to SemVersion.
|
||||
/// </summary>
|
||||
/// <param name="version">The semantic version.</param>
|
||||
/// <returns>The SemVersion object.</returns>
|
||||
public static implicit operator SemVersion(string version)
|
||||
{
|
||||
return SemVersion.Parse(version);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The override of the equals operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left value.</param>
|
||||
/// <param name="right">The right value.</param>
|
||||
/// <returns>If left is equal to right <c>true</c>, else <c>false</c>.</returns>
|
||||
public static bool operator ==(SemVersion left, SemVersion right)
|
||||
{
|
||||
return SemVersion.Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The override of the un-equal operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left value.</param>
|
||||
/// <param name="right">The right value.</param>
|
||||
/// <returns>If left is not equal to right <c>true</c>, else <c>false</c>.</returns>
|
||||
public static bool operator !=(SemVersion left, SemVersion right)
|
||||
{
|
||||
return !SemVersion.Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The override of the greater operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left value.</param>
|
||||
/// <param name="right">The right value.</param>
|
||||
/// <returns>If left is greater than right <c>true</c>, else <c>false</c>.</returns>
|
||||
public static bool operator >(SemVersion left, SemVersion right)
|
||||
{
|
||||
return SemVersion.Compare(left, right) > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The override of the greater than or equal operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left value.</param>
|
||||
/// <param name="right">The right value.</param>
|
||||
/// <returns>If left is greater than or equal to right <c>true</c>, else <c>false</c>.</returns>
|
||||
public static bool operator >=(SemVersion left, SemVersion right)
|
||||
{
|
||||
return left == right || left > right;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The override of the less operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left value.</param>
|
||||
/// <param name="right">The right value.</param>
|
||||
/// <returns>If left is less than right <c>true</c>, else <c>false</c>.</returns>
|
||||
public static bool operator <(SemVersion left, SemVersion right)
|
||||
{
|
||||
return SemVersion.Compare(left, right) < 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The override of the less than or equal operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left value.</param>
|
||||
/// <param name="right">The right value.</param>
|
||||
/// <returns>If left is less than or equal to right <c>true</c>, else <c>false</c>.</returns>
|
||||
public static bool operator <=(SemVersion left, SemVersion right)
|
||||
{
|
||||
return left == right || left < right;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<RootNamespace>Umbraco.Core</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
+3
-1
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
public static class AssemblyExtensions
|
||||
internal static class AssemblyExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the file used to load the assembly
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Core
|
||||
// been closed, the Semaphore system object is destroyed - so in any case
|
||||
// an iisreset should clean up everything
|
||||
//
|
||||
public class AsyncLock
|
||||
internal class AsyncLock
|
||||
{
|
||||
private readonly SemaphoreSlim _semaphore;
|
||||
private readonly Semaphore _semaphore2;
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
using Umbraco.Core;
|
||||
|
||||
// no binding redirect for now = de-activate
|
||||
//[assembly: PreApplicationStartMethod(typeof(BindingRedirects), "Initialize")]
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages any assembly binding redirects that cannot be done via config (i.e. unsigned --> signed assemblies)
|
||||
/// </summary>
|
||||
public sealed class BindingRedirects
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
// this only gets called when an assembly can't be resolved
|
||||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used to do an assembly binding redirect via code - normally required due to signature changes in assemblies
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
||||
{
|
||||
// When an assembly can't be resolved. In here we can do magic with the assembly name and try loading another.
|
||||
|
||||
// keep here for reference - we don't use AutoMapper
|
||||
/*
|
||||
//AutoMapper:
|
||||
// this is used for loading a signed assembly of AutoMapper (v. 3.1+) without having to recompile old code.
|
||||
// ensure the assembly is indeed AutoMapper and that the PublicKeyToken is null before trying to Load again
|
||||
// do NOT just replace this with 'return Assembly', as it will cause an infinite loop -> stackoverflow
|
||||
if (args.Name.StartsWith("AutoMapper") && args.Name.EndsWith("PublicKeyToken=null"))
|
||||
return Assembly.Load(args.Name.Replace(", PublicKeyToken=null", ", PublicKeyToken=be96cd2c38ef1005"));
|
||||
*/
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ namespace Umbraco.Core.Cache
|
||||
/// This is much better for performance when we're not running in a load balanced environment so we can refresh the cache
|
||||
/// against a already resolved object instead of looking the object back up by id.
|
||||
/// </remarks>
|
||||
public interface ICacheRefresher<T> : ICacheRefresher
|
||||
interface ICacheRefresher<T> : ICacheRefresher
|
||||
{
|
||||
void Refresh(T instance);
|
||||
void Remove(T instance);
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
/// <summary>
|
||||
/// A cache refresher that supports refreshing or removing cache based on a custom Json payload
|
||||
/// </summary>
|
||||
public interface IJsonCacheRefresher : ICacheRefresher
|
||||
interface IJsonCacheRefresher : ICacheRefresher
|
||||
{
|
||||
/// <summary>
|
||||
/// Refreshes, clears, etc... any cache based on the information provided in the json
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
/// <summary>
|
||||
/// A cache refresher that supports refreshing cache based on a custom payload
|
||||
/// </summary>
|
||||
public interface IPayloadCacheRefresher<TPayload> : IJsonCacheRefresher
|
||||
interface IPayloadCacheRefresher<TPayload> : IJsonCacheRefresher
|
||||
{
|
||||
/// <summary>
|
||||
/// Refreshes, clears, etc... any cache based on the information provided in the payload
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace Umbraco.Core.CodeAnnotations
|
||||
/// Attribute to add a Friendly Name string with an UmbracoObjectType enum value
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = false)]
|
||||
public class FriendlyNameAttribute : Attribute
|
||||
internal class FriendlyNameAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// friendly name value
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace Umbraco.Core.CodeAnnotations
|
||||
/// Attribute to associate a GUID string and Type with an UmbracoObjectType Enum value
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
|
||||
public class UmbracoObjectTypeAttribute : Attribute
|
||||
internal class UmbracoObjectTypeAttribute : Attribute
|
||||
{
|
||||
public UmbracoObjectTypeAttribute(string objectId)
|
||||
{
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
namespace Umbraco.Core.CodeAnnotations
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
|
||||
public class UmbracoUdiTypeAttribute : Attribute
|
||||
internal class UmbracoUdiTypeAttribute : Attribute
|
||||
{
|
||||
public string UdiType { get; private set; }
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ namespace Umbraco.Core.Collections
|
||||
/// <summary>
|
||||
/// Represents a composite key of (Type, Type) for fast dictionaries.
|
||||
/// </summary>
|
||||
public struct CompositeTypeTypeKey : IEquatable<CompositeTypeTypeKey>
|
||||
internal struct CompositeTypeTypeKey : IEquatable<CompositeTypeTypeKey>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CompositeTypeTypeKey"/> struct.
|
||||
+1
-1
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Collections
|
||||
/// A List that can be deep cloned with deep cloned elements and can reset the collection's items dirty flags
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class DeepCloneableList<T> : List<T>, IDeepCloneable, IRememberBeingDirty
|
||||
internal class DeepCloneableList<T> : List<T>, IDeepCloneable, IRememberBeingDirty
|
||||
{
|
||||
private readonly ListCloneBehavior _listCloneBehavior;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace Umbraco.Core.Collections
|
||||
{
|
||||
public enum ListCloneBehavior
|
||||
internal enum ListCloneBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// When set, DeepClone will clone the items one time and the result list behavior will be None
|
||||
+1
-1
@@ -7,7 +7,7 @@ namespace Umbraco.Core.Collections
|
||||
/// and is customizable to keep the newest or oldest equatable item
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class OrderedHashSet<T> : KeyedCollection<T, T>
|
||||
internal class OrderedHashSet<T> : KeyedCollection<T, T>
|
||||
{
|
||||
private readonly bool _keepOldest;
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ namespace Umbraco.Core.Collections
|
||||
/// </summary>
|
||||
/// <remarks>Types in the list are, or derive from, or implement, the base type.</remarks>
|
||||
/// <typeparam name="TBase">The base type.</typeparam>
|
||||
public class TypeList<TBase>
|
||||
internal class TypeList<TBase>
|
||||
{
|
||||
private readonly List<Type> _list = new List<Type>();
|
||||
|
||||
@@ -30,4 +30,4 @@ namespace Umbraco.Core.Collections
|
||||
return _list.Contains(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Composing
|
||||
/// A utility class for type checking, this provides internal caching so that calls to these methods will be faster
|
||||
/// than doing a manual type check in c#
|
||||
/// </summary>
|
||||
public static class TypeHelper
|
||||
internal static class TypeHelper
|
||||
{
|
||||
private static readonly ConcurrentDictionary<Tuple<Type, bool, bool, bool>, PropertyInfo[]> GetPropertiesCache
|
||||
= new ConcurrentDictionary<Tuple<Type, bool, bool, bool>, PropertyInfo[]>();
|
||||
@@ -25,7 +25,7 @@ namespace Umbraco.Core.Composing
|
||||
/// Based on a type we'll check if it is IEnumerable{T} (or similar) and if so we'll return a List{T}, this will also deal with array types and return List{T} for those too.
|
||||
/// If it cannot be done, null is returned.
|
||||
/// </summary>
|
||||
public static IList CreateGenericEnumerableFromObject(object obj)
|
||||
internal static IList CreateGenericEnumerableFromObject(object obj)
|
||||
{
|
||||
var type = obj.GetType();
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace Umbraco.Core.Composing
|
||||
return MatchType(implementation, contract, new Dictionary<string, Type>());
|
||||
}
|
||||
|
||||
public static bool MatchType(Type implementation, Type contract, IDictionary<string, Type> bindings, bool variance = true)
|
||||
internal static bool MatchType(Type implementation, Type contract, IDictionary<string, Type> bindings, bool variance = true)
|
||||
{
|
||||
if (contract.IsGenericType)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ namespace Umbraco.Core.Configuration
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_stringEnumerator.DisposeIfDisposable();
|
||||
ObjectExtensions.DisposeIfDisposable(_stringEnumerator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Umbraco.Core.Configuration.Grid
|
||||
{
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Umbraco configuration section which can be used to pass to UmbracoConfiguration.For{T}
|
||||
/// </summary>
|
||||
public interface IUmbracoConfigurationSection
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents an Umbraco section within the configuration file.
|
||||
/// </summary>
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace Umbraco.Core
|
||||
/// <summary>
|
||||
/// Allows for converting string representations of 0 and 1 to boolean
|
||||
/// </summary>
|
||||
public class CustomBooleanTypeConverter : BooleanConverter
|
||||
internal class CustomBooleanTypeConverter : BooleanConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
namespace Umbraco.Core.Dashboards
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.Manifest;
|
||||
|
||||
namespace Umbraco.Core.Dashboards
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an access rule.
|
||||
+11
-3
@@ -1,15 +1,23 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Static and extension methods for the DataTable object
|
||||
/// </summary>
|
||||
public static class DataTableExtensions
|
||||
internal static class DataTableExtensions
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a DataTable with the specified alias and columns and uses a callback to populate the headers.
|
||||
/// </summary>
|
||||
@@ -57,7 +65,7 @@ namespace Umbraco.Core
|
||||
/// <remarks>
|
||||
/// This is for legacy code, I didn't want to go creating custom classes for these
|
||||
/// </remarks>
|
||||
public static List<System.Tuple<IEnumerable<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>>> CreateTableData()
|
||||
internal static List<System.Tuple<IEnumerable<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>>> CreateTableData()
|
||||
{
|
||||
return new List<System.Tuple<IEnumerable<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>>>();
|
||||
}
|
||||
@@ -71,7 +79,7 @@ namespace Umbraco.Core
|
||||
/// <remarks>
|
||||
/// This is for legacy code, I didn't want to go creating custom classes for these
|
||||
/// </remarks>
|
||||
public static void AddRowData(
|
||||
internal static void AddRowData(
|
||||
List<System.Tuple<IEnumerable<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>>> rowData,
|
||||
IEnumerable<KeyValuePair<string, object>> standardVals,
|
||||
IEnumerable<KeyValuePair<string, object>> userVals)
|
||||
+1
-1
@@ -12,7 +12,7 @@ namespace Umbraco.Core
|
||||
///<summary>
|
||||
/// Extension methods for Dictionary & ConcurrentDictionary
|
||||
///</summary>
|
||||
public static class DictionaryExtensions
|
||||
internal static class DictionaryExtensions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@@ -1,7 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Events;
|
||||
|
||||
|
||||
+1
-39
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
@@ -9,45 +10,6 @@ namespace Umbraco.Core
|
||||
///</summary>
|
||||
public static class EnumerableExtensions
|
||||
{
|
||||
// based upon the original Zip<T1, T2, TResult> method
|
||||
public static IEnumerable<TResult> Zip<T1, T2, T3, TResult>(this IEnumerable<T1> e1, IEnumerable<T2> e2, IEnumerable<T3> e3,
|
||||
Func<T1, T2, T3, TResult> resultSelector)
|
||||
{
|
||||
if (e1 == null) throw new ArgumentNullException("e1");
|
||||
if (e2 == null) throw new ArgumentNullException("e2");
|
||||
if (e3 == null) throw new ArgumentNullException("e3");
|
||||
if (resultSelector == null) throw new ArgumentNullException("resultSelector");
|
||||
return ZipIterator(e1, e2, e3, resultSelector);
|
||||
}
|
||||
|
||||
private static IEnumerable<TResult> ZipIterator<T1, T2, T3, TResult>(IEnumerable<T1> ie1, IEnumerable<T2> ie2, IEnumerable<T3> ie3,
|
||||
Func<T1, T2, T3, TResult> resultSelector)
|
||||
{
|
||||
var e1 = ie1.GetEnumerator();
|
||||
try
|
||||
{
|
||||
var e2 = ie2.GetEnumerator();
|
||||
var e3 = ie3.GetEnumerator();
|
||||
try
|
||||
{
|
||||
while (e1.MoveNext() && e2.MoveNext() && e3.MoveNext())
|
||||
yield return resultSelector(e1.Current, e2.Current, e3.Current);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (e2 != null)
|
||||
e2.Dispose();
|
||||
if (e3 != null)
|
||||
e3.Dispose();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (e1 != null)
|
||||
e1.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool HasDuplicates<T>(this IEnumerable<T> items, bool includeNull)
|
||||
{
|
||||
var hs = new HashSet<T>();
|
||||
+2
-2
@@ -96,7 +96,7 @@ namespace Umbraco.Core.Events
|
||||
/// This allows for a bit of flexibility in our event raising - it's not pretty but we need to maintain backwards compatibility
|
||||
/// so we cannot change the strongly typed nature for some events.
|
||||
/// </remarks>
|
||||
public ReadOnlyDictionary<string, object> AdditionalData { get; set; }
|
||||
public ReadOnlyDictionary<string, object> AdditionalData { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// This can be used by event subscribers to store state in the event args so they easily deal with custom state data between a starting ("ing")
|
||||
@@ -105,7 +105,7 @@ namespace Umbraco.Core.Events
|
||||
public IDictionary<string, object> EventState
|
||||
{
|
||||
get => _eventState ?? (_eventState = new Dictionary<string, object>());
|
||||
set => _eventState = value;
|
||||
internal set => _eventState = value;
|
||||
}
|
||||
|
||||
public bool Equals(CancellableEventArgs other)
|
||||
+1
-1
@@ -41,6 +41,6 @@ namespace Umbraco.Core.Events
|
||||
/// <remarks>
|
||||
/// This is protected so that inheritors can expose it with their own name
|
||||
/// </remarks>
|
||||
public object EventObject { get; set; }
|
||||
internal object EventObject { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
internal class DatabaseCreationEventArgs : System.ComponentModel.CancelEventArgs{}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
public class EventDefinition : EventDefinitionBase
|
||||
internal class EventDefinition : EventDefinitionBase
|
||||
{
|
||||
private readonly EventHandler _trackedEvent;
|
||||
private readonly object _sender;
|
||||
@@ -25,7 +25,7 @@ namespace Umbraco.Core.Events
|
||||
}
|
||||
}
|
||||
|
||||
public class EventDefinition<TEventArgs> : EventDefinitionBase
|
||||
internal class EventDefinition<TEventArgs> : EventDefinitionBase
|
||||
{
|
||||
private readonly EventHandler<TEventArgs> _trackedEvent;
|
||||
private readonly object _sender;
|
||||
@@ -48,7 +48,7 @@ namespace Umbraco.Core.Events
|
||||
}
|
||||
}
|
||||
|
||||
public class EventDefinition<TSender, TEventArgs> : EventDefinitionBase
|
||||
internal class EventDefinition<TSender, TEventArgs> : EventDefinitionBase
|
||||
{
|
||||
private readonly TypedEventHandler<TSender, TEventArgs> _trackedEvent;
|
||||
private readonly TSender _sender;
|
||||
+1
-1
@@ -22,6 +22,6 @@
|
||||
/// <summary>
|
||||
/// This is used to track if this message should be used as a default message so that Umbraco doesn't also append it's own default messages
|
||||
/// </summary>
|
||||
public bool IsDefaultEventMessage { get; set; }
|
||||
internal bool IsDefaultEventMessage { get; set; }
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -20,7 +20,7 @@ namespace Umbraco.Core.Events
|
||||
///
|
||||
/// We can also write tests to validate these are all working correctly for all services.
|
||||
/// </summary>
|
||||
public class EventNameExtractor
|
||||
internal class EventNameExtractor
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@@ -52,7 +52,7 @@ namespace Umbraco.Core.Events
|
||||
}
|
||||
}
|
||||
|
||||
public static string[] FindEvents(Type senderType, Type argsType, Func<string, bool> exclude)
|
||||
internal static string[] FindEvents(Type senderType, Type argsType, Func<string, bool> exclude)
|
||||
{
|
||||
var found = MatchedEventNames.GetOrAdd(new Tuple<Type, Type>(senderType, argsType), tuple =>
|
||||
{
|
||||
@@ -120,7 +120,7 @@ namespace Umbraco.Core.Events
|
||||
/// </summary>
|
||||
/// <param name="eventName"></param>
|
||||
/// <returns></returns>
|
||||
public static bool MatchIngNames(string eventName)
|
||||
internal static bool MatchIngNames(string eventName)
|
||||
{
|
||||
var splitter = new Regex(@"(?<!^)(?=[A-Z])");
|
||||
var words = splitter.Split(eventName);
|
||||
@@ -134,7 +134,7 @@ namespace Umbraco.Core.Events
|
||||
/// </summary>
|
||||
/// <param name="eventName"></param>
|
||||
/// <returns></returns>
|
||||
public static bool MatchNonIngNames(string eventName)
|
||||
internal static bool MatchNonIngNames(string eventName)
|
||||
{
|
||||
var splitter = new Regex(@"(?<!^)(?=[A-Z])");
|
||||
var words = splitter.Split(eventName);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user