mirror of https://github.com/Squidex/squidex.git
Browse Source
* Simplify immutability. * More cleanup. * Code cleanup. * Fix. * More simplifications. * Just a spelling fix.pull/697/head
committed by
GitHub
179 changed files with 1362 additions and 2232 deletions
@ -1,33 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.Apps.Json |
|||
{ |
|||
public sealed class AppClientsSurrogate : Dictionary<string, AppClient>, ISurrogate<AppClients> |
|||
{ |
|||
public void FromSource(AppClients source) |
|||
{ |
|||
foreach (var (key, client) in source) |
|||
{ |
|||
Add(key, client); |
|||
} |
|||
} |
|||
|
|||
public AppClients ToSource() |
|||
{ |
|||
if (Count == 0) |
|||
{ |
|||
return AppClients.Empty; |
|||
} |
|||
|
|||
return new AppClients(this); |
|||
} |
|||
} |
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.Apps.Json |
|||
{ |
|||
public sealed class AppContributorsSurrogate : Dictionary<string, string>, ISurrogate<AppContributors> |
|||
{ |
|||
public void FromSource(AppContributors source) |
|||
{ |
|||
foreach (var (userId, role) in source) |
|||
{ |
|||
Add(userId, role); |
|||
} |
|||
} |
|||
|
|||
public AppContributors ToSource() |
|||
{ |
|||
if (Count == 0) |
|||
{ |
|||
return AppContributors.Empty; |
|||
} |
|||
|
|||
return new AppContributors(this); |
|||
} |
|||
} |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.Contents.Json |
|||
{ |
|||
public sealed class WorkflowsSurrogate : Dictionary<DomainId, Workflow>, ISurrogate<Workflows> |
|||
{ |
|||
public void FromSource(Workflows source) |
|||
{ |
|||
foreach (var (key, workflow) in source) |
|||
{ |
|||
Add(key, workflow); |
|||
} |
|||
} |
|||
|
|||
public Workflows ToSource() |
|||
{ |
|||
return new Workflows(this); |
|||
} |
|||
} |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<SquidexFreezable /> |
|||
|
|||
<Equals /> |
|||
</Weavers> |
|||
@ -1,27 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="SquidexFreezable" minOccurs="0" maxOccurs="1" type="xs:anyType" /> |
|||
<xs:element name="Equals" minOccurs="0" maxOccurs="1" type="xs:anyType" /> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -1,39 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using Squidex.Infrastructure; |
|||
using Squidex.Infrastructure.Reflection; |
|||
|
|||
namespace Squidex.Domain.Apps.Core |
|||
{ |
|||
[Equals(DoNotAddEquals = true, DoNotAddGetHashCode = true, DoNotAddEqualityOperators = true)] |
|||
public abstract class Freezable : IFreezable |
|||
{ |
|||
private bool isFrozen; |
|||
|
|||
[IgnoreEquals] |
|||
[IgnoreDuringEquals] |
|||
public bool IsFrozen |
|||
{ |
|||
get => isFrozen; |
|||
} |
|||
|
|||
protected void CheckIfFrozen() |
|||
{ |
|||
if (isFrozen) |
|||
{ |
|||
throw new InvalidOperationException("Object is frozen"); |
|||
} |
|||
} |
|||
|
|||
public virtual void Freeze() |
|||
{ |
|||
isFrozen = true; |
|||
} |
|||
} |
|||
} |
|||
@ -1,147 +1,124 @@ |
|||
// ==========================================================================
|
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Diagnostics.Contracts; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.Schemas |
|||
{ |
|||
public abstract class RootField : Cloneable<RootField>, IRootField |
|||
public abstract class RootField : FieldBase, IRootField |
|||
{ |
|||
private readonly long fieldId; |
|||
private readonly string fieldName; |
|||
private readonly Partitioning partitioning; |
|||
private bool isDisabled; |
|||
private bool isHidden; |
|||
private bool isLocked; |
|||
|
|||
public long Id |
|||
{ |
|||
get => fieldId; |
|||
} |
|||
public Partitioning Partitioning { get; } |
|||
|
|||
public string Name |
|||
{ |
|||
get => fieldName; |
|||
} |
|||
public bool IsLocked { get; private set; } |
|||
|
|||
public bool IsLocked |
|||
{ |
|||
get => isLocked; |
|||
} |
|||
public bool IsHidden { get; private set; } |
|||
|
|||
public bool IsHidden |
|||
{ |
|||
get => isHidden; |
|||
} |
|||
|
|||
public bool IsDisabled |
|||
{ |
|||
get => isDisabled; |
|||
} |
|||
|
|||
public Partitioning Partitioning |
|||
{ |
|||
get => partitioning; |
|||
} |
|||
public bool IsDisabled { get; private set; } |
|||
|
|||
public abstract FieldProperties RawProperties { get; } |
|||
|
|||
protected RootField(long id, string name, Partitioning partitioning, IFieldSettings? settings = null) |
|||
: base(id, name) |
|||
{ |
|||
Guard.NotNullOrEmpty(name, nameof(name)); |
|||
Guard.GreaterThan(id, 0, nameof(id)); |
|||
Guard.NotNull(partitioning, nameof(partitioning)); |
|||
|
|||
fieldId = id; |
|||
fieldName = name; |
|||
|
|||
this.partitioning = partitioning; |
|||
Partitioning = partitioning; |
|||
|
|||
if (settings != null) |
|||
{ |
|||
isLocked = settings.IsLocked; |
|||
isHidden = settings.IsHidden; |
|||
isDisabled = settings.IsDisabled; |
|||
IsLocked = settings.IsLocked; |
|||
IsHidden = settings.IsHidden; |
|||
IsDisabled = settings.IsDisabled; |
|||
} |
|||
} |
|||
|
|||
[Pure] |
|||
public RootField Lock() |
|||
{ |
|||
if (isLocked) |
|||
if (IsLocked) |
|||
{ |
|||
return this; |
|||
} |
|||
|
|||
return Clone(clone => |
|||
{ |
|||
clone.isLocked = true; |
|||
clone.IsLocked = true; |
|||
}); |
|||
} |
|||
|
|||
[Pure] |
|||
public RootField Hide() |
|||
{ |
|||
if (isHidden) |
|||
if (IsHidden) |
|||
{ |
|||
return this; |
|||
} |
|||
|
|||
return Clone(clone => |
|||
{ |
|||
clone.isHidden = true; |
|||
clone.IsHidden = true; |
|||
}); |
|||
} |
|||
|
|||
[Pure] |
|||
public RootField Show() |
|||
{ |
|||
if (!isHidden) |
|||
if (!IsHidden) |
|||
{ |
|||
return this; |
|||
} |
|||
|
|||
return Clone(clone => |
|||
{ |
|||
clone.isHidden = false; |
|||
clone.IsHidden = false; |
|||
}); |
|||
} |
|||
|
|||
[Pure] |
|||
public RootField Disable() |
|||
{ |
|||
if (isDisabled) |
|||
if (IsDisabled) |
|||
{ |
|||
return this; |
|||
} |
|||
|
|||
return Clone(clone => |
|||
{ |
|||
clone.isDisabled = true; |
|||
clone.IsDisabled = true; |
|||
}); |
|||
} |
|||
|
|||
[Pure] |
|||
public RootField Enable() |
|||
{ |
|||
if (!isDisabled) |
|||
if (!IsDisabled) |
|||
{ |
|||
return this; |
|||
} |
|||
|
|||
return Clone(clone => |
|||
{ |
|||
clone.isDisabled = false; |
|||
clone.IsDisabled = false; |
|||
}); |
|||
} |
|||
|
|||
public abstract T Accept<T, TArgs>(IFieldVisitor<T, TArgs> visitor, TArgs args); |
|||
|
|||
public abstract RootField Update(FieldProperties newProperties); |
|||
|
|||
protected RootField Clone(Action<RootField> updater) |
|||
{ |
|||
var clone = (RootField)MemberwiseClone(); |
|||
|
|||
updater(clone); |
|||
|
|||
return clone; |
|||
} |
|||
} |
|||
} |
|||
@ -1,25 +1,24 @@ |
|||
// ==========================================================================
|
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.ObjectModel; |
|||
using Squidex.Infrastructure.Collections; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.Schemas |
|||
{ |
|||
[Equals(DoNotAddEqualityOperators = true)] |
|||
public sealed class SchemaProperties : NamedElementPropertiesBase |
|||
public sealed record SchemaProperties : NamedElementPropertiesBase |
|||
{ |
|||
public ReadOnlyCollection<string>? Tags { get; set; } |
|||
public ImmutableList<string>? Tags { get; init; } |
|||
|
|||
public string? ContentsSidebarUrl { get; set; } |
|||
public string? ContentsSidebarUrl { get; init; } |
|||
|
|||
public string? ContentSidebarUrl { get; set; } |
|||
public string? ContentSidebarUrl { get; init; } |
|||
|
|||
public string? ContentEditorUrl { get; set; } |
|||
public string? ContentEditorUrl { get; init; } |
|||
|
|||
public bool ValidateOnPublish { get; set; } |
|||
public bool ValidateOnPublish { get; init; } |
|||
} |
|||
} |
|||
@ -1,19 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
|
|||
namespace Squidex.Infrastructure |
|||
{ |
|||
public abstract class Cloneable<T> : Cloneable where T : Cloneable |
|||
{ |
|||
protected T Clone(Action<T> updater) |
|||
{ |
|||
return base.Clone(updater); |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue