コード例 #1
0
        public override async ValueTask <FluidValue> ResolveAsync(Scope value, TemplateContext context)
        {
            var result = value.GetValue(Identifier);

            if (result.IsNil() && context.Model != null)
            {
                // Look into the Model if defined
                _accessor = _accessor ?? context.MemberAccessStrategy.GetAccessor(context.Model.GetType(), Identifier);

                if (_accessor != null)
                {
                    if (_accessor is IAsyncMemberAccessor asyncAccessor)
                    {
                        var o = await asyncAccessor.GetAsync(context.Model, Identifier, context);

                        return(FluidValue.Create(o));
                    }

                    return(FluidValue.Create(_accessor.Get(context.Model, Identifier, context)));
                }
                else
                {
                    return(NilValue.Instance);
                }
            }

            return(result);
        }
コード例 #2
0
        public object GetValue()
        {
            switch (_status)
            {
            case MemberStatus.Unknown:
                this.InitAccessor();
                return(_accessor != null?_accessor.Get(_target) : null);

            case MemberStatus.Primitive:
            case MemberStatus.Complex:
                return(_accessor.Get(_target));

            default:
                return(null);
            }
        }
コード例 #3
0
 /// <summary>
 /// Sets the base value to the current state. This should only be called if you've modified what you'd like the base value to be on the target.
 /// </summary>
 public void ReinitBaseValue()
 {
     if (_accessor != null)
     {
         _baseValue = ConvertUtil.ToDouble(_accessor.Get(_target));
         this.ApplyModifier(this, _baseValue);
     }
 }
コード例 #4
0
ファイル: IdentifierSegment.cs プロジェクト: Codinlab/fluid
        public override ValueTask <FluidValue> ResolveAsync(Scope value, TemplateContext context)
        {
            async ValueTask <FluidValue> Awaited(
                IAsyncMemberAccessor asyncAccessor,
                TemplateContext ctx,
                string identifier)
            {
                var o = await asyncAccessor.GetAsync(ctx.Model, identifier, ctx);

                return(FluidValue.Create(o, context.Options));
            }

            var result = value.GetValue(Identifier);

            // If there are no named property for this identifier, check in the Model
            if (result.IsNil() && context.Model != null)
            {
                // Check for a custom registration
                var modelType = context.Model.GetType();
                if (modelType != _type)
                {
                    _accessor = context.Options.MemberAccessStrategy.GetAccessor(modelType, Identifier);
                    _accessor ??= MemberAccessStrategyExtensions.GetNamedAccessor(modelType, Identifier, MemberNameStrategies.Default);

                    if (_accessor != null)
                    {
                        _type = modelType;
                    }
                }

                if (_accessor != null)
                {
                    if (_accessor is IAsyncMemberAccessor asyncAccessor)
                    {
                        return(Awaited(asyncAccessor, context, Identifier));
                    }

                    return(new ValueTask <FluidValue>(FluidValue.Create(_accessor.Get(context.Model, Identifier, context), context.Options)));
                }

                return(new ValueTask <FluidValue>(NilValue.Instance));
            }

            return(new ValueTask <FluidValue>(result));
        }
コード例 #5
0
ファイル: ABSTweenPlugin.cs プロジェクト: yueding/hotween
        /// <summary>
        /// Gets the current value of the controlled property.
        /// Some plugins (like PlugSetColor) might override this to set values on different properties.
        /// </summary>
        protected virtual object GetValue()
        {
            if (_useSpeedTransformAccessors)
            {
                // Use specific accessors
                if (_getTransformVector3 != null)
                {
                    return(_getTransformVector3());
                }
                else
                {
                    return(_getTransformQuaternion());
                }
            }
            else
            {
#if MICRO
                if (propInfo != null)
                {
                    //return propInfo.GetValue(tweenObj.target, null);
                    return(propInfo.GetGetMethod().Invoke(tweenObj.target, null)); // HACK for reflection bug with some generics on iOS
                }
                return(fieldInfo.GetValue(tweenObj.target));
#else
                if (HOTween.isIOS)
                {
                    if (propInfo != null)
                    {
                        //return propInfo.GetValue(tweenObj.target, null);
                        return(propInfo.GetGetMethod().Invoke(tweenObj.target, null)); // HACK for reflection bug with some generics on iOS
                    }
                    return(fieldInfo.GetValue(tweenObj.target));
                }
                return(valAccessor.Get(tweenObj.target));
#endif
            }
        }
コード例 #6
0
 public object Get(object target)
 {
     return(_pimp.Get(_chain.Get(target)));
 }
コード例 #7
0
 /// <summary>
 /// Retrieves the value currently stored in the member (field or property) connected to this out-pin.
 /// </summary>
 /// <returns></returns>
 public T GetValue()
 {
     return(_memberAccessor.Get(N.O));
 }
コード例 #8
0
 public object Get(object target)
 {
     return((_alternate != null) ? _alternate.Get(target) : _getter(target as Transform));
 }