Merge branch 'v8/dev' into pr/7003
This commit is contained in:
+3
-1
@@ -39,6 +39,8 @@ To build Umbraco, fire up PowerShell and move to Umbraco's repository root (the
|
||||
|
||||
build/build.ps1
|
||||
|
||||
If you only see a build.bat-file, you're probably on the wrong branch. If you switch to the correct branch (dev-v8) the file will appear and you can build it.
|
||||
|
||||
You might run into [Powershell quirks](#powershell-quirks).
|
||||
|
||||
### Build Infrastructure
|
||||
@@ -209,4 +211,4 @@ The best solution is to unblock the Zip file before un-zipping: right-click the
|
||||
|
||||
### Git Quirks
|
||||
|
||||
Git might have issues dealing with long file paths during build. You may want/need to enable `core.longpaths` support (see [this page](https://github.com/msysgit/msysgit/wiki/Git-cannot-create-a-file-or-directory-with-a-long-path) for details).
|
||||
Git might have issues dealing with long file paths during build. You may want/need to enable `core.longpaths` support (see [this page](https://github.com/msysgit/msysgit/wiki/Git-cannot-create-a-file-or-directory-with-a-long-path) for details).
|
||||
|
||||
@@ -59,7 +59,8 @@ Great question! The short version goes like this:
|
||||
* **Clone** - when GitHub has created your fork, you can clone it in your favorite Git tool
|
||||
|
||||

|
||||
|
||||
|
||||
* **Switch to the correct branch** - switch to the v8-dev branch
|
||||
* **Build** - build your fork of Umbraco locally as described in [building Umbraco from source code](BUILD.md)
|
||||
* **Change** - make your changes, experiment, have fun, explore and learn, and don't be afraid. We welcome all contributions and will [happily give feedback](#questions)
|
||||
* **Commit** - done? Yay! 🎉 **Important:** create a new branch now and name it after the issue you're fixing, we usually follow the format: `temp-12345`. This means it's a temporary branch for the particular issue you're working on, in this case `12345`. When you have a branch, commit your changes. Don't commit to `v8/dev`, create a new branch first.
|
||||
|
||||
@@ -7,15 +7,15 @@ A brief description of the issue goes here.
|
||||
|
||||
<!--
|
||||
|
||||
If you haven't yet done so, please read the "contributing guidelines"
|
||||
thoroughly. Then, proceed by filling out the rest of the details in the issue
|
||||
template below. The more details you can give us, the easier it will be for us
|
||||
Please fill out the rest of the details in the issue template below.
|
||||
The more details you can give us, the easier it will be for us
|
||||
to determine the cause of a problem.
|
||||
|
||||
See: https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/.github/CONTRIBUTING.md
|
||||
|
||||
-->
|
||||
|
||||
## Umbraco version
|
||||
|
||||
I am seeing this issue on Umbraco version: <!-- please note the version here -->
|
||||
|
||||
|
||||
Reproduction
|
||||
|
||||
@@ -11,17 +11,12 @@ Y88 88Y 888 888 888 888 d88P 888 888 888 Y88b. Y88..88P
|
||||
|
||||
Don't forget to build!
|
||||
|
||||
We've done our best to transform your configuration files but in case something is not quite right: remember we
|
||||
backed up your files in App_Data\NuGetBackup so you can find the original files before they were transformed.
|
||||
|
||||
We've overwritten all the files in the Umbraco folder, these have been backed up in
|
||||
App_Data\NuGetBackup. We didn't overwrite the UI.xml file nor did we remove any files or folders that you or
|
||||
a package might have added. Only the existing files were overwritten. If you customized anything then make
|
||||
sure to do a compare and merge with the NuGetBackup folder.
|
||||
We've done our best to transform your configuration files but in case something is not quite right: we recommmend you look in source control for the previous version so you can find the original files before they were transformed.
|
||||
|
||||
This NuGet package includes build targets that extend the creation of a deploy package, which is generated by
|
||||
Publishing from Visual Studio. The targets will only work once Publishing is configured, so if you don't use
|
||||
Publish this won't affect you.
|
||||
|
||||
The following items will now be automatically included when creating a deploy package or publishing to the file
|
||||
system: umbraco, config\splashes and global.asax.
|
||||
|
||||
|
||||
+2
-2
@@ -18,5 +18,5 @@ using System.Resources;
|
||||
[assembly: AssemblyVersion("8.0.0")]
|
||||
|
||||
// these are FYI and changed automatically
|
||||
[assembly: AssemblyFileVersion("8.3.0")]
|
||||
[assembly: AssemblyInformationalVersion("8.3.0")]
|
||||
[assembly: AssemblyFileVersion("8.6.0")]
|
||||
[assembly: AssemblyInformationalVersion("8.6.0")]
|
||||
|
||||
@@ -70,7 +70,23 @@ namespace Umbraco.Core.Collections
|
||||
/// The number of elements contained in the <see cref="T:System.Collections.ICollection"/>.
|
||||
/// </returns>
|
||||
/// <filterpriority>2</filterpriority>
|
||||
public int Count => GetThreadSafeClone().Count;
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
_instanceLocker.EnterReadLock();
|
||||
return _innerSet.Count;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_instanceLocker.IsReadLockHeld)
|
||||
_instanceLocker.ExitReadLock();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.
|
||||
@@ -105,8 +121,7 @@ namespace Umbraco.Core.Collections
|
||||
/// <returns></returns>
|
||||
public bool TryAdd(T item)
|
||||
{
|
||||
var clone = GetThreadSafeClone();
|
||||
if (clone.Contains(item)) return false;
|
||||
if (Contains(item)) return false;
|
||||
try
|
||||
{
|
||||
_instanceLocker.EnterWriteLock();
|
||||
@@ -150,7 +165,16 @@ namespace Umbraco.Core.Collections
|
||||
/// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
|
||||
public bool Contains(T item)
|
||||
{
|
||||
return GetThreadSafeClone().Contains(item);
|
||||
try
|
||||
{
|
||||
_instanceLocker.EnterReadLock();
|
||||
return _innerSet.Contains(item);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_instanceLocker.IsReadLockHeld)
|
||||
_instanceLocker.ExitReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -168,13 +192,13 @@ namespace Umbraco.Core.Collections
|
||||
HashSet<T> clone = null;
|
||||
try
|
||||
{
|
||||
_instanceLocker.EnterWriteLock();
|
||||
_instanceLocker.EnterReadLock();
|
||||
clone = new HashSet<T>(_innerSet, _innerSet.Comparer);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_instanceLocker.IsWriteLockHeld)
|
||||
_instanceLocker.ExitWriteLock();
|
||||
if (_instanceLocker.IsReadLockHeld)
|
||||
_instanceLocker.ExitReadLock();
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Collections
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace Umbraco.Core.Collections
|
||||
/// <param name="equalityComparer">The equality comparer to use when comparing keys, or null to use the default comparer.</param>
|
||||
public ObservableDictionary(Func<TValue, TKey> keySelector, IEqualityComparer<TKey> equalityComparer = null)
|
||||
{
|
||||
KeySelector = keySelector ?? throw new ArgumentException("keySelector");
|
||||
KeySelector = keySelector ?? throw new ArgumentException(nameof(keySelector));
|
||||
Indecies = new Dictionary<TKey, int>(equalityComparer);
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@ namespace Umbraco.Core.Collections
|
||||
{
|
||||
var key = KeySelector(item);
|
||||
if (Indecies.ContainsKey(key))
|
||||
throw new DuplicateKeyException(key.ToString());
|
||||
throw new ArgumentException($"An element with the same key '{key}' already exists in the dictionary.", nameof(item));
|
||||
|
||||
if (index != Count)
|
||||
{
|
||||
@@ -91,7 +92,7 @@ namespace Umbraco.Core.Collections
|
||||
{
|
||||
//confirm key matches
|
||||
if (!KeySelector(value).Equals(key))
|
||||
throw new InvalidOperationException("Key of new value does not match");
|
||||
throw new InvalidOperationException("Key of new value does not match.");
|
||||
|
||||
if (!Indecies.ContainsKey(key))
|
||||
{
|
||||
@@ -118,7 +119,7 @@ namespace Umbraco.Core.Collections
|
||||
|
||||
//confirm key matches
|
||||
if (!KeySelector(value).Equals(key))
|
||||
throw new InvalidOperationException("Key of new value does not match");
|
||||
throw new InvalidOperationException("Key of new value does not match.");
|
||||
|
||||
this[Indecies[key]] = value;
|
||||
return true;
|
||||
@@ -155,12 +156,12 @@ namespace Umbraco.Core.Collections
|
||||
{
|
||||
if (!Indecies.ContainsKey(currentKey))
|
||||
{
|
||||
throw new InvalidOperationException("No item with the key " + currentKey + "was found in the collection");
|
||||
throw new InvalidOperationException($"No item with the key '{currentKey}' was found in the dictionary.");
|
||||
}
|
||||
|
||||
if (ContainsKey(newKey))
|
||||
{
|
||||
throw new DuplicateKeyException(newKey.ToString());
|
||||
throw new ArgumentException($"An element with the same key '{newKey}' already exists in the dictionary.", nameof(newKey));
|
||||
}
|
||||
|
||||
var currentIndex = Indecies[currentKey];
|
||||
@@ -234,16 +235,5 @@ namespace Umbraco.Core.Collections
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal class DuplicateKeyException : Exception
|
||||
{
|
||||
public DuplicateKeyException(string key)
|
||||
: base("Attempted to insert duplicate key \"" + key + "\" in collection.")
|
||||
{
|
||||
Key = key;
|
||||
}
|
||||
|
||||
public string Key { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
|
||||
namespace Umbraco.Core.Composing.LightInject
|
||||
@@ -6,20 +7,51 @@ namespace Umbraco.Core.Composing.LightInject
|
||||
/// <summary>
|
||||
/// Represents errors that occur due to LightInject.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Serializable]
|
||||
public class LightInjectException : Exception
|
||||
{
|
||||
public LightInjectException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
public LightInjectException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
private const string LightInjectUnableToResolveType = "Unable to resolve type:";
|
||||
private const string LightInjectUnresolvedDependency = "Unresolved dependency ";
|
||||
private const string LightInjectRequestedDependency = "[Requested dependency:";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LightInjectException" /> class.
|
||||
/// </summary>
|
||||
public LightInjectException()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LightInjectException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public LightInjectException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LightInjectException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
|
||||
public LightInjectException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LightInjectException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
protected LightInjectException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Tries to throw the exception with additional details.
|
||||
/// </summary>
|
||||
/// <param name="e">The exception.</param>
|
||||
/// <exception cref="Umbraco.Core.Composing.LightInject.LightInjectException"></exception>
|
||||
public static void TryThrow(Exception e)
|
||||
{
|
||||
var ex = e as InvalidOperationException;
|
||||
@@ -32,6 +64,12 @@ namespace Umbraco.Core.Composing.LightInject
|
||||
throw new LightInjectException(sb.ToString(), e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to throw the exception with additional details.
|
||||
/// </summary>
|
||||
/// <param name="e">The exception.</param>
|
||||
/// <param name="implementingType">The implementing type.</param>
|
||||
/// <exception cref="Umbraco.Core.Composing.LightInject.LightInjectException"></exception>
|
||||
public static void TryThrow(Exception e, Type implementingType)
|
||||
{
|
||||
var ex = e as InvalidOperationException;
|
||||
@@ -45,6 +83,11 @@ namespace Umbraco.Core.Composing.LightInject
|
||||
throw new LightInjectException(sb.ToString(), e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the details.
|
||||
/// </summary>
|
||||
/// <param name="ex">The exception.</param>
|
||||
/// <param name="sb">The <see cref="StringBuilder" /> to write the details to.</param>
|
||||
private static void WriteDetails(InvalidOperationException ex, StringBuilder sb)
|
||||
{
|
||||
ex = ex.InnerException as InvalidOperationException;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
@@ -813,11 +814,44 @@ namespace Umbraco.Core.Composing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the error that occurs when a type was not found in the cache type
|
||||
/// list with the specified TypeResolutionKind.
|
||||
/// Represents the error that occurs when a type was not found in the cache type list with the specified TypeResolutionKind.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Serializable]
|
||||
internal class CachedTypeNotFoundInFileException : Exception
|
||||
{ }
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CachedTypeNotFoundInFileException" /> class.
|
||||
/// </summary>
|
||||
public CachedTypeNotFoundInFileException()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CachedTypeNotFoundInFileException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public CachedTypeNotFoundInFileException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CachedTypeNotFoundInFileException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
|
||||
public CachedTypeNotFoundInFileException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CachedTypeNotFoundInFileException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
protected CachedTypeNotFoundInFileException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -221,7 +221,8 @@ namespace Umbraco.Core
|
||||
FailedPasswordAttempts,
|
||||
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Integer, true, FailedPasswordAttempts)
|
||||
{
|
||||
Name = FailedPasswordAttemptsLabel
|
||||
Name = FailedPasswordAttemptsLabel,
|
||||
DataTypeId = Constants.DataTypes.LabelInt
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -242,35 +243,40 @@ namespace Umbraco.Core
|
||||
LastLockoutDate,
|
||||
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastLockoutDate)
|
||||
{
|
||||
Name = LastLockoutDateLabel
|
||||
Name = LastLockoutDateLabel,
|
||||
DataTypeId = Constants.DataTypes.LabelDateTime
|
||||
}
|
||||
},
|
||||
{
|
||||
LastLoginDate,
|
||||
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastLoginDate)
|
||||
{
|
||||
Name = LastLoginDateLabel
|
||||
Name = LastLoginDateLabel,
|
||||
DataTypeId = Constants.DataTypes.LabelDateTime
|
||||
}
|
||||
},
|
||||
{
|
||||
LastPasswordChangeDate,
|
||||
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastPasswordChangeDate)
|
||||
{
|
||||
Name = LastPasswordChangeDateLabel
|
||||
Name = LastPasswordChangeDateLabel,
|
||||
DataTypeId = Constants.DataTypes.LabelDateTime
|
||||
}
|
||||
},
|
||||
{
|
||||
PasswordAnswer,
|
||||
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar, true, PasswordAnswer)
|
||||
{
|
||||
Name = PasswordAnswerLabel
|
||||
Name = PasswordAnswerLabel,
|
||||
DataTypeId = Constants.DataTypes.LabelString
|
||||
}
|
||||
},
|
||||
{
|
||||
PasswordQuestion,
|
||||
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar, true, PasswordQuestion)
|
||||
{
|
||||
Name = PasswordQuestionLabel
|
||||
Name = PasswordQuestionLabel,
|
||||
DataTypeId = Constants.DataTypes.LabelString
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,5 +41,43 @@ namespace Umbraco.Core
|
||||
|
||||
return (num & nums) > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a flag of the given input enum
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="input">Enum to set flag of</param>
|
||||
/// <param name="flag">Flag to set</param>
|
||||
/// <returns>A new enum with the flag set</returns>
|
||||
public static T SetFlag<T>(this T input, T flag)
|
||||
where T : Enum
|
||||
{
|
||||
var i = Convert.ToUInt64(input);
|
||||
var f = Convert.ToUInt64(flag);
|
||||
|
||||
// bitwise OR to set flag f of enum i
|
||||
var result = i | f;
|
||||
|
||||
return (T)Enum.ToObject(typeof(T), result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unsets a flag of the given input enum
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="input">Enum to unset flag of</param>
|
||||
/// <param name="flag">Flag to unset</param>
|
||||
/// <returns>A new enum with the flag unset</returns>
|
||||
public static T UnsetFlag<T>(this T input, T flag)
|
||||
where T : Enum
|
||||
{
|
||||
var i = Convert.ToUInt64(input);
|
||||
var f = Convert.ToUInt64(flag);
|
||||
|
||||
// bitwise AND combined with bitwise complement to unset flag f of enum i
|
||||
var result = i & ~f;
|
||||
|
||||
return (T)Enum.ToObject(typeof(T), result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception that is thrown when a null reference, or an empty argument,
|
||||
/// is passed to a method that does not accept it as a valid argument.
|
||||
/// The exception that is thrown when a null reference, or an empty argument, is passed to a method that does not accept it as a valid argument.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.ArgumentNullException" />
|
||||
[Obsolete("Throw an ArgumentNullException when the parameter is null or an ArgumentException when its empty instead.")]
|
||||
[Serializable]
|
||||
public class ArgumentNullOrEmptyException : ArgumentNullException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ArgumentNullOrEmptyException"/> class
|
||||
/// with the name of the parameter that caused this exception.
|
||||
/// Initializes a new instance of the <see cref="ArgumentNullOrEmptyException" /> class.
|
||||
/// </summary>
|
||||
public ArgumentNullOrEmptyException()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ArgumentNullOrEmptyException" /> class with the name of the parameter that caused this exception.
|
||||
/// </summary>
|
||||
/// <param name="paramName">The named of the parameter that caused the exception.</param>
|
||||
public ArgumentNullOrEmptyException(string paramName)
|
||||
@@ -18,13 +26,30 @@ namespace Umbraco.Core.Exceptions
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ArgumentNullOrEmptyException"/> class
|
||||
/// with a specified error message and the name of the parameter that caused this exception.
|
||||
/// Initializes a new instance of the <see cref="ArgumentNullOrEmptyException" /> class with a specified error message and the name of the parameter that caused this exception.
|
||||
/// </summary>
|
||||
/// <param name="paramName">The named of the parameter that caused the exception.</param>
|
||||
/// <param name="message">A message that describes the error.</param>
|
||||
public ArgumentNullOrEmptyException(string paramName, string message)
|
||||
: base(paramName, message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ArgumentNullOrEmptyException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for this exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
|
||||
public ArgumentNullOrEmptyException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ArgumentNullOrEmptyException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The object that holds the serialized object data.</param>
|
||||
/// <param name="context">An object that describes the source or destination of the serialized data.</param>
|
||||
protected ArgumentNullOrEmptyException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,45 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception that is thrown when authorization failed.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Serializable]
|
||||
public class AuthorizationException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AuthorizationException" /> class.
|
||||
/// </summary>
|
||||
public AuthorizationException()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AuthorizationException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public AuthorizationException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AuthorizationException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
|
||||
public AuthorizationException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AuthorizationException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
protected AuthorizationException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
|
||||
namespace Umbraco.Core.Exceptions
|
||||
@@ -6,6 +7,8 @@ namespace Umbraco.Core.Exceptions
|
||||
/// <summary>
|
||||
/// An exception that is thrown if the Umbraco application cannot boot.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Serializable]
|
||||
public class BootFailedException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
@@ -14,27 +17,47 @@ namespace Umbraco.Core.Exceptions
|
||||
public const string DefaultMessage = "Boot failed: Umbraco cannot run. See Umbraco's log file for more details.";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Exception"/> class with a specified error message.
|
||||
/// Initializes a new instance of the <see cref="BootFailedException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error. </param>
|
||||
public BootFailedException()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Exception" /> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public BootFailedException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Exception"/> class with a specified error message
|
||||
/// Initializes a new instance of the <see cref="Exception" /> class with a specified error message
|
||||
/// and a reference to the inner exception which is the cause of this exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error. </param>
|
||||
/// <param name="inner">The inner exception, or null.</param>
|
||||
public BootFailedException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
/// <param name="innerException">The inner exception, or null.</param>
|
||||
public BootFailedException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Rethrows a captured <see cref="BootFailedException"/>.
|
||||
/// Initializes a new instance of the <see cref="BootFailedException" /> class.
|
||||
/// </summary>
|
||||
/// <remarks>The exception can be null, in which case a default message is used.</remarks>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
protected BootFailedException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Rethrows a captured <see cref="BootFailedException" />.
|
||||
/// </summary>
|
||||
/// <param name="bootFailedException">The boot failed exception.</param>
|
||||
/// <exception cref="Umbraco.Core.Exceptions.BootFailedException">
|
||||
/// </exception>
|
||||
/// <remarks>
|
||||
/// The exception can be null, in which case a default message is used.
|
||||
/// </remarks>
|
||||
public static void Rethrow(BootFailedException bootFailedException)
|
||||
{
|
||||
if (bootFailedException == null)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core.Exceptions
|
||||
{
|
||||
internal class ConnectionException : Exception
|
||||
{
|
||||
public ConnectionException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,98 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Serializable]
|
||||
internal class DataOperationException<T> : Exception
|
||||
where T : Enum
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the operation.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The operation.
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// This object should be serializable to prevent a <see cref="SerializationException" /> to be thrown.
|
||||
/// </remarks>
|
||||
public T Operation { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataOperationException{T}" /> class.
|
||||
/// </summary>
|
||||
public DataOperationException()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataOperationException{T}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public DataOperationException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataOperationException{T}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
|
||||
public DataOperationException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataOperationException{T}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="operation">The operation.</param>
|
||||
public DataOperationException(T operation)
|
||||
: this(operation, "Data operation exception: " + operation)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataOperationException{T}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="operation">The operation.</param>
|
||||
/// <param name="message">The message.</param>
|
||||
public DataOperationException(T operation, string message)
|
||||
: base(message)
|
||||
{
|
||||
Operation = operation;
|
||||
}
|
||||
|
||||
public DataOperationException(T operation)
|
||||
: base("Data operation exception: " + operation)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataOperationException{T}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
/// <exception cref="ArgumentNullException">info</exception>
|
||||
protected DataOperationException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
Operation = operation;
|
||||
Operation = (T)Enum.Parse(typeof(T), info.GetString(nameof(Operation)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When overridden in a derived class, sets the <see cref="T:System.Runtime.Serialization.SerializationInfo" /> with information about the exception.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
/// <exception cref="ArgumentNullException">info</exception>
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if (info == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
|
||||
info.AddValue(nameof(Operation), Enum.GetName(typeof(T), Operation));
|
||||
|
||||
base.GetObjectData(info, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,126 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception that is thrown when a composition is invalid.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Serializable]
|
||||
public class InvalidCompositionException : Exception
|
||||
{
|
||||
public InvalidCompositionException(string contentTypeAlias, string addedCompositionAlias, string[] propertyTypeAliass)
|
||||
{
|
||||
ContentTypeAlias = contentTypeAlias;
|
||||
AddedCompositionAlias = addedCompositionAlias;
|
||||
PropertyTypeAliases = propertyTypeAliass;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the content type alias.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The content type alias.
|
||||
/// </value>
|
||||
public string ContentTypeAlias { get; }
|
||||
|
||||
public InvalidCompositionException(string contentTypeAlias, string[] propertyTypeAliass)
|
||||
{
|
||||
ContentTypeAlias = contentTypeAlias;
|
||||
PropertyTypeAliases = propertyTypeAliass;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the added composition alias.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The added composition alias.
|
||||
/// </value>
|
||||
public string AddedCompositionAlias { get; }
|
||||
|
||||
public string ContentTypeAlias { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets the property type aliases.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The property type aliases.
|
||||
/// </value>
|
||||
public string[] PropertyTypeAliases { get; }
|
||||
|
||||
public string AddedCompositionAlias { get; private set; }
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InvalidCompositionException" /> class.
|
||||
/// </summary>
|
||||
public InvalidCompositionException()
|
||||
{ }
|
||||
|
||||
public string[] PropertyTypeAliases { get; private set; }
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InvalidCompositionException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="contentTypeAlias">The content type alias.</param>
|
||||
/// <param name="propertyTypeAliases">The property type aliases.</param>
|
||||
public InvalidCompositionException(string contentTypeAlias, string[] propertyTypeAliases)
|
||||
: this(contentTypeAlias, null, propertyTypeAliases)
|
||||
{ }
|
||||
|
||||
public override string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return AddedCompositionAlias.IsNullOrWhiteSpace()
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InvalidCompositionException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="contentTypeAlias">The content type alias.</param>
|
||||
/// <param name="addedCompositionAlias">The added composition alias.</param>
|
||||
/// <param name="propertyTypeAliases">The property type aliases.</param>
|
||||
public InvalidCompositionException(string contentTypeAlias, string addedCompositionAlias, string[] propertyTypeAliases)
|
||||
: this(addedCompositionAlias.IsNullOrWhiteSpace()
|
||||
? string.Format(
|
||||
"ContentType with alias '{0}' has an invalid composition " +
|
||||
"and there was a conflict on the following PropertyTypes: '{1}'. " +
|
||||
"PropertyTypes must have a unique alias across all Compositions in order to compose a valid ContentType Composition.",
|
||||
ContentTypeAlias, string.Join(", ", PropertyTypeAliases))
|
||||
contentTypeAlias, string.Join(", ", propertyTypeAliases))
|
||||
: string.Format(
|
||||
"ContentType with alias '{0}' was added as a Composition to ContentType with alias '{1}', " +
|
||||
"but there was a conflict on the following PropertyTypes: '{2}'. " +
|
||||
"PropertyTypes must have a unique alias across all Compositions in order to compose a valid ContentType Composition.",
|
||||
AddedCompositionAlias, ContentTypeAlias, string.Join(", ", PropertyTypeAliases));
|
||||
addedCompositionAlias, contentTypeAlias, string.Join(", ", propertyTypeAliases)))
|
||||
{
|
||||
ContentTypeAlias = contentTypeAlias;
|
||||
AddedCompositionAlias = addedCompositionAlias;
|
||||
PropertyTypeAliases = propertyTypeAliases;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InvalidCompositionException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public InvalidCompositionException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InvalidCompositionException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
|
||||
public InvalidCompositionException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InvalidCompositionException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
protected InvalidCompositionException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
ContentTypeAlias = info.GetString(nameof(ContentTypeAlias));
|
||||
AddedCompositionAlias = info.GetString(nameof(AddedCompositionAlias));
|
||||
PropertyTypeAliases = (string[])info.GetValue(nameof(PropertyTypeAliases), typeof(string[]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When overridden in a derived class, sets the <see cref="T:System.Runtime.Serialization.SerializationInfo" /> with information about the exception.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
/// <exception cref="ArgumentNullException">info</exception>
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if (info == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
|
||||
info.AddValue(nameof(ContentTypeAlias), ContentTypeAlias);
|
||||
info.AddValue(nameof(AddedCompositionAlias), AddedCompositionAlias);
|
||||
info.AddValue(nameof(PropertyTypeAliases), PropertyTypeAliases);
|
||||
|
||||
base.GetObjectData(info, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,25 +4,42 @@ using System.Runtime.Serialization;
|
||||
namespace Umbraco.Core.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Internal exception that in theory should never ben thrown, it is only thrown in circumstances that should never happen
|
||||
/// Represents an internal exception that in theory should never been thrown, it is only thrown in circumstances that should never happen.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Serializable]
|
||||
internal class PanicException : Exception
|
||||
public class PanicException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PanicException" /> class.
|
||||
/// </summary>
|
||||
public PanicException()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
public PanicException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PanicException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public PanicException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
public PanicException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PanicException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
|
||||
public PanicException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
protected PanicException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PanicException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
protected PanicException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,52 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception that is thrown when a requested method or operation is not, and will not be, implemented.
|
||||
/// </summary>
|
||||
/// <remarks>The <see cref="NotImplementedException"/> is to be used when some code is not implemented,
|
||||
/// <remarks>
|
||||
/// The <see cref="NotImplementedException" /> is to be used when some code is not implemented,
|
||||
/// but should eventually be implemented (i.e. work in progress) and is reported by tools such as ReSharper.
|
||||
/// This exception is to be used when some code is not implemented, and is not meant to be, for whatever
|
||||
/// reason.</remarks>
|
||||
/// reason.
|
||||
/// </remarks>
|
||||
/// <seealso cref="System.NotImplementedException" />
|
||||
[Serializable]
|
||||
[Obsolete("If a method or operation is not, and will not be, implemented, it is invalid or not supported, so we should throw either an InvalidOperationException or NotSupportedException instead.")]
|
||||
public class WontImplementException : NotImplementedException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WontImplementException"/> class.
|
||||
/// Initializes a new instance of the <see cref="WontImplementException" /> class.
|
||||
/// </summary>
|
||||
public WontImplementException()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WontImplementException"/> class with a specified reason message.
|
||||
/// Initializes a new instance of the <see cref="WontImplementException" /> class with a specified reason message.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
public WontImplementException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WontImplementException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="inner">The exception that is the cause of the current exception. If the <paramref name="inner" /> parameter is not <see langword="null" />, the current exception is raised in a <see langword="catch" /> block that handles the inner exception.</param>
|
||||
public WontImplementException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WontImplementException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
protected WontImplementException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.IO
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception that is thrown when the caller does not have the required permission to access a file.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Obsolete("Throw an UnauthorizedAccessException instead.")]
|
||||
[Serializable]
|
||||
public class FileSecurityException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileSecurityException" /> class.
|
||||
/// </summary>
|
||||
public FileSecurityException()
|
||||
{
|
||||
{ }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileSecurityException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public FileSecurityException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
public FileSecurityException(string message) : base(message)
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileSecurityException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
|
||||
public FileSecurityException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileSecurityException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
protected FileSecurityException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Media;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.IO
|
||||
@@ -92,7 +87,8 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
if (content == null) throw new ArgumentNullException(nameof(content));
|
||||
if (propertyType == null) throw new ArgumentNullException(nameof(propertyType));
|
||||
if (string.IsNullOrWhiteSpace(filename)) throw new ArgumentNullOrEmptyException(nameof(filename));
|
||||
if (filename == null) throw new ArgumentNullException(nameof(filename));
|
||||
if (string.IsNullOrWhiteSpace(filename)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(filename));
|
||||
if (filestream == null) throw new ArgumentNullException(nameof(filestream));
|
||||
|
||||
// clear the old file, if any
|
||||
@@ -111,7 +107,8 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
if (content == null) throw new ArgumentNullException(nameof(content));
|
||||
if (propertyType == null) throw new ArgumentNullException(nameof(propertyType));
|
||||
if (string.IsNullOrWhiteSpace(sourcepath)) throw new ArgumentNullOrEmptyException(nameof(sourcepath));
|
||||
if (sourcepath == null) throw new ArgumentNullException(nameof(sourcepath));
|
||||
if (string.IsNullOrWhiteSpace(sourcepath)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(sourcepath));
|
||||
|
||||
// ensure we have a file to copy
|
||||
if (FileExists(sourcepath) == false) return null;
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using System.Threading;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
@@ -39,9 +38,11 @@ namespace Umbraco.Core.IO
|
||||
|
||||
public PhysicalFileSystem(string rootPath, string rootUrl)
|
||||
{
|
||||
if (string.IsNullOrEmpty(rootPath)) throw new ArgumentNullOrEmptyException(nameof(rootPath));
|
||||
if (string.IsNullOrEmpty(rootUrl)) throw new ArgumentNullOrEmptyException(nameof(rootUrl));
|
||||
if (rootPath.StartsWith("~/")) throw new ArgumentException("The rootPath argument cannot be a virtual path and cannot start with '~/'");
|
||||
if (rootPath == null) throw new ArgumentNullException(nameof(rootPath));
|
||||
if (string.IsNullOrEmpty(rootPath)) throw new ArgumentException("Value can't be empty.", nameof(rootPath));
|
||||
if (rootUrl == null) throw new ArgumentNullException(nameof(rootUrl));
|
||||
if (string.IsNullOrEmpty(rootUrl)) throw new ArgumentException("Value can't be empty.", nameof(rootUrl));
|
||||
if (rootPath.StartsWith("~/")) throw new ArgumentException("Value can't be a virtual path and start with '~/'.", nameof(rootPath));
|
||||
|
||||
// rootPath should be... rooted, as in, it's a root path!
|
||||
if (Path.IsPathRooted(rootPath) == false)
|
||||
@@ -314,7 +315,7 @@ namespace Umbraco.Core.IO
|
||||
|
||||
// nothing prevents us to reach the file, security-wise, yet it is outside
|
||||
// this filesystem's root - throw
|
||||
throw new FileSecurityException("File '" + opath + "' is outside this filesystem's root.");
|
||||
throw new UnauthorizedAccessException("File '" + opath + "' is outside this filesystem's root.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
@@ -42,7 +41,8 @@ namespace Umbraco.Core.Manifest
|
||||
_cache = appCaches.RuntimeCache;
|
||||
_validators = validators ?? throw new ArgumentNullException(nameof(validators));
|
||||
_filters = filters ?? throw new ArgumentNullException(nameof(filters));
|
||||
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentNullOrEmptyException(nameof(path));
|
||||
if (path == null) throw new ArgumentNullException(nameof(path));
|
||||
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(path));
|
||||
Path = path;
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
@@ -155,8 +155,8 @@ namespace Umbraco.Core.Manifest
|
||||
/// </summary>
|
||||
internal PackageManifest ParseManifest(string text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
throw new ArgumentNullOrEmptyException(nameof(text));
|
||||
if (text == null) throw new ArgumentNullException(nameof(text));
|
||||
if (string.IsNullOrWhiteSpace(text)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(text));
|
||||
|
||||
var manifest = JsonConvert.DeserializeObject<PackageManifest>(text,
|
||||
new DataEditorConverter(_logger),
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core.Migrations
|
||||
{
|
||||
/// <summary>
|
||||
/// Used if a migration has executed but the whole process has failed and cannot be rolled back
|
||||
/// </summary>
|
||||
internal class DataLossException : Exception
|
||||
{
|
||||
public DataLossException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DataLossException(string msg, Exception inner)
|
||||
: base(msg, inner)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Core.Exceptions;
|
||||
using System;
|
||||
using Umbraco.Core.Migrations.Expressions.Common;
|
||||
using Umbraco.Core.Migrations.Expressions.Delete.Column;
|
||||
using Umbraco.Core.Migrations.Expressions.Delete.Constraint;
|
||||
@@ -39,8 +39,9 @@ namespace Umbraco.Core.Migrations.Expressions.Delete
|
||||
/// <inheritdoc />
|
||||
public IExecutableBuilder KeysAndIndexes(string tableName, bool local = true, bool foreign = true)
|
||||
{
|
||||
if (tableName.IsNullOrWhiteSpace())
|
||||
throw new ArgumentNullOrEmptyException(nameof(tableName));
|
||||
if (tableName == null) throw new ArgumentNullException(nameof(tableName));
|
||||
if (string.IsNullOrWhiteSpace(tableName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(tableName));
|
||||
|
||||
return new DeleteKeysAndIndexesBuilder(_context) { TableName = tableName, DeleteLocal = local, DeleteForeign = foreign };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,49 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Migrations
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents errors that occurs when a migration exception is not executed.
|
||||
/// The exception that is thrown when a migration expression is not executed.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>Migration expression such as Alter.Table(...).Do() *must* end with Do() else they are
|
||||
/// not executed. When a non-executed expression is detected, an IncompleteMigrationExpressionException
|
||||
/// is thrown.</para>
|
||||
/// Migration expressions such as Alter.Table(...).Do() must end with Do(), else they are not executed.
|
||||
/// When a non-executed expression is detected, an IncompleteMigrationExpressionException is thrown.
|
||||
/// </remarks>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Serializable]
|
||||
public class IncompleteMigrationExpressionException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IncompleteMigrationExpressionException"/> class.
|
||||
/// Initializes a new instance of the <see cref="IncompleteMigrationExpressionException" /> class.
|
||||
/// </summary>
|
||||
public IncompleteMigrationExpressionException()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IncompleteMigrationExpressionException"/> class with a message.
|
||||
/// Initializes a new instance of the <see cref="IncompleteMigrationExpressionException" /> class with a message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public IncompleteMigrationExpressionException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IncompleteMigrationExpressionException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
|
||||
public IncompleteMigrationExpressionException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IncompleteMigrationExpressionException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
protected IncompleteMigrationExpressionException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Migrations.Upgrade;
|
||||
@@ -278,8 +277,10 @@ namespace Umbraco.Core.Migrations.Install
|
||||
/// <param name="logger">A logger.</param>
|
||||
private static void SaveConnectionString(string connectionString, string providerName, ILogger logger)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(connectionString)) throw new ArgumentNullOrEmptyException(nameof(connectionString));
|
||||
if (string.IsNullOrWhiteSpace(providerName)) throw new ArgumentNullOrEmptyException(nameof(providerName));
|
||||
if (connectionString == null) throw new ArgumentNullException(nameof(connectionString));
|
||||
if (string.IsNullOrWhiteSpace(connectionString)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(connectionString));
|
||||
if (providerName == null) throw new ArgumentNullException(nameof(providerName));
|
||||
if (string.IsNullOrWhiteSpace(providerName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(providerName));
|
||||
|
||||
var fileSource = "web.config";
|
||||
var fileName = IOHelper.MapPath(SystemDirectories.Root +"/" + fileSource);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Scoping;
|
||||
using Type = System.Type;
|
||||
@@ -25,7 +24,9 @@ namespace Umbraco.Core.Migrations
|
||||
/// <param name="name">The name of the plan.</param>
|
||||
public MigrationPlan(string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
Name = name;
|
||||
}
|
||||
|
||||
@@ -43,7 +44,8 @@ namespace Umbraco.Core.Migrations
|
||||
private MigrationPlan Add(string sourceState, string targetState, Type migration)
|
||||
{
|
||||
if (sourceState == null) throw new ArgumentNullException(nameof(sourceState));
|
||||
if (string.IsNullOrWhiteSpace(targetState)) throw new ArgumentNullOrEmptyException(nameof(targetState));
|
||||
if (targetState == null) throw new ArgumentNullException(nameof(targetState));
|
||||
if (string.IsNullOrWhiteSpace(targetState)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(targetState));
|
||||
if (sourceState == targetState) throw new ArgumentException("Source and target state cannot be identical.");
|
||||
if (migration == null) throw new ArgumentNullException(nameof(migration));
|
||||
if (!migration.Implements<IMigration>()) throw new ArgumentException($"Type {migration.Name} does not implement IMigration.", nameof(migration));
|
||||
@@ -135,10 +137,12 @@ namespace Umbraco.Core.Migrations
|
||||
/// </summary>
|
||||
public MigrationPlan ToWithClone(string startState, string endState, string targetState)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(startState)) throw new ArgumentNullOrEmptyException(nameof(startState));
|
||||
if (string.IsNullOrWhiteSpace(endState)) throw new ArgumentNullOrEmptyException(nameof(endState));
|
||||
if (string.IsNullOrWhiteSpace(targetState)) throw new ArgumentNullOrEmptyException(nameof(targetState));
|
||||
|
||||
if (startState == null) throw new ArgumentNullException(nameof(startState));
|
||||
if (string.IsNullOrWhiteSpace(startState)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(startState));
|
||||
if (endState == null) throw new ArgumentNullException(nameof(endState));
|
||||
if (string.IsNullOrWhiteSpace(endState)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(endState));
|
||||
if (targetState == null) throw new ArgumentNullException(nameof(targetState));
|
||||
if (string.IsNullOrWhiteSpace(targetState)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(targetState));
|
||||
if (startState == endState) throw new ArgumentException("Start and end states cannot be identical.");
|
||||
|
||||
startState = startState.Trim();
|
||||
@@ -317,7 +321,7 @@ namespace Umbraco.Core.Migrations
|
||||
// throw a raw exception here: this should never happen as the plan has
|
||||
// been validated - this is just a paranoid safety test
|
||||
if (!_transitions.TryGetValue(origState, out transition))
|
||||
throw new Exception($"Unknown state \"{origState}\".");
|
||||
throw new InvalidOperationException($"Unknown state \"{origState}\".");
|
||||
}
|
||||
|
||||
// prepare and de-duplicate post-migrations, only keeping the 1st occurence
|
||||
@@ -339,7 +343,7 @@ namespace Umbraco.Core.Migrations
|
||||
// safety check - again, this should never happen as the plan has been validated,
|
||||
// and this is just a paranoid safety test
|
||||
if (origState != _finalState)
|
||||
throw new Exception($"Internal error, reached state {origState} which is not final state {_finalState}");
|
||||
throw new InvalidOperationException($"Internal error, reached state {origState} which is not final state {_finalState}");
|
||||
|
||||
return origState;
|
||||
}
|
||||
@@ -358,7 +362,7 @@ namespace Umbraco.Core.Migrations
|
||||
var states = new List<string> { origState };
|
||||
|
||||
if (!_transitions.TryGetValue(origState, out var transition))
|
||||
throw new Exception($"Unknown state \"{origState}\".");
|
||||
throw new InvalidOperationException($"Unknown state \"{origState}\".");
|
||||
|
||||
while (transition != null)
|
||||
{
|
||||
@@ -373,12 +377,12 @@ namespace Umbraco.Core.Migrations
|
||||
}
|
||||
|
||||
if (!_transitions.TryGetValue(origState, out transition))
|
||||
throw new Exception($"Unknown state \"{origState}\".");
|
||||
throw new InvalidOperationException($"Unknown state \"{origState}\".");
|
||||
}
|
||||
|
||||
// safety check
|
||||
if (origState != (toState ?? _finalState))
|
||||
throw new Exception($"Internal error, reached state {origState} which is not state {toState ?? _finalState}");
|
||||
throw new InvalidOperationException($"Internal error, reached state {origState} which is not state {toState ?? _finalState}");
|
||||
|
||||
return states;
|
||||
}
|
||||
@@ -417,7 +421,7 @@ namespace Umbraco.Core.Migrations
|
||||
public override string ToString()
|
||||
{
|
||||
return MigrationType == typeof(NoopMigration)
|
||||
? $"{(SourceState == "" ? "<empty>" : SourceState)} --> {TargetState}"
|
||||
? $"{(SourceState == string.Empty ? "<empty>" : SourceState)} --> {TargetState}"
|
||||
: $"{SourceState} -- ({MigrationType.FullName}) --> {TargetState}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using Umbraco.Core.Migrations.Upgrade.Common;
|
||||
using Umbraco.Core.Migrations.Upgrade.V_8_0_0;
|
||||
using Umbraco.Core.Migrations.Upgrade.V_8_0_1;
|
||||
using Umbraco.Core.Migrations.Upgrade.V_8_1_0;
|
||||
using Umbraco.Core.Migrations.Upgrade.V_8_6_0;
|
||||
|
||||
namespace Umbraco.Core.Migrations.Upgrade
|
||||
{
|
||||
@@ -182,6 +183,9 @@ namespace Umbraco.Core.Migrations.Upgrade
|
||||
To<RenameUserLoginDtoDateIndex>("{0372A42B-DECF-498D-B4D1-6379E907EB94}");
|
||||
To<FixContentNuCascade>("{5B1E0D93-F5A3-449B-84BA-65366B84E2D4}");
|
||||
|
||||
// to 8.6.0
|
||||
To<AddPropertyTypeValidationMessageColumns>("{3D67D2C8-5E65-47D0-A9E1-DC2EE0779D6B}");
|
||||
|
||||
//FINAL
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_8_6_0
|
||||
{
|
||||
public class AddPropertyTypeValidationMessageColumns : MigrationBase
|
||||
{
|
||||
public AddPropertyTypeValidationMessageColumns(IMigrationContext context)
|
||||
: base(context)
|
||||
{ }
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToList();
|
||||
|
||||
AddColumnIfNotExists<PropertyTypeDto>(columns, "mandatoryMessage");
|
||||
AddColumnIfNotExists<PropertyTypeDto>(columns, "validationRegExpMessage");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@ using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
@@ -229,8 +227,8 @@ namespace Umbraco.Core.Models
|
||||
|
||||
private void ClearCultureInfo(string culture)
|
||||
{
|
||||
if (culture.IsNullOrWhiteSpace())
|
||||
throw new ArgumentNullOrEmptyException(nameof(culture));
|
||||
if (culture == null) throw new ArgumentNullException(nameof(culture));
|
||||
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
|
||||
|
||||
if (_cultureInfos == null) return;
|
||||
_cultureInfos.Remove(culture);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
@@ -18,7 +17,9 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
public ContentCultureInfos(string culture)
|
||||
{
|
||||
if (culture.IsNullOrWhiteSpace()) throw new ArgumentNullOrEmptyException(nameof(culture));
|
||||
if (culture == null) throw new ArgumentNullException(nameof(culture));
|
||||
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
|
||||
|
||||
Culture = culture;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using Umbraco.Core.Collections;
|
||||
using Umbraco.Core.Exceptions;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
@@ -23,7 +21,9 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
public void AddOrUpdate(string culture, string name, DateTime date)
|
||||
{
|
||||
if (culture.IsNullOrWhiteSpace()) throw new ArgumentNullOrEmptyException(nameof(culture));
|
||||
if (culture == null) throw new ArgumentNullException(nameof(culture));
|
||||
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
|
||||
|
||||
culture = culture.ToLowerInvariant();
|
||||
|
||||
if (TryGetValue(culture, out var item))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Exceptions;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
@@ -103,11 +102,11 @@ namespace Umbraco.Core.Models
|
||||
|
||||
public static void SetPublishInfo(this IContent content, string culture, string name, DateTime date)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
if (culture.IsNullOrWhiteSpace())
|
||||
throw new ArgumentNullOrEmptyException(nameof(culture));
|
||||
if (culture == null) throw new ArgumentNullException(nameof(culture));
|
||||
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
|
||||
|
||||
content.PublishCultureInfos.AddOrUpdate(culture, name, date);
|
||||
}
|
||||
@@ -153,11 +152,11 @@ namespace Umbraco.Core.Models
|
||||
|
||||
public static void SetCultureInfo(this IContentBase content, string culture, string name, DateTime date)
|
||||
{
|
||||
if (name.IsNullOrWhiteSpace())
|
||||
throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
if (culture.IsNullOrWhiteSpace())
|
||||
throw new ArgumentNullOrEmptyException(nameof(culture));
|
||||
if (culture == null) throw new ArgumentNullException(nameof(culture));
|
||||
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
|
||||
|
||||
content.CultureInfos.AddOrUpdate(culture, name, date);
|
||||
}
|
||||
@@ -276,8 +275,8 @@ namespace Umbraco.Core.Models
|
||||
/// <returns></returns>
|
||||
public static bool ClearPublishInfo(this IContent content, string culture)
|
||||
{
|
||||
if (culture.IsNullOrWhiteSpace())
|
||||
throw new ArgumentNullOrEmptyException(nameof(culture));
|
||||
if (culture == null) throw new ArgumentNullException(nameof(culture));
|
||||
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
|
||||
|
||||
var removed = content.PublishCultureInfos.Remove(culture);
|
||||
if (removed)
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Core.Models.Entities
|
||||
public int ParentId { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetParent(ITreeEntity parent) => throw new WontImplementException();
|
||||
public void SetParent(ITreeEntity parent) => throw new InvalidOperationException("This property won't be implemented.");
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataMember]
|
||||
@@ -116,7 +116,7 @@ namespace Umbraco.Core.Models.Entities
|
||||
/// <inheritdoc />
|
||||
public object DeepClone()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -128,47 +128,47 @@ namespace Umbraco.Core.Models.Entities
|
||||
|
||||
public bool IsDirty()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
public bool IsPropertyDirty(string propName)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetDirtyProperties()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
public void ResetDirtyProperties()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
public bool WasDirty()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
public bool WasPropertyDirty(string propertyName)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
public void ResetWereDirtyProperties()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
public void ResetDirtyProperties(bool rememberDirty)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetWereDirtyProperties()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
@@ -43,7 +42,8 @@ namespace Umbraco.Core.Models
|
||||
public Member(string name, IMemberType contentType)
|
||||
: base(name, -1, contentType, new PropertyCollection())
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
IsApproved = true;
|
||||
|
||||
@@ -63,9 +63,12 @@ namespace Umbraco.Core.Models
|
||||
public Member(string name, string email, string username, IMemberType contentType, bool isApproved = true)
|
||||
: base(name, -1, contentType, new PropertyCollection())
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(email)) throw new ArgumentNullOrEmptyException(nameof(email));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(username)) throw new ArgumentNullOrEmptyException(nameof(username));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
if (email == null) throw new ArgumentNullException(nameof(email));
|
||||
if (string.IsNullOrWhiteSpace(email)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(email));
|
||||
if (username == null) throw new ArgumentNullException(nameof(username));
|
||||
if (string.IsNullOrWhiteSpace(username)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(username));
|
||||
|
||||
_email = email;
|
||||
_username = username;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
@@ -9,7 +8,7 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[DataContract(Name = "pagedCollection", Namespace = "")]
|
||||
public class PagedResult<T>
|
||||
public abstract class PagedResult
|
||||
{
|
||||
public PagedResult(long totalItems, long pageNumber, long pageSize)
|
||||
{
|
||||
@@ -39,9 +38,6 @@ namespace Umbraco.Core.Models
|
||||
[DataMember(Name = "totalItems")]
|
||||
public long TotalItems { get; private set; }
|
||||
|
||||
[DataMember(Name = "items")]
|
||||
public IEnumerable<T> Items { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the skip size based on the paged parameters specified
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a paged result for a model collection
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[DataContract(Name = "pagedCollection", Namespace = "")]
|
||||
public class PagedResult<T> : PagedResult
|
||||
{
|
||||
public PagedResult(long totalItems, long pageNumber, long pageSize)
|
||||
: base(totalItems, pageNumber, pageSize)
|
||||
{ }
|
||||
|
||||
[DataMember(Name = "items")]
|
||||
public IEnumerable<T> Items { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,10 @@ namespace Umbraco.Core.Models
|
||||
private string _propertyEditorAlias;
|
||||
private ValueStorageType _valueStorageType;
|
||||
private bool _mandatory;
|
||||
private string _mandatoryMessage;
|
||||
private int _sortOrder;
|
||||
private string _validationRegExp;
|
||||
private string _validationRegExpMessage;
|
||||
private ContentVariation _variations;
|
||||
|
||||
/// <summary>
|
||||
@@ -183,7 +185,7 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets of sets a value indicating whether a value for this property type is required.
|
||||
/// Gets or sets a value indicating whether a value for this property type is required.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public bool Mandatory
|
||||
@@ -192,6 +194,16 @@ namespace Umbraco.Core.Models
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _mandatory, nameof(Mandatory));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom validation message used when a value for this PropertyType is required
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public string MandatoryMessage
|
||||
{
|
||||
get => _mandatoryMessage;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _mandatoryMessage, nameof(MandatoryMessage));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets of sets the sort order of the property type.
|
||||
/// </summary>
|
||||
@@ -212,6 +224,16 @@ namespace Umbraco.Core.Models
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _validationRegExp, nameof(ValidationRegExp));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom validation message used when a pattern for this PropertyType must be matched
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public string ValidationRegExpMessage
|
||||
{
|
||||
get => _validationRegExpMessage;
|
||||
set => SetPropertyValueAndDetectChanges(value, ref _validationRegExpMessage, nameof(ValidationRegExpMessage));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the content variation of the property type.
|
||||
/// </summary>
|
||||
|
||||
@@ -20,7 +20,9 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
private ModelType(string contentTypeAlias)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(contentTypeAlias));
|
||||
if (contentTypeAlias == null) throw new ArgumentNullException(nameof(contentTypeAlias));
|
||||
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(contentTypeAlias));
|
||||
|
||||
ContentTypeAlias = contentTypeAlias;
|
||||
Name = "{" + ContentTypeAlias + "}";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Umbraco.Core.Exceptions;
|
||||
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
@@ -13,7 +12,8 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// </summary>
|
||||
public PublishedCultureInfo(string culture, string name, string urlSegment, DateTime date)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
Culture = culture ?? throw new ArgumentNullException(nameof(culture));
|
||||
Name = name;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Umbraco.Core.Exceptions;
|
||||
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
@@ -19,7 +18,9 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// <param name="contentTypeAlias">The content type alias.</param>
|
||||
public PublishedModelAttribute(string contentTypeAlias)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(contentTypeAlias));
|
||||
if (contentTypeAlias == null) throw new ArgumentNullException(nameof(contentTypeAlias));
|
||||
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(contentTypeAlias));
|
||||
|
||||
ContentTypeAlias = contentTypeAlias;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
@@ -20,7 +19,9 @@ namespace Umbraco.Core.Models
|
||||
|
||||
public RelationType(Guid childObjectType, Guid parentObjectType, string alias)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(alias)) throw new ArgumentNullOrEmptyException(nameof(alias));
|
||||
if (alias == null) throw new ArgumentNullException(nameof(alias));
|
||||
if (string.IsNullOrWhiteSpace(alias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(alias));
|
||||
|
||||
_childObjectType = childObjectType;
|
||||
_parentObjectType = parentObjectType;
|
||||
_alias = alias;
|
||||
@@ -30,7 +31,9 @@ namespace Umbraco.Core.Models
|
||||
public RelationType(Guid childObjectType, Guid parentObjectType, string alias, string name)
|
||||
: this(childObjectType, parentObjectType, alias)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
Name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -787,7 +787,14 @@ namespace Umbraco.Core.Packaging
|
||||
Mandatory = property.Element("Mandatory") != null
|
||||
? property.Element("Mandatory").Value.ToLowerInvariant().Equals("true")
|
||||
: false,
|
||||
MandatoryMessage = property.Element("MandatoryMessage") != null
|
||||
? (string)property.Element("MandatoryMessage")
|
||||
: string.Empty,
|
||||
|
||||
ValidationRegExp = (string)property.Element("Validation"),
|
||||
ValidationRegExpMessage = property.Element("ValidationRegExpMessage") != null
|
||||
? (string)property.Element("ValidationRegExpMessage")
|
||||
: string.Empty,
|
||||
SortOrder = sortOrder,
|
||||
Variations = property.Element("Variations") != null
|
||||
? (ContentVariation)Enum.Parse(typeof(ContentVariation), property.Element("Variations").Value)
|
||||
|
||||
@@ -43,10 +43,20 @@ namespace Umbraco.Core.Persistence.Dtos
|
||||
[Constraint(Default = "0")]
|
||||
public bool Mandatory { get; set; }
|
||||
|
||||
[Column("mandatoryMessage")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
[Length(500)]
|
||||
public string MandatoryMessage { get; set; }
|
||||
|
||||
[Column("validationRegExp")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
public string ValidationRegExp { get; set; }
|
||||
|
||||
[Column("validationRegExpMessage")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
[Length(500)]
|
||||
public string ValidationRegExpMessage { get; set; }
|
||||
|
||||
[Column("Description")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
[Length(2000)]
|
||||
|
||||
@@ -32,9 +32,15 @@ namespace Umbraco.Core.Persistence.Dtos
|
||||
[Column("mandatory")]
|
||||
public bool Mandatory { get; set; }
|
||||
|
||||
[Column("mandatoryMessage")]
|
||||
public string MandatoryMessage { get; set; }
|
||||
|
||||
[Column("validationRegExp")]
|
||||
public string ValidationRegExp { get; set; }
|
||||
|
||||
[Column("validationRegExpMessage")]
|
||||
public string ValidationRegExpMessage { get; set; }
|
||||
|
||||
[Column("Description")]
|
||||
public string Description { get; set; }
|
||||
|
||||
|
||||
@@ -1,38 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Persistence
|
||||
{
|
||||
|
||||
// TODO: Would be good to use this exception type anytime we cannot find an entity
|
||||
|
||||
/// <summary>
|
||||
/// An exception used to indicate that an umbraco entity could not be found
|
||||
/// An exception used to indicate that an Umbraco entity could not be found.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Obsolete("Instead of throwing an exception, return null or an HTTP 404 status code instead.")]
|
||||
[Serializable]
|
||||
public class EntityNotFoundException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the identifier.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The identifier.
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// This object should be serializable to prevent a <see cref="SerializationException" /> to be thrown.
|
||||
/// </remarks>
|
||||
public object Id { get; private set; }
|
||||
private readonly string _msg;
|
||||
|
||||
public EntityNotFoundException(object id, string msg)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EntityNotFoundException" /> class.
|
||||
/// </summary>
|
||||
public EntityNotFoundException()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EntityNotFoundException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <param name="message">The message.</param>
|
||||
public EntityNotFoundException(object id, string message)
|
||||
: base(message)
|
||||
{
|
||||
Id = id;
|
||||
_msg = msg;
|
||||
}
|
||||
|
||||
public EntityNotFoundException(string msg)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EntityNotFoundException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public EntityNotFoundException(string message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EntityNotFoundException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
|
||||
public EntityNotFoundException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EntityNotFoundException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
protected EntityNotFoundException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
_msg = msg;
|
||||
Id = info.GetValue(nameof(Id), typeof(object));
|
||||
}
|
||||
|
||||
public override string Message
|
||||
/// <summary>
|
||||
/// When overridden in a derived class, sets the <see cref="T:System.Runtime.Serialization.SerializationInfo" /> with information about the exception.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
/// <exception cref="ArgumentNullException">info</exception>
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
get { return _msg; }
|
||||
if (info == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
|
||||
info.AddValue(nameof(Id), Id);
|
||||
|
||||
base.GetObjectData(info, context);
|
||||
}
|
||||
|
||||
/// <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 result = base.ToString();
|
||||
|
||||
@@ -60,8 +60,10 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
propertyType.Key = typeDto.UniqueId;
|
||||
propertyType.Name = typeDto.Name;
|
||||
propertyType.Mandatory = typeDto.Mandatory;
|
||||
propertyType.MandatoryMessage = typeDto.MandatoryMessage;
|
||||
propertyType.SortOrder = typeDto.SortOrder;
|
||||
propertyType.ValidationRegExp = typeDto.ValidationRegExp;
|
||||
propertyType.ValidationRegExpMessage = typeDto.ValidationRegExpMessage;
|
||||
propertyType.PropertyGroupId = new Lazy<int>(() => tempGroupDto.Id);
|
||||
propertyType.CreateDate = createDate;
|
||||
propertyType.UpdateDate = updateDate;
|
||||
@@ -124,9 +126,11 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
DataTypeId = propertyType.DataTypeId,
|
||||
Description = propertyType.Description,
|
||||
Mandatory = propertyType.Mandatory,
|
||||
MandatoryMessage = propertyType.MandatoryMessage,
|
||||
Name = propertyType.Name,
|
||||
SortOrder = propertyType.SortOrder,
|
||||
ValidationRegExp = propertyType.ValidationRegExp,
|
||||
ValidationRegExpMessage = propertyType.ValidationRegExpMessage,
|
||||
UniqueId = propertyType.Key,
|
||||
Variations = (byte)propertyType.Variations
|
||||
};
|
||||
|
||||
@@ -4,59 +4,51 @@ using System.Runtime.Serialization;
|
||||
namespace Umbraco.Core.Persistence.FaultHandling
|
||||
{
|
||||
/// <summary>
|
||||
/// The special type of exception that provides managed exit from a retry loop. The user code can use this
|
||||
/// exception to notify the retry policy that no further retry attempts are required.
|
||||
/// The special type of exception that provides managed exit from a retry loop. The user code can use this exception to notify the retry policy that no further retry attempts are required.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Exception" />
|
||||
[Serializable]
|
||||
public sealed class RetryLimitExceededException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RetryLimitExceededException"/> class with a default error message.
|
||||
/// Initializes a new instance of the <see cref="RetryLimitExceededException" /> class with a default error message.
|
||||
/// </summary>
|
||||
public RetryLimitExceededException()
|
||||
: this("RetryLimitExceeded")
|
||||
{
|
||||
}
|
||||
: base()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RetryLimitExceededException"/> class with a specified error message.
|
||||
/// Initializes a new instance of the <see cref="RetryLimitExceededException" /> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public RetryLimitExceededException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RetryLimitExceededException"/> class with a reference to the inner exception
|
||||
/// that is the cause of this exception.
|
||||
/// Initializes a new instance of the <see cref="RetryLimitExceededException" /> class with a reference to the inner exception that is the cause of this exception.
|
||||
/// </summary>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception.</param>
|
||||
public RetryLimitExceededException(Exception innerException)
|
||||
: base(innerException != null ? innerException.Message : "RetryLimitExceeded", innerException)
|
||||
{
|
||||
}
|
||||
: base(null, innerException)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RetryLimitExceededException"/> class.
|
||||
/// Initializes a new instance of the <see cref="RetryLimitExceededException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception.</param>
|
||||
public RetryLimitExceededException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RetryLimitExceededException"/> class.
|
||||
/// Initializes a new instance of the <see cref="RetryLimitExceededException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
|
||||
/// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is null.</exception>
|
||||
/// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0).</exception>
|
||||
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||
private RetryLimitExceededException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,11 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.DataTypeId), nameof(PropertyTypeDto.DataTypeId));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.Description), nameof(PropertyTypeDto.Description));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.Mandatory), nameof(PropertyTypeDto.Mandatory));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.MandatoryMessage), nameof(PropertyTypeDto.MandatoryMessage));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.Name), nameof(PropertyTypeDto.Name));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.SortOrder), nameof(PropertyTypeDto.SortOrder));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.ValidationRegExp), nameof(PropertyTypeDto.ValidationRegExp));
|
||||
DefineMap<PropertyType, PropertyTypeDto>(nameof(PropertyType.ValidationRegExpMessage), nameof(PropertyTypeDto.ValidationRegExpMessage));
|
||||
DefineMap<PropertyType, DataTypeDto>(nameof(PropertyType.PropertyEditorAlias), nameof(DataTypeDto.EditorAlias));
|
||||
DefineMap<PropertyType, DataTypeDto>(nameof(PropertyType.ValueStorageType), nameof(DataTypeDto.DbType));
|
||||
}
|
||||
|
||||
@@ -297,10 +297,12 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
Id = dto.Id,
|
||||
Key = dto.UniqueId,
|
||||
Mandatory = dto.Mandatory,
|
||||
MandatoryMessage = dto.MandatoryMessage,
|
||||
Name = dto.Name,
|
||||
PropertyGroupId = groupId.HasValue ? new Lazy<int>(() => groupId.Value) : null,
|
||||
SortOrder = dto.SortOrder,
|
||||
ValidationRegExp = dto.ValidationRegExp,
|
||||
ValidationRegExpMessage = dto.ValidationRegExpMessage,
|
||||
Variations = (ContentVariation)dto.Variations
|
||||
};
|
||||
}
|
||||
|
||||
@@ -924,32 +924,32 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
protected override IEnumerable<IContent> PerformGetByQuery(IQuery<IContent> query)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> GetDeleteClauses()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override void PersistNewItem(IContent entity)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override void PersistUpdatedItem(IContent entity)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override Sql<ISqlContext> GetBaseQuery(bool isCount)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override string GetBaseWhereClause()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NPoco;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
@@ -129,6 +128,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
protected override void PersistDeletedItem(EntityContainer entity)
|
||||
{
|
||||
if (entity == null) throw new ArgumentNullException(nameof(entity));
|
||||
EnsureContainerType(entity);
|
||||
|
||||
var nodeDto = Database.FirstOrDefault<NodeDto>(Sql().SelectAll()
|
||||
@@ -162,9 +162,11 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
protected override void PersistNewItem(EntityContainer entity)
|
||||
{
|
||||
if (entity == null) throw new ArgumentNullException(nameof(entity));
|
||||
EnsureContainerType(entity);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(entity.Name)) throw new ArgumentNullOrEmptyException("entity.Name");
|
||||
if (entity.Name == null) throw new InvalidOperationException("Entity name can't be null.");
|
||||
if (string.IsNullOrWhiteSpace(entity.Name)) throw new InvalidOperationException("Entity name can't be empty or consist only of white-space characters.");
|
||||
entity.Name = entity.Name.Trim();
|
||||
|
||||
// guard against duplicates
|
||||
@@ -184,7 +186,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
.Where<NodeDto>(dto => dto.NodeId == entity.ParentId && dto.NodeObjectType == entity.ContainerObjectType));
|
||||
|
||||
if (parentDto == null)
|
||||
throw new NullReferenceException("Could not find parent container with id " + entity.ParentId);
|
||||
throw new InvalidOperationException("Could not find parent container with id " + entity.ParentId);
|
||||
|
||||
level = parentDto.Level;
|
||||
path = parentDto.Path;
|
||||
@@ -223,10 +225,12 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
//
|
||||
protected override void PersistUpdatedItem(EntityContainer entity)
|
||||
{
|
||||
if (entity == null) throw new ArgumentNullException(nameof(entity));
|
||||
EnsureContainerType(entity);
|
||||
|
||||
if (entity.Name == null) throw new InvalidOperationException("Entity name can't be null.");
|
||||
if (string.IsNullOrWhiteSpace(entity.Name)) throw new InvalidOperationException("Entity name can't be empty or consist only of white-space characters.");
|
||||
entity.Name = entity.Name.Trim();
|
||||
if (string.IsNullOrWhiteSpace(entity.Name)) throw new ArgumentNullOrEmptyException("entity.Name");
|
||||
|
||||
// find container to update
|
||||
var nodeDto = Database.FirstOrDefault<NodeDto>(Sql().SelectAll()
|
||||
@@ -255,7 +259,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
.Where<NodeDto>(dto => dto.NodeId == entity.ParentId && dto.NodeObjectType == entity.ContainerObjectType));
|
||||
|
||||
if (parent == null)
|
||||
throw new NullReferenceException("Could not find parent container with id " + entity.ParentId);
|
||||
throw new InvalidOperationException("Could not find parent container with id " + entity.ParentId);
|
||||
|
||||
nodeDto.Level = Convert.ToInt16(parent.Level + 1);
|
||||
nodeDto.Path = parent.Path + "," + nodeDto.NodeId;
|
||||
|
||||
@@ -425,32 +425,32 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
protected override IEnumerable<IMedia> PerformGetByQuery(IQuery<IMedia> query)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> GetDeleteClauses()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override void PersistNewItem(IMedia entity)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override void PersistUpdatedItem(IMedia entity)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override Sql<ISqlContext> GetBaseQuery(bool isCount)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override string GetBaseWhereClause()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -225,8 +225,17 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
if (builtinProperties.ContainsKey(propertyType.Alias))
|
||||
{
|
||||
//this reset's its current data type reference which will be re-assigned based on the property editor assigned on the next line
|
||||
propertyType.DataTypeId = 0;
|
||||
propertyType.DataTypeKey = default;
|
||||
var propDefinition = builtinProperties[propertyType.Alias];
|
||||
if (propDefinition != null)
|
||||
{
|
||||
propertyType.DataTypeId = propDefinition.DataTypeId;
|
||||
propertyType.DataTypeKey = propDefinition.DataTypeKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyType.DataTypeId = 0;
|
||||
propertyType.DataTypeKey = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,27 +252,27 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
protected override ContentPermissionSet PerformGet(int id)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override IEnumerable<ContentPermissionSet> PerformGetAll(params int[] ids)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override IEnumerable<ContentPermissionSet> PerformGetByQuery(IQuery<ContentPermissionSet> query)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override Sql<ISqlContext> GetBaseQuery(bool isCount)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override string GetBaseWhereClause()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> GetDeleteClauses()
|
||||
@@ -280,11 +280,11 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
protected override Guid NodeObjectTypeId => throw new WontImplementException();
|
||||
protected override Guid NodeObjectTypeId => throw new InvalidOperationException("This property won't be implemented.");
|
||||
|
||||
protected override void PersistDeletedItem(ContentPermissionSet entity)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -75,19 +75,19 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
protected sealed override IEnumerable<string> GetDeleteClauses()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected sealed override Guid NodeObjectTypeId => throw new WontImplementException();
|
||||
protected sealed override Guid NodeObjectTypeId => throw new InvalidOperationException("This property won't be implemented.");
|
||||
|
||||
protected sealed override void PersistNewItem(TEntity entity)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected sealed override void PersistUpdatedItem(TEntity entity)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
return list;
|
||||
}
|
||||
|
||||
protected override Guid NodeObjectTypeId => throw new WontImplementException();
|
||||
protected override Guid NodeObjectTypeId => throw new InvalidOperationException("This property won't be implemented.");
|
||||
|
||||
protected override void PersistNewItem(IUserGroup entity)
|
||||
{
|
||||
@@ -370,35 +370,35 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
protected override UserGroupWithUsers PerformGet(int id)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override IEnumerable<UserGroupWithUsers> PerformGetAll(params int[] ids)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override IEnumerable<UserGroupWithUsers> PerformGetByQuery(IQuery<UserGroupWithUsers> query)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override Sql<ISqlContext> GetBaseQuery(bool isCount)
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override string GetBaseWhereClause()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> GetDeleteClauses()
|
||||
{
|
||||
throw new WontImplementException();
|
||||
throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
|
||||
protected override Guid NodeObjectTypeId => throw new WontImplementException();
|
||||
protected override Guid NodeObjectTypeId => throw new InvalidOperationException("This property won't be implemented.");
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Data.Common;
|
||||
using System.Threading;
|
||||
using NPoco;
|
||||
using NPoco.FluentMappings;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence.FaultHandling;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
@@ -61,8 +60,8 @@ namespace Umbraco.Core.Persistence
|
||||
/// <remarks>Used by the other ctor and in tests.</remarks>
|
||||
public UmbracoDatabaseFactory(string connectionStringName, ILogger logger, Lazy<IMapperCollection> mappers)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(connectionStringName))
|
||||
throw new ArgumentNullOrEmptyException(nameof(connectionStringName));
|
||||
if (connectionStringName == null) throw new ArgumentNullException(nameof(connectionStringName));
|
||||
if (string.IsNullOrWhiteSpace(connectionStringName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(connectionStringName));
|
||||
|
||||
_mappers = mappers ?? throw new ArgumentNullException(nameof(mappers));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Umbraco.Core.Exceptions;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
{
|
||||
@@ -28,13 +27,15 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// <param name="view">The view to use to render the field editor.</param>
|
||||
public ConfigurationFieldAttribute(string key, string name, string view)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullOrEmptyException(nameof(key));
|
||||
if (key == null) throw new ArgumentNullException(nameof(key));
|
||||
if (string.IsNullOrWhiteSpace(key)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(key));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
if (view == null) throw new ArgumentNullException(nameof(view));
|
||||
if (string.IsNullOrWhiteSpace(view)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(view));
|
||||
|
||||
Key = key;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
Name = name;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(view)) throw new ArgumentNullOrEmptyException(nameof(view));
|
||||
View = view;
|
||||
}
|
||||
|
||||
@@ -47,10 +48,12 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// from the name of the property marked with this attribute.</remarks>
|
||||
public ConfigurationFieldAttribute(string name, string view)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
Name = name;
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
if (view == null) throw new ArgumentNullException(nameof(view));
|
||||
if (string.IsNullOrWhiteSpace(view)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(view));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(view)) throw new ArgumentNullOrEmptyException(nameof(view));
|
||||
Name = name;
|
||||
View = view;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Umbraco.Core.Exceptions;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
{
|
||||
@@ -53,17 +52,17 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// </remarks>
|
||||
public DataEditorAttribute(string alias, EditorType type, string name, string view)
|
||||
{
|
||||
if ((type & ~(EditorType.PropertyValue | EditorType.MacroParameter)) > 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(type), $"Not a valid {typeof(EditorType)} value.");
|
||||
if (alias == null) throw new ArgumentNullException(nameof(alias));
|
||||
if (string.IsNullOrWhiteSpace(alias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(alias));
|
||||
if ((type & ~(EditorType.PropertyValue | EditorType.MacroParameter)) > 0) throw new ArgumentOutOfRangeException(nameof(type), type, $"Not a valid {typeof(EditorType)} value.");
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
if (view == null) throw new ArgumentNullException(nameof(view));
|
||||
if (string.IsNullOrWhiteSpace(view)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(view));
|
||||
|
||||
Type = type;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(alias)) throw new ArgumentNullOrEmptyException(nameof(alias));
|
||||
Alias = alias;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
Name = name;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(view)) throw new ArgumentNullOrEmptyException(nameof(view));
|
||||
View = view == NullView ? null : view;
|
||||
}
|
||||
|
||||
@@ -100,8 +99,10 @@ namespace Umbraco.Core.PropertyEditors
|
||||
get => _valueType;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)) throw new ArgumentNullOrEmptyException(nameof(value));
|
||||
if (!ValueTypes.IsValue(value)) throw new ArgumentOutOfRangeException(nameof(value), $"Not a valid {typeof(ValueTypes)} value.");
|
||||
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||
if (string.IsNullOrWhiteSpace(value)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(value));
|
||||
if (!ValueTypes.IsValue(value)) throw new ArgumentOutOfRangeException(nameof(value), value, $"Not a valid {typeof(ValueTypes)} value.");
|
||||
|
||||
_valueType = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,4 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// </remarks>
|
||||
IEnumerable<ValidationResult> ValidateFormat(object value, string valueType, string format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// </remarks>
|
||||
IEnumerable<ValidationResult> ValidateRequired(object value, string valueType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.RegularExpressions;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors.Validators
|
||||
@@ -48,8 +47,9 @@ namespace Umbraco.Core.PropertyEditors.Validators
|
||||
get => _regex;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
throw new ArgumentNullOrEmptyException(nameof(value));
|
||||
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||
if (string.IsNullOrWhiteSpace(value)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(value));
|
||||
|
||||
_regex = value;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,9 @@ namespace Umbraco.Core.PropertyEditors.Validators
|
||||
public IEnumerable<ValidationResult> Validate(object value, string valueType, object dataTypeConfiguration)
|
||||
{
|
||||
if (_regex == null)
|
||||
{
|
||||
throw new InvalidOperationException("The validator has not been configured.");
|
||||
}
|
||||
|
||||
return ValidateFormat(value, valueType, _regex);
|
||||
}
|
||||
@@ -66,9 +68,12 @@ namespace Umbraco.Core.PropertyEditors.Validators
|
||||
/// <inheritdoc cref="IValueFormatValidator.ValidateFormat"/>
|
||||
public IEnumerable<ValidationResult> ValidateFormat(object value, string valueType, string format)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(format)) throw new ArgumentNullOrEmptyException(nameof(format));
|
||||
if (format == null) throw new ArgumentNullException(nameof(format));
|
||||
if (string.IsNullOrWhiteSpace(format)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(format));
|
||||
if (value == null || !new Regex(format).IsMatch(value.ToString()))
|
||||
{
|
||||
yield return new ValidationResult(_textService.Localize("validation", "invalidPattern"), new[] { "value" });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,17 @@ namespace Umbraco.Core.PropertyEditors.Validators
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
yield return new ValidationResult(_textService.Localize("validation", "invalidNull"), new[] {"value"});
|
||||
yield return new ValidationResult(_textService.Localize("validation", "invalidNull"), new[] { "value" });
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (valueType.InvariantEquals(ValueTypes.Json))
|
||||
{
|
||||
if (value.ToString().DetectIsEmptyJson())
|
||||
{
|
||||
yield return new ValidationResult(_textService.Localize("validation", "invalidEmpty"), new[] { "value" });
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using Umbraco.Core.Exceptions;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
@@ -29,10 +28,14 @@ namespace Umbraco.Core
|
||||
/// <typeparam name="TDeclaring">The declaring type.</typeparam>
|
||||
/// <typeparam name="TValue">The field type.</typeparam>
|
||||
/// <param name="fieldName">The name of the field.</param>
|
||||
/// <returns>A field getter function.</returns>
|
||||
/// <exception cref="ArgumentNullOrEmptyException">Occurs when <paramref name="fieldName"/> is null or empty.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when the field does not exist.</exception>
|
||||
/// <exception cref="ArgumentException">Occurs when <typeparamref name="TValue"/> does not match the type of the field.</exception>
|
||||
/// <returns>
|
||||
/// A field getter function.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentNullException">fieldName</exception>
|
||||
/// <exception cref="ArgumentException">Value can't be empty or consist only of white-space characters. - <paramref name="fieldName" />
|
||||
/// or
|
||||
/// Value type <typeparamref name="TValue" /> does not match field <typeparamref name="TDeclaring" />.<paramref name="fieldName" /> type.</exception>
|
||||
/// <exception cref="InvalidOperationException">Could not find field <typeparamref name="TDeclaring" />.<paramref name="fieldName" />.</exception>
|
||||
public static Func<TDeclaring, TValue> EmitFieldGetter<TDeclaring, TValue>(string fieldName)
|
||||
{
|
||||
var field = GetField<TDeclaring, TValue>(fieldName);
|
||||
@@ -45,10 +48,14 @@ namespace Umbraco.Core
|
||||
/// <typeparam name="TDeclaring">The declaring type.</typeparam>
|
||||
/// <typeparam name="TValue">The field type.</typeparam>
|
||||
/// <param name="fieldName">The name of the field.</param>
|
||||
/// <returns>A field setter action.</returns>
|
||||
/// <exception cref="ArgumentNullOrEmptyException">Occurs when <paramref name="fieldName"/> is null or empty.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when the field does not exist.</exception>
|
||||
/// <exception cref="ArgumentException">Occurs when <typeparamref name="TValue"/> does not match the type of the field.</exception>
|
||||
/// <returns>
|
||||
/// A field setter action.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentNullException">fieldName</exception>
|
||||
/// <exception cref="ArgumentException">Value can't be empty or consist only of white-space characters. - <paramref name="fieldName" />
|
||||
/// or
|
||||
/// Value type <typeparamref name="TValue" /> does not match field <typeparamref name="TDeclaring" />.<paramref name="fieldName" /> type.</exception>
|
||||
/// <exception cref="InvalidOperationException">Could not find field <typeparamref name="TDeclaring" />.<paramref name="fieldName" />.</exception>
|
||||
public static Action<TDeclaring, TValue> EmitFieldSetter<TDeclaring, TValue>(string fieldName)
|
||||
{
|
||||
var field = GetField<TDeclaring, TValue>(fieldName);
|
||||
@@ -61,19 +68,36 @@ namespace Umbraco.Core
|
||||
/// <typeparam name="TDeclaring">The declaring type.</typeparam>
|
||||
/// <typeparam name="TValue">The field type.</typeparam>
|
||||
/// <param name="fieldName">The name of the field.</param>
|
||||
/// <returns>A field getter and setter functions.</returns>
|
||||
/// <exception cref="ArgumentNullOrEmptyException">Occurs when <paramref name="fieldName"/> is null or empty.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when the field does not exist.</exception>
|
||||
/// <exception cref="ArgumentException">Occurs when <typeparamref name="TValue"/> does not match the type of the field.</exception>
|
||||
/// <returns>
|
||||
/// A field getter and setter functions.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentNullException">fieldName</exception>
|
||||
/// <exception cref="ArgumentException">Value can't be empty or consist only of white-space characters. - <paramref name="fieldName" />
|
||||
/// or
|
||||
/// Value type <typeparamref name="TValue" /> does not match field <typeparamref name="TDeclaring" />.<paramref name="fieldName" /> type.</exception>
|
||||
/// <exception cref="InvalidOperationException">Could not find field <typeparamref name="TDeclaring" />.<paramref name="fieldName" />.</exception>
|
||||
public static (Func<TDeclaring, TValue>, Action<TDeclaring, TValue>) EmitFieldGetterAndSetter<TDeclaring, TValue>(string fieldName)
|
||||
{
|
||||
var field = GetField<TDeclaring, TValue>(fieldName);
|
||||
return (EmitFieldGetter<TDeclaring, TValue>(field), EmitFieldSetter<TDeclaring, TValue>(field));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the field.
|
||||
/// </summary>
|
||||
/// <typeparam name="TDeclaring">The type of the declaring.</typeparam>
|
||||
/// <typeparam name="TValue">The type of the value.</typeparam>
|
||||
/// <param name="fieldName">Name of the field.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException">fieldName</exception>
|
||||
/// <exception cref="ArgumentException">Value can't be empty or consist only of white-space characters. - <paramref name="fieldName" />
|
||||
/// or
|
||||
/// Value type <typeparamref name="TValue" /> does not match field <typeparamref name="TDeclaring" />.<paramref name="fieldName" /> type.</exception>
|
||||
/// <exception cref="InvalidOperationException">Could not find field <typeparamref name="TDeclaring" />.<paramref name="fieldName" />.</exception>
|
||||
private static FieldInfo GetField<TDeclaring, TValue>(string fieldName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(fieldName)) throw new ArgumentNullOrEmptyException(nameof(fieldName));
|
||||
if (fieldName == null) throw new ArgumentNullException(nameof(fieldName));
|
||||
if (string.IsNullOrWhiteSpace(fieldName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(fieldName));
|
||||
|
||||
// get the field
|
||||
var field = typeof(TDeclaring).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
@@ -120,13 +144,18 @@ namespace Umbraco.Core
|
||||
/// <typeparam name="TValue">The property type.</typeparam>
|
||||
/// <param name="propertyName">The name of the property.</param>
|
||||
/// <param name="mustExist">A value indicating whether the property and its getter must exist.</param>
|
||||
/// <returns>A property getter function. If <paramref name="mustExist"/> is <c>false</c>, returns null when the property or its getter does not exist.</returns>
|
||||
/// <exception cref="ArgumentNullOrEmptyException">Occurs when <paramref name="propertyName"/> is null or empty.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when the property or its getter does not exist.</exception>
|
||||
/// <exception cref="ArgumentException">Occurs when <typeparamref name="TValue"/> does not match the type of the property.</exception>
|
||||
/// <returns>
|
||||
/// A property getter function. If <paramref name="mustExist" /> is <c>false</c>, returns null when the property or its getter does not exist.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentNullException">propertyName</exception>
|
||||
/// <exception cref="ArgumentException">Value can't be empty or consist only of white-space characters. - <paramref name="propertyName" />
|
||||
/// or
|
||||
/// Value type <typeparamref name="TValue" /> does not match property <typeparamref name="TDeclaring" />.<paramref name="propertyName" /> type.</exception>
|
||||
/// <exception cref="InvalidOperationException">Could not find property getter for <typeparamref name="TDeclaring" />.<paramref name="propertyName" />.</exception>
|
||||
public static Func<TDeclaring, TValue> EmitPropertyGetter<TDeclaring, TValue>(string propertyName, bool mustExist = true)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(propertyName)) throw new ArgumentNullOrEmptyException(nameof(propertyName));
|
||||
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
|
||||
if (string.IsNullOrWhiteSpace(propertyName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyName));
|
||||
|
||||
var property = typeof(TDeclaring).GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
|
||||
@@ -146,13 +175,18 @@ namespace Umbraco.Core
|
||||
/// <typeparam name="TValue">The property type.</typeparam>
|
||||
/// <param name="propertyName">The name of the property.</param>
|
||||
/// <param name="mustExist">A value indicating whether the property and its setter must exist.</param>
|
||||
/// <returns>A property setter function. If <paramref name="mustExist"/> is <c>false</c>, returns null when the property or its setter does not exist.</returns>
|
||||
/// <exception cref="ArgumentNullOrEmptyException">Occurs when <paramref name="propertyName"/> is null or empty.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when the property or its setter does not exist.</exception>
|
||||
/// <exception cref="ArgumentException">Occurs when <typeparamref name="TValue"/> does not match the type of the property.</exception>
|
||||
/// <returns>
|
||||
/// A property setter function. If <paramref name="mustExist" /> is <c>false</c>, returns null when the property or its setter does not exist.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentNullException">propertyName</exception>
|
||||
/// <exception cref="ArgumentException">Value can't be empty or consist only of white-space characters. - <paramref name="propertyName" />
|
||||
/// or
|
||||
/// Value type <typeparamref name="TValue" /> does not match property <typeparamref name="TDeclaring" />.<paramref name="propertyName" /> type.</exception>
|
||||
/// <exception cref="InvalidOperationException">Could not find property setter for <typeparamref name="TDeclaring" />.<paramref name="propertyName" />.</exception>
|
||||
public static Action<TDeclaring, TValue> EmitPropertySetter<TDeclaring, TValue>(string propertyName, bool mustExist = true)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(propertyName)) throw new ArgumentNullOrEmptyException(nameof(propertyName));
|
||||
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
|
||||
if (string.IsNullOrWhiteSpace(propertyName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyName));
|
||||
|
||||
var property = typeof(TDeclaring).GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
|
||||
@@ -172,13 +206,18 @@ namespace Umbraco.Core
|
||||
/// <typeparam name="TValue">The property type.</typeparam>
|
||||
/// <param name="propertyName">The name of the property.</param>
|
||||
/// <param name="mustExist">A value indicating whether the property and its getter and setter must exist.</param>
|
||||
/// <returns>A property getter and setter functions. If <paramref name="mustExist"/> is <c>false</c>, returns null when the property or its getter or setter does not exist.</returns>
|
||||
/// <exception cref="ArgumentNullOrEmptyException">Occurs when <paramref name="propertyName"/> is null or empty.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when the property or its getter or setter does not exist.</exception>
|
||||
/// <exception cref="ArgumentException">Occurs when <typeparamref name="TValue"/> does not match the type of the property.</exception>
|
||||
/// <returns>
|
||||
/// A property getter and setter functions. If <paramref name="mustExist" /> is <c>false</c>, returns null when the property or its getter or setter does not exist.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentNullException">propertyName</exception>
|
||||
/// <exception cref="ArgumentException">Value can't be empty or consist only of white-space characters. - <paramref name="propertyName" />
|
||||
/// or
|
||||
/// Value type <typeparamref name="TValue" /> does not match property <typeparamref name="TDeclaring" />.<paramref name="propertyName" /> type.</exception>
|
||||
/// <exception cref="InvalidOperationException">Could not find property getter and setter for <typeparamref name="TDeclaring" />.<paramref name="propertyName" />.</exception>
|
||||
public static (Func<TDeclaring, TValue>, Action<TDeclaring, TValue>) EmitPropertyGetterAndSetter<TDeclaring, TValue>(string propertyName, bool mustExist = true)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(propertyName)) throw new ArgumentNullOrEmptyException(nameof(propertyName));
|
||||
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
|
||||
if (string.IsNullOrWhiteSpace(propertyName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyName));
|
||||
|
||||
var property = typeof(TDeclaring).GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
|
||||
@@ -402,13 +441,17 @@ namespace Umbraco.Core
|
||||
/// <typeparam name="TLambda">A lambda representing the method.</typeparam>
|
||||
/// <param name="methodName">The name of the method.</param>
|
||||
/// <param name="mustExist">A value indicating whether the constructor must exist.</param>
|
||||
/// <returns>The method. If <paramref name="mustExist"/> is <c>false</c>, returns null when the method does not exist.</returns>
|
||||
/// <returns>
|
||||
/// The method. If <paramref name="mustExist" /> is <c>false</c>, returns null when the method does not exist.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentNullException">methodName</exception>
|
||||
/// <exception cref="ArgumentException">Value can't be empty or consist only of white-space characters. - <paramref name="methodName" />
|
||||
/// or
|
||||
/// Occurs when <typeparamref name="TLambda" /> does not match the method signature..</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when no proper method with name <paramref name="methodName" /> could be found.</exception>
|
||||
/// <remarks>
|
||||
/// <para>The method arguments are determined by <typeparamref name="TLambda"/> generic arguments.</para>
|
||||
/// The method arguments are determined by <typeparamref name="TLambda" /> generic arguments.
|
||||
/// </remarks>
|
||||
/// <exception cref="ArgumentNullOrEmptyException">Occurs when <paramref name="methodName"/> is null or empty.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when no proper method with name <paramref name="methodName"/> could be found.</exception>
|
||||
/// <exception cref="ArgumentException">Occurs when Occurs when <typeparamref name="TLambda"/> does not match the method signature.</exception>
|
||||
public static TLambda EmitMethod<TDeclaring, TLambda>(string methodName, bool mustExist = true)
|
||||
{
|
||||
return EmitMethod<TLambda>(typeof(TDeclaring), methodName, mustExist);
|
||||
@@ -421,16 +464,21 @@ namespace Umbraco.Core
|
||||
/// <param name="declaring">The declaring type.</param>
|
||||
/// <param name="methodName">The name of the method.</param>
|
||||
/// <param name="mustExist">A value indicating whether the constructor must exist.</param>
|
||||
/// <returns>The method. If <paramref name="mustExist"/> is <c>false</c>, returns null when the method does not exist.</returns>
|
||||
/// <returns>
|
||||
/// The method. If <paramref name="mustExist" /> is <c>false</c>, returns null when the method does not exist.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentNullException">methodName</exception>
|
||||
/// <exception cref="ArgumentException">Value can't be empty or consist only of white-space characters. - <paramref name="methodName" />
|
||||
/// or
|
||||
/// Occurs when <typeparamref name="TLambda" /> does not match the method signature..</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when no proper method with name <paramref name="methodName" /> could be found.</exception>
|
||||
/// <remarks>
|
||||
/// <para>The method arguments are determined by <typeparamref name="TLambda"/> generic arguments.</para>
|
||||
/// The method arguments are determined by <typeparamref name="TLambda" /> generic arguments.
|
||||
/// </remarks>
|
||||
/// <exception cref="ArgumentNullOrEmptyException">Occurs when <paramref name="methodName"/> is null or empty.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when no proper method with name <paramref name="methodName"/> could be found.</exception>
|
||||
/// <exception cref="ArgumentException">Occurs when Occurs when <typeparamref name="TLambda"/> does not match the method signature.</exception>
|
||||
public static TLambda EmitMethod<TLambda>(Type declaring, string methodName, bool mustExist = true)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(methodName)) throw new ArgumentNullOrEmptyException(nameof(methodName));
|
||||
if (methodName == null) throw new ArgumentNullException(nameof(methodName));
|
||||
if (string.IsNullOrWhiteSpace(methodName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(methodName));
|
||||
|
||||
var (lambdaDeclaring, lambdaParameters, lambdaReturned) = AnalyzeLambda<TLambda>(true, out var isFunction);
|
||||
|
||||
@@ -510,17 +558,21 @@ namespace Umbraco.Core
|
||||
/// <typeparam name="TLambda">A lambda representing the method.</typeparam>
|
||||
/// <param name="methodName">The name of the method.</param>
|
||||
/// <param name="mustExist">A value indicating whether the constructor must exist.</param>
|
||||
/// <returns>The method. If <paramref name="mustExist"/> is <c>false</c>, returns null when the method does not exist.</returns>
|
||||
/// <returns>
|
||||
/// The method. If <paramref name="mustExist" /> is <c>false</c>, returns null when the method does not exist.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentNullException">methodName</exception>
|
||||
/// <exception cref="ArgumentException">Value can't be empty or consist only of white-space characters. - <paramref name="methodName" />
|
||||
/// or
|
||||
/// Occurs when <typeparamref name="TLambda" /> does not match the method signature..</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when no proper method with name <paramref name="methodName" /> could be found.</exception>
|
||||
/// <remarks>
|
||||
/// <para>The method arguments are determined by <typeparamref name="TLambda"/> generic arguments.</para>
|
||||
/// The method arguments are determined by <typeparamref name="TLambda" /> generic arguments.
|
||||
/// </remarks>
|
||||
/// <exception cref="ArgumentNullOrEmptyException">Occurs when <paramref name="methodName"/> is null or empty.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when no proper method with name <paramref name="methodName"/> could be found.</exception>
|
||||
/// <exception cref="ArgumentException">Occurs when Occurs when <typeparamref name="TLambda"/> does not match the method signature.</exception>
|
||||
public static TLambda EmitMethod<TLambda>(string methodName, bool mustExist = true)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(methodName))
|
||||
throw new ArgumentNullOrEmptyException(nameof(methodName));
|
||||
if (methodName == null) throw new ArgumentNullException(nameof(methodName));
|
||||
if (string.IsNullOrWhiteSpace(methodName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(methodName));
|
||||
|
||||
// validate lambda type
|
||||
var (lambdaDeclaring, lambdaParameters, lambdaReturned) = AnalyzeLambda<TLambda>(false, out var isFunction);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using Semver;
|
||||
using Umbraco.Core.Collections;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Exceptions;
|
||||
@@ -22,7 +22,7 @@ namespace Umbraco.Core
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUmbracoSettingsSection _settings;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly HashSet<string> _applicationUrls = new HashSet<string>();
|
||||
private readonly ConcurrentHashSet<string> _applicationUrls = new ConcurrentHashSet<string>();
|
||||
private readonly Lazy<IMainDom> _mainDom;
|
||||
private readonly Lazy<IServerRegistrar> _serverRegistrar;
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
||||
using System.Web.Security;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Identity;
|
||||
@@ -217,7 +216,8 @@ namespace Umbraco.Core.Security
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
if (string.IsNullOrEmpty(passwordHash)) throw new ArgumentNullOrEmptyException(nameof(passwordHash));
|
||||
if (passwordHash == null) throw new ArgumentNullException(nameof(passwordHash));
|
||||
if (string.IsNullOrEmpty(passwordHash)) throw new ArgumentException("Value can't be empty.", nameof(passwordHash));
|
||||
|
||||
user.PasswordHash = passwordHash;
|
||||
|
||||
@@ -329,7 +329,7 @@ namespace Umbraco.Core.Security
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
if (login == null) throw new ArgumentNullException("login");
|
||||
if (login == null) throw new ArgumentNullException(nameof(login));
|
||||
|
||||
var logins = user.Logins;
|
||||
var instance = new IdentityUserLogin(login.LoginProvider, login.ProviderKey, user.Id);
|
||||
@@ -348,7 +348,7 @@ namespace Umbraco.Core.Security
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
if (login == null) throw new ArgumentNullException("login");
|
||||
if (login == null) throw new ArgumentNullException(nameof(login));
|
||||
|
||||
var provider = login.LoginProvider;
|
||||
var key = login.ProviderKey;
|
||||
@@ -379,7 +379,7 @@ namespace Umbraco.Core.Security
|
||||
public Task<BackOfficeIdentityUser> FindAsync(UserLoginInfo login)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (login == null) throw new ArgumentNullException("login");
|
||||
if (login == null) throw new ArgumentNullException(nameof(login));
|
||||
|
||||
//get all logins associated with the login id
|
||||
var result = _externalLoginService.Find(login).ToArray();
|
||||
@@ -413,7 +413,8 @@ namespace Umbraco.Core.Security
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
if (string.IsNullOrWhiteSpace(roleName)) throw new ArgumentException("Value cannot be null or whitespace.", "roleName");
|
||||
if (roleName == null) throw new ArgumentNullException(nameof(roleName));
|
||||
if (string.IsNullOrWhiteSpace(roleName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(roleName));
|
||||
|
||||
var userRole = user.Roles.SingleOrDefault(r => r.RoleId == roleName);
|
||||
|
||||
@@ -434,7 +435,8 @@ namespace Umbraco.Core.Security
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
if (string.IsNullOrWhiteSpace(roleName)) throw new ArgumentException("Value cannot be null or whitespace.", "roleName");
|
||||
if (roleName == null) throw new ArgumentNullException(nameof(roleName));
|
||||
if (string.IsNullOrWhiteSpace(roleName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(roleName));
|
||||
|
||||
var userRole = user.Roles.SingleOrDefault(r => r.RoleId == roleName);
|
||||
|
||||
|
||||
@@ -2885,7 +2885,8 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
private IContentType GetContentType(IScope scope, string contentTypeAlias)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(contentTypeAlias));
|
||||
if (contentTypeAlias == null) throw new ArgumentNullException(nameof(contentTypeAlias));
|
||||
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(contentTypeAlias));
|
||||
|
||||
scope.ReadLock(Constants.Locks.ContentTypes);
|
||||
|
||||
@@ -2900,7 +2901,8 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
private IContentType GetContentType(string contentTypeAlias)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(contentTypeAlias));
|
||||
if (contentTypeAlias == null) throw new ArgumentNullException(nameof(contentTypeAlias));
|
||||
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(contentTypeAlias));
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
@@ -3083,7 +3085,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
var version = GetVersion(versionId);
|
||||
|
||||
//Good ole null checks
|
||||
if (content == null || version == null)
|
||||
if (content == null || version == null || content.Trashed)
|
||||
{
|
||||
return new OperationResult(OperationResultType.FailedCannot, evtMsgs);
|
||||
}
|
||||
|
||||
+3
-4
@@ -595,10 +595,9 @@ namespace Umbraco.Core.Services.Implement
|
||||
public TItem Copy(TItem original, string alias, string name, TItem parent)
|
||||
{
|
||||
if (original == null) throw new ArgumentNullException(nameof(original));
|
||||
if (string.IsNullOrWhiteSpace(alias)) throw new ArgumentNullOrEmptyException(nameof(alias));
|
||||
|
||||
if (parent != null && parent.HasIdentity == false)
|
||||
throw new InvalidOperationException("Parent must have an identity.");
|
||||
if (alias == null) throw new ArgumentNullException(nameof(alias));
|
||||
if (string.IsNullOrWhiteSpace(alias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(alias));
|
||||
if (parent != null && parent.HasIdentity == false) throw new InvalidOperationException("Parent must have an identity.");
|
||||
|
||||
// this is illegal
|
||||
//var originalb = (ContentTypeCompositionBase)original;
|
||||
|
||||
@@ -360,7 +360,9 @@ namespace Umbraco.Core.Services.Implement
|
||||
new XElement("Definition", definition.Key),
|
||||
new XElement("Tab", propertyGroup == null ? "" : propertyGroup.Name),
|
||||
new XElement("Mandatory", propertyType.Mandatory.ToString()),
|
||||
new XElement("MandatoryMessage", propertyType.MandatoryMessage),
|
||||
new XElement("Validation", propertyType.ValidationRegExp),
|
||||
new XElement("ValidationRegExpMessage", propertyType.ValidationRegExpMessage),
|
||||
new XElement("Description", new XCData(propertyType.Description)));
|
||||
genericProperties.Add(genericProperty);
|
||||
}
|
||||
@@ -487,7 +489,9 @@ namespace Umbraco.Core.Services.Implement
|
||||
new XElement("Tab", propertyGroup == null ? "" : propertyGroup.Name),
|
||||
new XElement("SortOrder", propertyType.SortOrder),
|
||||
new XElement("Mandatory", propertyType.Mandatory.ToString()),
|
||||
propertyType.MandatoryMessage != null ? new XElement("MandatoryMessage", propertyType.MandatoryMessage) : null,
|
||||
propertyType.ValidationRegExp != null ? new XElement("Validation", propertyType.ValidationRegExp) : null,
|
||||
propertyType.ValidationRegExpMessage != null ? new XElement("ValidationRegExpMessage", propertyType.ValidationRegExpMessage) : null,
|
||||
propertyType.Description != null ? new XElement("Description", new XCData(propertyType.Description)) : null,
|
||||
new XElement("Variations", propertyType.Variations.ToString()));
|
||||
|
||||
|
||||
@@ -405,6 +405,21 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <returns></returns>
|
||||
public ITemplate CreateTemplateWithIdentity(string name, string alias, string content, ITemplate masterTemplate = null, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new ArgumentException("Name cannot be empty or contain only white-space characters", nameof(name));
|
||||
}
|
||||
|
||||
if (name.Length > 255)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(name), "Name cannot be more than 255 characters in length.");
|
||||
}
|
||||
|
||||
// file might already be on disk, if so grab the content to avoid overwriting
|
||||
var template = new Template(name, alias)
|
||||
{
|
||||
@@ -539,6 +554,17 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="userId"></param>
|
||||
public void SaveTemplate(ITemplate template, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
if (template == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(template));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(template.Name) || template.Name.Length > 255)
|
||||
{
|
||||
throw new InvalidOperationException("Name cannot be null, empty, contain only white-space characters or be more than 255 characters in length.");
|
||||
}
|
||||
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
if (scope.Events.DispatchCancelable(SavingTemplate, this, new SaveEventArgs<ITemplate>(template)))
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -1340,7 +1339,8 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
private IMediaType GetMediaType(string mediaTypeAlias)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(mediaTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(mediaTypeAlias));
|
||||
if (mediaTypeAlias == null) throw new ArgumentNullException(nameof(mediaTypeAlias));
|
||||
if (string.IsNullOrWhiteSpace(mediaTypeAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(mediaTypeAlias));
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -1350,7 +1350,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
var mediaType = _mediaTypeRepository.Get(query).FirstOrDefault();
|
||||
|
||||
if (mediaType == null)
|
||||
throw new Exception($"No MediaType matching the passed in Alias: '{mediaTypeAlias}' was found"); // causes rollback // causes rollback
|
||||
throw new InvalidOperationException($"No media type matched the specified alias '{mediaTypeAlias}'.");
|
||||
|
||||
scope.Complete();
|
||||
return mediaType;
|
||||
|
||||
@@ -816,8 +816,8 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
//trimming username and email to make sure we have no trailing space
|
||||
member.Username = member.Username.Trim();
|
||||
member.Email = member.Email.Trim();
|
||||
|
||||
member.Email = member.Email.Trim();
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var saveEventArgs = new SaveEventArgs<IMember>(member);
|
||||
@@ -1344,7 +1344,8 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
private IMemberType GetMemberType(IScope scope, string memberTypeAlias)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(memberTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(memberTypeAlias));
|
||||
if (memberTypeAlias == null) throw new ArgumentNullException(nameof(memberTypeAlias));
|
||||
if (string.IsNullOrWhiteSpace(memberTypeAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(memberTypeAlias));
|
||||
|
||||
scope.ReadLock(Constants.Locks.MemberTypes);
|
||||
|
||||
@@ -1358,7 +1359,8 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
private IMemberType GetMemberType(string memberTypeAlias)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(memberTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(memberTypeAlias));
|
||||
if (memberTypeAlias == null) throw new ArgumentNullException(nameof(memberTypeAlias));
|
||||
if (string.IsNullOrWhiteSpace(memberTypeAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(memberTypeAlias));
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
throw new ConnectionException("An error occurring downloading the package from " + url, ex);
|
||||
throw new HttpRequestException("An error occurring downloading the package from " + url, ex);
|
||||
}
|
||||
|
||||
//successful
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data.Common;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data.SqlServerCe;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
@@ -17,7 +13,6 @@ using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
using Umbraco.Core.Persistence.Repositories.Implement;
|
||||
using Umbraco.Core.Scoping;
|
||||
using Umbraco.Core.Security;
|
||||
|
||||
namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
@@ -107,7 +102,8 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <returns><see cref="IUser"/></returns>
|
||||
private IUser CreateUserWithIdentity(string username, string email, string passwordValue, bool isApproved = true)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(username)) throw new ArgumentNullOrEmptyException(nameof(username));
|
||||
if (username == null) throw new ArgumentNullException(nameof(username));
|
||||
if (string.IsNullOrWhiteSpace(username)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(username));
|
||||
|
||||
// TODO: PUT lock here!!
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web.Security;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Strings;
|
||||
|
||||
@@ -1091,7 +1089,8 @@ namespace Umbraco.Core
|
||||
/// <returns>The safe url segment.</returns>
|
||||
public static string ToUrlSegment(this string text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text)) throw new ArgumentNullOrEmptyException(nameof(text));
|
||||
if (text == null) throw new ArgumentNullException(nameof(text));
|
||||
if (string.IsNullOrWhiteSpace(text)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(text));
|
||||
|
||||
return Current.ShortStringHelper.CleanStringForUrlSegment(text);
|
||||
}
|
||||
@@ -1104,7 +1103,8 @@ namespace Umbraco.Core
|
||||
/// <returns>The safe url segment.</returns>
|
||||
public static string ToUrlSegment(this string text, string culture)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text)) throw new ArgumentNullOrEmptyException(nameof(text));
|
||||
if (text == null) throw new ArgumentNullException(nameof(text));
|
||||
if (string.IsNullOrWhiteSpace(text)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(text));
|
||||
|
||||
return Current.ShortStringHelper.CleanStringForUrlSegment(text, culture);
|
||||
}
|
||||
|
||||
@@ -260,6 +260,7 @@
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\RenameMediaVersionTable.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\DataTypes\ValueListPreValueMigrator.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\DataTypes\UmbracoSliderPreValueMigrator.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_6_0\AddPropertyTypeValidationMessageColumns.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_1_0\FixContentNuCascade.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_1_0\RenameUserLoginDtoDateIndex.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_1\ChangeNuCacheJsonFormat.cs" />
|
||||
@@ -273,6 +274,7 @@
|
||||
<Compile Include="Models\Entities\IMediaEntitySlim.cs" />
|
||||
<Compile Include="Models\Entities\IMemberEntitySlim.cs" />
|
||||
<Compile Include="Models\Entities\MediaEntitySlim.cs" />
|
||||
<Compile Include="Models\PagedResult.cs" />
|
||||
<Compile Include="Models\Entities\MemberEntitySlim.cs" />
|
||||
<Compile Include="Models\PublishedContent\ILivePublishedModelFactory.cs" />
|
||||
<Compile Include="Models\PublishedContent\IPublishedContentType.cs" />
|
||||
@@ -679,7 +681,6 @@
|
||||
<Compile Include="Exceptions\ArgumentNullOrEmptyException.cs" />
|
||||
<Compile Include="Exceptions\AuthorizationException.cs" />
|
||||
<Compile Include="Exceptions\BootFailedException.cs" />
|
||||
<Compile Include="Exceptions\ConnectionException.cs" />
|
||||
<Compile Include="Exceptions\DataOperationException.cs" />
|
||||
<Compile Include="Exceptions\InvalidCompositionException.cs" />
|
||||
<Compile Include="Composing\LightInject\LightInjectException.cs" />
|
||||
@@ -847,7 +848,7 @@
|
||||
<Compile Include="Models\Packaging\InstallationSummary.cs" />
|
||||
<Compile Include="Models\Packaging\PackageAction.cs" />
|
||||
<Compile Include="Models\Packaging\PreInstallWarnings.cs" />
|
||||
<Compile Include="Models\PagedResult.cs" />
|
||||
<Compile Include="Models\PagedResultOfT.cs" />
|
||||
<Compile Include="Models\PartialView.cs" />
|
||||
<Compile Include="Models\PartialViewType.cs" />
|
||||
<Compile Include="Models\Property.cs" />
|
||||
@@ -1064,7 +1065,6 @@
|
||||
<Compile Include="Persistence\Mappers\UserGroupMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\UserMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\UserSectionMapper.cs" />
|
||||
<Compile Include="Migrations\DataLossException.cs" />
|
||||
<Compile Include="Migrations\IMigration.cs" />
|
||||
<Compile Include="Migrations\IMigrationContext.cs" />
|
||||
<Compile Include="Migrations\IMigrationExpression.cs" />
|
||||
@@ -1571,4 +1571,4 @@
|
||||
<Folder Include="Auditing\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Exceptions;
|
||||
|
||||
namespace Umbraco.Core.Xml
|
||||
{
|
||||
@@ -37,7 +34,8 @@ namespace Umbraco.Core.Xml
|
||||
// allowed 'inline', not just at the beginning... whether or not we want to support that is up
|
||||
// for discussion.
|
||||
|
||||
if (string.IsNullOrWhiteSpace(xpathExpression)) throw new ArgumentNullOrEmptyException(nameof(xpathExpression));
|
||||
if (xpathExpression == null) throw new ArgumentNullException(nameof(xpathExpression));
|
||||
if (string.IsNullOrWhiteSpace(xpathExpression)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(xpathExpression));
|
||||
if (getPath == null) throw new ArgumentNullException(nameof(getPath));
|
||||
if (publishedContentExists == null) throw new ArgumentNullException(nameof(publishedContentExists));
|
||||
|
||||
|
||||
@@ -4,9 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core.Xml
|
||||
@@ -25,9 +23,10 @@ namespace Umbraco.Core.Xml
|
||||
/// <param name="value"></param>
|
||||
public static void SetAttribute(XmlDocument xml, XmlNode n, string name, string value)
|
||||
{
|
||||
if (xml == null) throw new ArgumentNullException("xml");
|
||||
if (n == null) throw new ArgumentNullException("n");
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (xml == null) throw new ArgumentNullException(nameof(xml));
|
||||
if (n == null) throw new ArgumentNullException(nameof(n));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
if (n.Attributes == null)
|
||||
{
|
||||
@@ -229,8 +228,9 @@ namespace Umbraco.Core.Xml
|
||||
/// <returns>a XmlAttribute</returns>
|
||||
public static XmlAttribute AddAttribute(XmlDocument xd, string name, string value)
|
||||
{
|
||||
if (xd == null) throw new ArgumentNullException("xd");
|
||||
if (string.IsNullOrEmpty(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (xd == null) throw new ArgumentNullException(nameof(xd));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
var temp = xd.CreateAttribute(name);
|
||||
temp.Value = value;
|
||||
@@ -246,8 +246,9 @@ namespace Umbraco.Core.Xml
|
||||
/// <returns>a XmlNode</returns>
|
||||
public static XmlNode AddTextNode(XmlDocument xd, string name, string value)
|
||||
{
|
||||
if (xd == null) throw new ArgumentNullException("xd");
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (xd == null) throw new ArgumentNullException(nameof(xd));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
var temp = xd.CreateNode(XmlNodeType.Element, name, "");
|
||||
temp.AppendChild(xd.CreateTextNode(value));
|
||||
@@ -264,9 +265,10 @@ namespace Umbraco.Core.Xml
|
||||
/// <returns>a XmlNode</returns>
|
||||
public static XmlNode SetTextNode(XmlDocument xd, XmlNode parent, string name, string value)
|
||||
{
|
||||
if (xd == null) throw new ArgumentNullException("xd");
|
||||
if (parent == null) throw new ArgumentNullException("parent");
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (xd == null) throw new ArgumentNullException(nameof(xd));
|
||||
if (parent == null) throw new ArgumentNullException(nameof(parent));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
var child = parent.SelectSingleNode(name);
|
||||
if (child != null)
|
||||
@@ -289,7 +291,8 @@ namespace Umbraco.Core.Xml
|
||||
{
|
||||
if (xd == null) throw new ArgumentNullException(nameof(xd));
|
||||
if (parent == null) throw new ArgumentNullException(nameof(parent));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value cannot be null or whitespace.", nameof(name));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
var child = parent.SelectSingleNode(name) ?? xd.CreateNode(XmlNodeType.Element, name, "");
|
||||
child.InnerXml = value;
|
||||
@@ -305,8 +308,9 @@ namespace Umbraco.Core.Xml
|
||||
/// <returns>A XmlNode</returns>
|
||||
public static XmlNode AddCDataNode(XmlDocument xd, string name, string value)
|
||||
{
|
||||
if (xd == null) throw new ArgumentNullException("xd");
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (xd == null) throw new ArgumentNullException(nameof(xd));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
var temp = xd.CreateNode(XmlNodeType.Element, name, "");
|
||||
temp.AppendChild(xd.CreateCDataSection(value));
|
||||
@@ -323,9 +327,10 @@ namespace Umbraco.Core.Xml
|
||||
/// <returns>a XmlNode</returns>
|
||||
public static XmlNode SetCDataNode(XmlDocument xd, XmlNode parent, string name, string value)
|
||||
{
|
||||
if (xd == null) throw new ArgumentNullException("xd");
|
||||
if (parent == null) throw new ArgumentNullException("parent");
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (xd == null) throw new ArgumentNullException(nameof(xd));
|
||||
if (parent == null) throw new ArgumentNullException(nameof(parent));
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
|
||||
|
||||
var child = parent.SelectSingleNode(name);
|
||||
if (child != null)
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
using Examine;
|
||||
using System;
|
||||
using Examine;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.PropertyEditors.ValueConverters;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
|
||||
@@ -13,14 +17,16 @@ namespace Umbraco.Examine
|
||||
{
|
||||
private readonly UrlSegmentProviderCollection _urlSegmentProviders;
|
||||
private readonly IUserService _userService;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public MediaValueSetBuilder(PropertyEditorCollection propertyEditors,
|
||||
UrlSegmentProviderCollection urlSegmentProviders,
|
||||
IUserService userService)
|
||||
IUserService userService, ILogger logger)
|
||||
: base(propertyEditors, false)
|
||||
{
|
||||
_urlSegmentProviders = urlSegmentProviders;
|
||||
_userService = userService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -29,6 +35,42 @@ namespace Umbraco.Examine
|
||||
foreach (var m in media)
|
||||
{
|
||||
var urlValue = m.GetUrlSegment(_urlSegmentProviders);
|
||||
|
||||
var umbracoFilePath = string.Empty;
|
||||
var umbracoFile = string.Empty;
|
||||
|
||||
var umbracoFileSource = m.GetValue<string>(Constants.Conventions.Media.File);
|
||||
|
||||
if (umbracoFileSource.DetectIsJson())
|
||||
{
|
||||
ImageCropperValue cropper = null;
|
||||
try
|
||||
{
|
||||
cropper = JsonConvert.DeserializeObject<ImageCropperValue>(
|
||||
m.GetValue<string>(Constants.Conventions.Media.File));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error<MediaValueSetBuilder>(ex, $"Could not Deserialize ImageCropperValue for item with key {m.Key} ");
|
||||
}
|
||||
|
||||
if (cropper != null)
|
||||
{
|
||||
umbracoFilePath = cropper.Src;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
umbracoFilePath = umbracoFileSource;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(umbracoFilePath))
|
||||
{
|
||||
// intentional dummy Uri
|
||||
var uri = new Uri("https://localhost/" + umbracoFilePath);
|
||||
umbracoFile = uri.Segments.Last();
|
||||
}
|
||||
|
||||
var values = new Dictionary<string, IEnumerable<object>>
|
||||
{
|
||||
{"icon", m.ContentType.Icon?.Yield() ?? Enumerable.Empty<string>()},
|
||||
@@ -44,7 +86,8 @@ namespace Umbraco.Examine
|
||||
{"urlName", urlValue?.Yield() ?? Enumerable.Empty<string>()},
|
||||
{"path", m.Path?.Yield() ?? Enumerable.Empty<string>()},
|
||||
{"nodeType", m.ContentType.Id.ToString().Yield() },
|
||||
{"creatorName", (m.GetCreatorProfile(_userService)?.Name ?? "??").Yield()}
|
||||
{"creatorName", (m.GetCreatorProfile(_userService)?.Name ?? "??").Yield()},
|
||||
{UmbracoExamineIndex.UmbracoFileFieldName, umbracoFile.Yield()}
|
||||
};
|
||||
|
||||
foreach (var property in m.Properties)
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- note: NuGet deals with transitive references now -->
|
||||
<PackageReference Include="Examine" Version="1.0.0" />
|
||||
<PackageReference Include="Examine" Version="1.0.1" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub">
|
||||
<Version>1.0.0-beta2-19324-01</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Umbraco.Examine
|
||||
/// </summary>
|
||||
public const string IndexPathFieldName = SpecialFieldPrefix + "Path";
|
||||
public const string NodeKeyFieldName = SpecialFieldPrefix + "Key";
|
||||
public const string UmbracoFileFieldName = "umbracoFileSrc";
|
||||
public const string IconFieldName = SpecialFieldPrefix + "Icon";
|
||||
public const string PublishedFieldName = SpecialFieldPrefix + "Published";
|
||||
|
||||
|
||||
@@ -51,5 +51,47 @@ namespace Umbraco.Tests.CoreThings
|
||||
else
|
||||
Assert.IsFalse(value.HasFlagAny(test));
|
||||
}
|
||||
|
||||
[TestCase(TreeUse.None, TreeUse.None, TreeUse.None)]
|
||||
[TestCase(TreeUse.None, TreeUse.Main, TreeUse.Main)]
|
||||
[TestCase(TreeUse.None, TreeUse.Dialog, TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.None, TreeUse.Main | TreeUse.Dialog, TreeUse.Main | TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Main, TreeUse.None, TreeUse.Main)]
|
||||
[TestCase(TreeUse.Main, TreeUse.Main, TreeUse.Main)]
|
||||
[TestCase(TreeUse.Main, TreeUse.Dialog, TreeUse.Main | TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Main, TreeUse.Main | TreeUse.Dialog, TreeUse.Main | TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Dialog, TreeUse.None, TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Dialog, TreeUse.Main, TreeUse.Main | TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Dialog, TreeUse.Dialog, TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Dialog, TreeUse.Main | TreeUse.Dialog, TreeUse.Main | TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Main | TreeUse.Dialog, TreeUse.None, TreeUse.Main | TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Main | TreeUse.Dialog, TreeUse.Main, TreeUse.Main | TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Main | TreeUse.Dialog, TreeUse.Dialog, TreeUse.Main | TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Main | TreeUse.Dialog, TreeUse.Main | TreeUse.Dialog, TreeUse.Main | TreeUse.Dialog)]
|
||||
public void SetFlagTests(TreeUse value, TreeUse flag, TreeUse expected)
|
||||
{
|
||||
Assert.AreEqual(expected, value.SetFlag(flag));
|
||||
}
|
||||
|
||||
[TestCase(TreeUse.None, TreeUse.None, TreeUse.None)]
|
||||
[TestCase(TreeUse.None, TreeUse.Main, TreeUse.None)]
|
||||
[TestCase(TreeUse.None, TreeUse.Dialog, TreeUse.None)]
|
||||
[TestCase(TreeUse.None, TreeUse.Main | TreeUse.Dialog, TreeUse.None)]
|
||||
[TestCase(TreeUse.Main, TreeUse.None, TreeUse.Main)]
|
||||
[TestCase(TreeUse.Main, TreeUse.Main, TreeUse.None)]
|
||||
[TestCase(TreeUse.Main, TreeUse.Dialog, TreeUse.Main)]
|
||||
[TestCase(TreeUse.Main, TreeUse.Main | TreeUse.Dialog, TreeUse.None)]
|
||||
[TestCase(TreeUse.Dialog, TreeUse.None, TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Dialog, TreeUse.Main, TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Dialog, TreeUse.Dialog, TreeUse.None)]
|
||||
[TestCase(TreeUse.Dialog, TreeUse.Main | TreeUse.Dialog, TreeUse.None)]
|
||||
[TestCase(TreeUse.Main | TreeUse.Dialog, TreeUse.None, TreeUse.Main | TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Main | TreeUse.Dialog, TreeUse.Main, TreeUse.Dialog)]
|
||||
[TestCase(TreeUse.Main | TreeUse.Dialog, TreeUse.Dialog, TreeUse.Main)]
|
||||
[TestCase(TreeUse.Main | TreeUse.Dialog, TreeUse.Main | TreeUse.Dialog, TreeUse.None)]
|
||||
public void UnsetFlagTests(TreeUse value, TreeUse flag, TreeUse expected)
|
||||
{
|
||||
Assert.AreEqual(expected, value.UnsetFlag(flag));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Umbraco.Tests.IO
|
||||
Assert.AreEqual(Path.Combine(basePath, @"foo\bar.tmp"), path);
|
||||
|
||||
// that path is invalid as it would be outside the root directory
|
||||
Assert.Throws<FileSecurityException>(() => _fileSystem.GetFullPath("../../foo.tmp"));
|
||||
Assert.Throws<UnauthorizedAccessException>(() => _fileSystem.GetFullPath("../../foo.tmp"));
|
||||
|
||||
// a very long path, which ends up being very long, works
|
||||
path = Repeat("bah/bah/", 50);
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace Umbraco.Tests.IO
|
||||
var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore");
|
||||
var ss = new ShadowFileSystem(fs, sfs);
|
||||
|
||||
Assert.Throws<FileSecurityException>(() =>
|
||||
Assert.Throws<UnauthorizedAccessException>(() =>
|
||||
{
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
|
||||
ss.AddFile("../../f1.txt", ms);
|
||||
|
||||
@@ -621,7 +621,9 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Validation = new PropertyTypeValidation()
|
||||
{
|
||||
Mandatory = true,
|
||||
Pattern = "xyz"
|
||||
MandatoryMessage = "Please enter a value",
|
||||
Pattern = "xyz",
|
||||
PatternMessage = "Please match the pattern",
|
||||
}
|
||||
};
|
||||
|
||||
@@ -634,7 +636,9 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Assert.AreEqual(basic.DataTypeId, result.DataTypeId);
|
||||
Assert.AreEqual(basic.Label, result.Name);
|
||||
Assert.AreEqual(basic.Validation.Mandatory, result.Mandatory);
|
||||
Assert.AreEqual(basic.Validation.MandatoryMessage, result.MandatoryMessage);
|
||||
Assert.AreEqual(basic.Validation.Pattern, result.ValidationRegExp);
|
||||
Assert.AreEqual(basic.Validation.PatternMessage, result.ValidationRegExpMessage);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -655,7 +659,9 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Validation = new PropertyTypeValidation()
|
||||
{
|
||||
Mandatory = true,
|
||||
Pattern = "xyz"
|
||||
MandatoryMessage = "Please enter a value",
|
||||
Pattern = "xyz",
|
||||
PatternMessage = "Please match the pattern",
|
||||
}
|
||||
};
|
||||
|
||||
@@ -668,7 +674,9 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Assert.AreEqual(basic.DataTypeId, result.DataTypeId);
|
||||
Assert.AreEqual(basic.Label, result.Name);
|
||||
Assert.AreEqual(basic.Validation.Mandatory, result.Mandatory);
|
||||
Assert.AreEqual(basic.Validation.MandatoryMessage, result.MandatoryMessage);
|
||||
Assert.AreEqual(basic.Validation.Pattern, result.ValidationRegExp);
|
||||
Assert.AreEqual(basic.Validation.PatternMessage, result.ValidationRegExpMessage);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -951,7 +959,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Name = "Tab 1",
|
||||
SortOrder = 0,
|
||||
Inherited = false,
|
||||
Properties = new []
|
||||
Properties = new[]
|
||||
{
|
||||
new MemberPropertyTypeBasic
|
||||
{
|
||||
@@ -965,7 +973,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Validation = new PropertyTypeValidation
|
||||
{
|
||||
Mandatory = false,
|
||||
Pattern = ""
|
||||
Pattern = string.Empty
|
||||
},
|
||||
SortOrder = 0,
|
||||
DataTypeId = 555
|
||||
@@ -1000,7 +1008,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Name = "Tab 1",
|
||||
SortOrder = 0,
|
||||
Inherited = false,
|
||||
Properties = new []
|
||||
Properties = new[]
|
||||
{
|
||||
new PropertyTypeBasic
|
||||
{
|
||||
@@ -1011,7 +1019,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Validation = new PropertyTypeValidation
|
||||
{
|
||||
Mandatory = false,
|
||||
Pattern = ""
|
||||
Pattern = string.Empty
|
||||
},
|
||||
SortOrder = 0,
|
||||
DataTypeId = 555
|
||||
@@ -1052,7 +1060,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Name = "Tab 1",
|
||||
SortOrder = 0,
|
||||
Inherited = false,
|
||||
Properties = new []
|
||||
Properties = new[]
|
||||
{
|
||||
new PropertyTypeBasic
|
||||
{
|
||||
@@ -1063,7 +1071,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Validation = new PropertyTypeValidation
|
||||
{
|
||||
Mandatory = false,
|
||||
Pattern = ""
|
||||
Pattern = string.Empty
|
||||
},
|
||||
SortOrder = 0,
|
||||
DataTypeId = 555
|
||||
@@ -1109,7 +1117,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Validation = new PropertyTypeValidation
|
||||
{
|
||||
Mandatory = false,
|
||||
Pattern = ""
|
||||
Pattern = string.Empty
|
||||
},
|
||||
SortOrder = 0,
|
||||
DataTypeId = 555
|
||||
@@ -1133,7 +1141,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Validation = new PropertyTypeValidation
|
||||
{
|
||||
Mandatory = false,
|
||||
Pattern = ""
|
||||
Pattern = string.Empty
|
||||
},
|
||||
SortOrder = 0,
|
||||
DataTypeId = 555
|
||||
@@ -1187,7 +1195,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Validation = new PropertyTypeValidation
|
||||
{
|
||||
Mandatory = false,
|
||||
Pattern = ""
|
||||
Pattern = string.Empty
|
||||
},
|
||||
SortOrder = 0,
|
||||
DataTypeId = 555
|
||||
@@ -1211,7 +1219,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
Validation = new PropertyTypeValidation
|
||||
{
|
||||
Mandatory = false,
|
||||
Pattern = ""
|
||||
Pattern = string.Empty
|
||||
},
|
||||
SortOrder = 0,
|
||||
DataTypeId = 555
|
||||
|
||||
@@ -7,6 +7,7 @@ using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Persistence.Repositories.Implement;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
@@ -77,7 +78,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.AreEqual("/Views/Partials/path-2/test-path-3.cshtml", partialView.VirtualPath);
|
||||
|
||||
partialView = new PartialView(PartialViewType.PartialView, "\\test-path-4.cshtml") { Content = "// partialView" };
|
||||
Assert.Throws<FileSecurityException>(() => // fixed in 7.3 - 7.2.8 used to strip the \
|
||||
Assert.Throws<UnauthorizedAccessException>(() => // fixed in 7.3 - 7.2.8 used to strip the \
|
||||
{
|
||||
repository.Save(partialView);
|
||||
});
|
||||
@@ -86,11 +87,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.IsNull(partialView);
|
||||
|
||||
// fixed in 7.3 - 7.2.8 used to...
|
||||
Assert.Throws<FileSecurityException>(() =>
|
||||
Assert.Throws<UnauthorizedAccessException>(() =>
|
||||
{
|
||||
partialView = (PartialView) repository.Get("\\test-path-4.cshtml"); // outside the filesystem, does not exist
|
||||
});
|
||||
Assert.Throws<FileSecurityException>(() =>
|
||||
Assert.Throws<UnauthorizedAccessException>(() =>
|
||||
{
|
||||
partialView = (PartialView) repository.Get("../../packages.config"); // outside the filesystem, exists
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Moq;
|
||||
@@ -301,7 +302,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.AreEqual("/scripts/path-2/test-path-3.js", script.VirtualPath);
|
||||
|
||||
script = new Script("\\test-path-4.js") { Content = "// script" };
|
||||
Assert.Throws<FileSecurityException>(() => // fixed in 7.3 - 7.2.8 used to strip the \
|
||||
Assert.Throws<UnauthorizedAccessException>(() => // fixed in 7.3 - 7.2.8 used to strip the \
|
||||
{
|
||||
repository.Save(script);
|
||||
});
|
||||
@@ -310,11 +311,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.IsNull(script);
|
||||
|
||||
// fixed in 7.3 - 7.2.8 used to...
|
||||
Assert.Throws<FileSecurityException>(() =>
|
||||
Assert.Throws<UnauthorizedAccessException>(() =>
|
||||
{
|
||||
script = repository.Get("\\test-path-4.js"); // outside the filesystem, does not exist
|
||||
});
|
||||
Assert.Throws<FileSecurityException>(() =>
|
||||
Assert.Throws<UnauthorizedAccessException>(() =>
|
||||
{
|
||||
script = repository.Get("../packages.config"); // outside the filesystem, exists
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Data;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -284,7 +285,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.AreEqual("/css/path-2/test-path-3.css", stylesheet.VirtualPath);
|
||||
|
||||
stylesheet = new Stylesheet("\\test-path-4.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
Assert.Throws<FileSecurityException>(() => // fixed in 7.3 - 7.2.8 used to strip the \
|
||||
Assert.Throws<UnauthorizedAccessException>(() => // fixed in 7.3 - 7.2.8 used to strip the \
|
||||
{
|
||||
repository.Save(stylesheet);
|
||||
});
|
||||
@@ -294,11 +295,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.IsNull(stylesheet);
|
||||
|
||||
// fixed in 7.3 - 7.2.8 used to...
|
||||
Assert.Throws<FileSecurityException>(() =>
|
||||
Assert.Throws<UnauthorizedAccessException>(() =>
|
||||
{
|
||||
stylesheet = repository.Get("\\test-path-4.css"); // outside the filesystem, does not exist
|
||||
});
|
||||
Assert.Throws<FileSecurityException>(() =>
|
||||
Assert.Throws<UnauthorizedAccessException>(() =>
|
||||
{
|
||||
stylesheet = repository.Get("../packages.config"); // outside the filesystem, exists
|
||||
});
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace Umbraco.Tests.Published
|
||||
public override bool HasValue(string culture = null, string segment = null) => _hasValue;
|
||||
public override object GetSourceValue(string culture = null, string segment = null) => _sourceValue;
|
||||
public override object GetValue(string culture = null, string segment = null) => PropertyType.ConvertInterToObject(_owner, ReferenceCacheLevel, InterValue, _preview);
|
||||
public override object GetXPathValue(string culture = null, string segment = null) => throw new WontImplementException();
|
||||
public override object GetXPathValue(string culture = null, string segment = null) => throw new InvalidOperationException("This method won't be implemented.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,7 +865,7 @@ namespace Umbraco.Tests.Services
|
||||
var userService = ServiceContext.UserService;
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<ArgumentNullOrEmptyException>(() => userService.CreateUserWithIdentity(string.Empty, "john@umbraco.io"));
|
||||
Assert.Throws<ArgumentException>(() => userService.CreateUserWithIdentity(string.Empty, "john@umbraco.io"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Castle.Core" Version="4.3.1" />
|
||||
<PackageReference Include="Examine" Version="1.0.0" />
|
||||
<PackageReference Include="Examine" Version="1.0.1" />
|
||||
<PackageReference Include="HtmlAgilityPack">
|
||||
<Version>1.8.14</Version>
|
||||
</PackageReference>
|
||||
|
||||
@@ -7,6 +7,7 @@ using Lucene.Net.Analysis;
|
||||
using Lucene.Net.Analysis.Standard;
|
||||
using Lucene.Net.Store;
|
||||
using Moq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
@@ -44,11 +45,10 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
|
||||
public static MediaIndexPopulator GetMediaIndexRebuilder(PropertyEditorCollection propertyEditors, IMediaService mediaService)
|
||||
{
|
||||
var mediaValueSetBuilder = new MediaValueSetBuilder(propertyEditors, new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider() }), GetMockUserService());
|
||||
var mediaValueSetBuilder = new MediaValueSetBuilder(propertyEditors, new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider() }), GetMockUserService(), GetMockLogger());
|
||||
var mediaIndexDataSource = new MediaIndexPopulator(null, mediaService, mediaValueSetBuilder);
|
||||
return mediaIndexDataSource;
|
||||
}
|
||||
|
||||
public static IContentService GetMockContentService()
|
||||
{
|
||||
long longTotalRecs;
|
||||
@@ -146,6 +146,11 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
return mediaTypeServiceMock.Object;
|
||||
}
|
||||
|
||||
public static IProfilingLogger GetMockLogger()
|
||||
{
|
||||
return new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>());
|
||||
}
|
||||
|
||||
public static UmbracoContentIndex GetUmbracoIndexer(
|
||||
IProfilingLogger profilingLogger,
|
||||
Directory luceneDir,
|
||||
|
||||
@@ -259,19 +259,18 @@ function dependencies() {
|
||||
//css, fonts and image files
|
||||
|
||||
var assetsTask = gulp.src(config.sources.globs.assets, { allowEmpty: true });
|
||||
if (global.isProd === true) {
|
||||
assetsTask = assetsTask.pipe(imagemin([
|
||||
imagemin.gifsicle({interlaced: true}),
|
||||
imagemin.jpegtran({progressive: true}),
|
||||
imagemin.optipng({optimizationLevel: 5}),
|
||||
imagemin.svgo({
|
||||
plugins: [
|
||||
{removeViewBox: true},
|
||||
{cleanupIDs: false}
|
||||
]
|
||||
})
|
||||
]));
|
||||
}
|
||||
assetsTask = assetsTask.pipe(imagemin([
|
||||
imagemin.gifsicle({interlaced: true}),
|
||||
imagemin.jpegtran({progressive: true}),
|
||||
imagemin.optipng({optimizationLevel: 5}),
|
||||
imagemin.svgo({
|
||||
plugins: [
|
||||
{removeViewBox: true},
|
||||
{cleanupIDs: false}
|
||||
]
|
||||
})
|
||||
]));
|
||||
|
||||
assetsTask = assetsTask.pipe(gulp.dest(config.root + config.targets.assets));
|
||||
|
||||
stream.add(assetsTask);
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var gulp = require('gulp');
|
||||
var through2 = require('through2');
|
||||
|
||||
function createEmptyStream() {
|
||||
var pass = through2.obj();
|
||||
process.nextTick(pass.end.bind(pass));
|
||||
return pass;
|
||||
}
|
||||
|
||||
/**************************
|
||||
* Copies all angular JS files into their separate umbraco.*.js file
|
||||
**************************/
|
||||
function removeProductionMode() {
|
||||
|
||||
global.isProd = false;
|
||||
|
||||
return createEmptyStream();
|
||||
};
|
||||
|
||||
module.exports = { removeProductionMode: removeProductionMode };
|
||||
@@ -20,7 +20,7 @@ function watchTask(cb) {
|
||||
//Setup a watcher for all groups of JS files
|
||||
_.forEach(config.sources.js, function (group) {
|
||||
if(group.watch !== false) {
|
||||
watch(group.files, { ignoreInitial: true, interval: watchInterval }, function JS_Group_Compile() { return processJs(group.files, group.out); });
|
||||
watch(group.files, { ignoreInitial: true, interval: watchInterval }, function JS_Group_Compile() { return processJs(group.files, group.out);});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -23,11 +23,10 @@ module.exports = function (files, out) {
|
||||
// sort files in stream by path or any custom sort comparator
|
||||
task = task.pipe(babel())
|
||||
.pipe(sort());
|
||||
|
||||
if (global.isProd === true) {
|
||||
//in production, embed the templates
|
||||
task = task.pipe(embedTemplates({ basePath: "./src/", minimize: { loose: true } }))
|
||||
}
|
||||
|
||||
//in production, embed the templates
|
||||
task = task.pipe(embedTemplates({ basePath: "./src/", minimize: { loose: true } }))
|
||||
|
||||
task = task.pipe(concat(out))
|
||||
.pipe(wrap('(function(){\n%= body %\n})();'))
|
||||
.pipe(gulp.dest(config.root + config.targets.js));
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
* and then add the exports command to add the new item into the task menu.
|
||||
*/
|
||||
|
||||
global.isProd = true;
|
||||
|
||||
const { src, dest, series, parallel, lastRun } = require('gulp');
|
||||
|
||||
const { dependencies } = require('./gulp/tasks/dependencies');
|
||||
@@ -20,7 +18,6 @@ const { less } = require('./gulp/tasks/less');
|
||||
const { testE2e, testUnit } = require('./gulp/tasks/test');
|
||||
const { views } = require('./gulp/tasks/views');
|
||||
const { watchTask } = require('./gulp/tasks/watchTask');
|
||||
const { removeProductionMode } = require('./gulp/tasks/removeProductionMode');
|
||||
|
||||
// Load local overwrites, can be used to overwrite paths in your local setup.
|
||||
var fs = require('fs');
|
||||
@@ -41,7 +38,6 @@ try {
|
||||
// ***********************************************************
|
||||
exports.build = series(parallel(dependencies, js, less, views), testUnit);
|
||||
exports.dev = series(parallel(dependencies, js, less, views), watchTask);
|
||||
exports.fastdev = series(removeProductionMode, parallel(dependencies, js, less, views), watchTask);
|
||||
exports.watch = series(watchTask);
|
||||
//
|
||||
exports.runTests = series(js, testUnit);
|
||||
|
||||
+5
-2
@@ -195,6 +195,7 @@ Use this directive to construct a header inside the main editor window.
|
||||
@param {string=} icon Show and edit the content icon. Opens an overlay to change the icon.
|
||||
@param {boolean=} hideIcon Set to <code>true</code> to hide icon.
|
||||
@param {string=} alias show and edit the content alias.
|
||||
@param {boolean=} aliasLocked Set to <code>true</code> to lock the alias.
|
||||
@param {boolean=} hideAlias Set to <code>true</code> to hide alias.
|
||||
@param {string=} description Add a description to the content.
|
||||
@param {boolean=} hideDescription Set to <code>true</code> to hide description.
|
||||
@@ -239,12 +240,13 @@ Use this directive to construct a header inside the main editor window.
|
||||
if (scope.editorfor) {
|
||||
localizeVars.push(scope.editorfor);
|
||||
}
|
||||
localizationService.localizeMany(localizeVars).then(function (data) {
|
||||
localizationService.localizeMany(localizeVars).then(function(data) {
|
||||
setAccessibilityForEditor(data);
|
||||
scope.loading = false;
|
||||
});
|
||||
} else {
|
||||
scope.loading = false;
|
||||
}
|
||||
|
||||
scope.goBack = function () {
|
||||
if (scope.onBack) {
|
||||
scope.onBack();
|
||||
@@ -346,6 +348,7 @@ Use this directive to construct a header inside the main editor window.
|
||||
icon: "=",
|
||||
hideIcon: "@",
|
||||
alias: "=",
|
||||
aliasLocked: "<",
|
||||
hideAlias: "=",
|
||||
description: "=",
|
||||
hideDescription: "@",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user