EdgeResolver.cs 863 Bytes
using Rcs.Domain.Entities;
using Rcs.Domain.Enums;
using Rcs.Domain.Models;
using Rcs.Domain.Services;
using Rcs.Shared.Utils;

namespace Rcs.Infrastructure.Services.ParameterResolvers
{
    /// <summary>
    /// 边属性解析器 - 从MapEdge对象获取属性值
    /// @author zzy
    /// </summary>
    public class EdgeResolver : IParameterValueResolver
    {
        public ParameterSourceType SourceType => ParameterSourceType.Edge;

        public object? Resolve(ActionParameterDefinition definition, ParameterContext context)
        {
            if (context.Edge == null || string.IsNullOrEmpty(definition.ParameterSourcePath))
                return definition.DefaultValue;

            var value = PropertyPathResolver.GetValue(context.Edge, definition.ParameterSourcePath);
            return value ?? definition.DefaultValue;
        }
    }
}