Ejemplo n.º 1
0
        protected override void TryConfigure(
            IDescriptorContext context,
            IDescriptor descriptor,
            ICustomAttributeProvider element)
        {
            if (descriptor is IObjectFieldDescriptor objectField)
            {
                objectField
                .Argument("unit", a => a.Type <EnumType <Unit> >().DefaultValue(Unit.Meters))
                .Use(next => async context =>
                {
                    await next(context).ConfigureAwait(false);

                    if (context.Result is double length)
                    {
                        context.Result = ConvertToUnit(length, context.Argument <Unit>("unit"));
                    }
                });
            }
            else if (descriptor is IInterfaceFieldDescriptor interfaceField)
            {
                interfaceField
                .Argument("unit", a => a.Type <EnumType <Unit> >().DefaultValue(Unit.Meters));
            }
        }