feat: Adds SerializedCommandProperty (#1249)

## Breaking Change
* Removes `SerializableFieldAttrAttribute` in favor of `SerializedPropertyAttr`.

## Important Change
* Adds `SerializedCommandProperty`

Example:
```cs
    [InvalidateProperties]
    [SerializableField(0)]
    [SerializedCommandProperty(AccessLevel.GameMaster)]
    private Mobile _completedBy;
```
This commit is contained in:
Kamron Batman 2022-11-14 18:24:33 -08:00 • committed by GitHub
parent 5660f4636e
commit 936000ecf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 272 additions and 231 deletions

View file

@ -1,6 +1,22 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2022 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: Attributes.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Collections.Generic;
using System.Reflection;
using ModernUO.Serialization;
namespace Server;
@ -133,3 +149,28 @@ public class CommandPropertyAttribute : Attribute
public bool ReadOnly { get; }
public bool CanModify { get; }
}
[AttributeUsage(AttributeTargets.Field)]
public class SerializedCommandPropertyAttribute : SerializedPropertyAttrAttribute<CommandPropertyAttribute>
{
public SerializedCommandPropertyAttribute(
AccessLevel level,
bool readOnly = false,
bool canModify = false
) : this(level, level)
{
ReadOnly = readOnly;
CanModify = canModify;
}
public SerializedCommandPropertyAttribute(AccessLevel readLevel, AccessLevel writeLevel)
{
ReadLevel = readLevel;
WriteLevel = writeLevel;
}
public AccessLevel ReadLevel { get; }
public AccessLevel WriteLevel { get; }
public bool ReadOnly { get; }
public bool CanModify { get; }
}

View file

@ -36,8 +36,8 @@
<PackageReference Include="Standart.Hash.xxHash.Signed" Version="4.0.5" />
<PackageReference Include="Zlib.Bindings" Version="1.10.1" />
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.5.3" />
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.5.2" />
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.6.0" />
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.6.0" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="Migrations/*.v*.json" />