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
|
// Squidex Headless CMS
|
||||
// ==========================================================================
|
// ==========================================================================
|
||||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
// All rights reserved. Licensed under the MIT license.
|
// All rights reserved. Licensed under the MIT license.
|
||||
// ==========================================================================
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
using System.Diagnostics.Contracts; |
using System.Diagnostics.Contracts; |
||||
using Squidex.Infrastructure; |
using Squidex.Infrastructure; |
||||
|
|
||||
namespace Squidex.Domain.Apps.Core.Schemas |
namespace Squidex.Domain.Apps.Core.Schemas |
||||
{ |
{ |
||||
public abstract class RootField : Cloneable<RootField>, IRootField |
public abstract class RootField : FieldBase, IRootField |
||||
{ |
{ |
||||
private readonly long fieldId; |
public Partitioning Partitioning { get; } |
||||
private readonly string fieldName; |
|
||||
private readonly Partitioning partitioning; |
|
||||
private bool isDisabled; |
|
||||
private bool isHidden; |
|
||||
private bool isLocked; |
|
||||
|
|
||||
public long Id |
|
||||
{ |
|
||||
get => fieldId; |
|
||||
} |
|
||||
|
|
||||
public string Name |
public bool IsLocked { get; private set; } |
||||
{ |
|
||||
get => fieldName; |
|
||||
} |
|
||||
|
|
||||
public bool IsLocked |
public bool IsHidden { get; private set; } |
||||
{ |
|
||||
get => isLocked; |
|
||||
} |
|
||||
|
|
||||
public bool IsHidden |
public bool IsDisabled { get; private set; } |
||||
{ |
|
||||
get => isHidden; |
|
||||
} |
|
||||
|
|
||||
public bool IsDisabled |
|
||||
{ |
|
||||
get => isDisabled; |
|
||||
} |
|
||||
|
|
||||
public Partitioning Partitioning |
|
||||
{ |
|
||||
get => partitioning; |
|
||||
} |
|
||||
|
|
||||
public abstract FieldProperties RawProperties { get; } |
public abstract FieldProperties RawProperties { get; } |
||||
|
|
||||
protected RootField(long id, string name, Partitioning partitioning, IFieldSettings? settings = null) |
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)); |
Guard.NotNull(partitioning, nameof(partitioning)); |
||||
|
|
||||
fieldId = id; |
Partitioning = partitioning; |
||||
fieldName = name; |
|
||||
|
|
||||
this.partitioning = partitioning; |
|
||||
|
|
||||
if (settings != null) |
if (settings != null) |
||||
{ |
{ |
||||
isLocked = settings.IsLocked; |
IsLocked = settings.IsLocked; |
||||
isHidden = settings.IsHidden; |
IsHidden = settings.IsHidden; |
||||
isDisabled = settings.IsDisabled; |
IsDisabled = settings.IsDisabled; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
[Pure] |
[Pure] |
||||
public RootField Lock() |
public RootField Lock() |
||||
{ |
{ |
||||
if (isLocked) |
if (IsLocked) |
||||
{ |
{ |
||||
return this; |
return this; |
||||
} |
} |
||||
|
|
||||
return Clone(clone => |
return Clone(clone => |
||||
{ |
{ |
||||
clone.isLocked = true; |
clone.IsLocked = true; |
||||
}); |
}); |
||||
} |
} |
||||
|
|
||||
[Pure] |
[Pure] |
||||
public RootField Hide() |
public RootField Hide() |
||||
{ |
{ |
||||
if (isHidden) |
if (IsHidden) |
||||
{ |
{ |
||||
return this; |
return this; |
||||
} |
} |
||||
|
|
||||
return Clone(clone => |
return Clone(clone => |
||||
{ |
{ |
||||
clone.isHidden = true; |
clone.IsHidden = true; |
||||
}); |
}); |
||||
} |
} |
||||
|
|
||||
[Pure] |
[Pure] |
||||
public RootField Show() |
public RootField Show() |
||||
{ |
{ |
||||
if (!isHidden) |
if (!IsHidden) |
||||
{ |
{ |
||||
return this; |
return this; |
||||
} |
} |
||||
|
|
||||
return Clone(clone => |
return Clone(clone => |
||||
{ |
{ |
||||
clone.isHidden = false; |
clone.IsHidden = false; |
||||
}); |
}); |
||||
} |
} |
||||
|
|
||||
[Pure] |
[Pure] |
||||
public RootField Disable() |
public RootField Disable() |
||||
{ |
{ |
||||
if (isDisabled) |
if (IsDisabled) |
||||
{ |
{ |
||||
return this; |
return this; |
||||
} |
} |
||||
|
|
||||
return Clone(clone => |
return Clone(clone => |
||||
{ |
{ |
||||
clone.isDisabled = true; |
clone.IsDisabled = true; |
||||
}); |
}); |
||||
} |
} |
||||
|
|
||||
[Pure] |
[Pure] |
||||
public RootField Enable() |
public RootField Enable() |
||||
{ |
{ |
||||
if (!isDisabled) |
if (!IsDisabled) |
||||
{ |
{ |
||||
return this; |
return this; |
||||
} |
} |
||||
|
|
||||
return Clone(clone => |
return Clone(clone => |
||||
{ |
{ |
||||
clone.isDisabled = false; |
clone.IsDisabled = false; |
||||
}); |
}); |
||||
} |
} |
||||
|
|
||||
public abstract T Accept<T, TArgs>(IFieldVisitor<T, TArgs> visitor, TArgs args); |
public abstract T Accept<T, TArgs>(IFieldVisitor<T, TArgs> visitor, TArgs args); |
||||
|
|
||||
public abstract RootField Update(FieldProperties newProperties); |
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
|
// Squidex Headless CMS
|
||||
// ==========================================================================
|
// ==========================================================================
|
||||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
// All rights reserved. Licensed under the MIT license.
|
// All rights reserved. Licensed under the MIT license.
|
||||
// ==========================================================================
|
// ==========================================================================
|
||||
|
|
||||
using System.Collections.ObjectModel; |
using Squidex.Infrastructure.Collections; |
||||
|
|
||||
namespace Squidex.Domain.Apps.Core.Schemas |
namespace Squidex.Domain.Apps.Core.Schemas |
||||
{ |
{ |
||||
[Equals(DoNotAddEqualityOperators = true)] |
public sealed record SchemaProperties : NamedElementPropertiesBase |
||||
public sealed class 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