RobotResolver.cs
871 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>
/// 机器人属性解析器 - 从Robot对象获取属性值
/// @author zzy
/// </summary>
public class RobotResolver : IParameterValueResolver
{
public ParameterSourceType SourceType => ParameterSourceType.Robot;
public object? Resolve(ActionParameterDefinition definition, ParameterContext context)
{
if (context.Robot == null || string.IsNullOrEmpty(definition.ParameterSourcePath))
return definition.DefaultValue;
var value = PropertyPathResolver.GetValue(context.Robot, definition.ParameterSourcePath);
return value ?? definition.DefaultValue;
}
}
}