diff --git a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceSynchronizationAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceSynchronizationAttribute.cs new file mode 100644 index 000000000..40c3ee3e1 --- /dev/null +++ b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceSynchronizationAttribute.cs @@ -0,0 +1,36 @@ +// Copyright (c) 2025, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System; + +namespace Moryx.AbstractionLayer.Resources.Attributes; + +/// +/// Specifies the synchronization behavior for a resource's digital twin +/// across multiple application instances. +/// +[AttributeUsage(AttributeTargets.Class, Inherited = false)] +public class ResourceSynchronizationAttribute: Attribute +{ + /// + /// Defines the property serialization strategy for this resource. + /// + public SynchronizationMode Mode { get; set; } +} + +/// +/// Defines the property serialization strategy. +/// +public enum SynchronizationMode +{ + /// + /// The entire resource object, including all its properties, is serialized and synchronized. + /// + Full, + + /// + /// Only properties explicitly marked with the [SynchronizableMember] attribute will be + /// serialized and synchronized. + /// + Selective +} \ No newline at end of file diff --git a/src/Moryx.AbstractionLayer/Resources/Attributes/SynchronizableMemberAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Attributes/SynchronizableMemberAttribute.cs new file mode 100644 index 000000000..4c5b752a9 --- /dev/null +++ b/src/Moryx.AbstractionLayer/Resources/Attributes/SynchronizableMemberAttribute.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2025, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System; + +namespace Moryx.AbstractionLayer.Resources.Attributes; + +/// +/// Marks a property as included in the payload when its class +/// is using 'Selective' synchronization mode. +/// +[AttributeUsage(AttributeTargets.Property)] +public class SynchronizableMemberAttribute : Attribute { } diff --git a/src/Moryx.AbstractionLayer/Resources/IResourceManagementChanges.cs b/src/Moryx.AbstractionLayer/Resources/IResourceManagementChanges.cs index a73eb238c..012607f19 100644 --- a/src/Moryx.AbstractionLayer/Resources/IResourceManagementChanges.cs +++ b/src/Moryx.AbstractionLayer/Resources/IResourceManagementChanges.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2025, Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System; namespace Moryx.AbstractionLayer.Resources;