예제 #1
0
        private static FuncFieldResolver <object?> PartitionResolver(ValueResolver valueResolver, string key)
        {
            return(new FuncFieldResolver <object?>(c =>
            {
                var source = (ContentFieldData)c.Source;

                if (source.TryGetValue(key, out var value) && value != null)
                {
                    return valueResolver(value, c);
                }
                else
                {
                    return null;
                }
            }));
        }
예제 #2
0
    protected override void DrawPropertyLayout(GUIContent label)
    {
        ValueResolver.DrawErrors(this.colorResolver, this.conditionResolver);

        bool condition = this.conditionResolver.GetValue();

        if (condition)
        {
            GUIHelper.PushColor(this.colorResolver.GetValue());
        }

        this.CallNextDrawer(label);

        if (condition)
        {
            GUIHelper.PopColor();
        }
    }
예제 #3
0
        public static ActionInfo BuildActionFromDefinition(ActionLinkDefinition definition, FormContext context)
        {
            string url = definition.Action;

            if (definition.ActionType == ActionType.Function)
            {
                url = "";
            }

            if (definition.ActionType != ActionType.Page)
            {
                url = GetUrlFromActionType(definition.ActionType);
            }

            url = string.Format("{0}{1}", context.Context.AppRoot, url);

            var q = context.RequestQuery.Clone();

            if (definition.QueryParam != null && definition.QueryParam.Count > 0)
            {
                q = new RequestQueryString();
                foreach (var p in definition.QueryParam)
                {
                    q.Add(p.Name, ValueResolver.ResolveValue(context, p.Value).ToString());
                }
            }

            var actionI = new ActionInfo(url, q, definition.ActionId);

            actionI.Title         = definition.Text;
            actionI.ActionType    = definition.ActionType;
            actionI.ExecutionType = definition.ExecType;

            if (definition.ActionType == ActionType.Function)
            {
                actionI.AddAttribute("Function", definition.Action);
                actionI.ExecutionType = ActionExecutionType.Custom;
            }

            return(actionI);
        }
예제 #4
0
        void ICanAddThenDo <TSource, TReceiverMember> .ThenDo(ValueResolver <TSource, TReceiverMember> resolver)
        {
            if (resolver == null)
            {
                throw new ArgumentNullException(nameof(resolver));
            }

            if (_state.Count == 0)
            {
                throw new InvalidOperationException("No mapping actions were configured");
            }

            var lastEntry = _state.Last();

            if (lastEntry.Value != null)
            {
                throw new InvalidOperationException("Last mapping action was configured");
            }

            _state[lastEntry.Key] = resolver;
        }
        public bool MatchesCondition(InspectorProperty property)
        {
#if ODIN_INSPECTOR_3
            if (string.IsNullOrEmpty(requiredCondition))
            {
                return(true);
            }

            // Cannot be cached very well unless we use a property resolver instead which is much messier
            var conditionResolver = ValueResolver.Get(property, RequiredCondition, true);

            conditionResolver.Context.Property = property;
            if (conditionResolver.HasError)
            {
                Debug.LogError(conditionResolver.ErrorMessage, this);
                return(true);                // Default to true
            }

            return(conditionResolver.GetValue());
#else
            return(true);
#endif
        }
예제 #6
0
 protected override void Initialize()
 {
     this.eventPathResolver = ValueResolver.Get <string>(this.Property, this.Attribute.EventPathResolver);
 }
예제 #7
0
 public void SetUp()
 {
     this.variableResolver = Substitute.For <IVariableResolver>();
     this.typeTranslator   = Substitute.For <ITypeTranslator>();
     this.valueResolver    = new ValueResolver(this.variableResolver, this.typeTranslator);
 }
예제 #8
0
 private static FuncFieldResolver <object?> ValueResolver(NestedField nestedField, ValueResolver resolver)
 {
     return(new FuncFieldResolver <object?>(c =>
     {
         if (((JsonObject)c.Source).TryGetValue(nestedField.Name, out var value))
         {
             return resolver(value, c);
         }
         else
         {
             return null;
         }
     }));
 }
 protected override void Initialize()
 {
     this.valueResolver = ValueResolver.Get <object>(this.Property, this.Attribute.ValueString);
 }
예제 #10
0
 public object ResolveValue(object dataContext)
 {
     return(ValueResolver.ResolveValue(this, dataContext));
 }
예제 #11
0
 protected override void Initialize()
 {
     this.colorResolver     = ValueResolver.Get <Color>(this.Property, this.Attribute.color, Color.white);
     this.conditionResolver = ValueResolver.Get <bool>(this.Property, this.Attribute.condition);
 }