From 0fef0ea4769eba61be8b84ccd0f94fc5043529cc Mon Sep 17 00:00:00 2001 From: usercode <2958488+usercode@users.noreply.github.com> Date: Sat, 27 Jan 2024 10:38:23 +0100 Subject: [PATCH] Refactoring --- src/DragonFly.App.Server/Program.cs | 9 +++- .../Assets/VideoProcessing.cs | 9 ---- .../BlockFieldAttribute.Generator.cs | 2 +- .../Extensions/DragonFlyApiExtensions.cs | 14 ++++-- .../Metadata/Base/IAssetMetadataComponent.cs | 3 +- .../Fields/Base/FieldComponent.cs | 2 +- .../Fields/Base/FieldComponent2.cs | 2 +- .../Fields/Base/IFieldComponent.cs | 6 +++ .../Query/Base/IFieldQueryComponent.cs | 4 +- .../Services/ComponentManager.cs | 16 +++---- .../Models/Fields/FieldFactory.cs | 48 ++++++------------- .../Fields/FieldManager/FieldManager.cs | 4 +- .../Fields/FieldManager/Results/FieldAdded.cs | 23 +++++---- .../Models/Fields/FieldOptions.cs | 3 ++ .../Models/Fields/IContentField.cs | 16 ------- .../Models/Fields/IContentFieldFactory.cs | 10 ++++ .../Models/Fields/SingleValueField.cs | 1 - .../Attributes/Fields/AssetFieldAttribute.cs | 4 +- .../Attributes/Fields/BaseFieldAttribute.cs | 2 +- .../Attributes/Fields/BoolFieldAttribute.cs | 4 +- .../Attributes/Fields/DateFieldAttribute.cs | 4 +- .../Attributes/Fields/FloatFieldAttribute.cs | 4 +- .../Fields/GeolocationFieldAttribute.cs | 4 +- .../Attributes/Fields/HtmlFieldAttribute.cs | 2 +- .../Fields/IntegerFieldAttribute.cs | 4 +- .../Fields/ReferenceFieldAttribute.cs | 4 +- .../Attributes/Fields/SlugFieldAttribute.cs | 4 +- .../Attributes/Fields/StringFieldAttribute.cs | 4 +- .../Attributes/Fields/TextFieldAttribute.cs | 2 +- src/DragonFly.Generator/FieldGenerator.cs | 2 +- .../SourceBuilder/SourceBuilderExtensions.cs | 2 +- 31 files changed, 101 insertions(+), 117 deletions(-) delete mode 100644 src/DragonFly.Core/Modules/ContentItems/Models/Fields/IContentField.cs create mode 100644 src/DragonFly.Core/Modules/ContentItems/Models/Fields/IContentFieldFactory.cs diff --git a/src/DragonFly.App.Server/Program.cs b/src/DragonFly.App.Server/Program.cs index f599fe90..5353881a 100644 --- a/src/DragonFly.App.Server/Program.cs +++ b/src/DragonFly.App.Server/Program.cs @@ -11,6 +11,7 @@ using DragonFly.MongoDB; using DragonFlyABC; using DragonFlyTEST; +using FFMpegCore; using ImageWizard; using ImageWizard.Caches; using Microsoft.AspNetCore.Builder; @@ -45,6 +46,12 @@ options.KnownProxies.Clear(); }); +GlobalFFOptions.Configure(x => +{ + x.BinaryFolder = "C:\\Users\\admin\\Downloads"; + x.TemporaryFilesFolder = "C:\\Users\\admin\\Downloads"; +}); + //DragonFly services builder.Services.AddDragonFly() .AddImageWizard() @@ -63,8 +70,6 @@ }) ; - - var app = builder.Build(); //init DragonFly diff --git a/src/DragonFly.AspNetCore/Assets/VideoProcessing.cs b/src/DragonFly.AspNetCore/Assets/VideoProcessing.cs index 8ac452de..e966056b 100644 --- a/src/DragonFly.AspNetCore/Assets/VideoProcessing.cs +++ b/src/DragonFly.AspNetCore/Assets/VideoProcessing.cs @@ -3,9 +3,6 @@ // MIT License using FFMpegCore; -using FFMpegCore.Builders.MetaData; -using Microsoft.AspNetCore.Components.Forms; -using SixLabors.ImageSharp; namespace DragonFly.AspNetCore; @@ -27,12 +24,6 @@ public bool CanUse(string mimeType) public async Task OnAssetChangedAsync(IAssetProcessingContext context) { - GlobalFFOptions.Configure(x => - { - x.BinaryFolder = "C:\\Users\\admin\\Downloads"; - x.TemporaryFilesFolder = "C:\\Users\\admin\\Downloads"; - }); - using Stream stream = await context.OpenAssetStreamAsync(); IMediaAnalysis mediaInfo = FFProbe.Analyse(stream); diff --git a/src/DragonFly.BlockField.Core/Attributes/BlockFieldAttribute.Generator.cs b/src/DragonFly.BlockField.Core/Attributes/BlockFieldAttribute.Generator.cs index 33a9a127..60f0b68b 100644 --- a/src/DragonFly.BlockField.Core/Attributes/BlockFieldAttribute.Generator.cs +++ b/src/DragonFly.BlockField.Core/Attributes/BlockFieldAttribute.Generator.cs @@ -12,7 +12,7 @@ public BlockFieldAttribute() { } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { schema.AddField( name: property, diff --git a/src/DragonFly.Client/Extensions/DragonFlyApiExtensions.cs b/src/DragonFly.Client/Extensions/DragonFlyApiExtensions.cs index f9cb8261..fadfb7b2 100644 --- a/src/DragonFly.Client/Extensions/DragonFlyApiExtensions.cs +++ b/src/DragonFly.Client/Extensions/DragonFlyApiExtensions.cs @@ -9,7 +9,15 @@ namespace DragonFly; public static class DragonFlyApiExtensions { - public static FieldAdded WithFieldView(this FieldAdded field) + //public static IFieldAdded WithFieldView2(this IFieldAdded field, Func> component) + // where T : ContentField + //{ + // ComponentManager.Default.Add(typeof(T), typeof(TFieldView)); + + // return field; + //} + + public static IFieldAdded WithFieldView(this IFieldAdded field) where TFieldView : IFieldComponent, new() { Type fieldType = new TFieldView().FieldType; @@ -19,7 +27,7 @@ public static FieldAdded WithFieldView(this FieldAdded field) return field; } - public static FieldAdded WithOptionView(this FieldAdded field) + public static IFieldAdded WithOptionView(this IFieldAdded field) where TFieldOptionsView : IFieldOptionsComponent, new() { Type optionsType = new TFieldOptionsView().OptionsType; @@ -29,7 +37,7 @@ public static FieldAdded WithOptionView(this FieldAdded field return field; } - public static FieldAdded WithQueryView(this FieldAdded field) + public static IFieldAdded WithQueryView(this IFieldAdded field) where TFieldQueryView : IFieldQueryComponent, new() { Type queryType = new TFieldQueryView().QueryType; diff --git a/src/DragonFly.Client/Pages/Assets/Metadata/Base/IAssetMetadataComponent.cs b/src/DragonFly.Client/Pages/Assets/Metadata/Base/IAssetMetadataComponent.cs index 4ed30fff..4776b232 100644 --- a/src/DragonFly.Client/Pages/Assets/Metadata/Base/IAssetMetadataComponent.cs +++ b/src/DragonFly.Client/Pages/Assets/Metadata/Base/IAssetMetadataComponent.cs @@ -3,10 +3,11 @@ // MIT License using System; +using Microsoft.AspNetCore.Components; namespace DragonFly.Client; -public interface IAssetMetadataComponent +public interface IAssetMetadataComponent : IComponent { AssetMetadata Metadata { get; } diff --git a/src/DragonFly.Client/Pages/ContentItems/Fields/Base/FieldComponent.cs b/src/DragonFly.Client/Pages/ContentItems/Fields/Base/FieldComponent.cs index 9bc6685e..2ca1fd30 100644 --- a/src/DragonFly.Client/Pages/ContentItems/Fields/Base/FieldComponent.cs +++ b/src/DragonFly.Client/Pages/ContentItems/Fields/Base/FieldComponent.cs @@ -7,7 +7,7 @@ namespace DragonFly.Client; -public abstract class FieldComponent : ComponentBase, IFieldComponent +public abstract class FieldComponent : ComponentBase, IFieldComponent where TField : ContentField where TFieldOptions : FieldOptions { diff --git a/src/DragonFly.Client/Pages/ContentItems/Fields/Base/FieldComponent2.cs b/src/DragonFly.Client/Pages/ContentItems/Fields/Base/FieldComponent2.cs index d356f4dd..94e6235e 100644 --- a/src/DragonFly.Client/Pages/ContentItems/Fields/Base/FieldComponent2.cs +++ b/src/DragonFly.Client/Pages/ContentItems/Fields/Base/FieldComponent2.cs @@ -10,7 +10,7 @@ namespace DragonFly.Client; /// /// FieldComponent /// -public abstract class FieldComponent : ComponentBase, IFieldComponent +public abstract class FieldComponent : ComponentBase, IFieldComponent where TField : ContentField { [Parameter] diff --git a/src/DragonFly.Client/Pages/ContentItems/Fields/Base/IFieldComponent.cs b/src/DragonFly.Client/Pages/ContentItems/Fields/Base/IFieldComponent.cs index ad661df6..7db76021 100644 --- a/src/DragonFly.Client/Pages/ContentItems/Fields/Base/IFieldComponent.cs +++ b/src/DragonFly.Client/Pages/ContentItems/Fields/Base/IFieldComponent.cs @@ -15,3 +15,9 @@ public interface IFieldComponent : IComponent FieldOptions Options { get; } } + +public interface IFieldComponent : IFieldComponent + where TField : ContentField +{ + new Type FieldType => typeof(TField); +} diff --git a/src/DragonFly.Client/Pages/ContentItems/Query/Base/IFieldQueryComponent.cs b/src/DragonFly.Client/Pages/ContentItems/Query/Base/IFieldQueryComponent.cs index 7d789ac8..13b2f0dd 100644 --- a/src/DragonFly.Client/Pages/ContentItems/Query/Base/IFieldQueryComponent.cs +++ b/src/DragonFly.Client/Pages/ContentItems/Query/Base/IFieldQueryComponent.cs @@ -3,11 +3,11 @@ // MIT License using System; -using DragonFly.Query; +using Microsoft.AspNetCore.Components; namespace DragonFly.Client; -public interface IFieldQueryComponent +public interface IFieldQueryComponent : IComponent { SchemaField Field { get; } diff --git a/src/DragonFly.Client/Services/ComponentManager.cs b/src/DragonFly.Client/Services/ComponentManager.cs index 3541f284..e638b468 100644 --- a/src/DragonFly.Client/Services/ComponentManager.cs +++ b/src/DragonFly.Client/Services/ComponentManager.cs @@ -17,21 +17,16 @@ public sealed class ComponentManager /// public static ComponentManager Default { get; } = new ComponentManager(); - private IDictionary _cacheFieldView; - - private ComponentManager() - { - _cacheFieldView = new Dictionary(); - } + private IDictionary _cacheFieldView = new Dictionary(); public void Add(Type fieldType, Type componentType) { _cacheFieldView[fieldType] = componentType; } - public Type GetComponentType(Type type) + public Type GetComponentType(Type fieldType) { - if (_cacheFieldView.TryGetValue(type, out Type componentType)) + if (_cacheFieldView.TryGetValue(fieldType, out Type componentType)) { return componentType; } @@ -39,8 +34,9 @@ public Type GetComponentType(Type type) return null; } - public Type GetComponentType() + public Type GetComponentType() + where TField : ContentField { - return GetComponentType(typeof(T)); + return GetComponentType(typeof(TField)); } } diff --git a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldFactory.cs b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldFactory.cs index 9db383ea..08697ab1 100644 --- a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldFactory.cs +++ b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldFactory.cs @@ -7,65 +7,47 @@ namespace DragonFly; /// /// FieldFactory /// -public sealed class FieldFactory +public sealed class FieldFactory( + string fieldName, + Type fieldType, + Type? optionsType, + Type? queryType, + Func factoryField, + Func? factoryOptions, + Func? factoryQuery) { - public FieldFactory( - string fieldName, - Type fieldType, - Type? optionsType, - Type? queryType, - Func factoryField, - Func? factoryOptions, - Func? factoryQuery) - { - FieldName = fieldName; - FieldType = fieldType; - OptionsType = optionsType; - QueryType = queryType; - _createField = factoryField; - _createOptions = factoryOptions; - _createQuery = factoryQuery; - } - /// /// FieldName /// - public string FieldName { get; } + public string FieldName { get; } = fieldName; /// /// FieldType /// - public Type FieldType { get; } + public Type FieldType { get; } = fieldType; /// /// OptionsType /// - public Type? OptionsType { get; } + public Type? OptionsType { get; } = optionsType; /// /// QueryType /// - public Type? QueryType { get; } - - - private Func _createField; + public Type? QueryType { get; } = queryType; /// /// CreateField /// - public ContentField CreateField() => _createField(); - - private Func? _createOptions; + public ContentField CreateField() => factoryField(); /// /// CreateOptions /// - public FieldOptions? CreateOptions() => _createOptions?.Invoke(); - - private Func? _createQuery; + public FieldOptions? CreateOptions() => factoryOptions?.Invoke(); /// /// CreateQuery /// - public FieldQuery? CreateQuery() => _createQuery?.Invoke(); + public FieldQuery? CreateQuery() => factoryQuery?.Invoke(); } diff --git a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldManager/FieldManager.cs b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldManager/FieldManager.cs index e7ae4f23..d280c8a1 100644 --- a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldManager/FieldManager.cs +++ b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldManager/FieldManager.cs @@ -26,8 +26,8 @@ public sealed class FieldManager /// /// Adds to field manager. /// - public FieldAdded Add() - where TField : ContentField, IContentField + public IFieldAdded Add() + where TField : ContentField, IContentFieldFactory { FieldFactory factory = TField.Factory; diff --git a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldManager/Results/FieldAdded.cs b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldManager/Results/FieldAdded.cs index bcf0f169..e7878ba4 100644 --- a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldManager/Results/FieldAdded.cs +++ b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldManager/Results/FieldAdded.cs @@ -7,20 +7,19 @@ namespace DragonFly; /// /// FieldAdded /// -public abstract class FieldAdded +/// +public class FieldAdded : IFieldAdded + where T : ContentField { - /// - /// FieldType - /// - public abstract Type FieldType { get; } + public Type FieldType => typeof(T); } -/// -/// FieldAdded -/// -/// -public class FieldAdded : FieldAdded - where T : ContentField +public interface IFieldAdded +{ + +} + +public interface IFieldAdded : IFieldAdded { - public override Type FieldType => typeof(T); + } diff --git a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldOptions.cs b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldOptions.cs index 8e3454dd..68df8aa5 100644 --- a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldOptions.cs +++ b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/FieldOptions.cs @@ -19,5 +19,8 @@ public abstract class FieldOptions /// public bool IsSearchable { get; set; } + /// + /// CreateContentField + /// public abstract ContentField CreateContentField(); } diff --git a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/IContentField.cs b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/IContentField.cs deleted file mode 100644 index b439f1cc..00000000 --- a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/IContentField.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) usercode -// https://github.com/usercode/DragonFly -// MIT License - -using DragonFly.Validations; - -namespace DragonFly; - -public interface IContentField -{ - static abstract FieldFactory Factory { get; } - - void Validate(string fieldName, FieldOptions options, ValidationContext context); - - void Clear(); -} diff --git a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/IContentFieldFactory.cs b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/IContentFieldFactory.cs new file mode 100644 index 00000000..b1514770 --- /dev/null +++ b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/IContentFieldFactory.cs @@ -0,0 +1,10 @@ +// Copyright (c) usercode +// https://github.com/usercode/DragonFly +// MIT License + +namespace DragonFly; + +public interface IContentFieldFactory +{ + static abstract FieldFactory Factory { get; } +} diff --git a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/SingleValueField.cs b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/SingleValueField.cs index 66912370..1778e168 100644 --- a/src/DragonFly.Core/Modules/ContentItems/Models/Fields/SingleValueField.cs +++ b/src/DragonFly.Core/Modules/ContentItems/Models/Fields/SingleValueField.cs @@ -12,7 +12,6 @@ namespace DragonFly; /// public abstract class SingleValueField : ContentField, ISingleValueField { - private T? _value; /// diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/AssetFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/AssetFieldAttribute.cs index d30a1a2e..127e1a39 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/AssetFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/AssetFieldAttribute.cs @@ -12,9 +12,9 @@ public AssetFieldAttribute() public bool ShowPreview { get; set; } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { - base.AddToSchema(schema, property); + base.ApplyToSchema(schema, property); schema.AddAsset(property, x => { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/BaseFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/BaseFieldAttribute.cs index eaf75af2..fe97369a 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/BaseFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/BaseFieldAttribute.cs @@ -19,7 +19,7 @@ public abstract class BaseFieldAttribute : Attribute public bool Index { get; set; } - public virtual void AddToSchema(ContentSchema schema, string property) + public virtual void ApplyToSchema(ContentSchema schema, string property) { if (ListField) { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/BoolFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/BoolFieldAttribute.cs index a5372436..6f82f0ed 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/BoolFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/BoolFieldAttribute.cs @@ -6,9 +6,9 @@ namespace DragonFly.Generator; public class BoolFieldAttribute : BaseFieldAttribute { - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { - base.AddToSchema(schema, property); + base.ApplyToSchema(schema, property); schema.AddBool(property, x => { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/DateFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/DateFieldAttribute.cs index 0b22ea95..0c574abd 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/DateFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/DateFieldAttribute.cs @@ -10,9 +10,9 @@ public DateFieldAttribute() { } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { - base.AddToSchema(schema, property); + base.ApplyToSchema(schema, property); schema.AddDate(property, x => { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/FloatFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/FloatFieldAttribute.cs index 8f029749..f72c5346 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/FloatFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/FloatFieldAttribute.cs @@ -10,9 +10,9 @@ public FloatFieldAttribute() { } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { - base.AddToSchema(schema, property); + base.ApplyToSchema(schema, property); schema.AddFloat(property, x => { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/GeolocationFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/GeolocationFieldAttribute.cs index 332c0a3b..dcca150c 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/GeolocationFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/GeolocationFieldAttribute.cs @@ -10,9 +10,9 @@ public GeolocationFieldAttribute() { } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { - base.AddToSchema(schema, property); + base.ApplyToSchema(schema, property); schema.AddGeolocation(property, x => { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/HtmlFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/HtmlFieldAttribute.cs index 3632b7ea..a54c7752 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/HtmlFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/HtmlFieldAttribute.cs @@ -11,7 +11,7 @@ public HtmlFieldAttribute(bool isRequired = false) Required = isRequired; } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { schema.AddHtml(property, x => { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/IntegerFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/IntegerFieldAttribute.cs index 4113fe09..ed8900d3 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/IntegerFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/IntegerFieldAttribute.cs @@ -10,9 +10,9 @@ public IntegerFieldAttribute() { } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { - base.AddToSchema(schema, property); + base.ApplyToSchema(schema, property); schema.AddInteger(property, x => { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/ReferenceFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/ReferenceFieldAttribute.cs index f9e5c012..6c77aaa8 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/ReferenceFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/ReferenceFieldAttribute.cs @@ -10,9 +10,9 @@ public ReferenceFieldAttribute() { } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { - base.AddToSchema(schema, property); + base.ApplyToSchema(schema, property); schema.AddReference(property, x => { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/SlugFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/SlugFieldAttribute.cs index 68037c37..2da802d7 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/SlugFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/SlugFieldAttribute.cs @@ -10,9 +10,9 @@ public SlugFieldAttribute() { } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { - base.AddToSchema(schema, property); + base.ApplyToSchema(schema, property); schema.AddSlug(property, x => { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/StringFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/StringFieldAttribute.cs index c637c1bc..78649a91 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/StringFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/StringFieldAttribute.cs @@ -17,9 +17,9 @@ public StringFieldAttribute() public int MaxLength { get; set; } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { - base.AddToSchema(schema, property); + base.ApplyToSchema(schema, property); schema.AddString(property, x => { diff --git a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/TextFieldAttribute.cs b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/TextFieldAttribute.cs index d7b68de6..7ef0ddd1 100644 --- a/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/TextFieldAttribute.cs +++ b/src/DragonFly.Core/Modules/ContentModels/Attributes/Fields/TextFieldAttribute.cs @@ -10,7 +10,7 @@ public TextFieldAttribute() { } - public override void AddToSchema(ContentSchema schema, string property) + public override void ApplyToSchema(ContentSchema schema, string property) { schema.AddTextArea(property, x => { diff --git a/src/DragonFly.Generator/FieldGenerator.cs b/src/DragonFly.Generator/FieldGenerator.cs index 8425e61f..44d0a90f 100644 --- a/src/DragonFly.Generator/FieldGenerator.cs +++ b/src/DragonFly.Generator/FieldGenerator.cs @@ -45,7 +45,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) baseTypes.Add("ContentField"); } - baseTypes.Add("IContentField"); + baseTypes.Add("IContentFieldFactory"); string? optionsParameter = ar.ClassSyntax.GetFirstAttributeParameters("FieldOptions").FirstOrDefault(); string optionsFactory = "null"; diff --git a/src/DragonFly.Generator/SourceBuilder/SourceBuilderExtensions.cs b/src/DragonFly.Generator/SourceBuilder/SourceBuilderExtensions.cs index 7db8f175..f53646f0 100644 --- a/src/DragonFly.Generator/SourceBuilder/SourceBuilderExtensions.cs +++ b/src/DragonFly.Generator/SourceBuilder/SourceBuilderExtensions.cs @@ -349,7 +349,7 @@ public static SourceBuilder AddContentMetadataCreateSchema(this SourceBuilder bu parameters = $" {{ {property.AttributeParameters} }}"; } - x.AppendLine($"new {property.AttributeTypeSymbol.ToDisplayString()}(){parameters}.AddToSchema(schema, \"{property.PropertyName}\");"); + x.AppendLine($"new {property.AttributeTypeSymbol.ToDisplayString()}(){parameters}.ApplyToSchema(schema, \"{property.PropertyName}\");"); } x.AppendLine();