internal override void OnRemoveDynamicResource(BindableProperty property) { DynamicResources.Remove(property); if (DynamicResources.Count == 0) { _dynamicResources = null; } base.OnRemoveDynamicResource(property); }
public override bool TryEvaluate(DynamicResources resources, IValue current, out IValue value) { if (current.Type != JmesPathType.Array) { value = JsonConstants.Null; return(true); } var result = new List <IValue>(); foreach (var item in current.EnumerateArray()) { if (item.Type == JmesPathType.Array) { foreach (var elem in item.EnumerateArray()) { if (elem.Type != JmesPathType.Null) { IValue val; if (!this.TryApplyExpressions(resources, elem, out val)) { value = JsonConstants.Null; return(false); } if (val.Type != JmesPathType.Null) { result.Add(val); } } } } else { if (item.Type != JmesPathType.Null) { IValue val; if (!this.TryApplyExpressions(resources, item, out val)) { value = JsonConstants.Null; return(false); } if (val.Type != JmesPathType.Null) { result.Add(val); } } } } value = new ArrayValue(result); return(true); }
internal override void OnSetDynamicResource(BindableProperty property, string key) { base.OnSetDynamicResource(property, key); DynamicResources.Add(new KeyValuePair <string, BindableProperty>(key, property)); object value; if (this.TryGetResource(key, out value)) { OnResourceChanged(property, value); } }
internal bool TryApplyExpressions(DynamicResources resources, IValue current, out IValue value) { value = current; foreach (var expression in _expressions) { if (!expression.TryEvaluate(resources, value, out value)) { return(false); } } return(true); }
static void Main(string[] args) { var res = new CompanyAResource(); var companyResources = new global::System.Resources.ResourceManager("ConsoleApplication1.CompanyAResource", typeof(CompanyAResource).Assembly); dynamic resources = new DynamicResources(companyResources); string name = resources.CompanyName; Console.WriteLine(name); }
static UnionCache() { Type infType = TypeOf <TUnion> .TypeID; TypeBuilder tb = DynamicResources.DefineDynamicType(TypeAttributes.Sealed | TypeAttributes.Public | TypeAttributes.ExplicitLayout); tb.SetParent(TypeOf <ValueType> .TypeID); tb.AddInterfaceImplementation(infType); ImplementInterfaces(tb, infType); ImplementDataType(tb); ImplementSize(tb); UnionType = tb.CreateType(); }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); var arg0 = args[0]; var arg1 = args[1]; var comparer = ValueEqualityComparer.Instance; switch (arg0.Type) { case JmesPathType.Array: foreach (var item in arg0.EnumerateArray()) { if (comparer.Equals(item, arg1)) { result = JsonConstants.True; return(true); } } result = JsonConstants.False; return(true); case JmesPathType.String: { if (arg1.Type != JmesPathType.String) { result = JsonConstants.Null; return(false); } var s0 = arg0.GetString(); var s1 = arg1.GetString(); if (s0.Contains(s1)) { result = JsonConstants.True; return(true); } else { result = JsonConstants.False; return(true); } } default: { result = JsonConstants.Null; return(false); } } }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { foreach (var arg in args) { if (arg.Type != JmesPathType.Null) { result = arg; return(true); } } result = JsonConstants.Null; return(true); }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); var arg0 = args[0]; if (arg0.Type != JmesPathType.Array) { result = JsonConstants.Null; return(false); } if (arg0.GetArrayLength() == 0) { result = JsonConstants.Null; return(false); } bool isNumber = arg0[0].Type == JmesPathType.Number; bool isString = arg0[0].Type == JmesPathType.String; if (!isNumber && !isString) { result = JsonConstants.Null; return(false); } var less = LtOperator.Instance; int index = 0; for (int i = 1; i < arg0.GetArrayLength(); ++i) { if (!(((arg0[i].Type == JmesPathType.Number) == isNumber) && (arg0[i].Type == JmesPathType.String) == isString)) { result = JsonConstants.Null; return(false); } IValue value; if (!less.TryEvaluate(arg0[i], arg0[index], out value)) { result = JsonConstants.Null; return(false); } if (value.Type == JmesPathType.True) { index = i; } } result = arg0[index]; return(true); }
public override bool TryEvaluate(DynamicResources resources, IValue current, out IValue value) { if (current.Type == JmesPathType.Object && current.TryGetProperty(_identifier, out value)) { return(true); } else { value = JsonConstants.Null; return(true); } }
public override bool TryEvaluate(DynamicResources resources, IValue current, out IValue value) { IValue val; if (!_expr.TryEvaluate(resources, current, out val)) { value = JsonConstants.Null; return(true); } value = val; return(true); }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); var arg0 = args[0]; if (arg0.Type != JmesPathType.Array) { result = JsonConstants.Null; return(false); } if (arg0.GetArrayLength() <= 1) { result = arg0; return(true); } bool isNumber1 = arg0[0].Type == JmesPathType.Number; bool isString1 = arg0[0].Type == JmesPathType.String; if (!isNumber1 && !isString1) { result = JsonConstants.Null; return(false); } var comparer = ValueComparer.Instance; var list = new List <IValue>(); foreach (var item in arg0.EnumerateArray()) { bool isNumber2 = item.Type == JmesPathType.Number; bool isString2 = item.Type == JmesPathType.String; if (!(isNumber2 == isNumber1 && isString2 == isString1)) { result = JsonConstants.Null; return(false); } list.Add(item); } list.Sort(comparer); result = new ArrayValue(list); return(true); }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { if (args.Count() == 0) { result = JsonConstants.Null; return(false); } var arg0 = args[0]; if (arg0.Type != JmesPathType.Object) { result = JsonConstants.Null; return(false); } if (args.Count == 1) { result = arg0; return(true); } var dict = new Dictionary <string, IValue>(); for (int i = 0; i < args.Count; ++i) { var argi = args[i]; if (argi.Type != JmesPathType.Object) { result = JsonConstants.Null; return(false); } foreach (var item in argi.EnumerateObject()) { if (!dict.TryAdd(item.Name, item.Value)) { dict.Remove(item.Name); dict.Add(item.Name, item.Value); } } } result = new ObjectValue(dict); return(true); }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); var arg0 = args[0]; if (arg0.Type == JmesPathType.Array) { result = arg0; return(true); } else { var list = new List <IValue>(); list.Add(arg0); result = new ArrayValue(list); return(true); } }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); var arg0 = args[0]; if (arg0.Type != JmesPathType.Object) { result = JsonConstants.Null; return(false); } var list = new List <IValue>(); foreach (var item in arg0.EnumerateObject()) { list.Add(item.Value); } result = new ArrayValue(list); return(true); }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); var arg0 = args[0]; switch (arg0.Type) { case JmesPathType.Number: result = arg0; return(true); case JmesPathType.String: { var s = arg0.GetString(); Decimal dec; double dbl; if (Decimal.TryParse(s, out dec)) { result = new DecimalValue(dec); return(true); } else if (Double.TryParse(s, out dbl)) { result = new DoubleValue(dbl); return(true); } else { result = JsonConstants.Null; return(false); } } default: result = JsonConstants.Null; return(false); } }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); var arg0 = args[0]; if (arg0.Type != JmesPathType.Array || arg0.GetArrayLength() == 0) { result = JsonConstants.Null; return(false); } IValue sum; if (!SumFunction.Instance.TryEvaluate(resources, args, out sum)) { result = JsonConstants.Null; return(false); } Decimal decVal; double dblVal; if (sum.TryGetDecimal(out decVal)) { result = new DecimalValue(decVal / arg0.GetArrayLength()); return(true); } else if (sum.TryGetDouble(out dblVal)) { result = new DoubleValue(dblVal / arg0.GetArrayLength()); return(true); } else { result = JsonConstants.Null; return(false); } }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); if (!(args[0].Type == JmesPathType.Array && args[1].Type == JmesPathType.Expression)) { result = JsonConstants.Null; return(false); } var arg0 = args[0]; if (arg0.GetArrayLength() <= 1) { result = arg0; return(true); } var expr = args[1].GetExpression(); var list = new List <IValue>(); foreach (var item in arg0.EnumerateArray()) { list.Add(item); } var comparer = new SortByComparer(resources, expr); list.Sort(comparer); if (comparer.IsValid) { result = new ArrayValue(list); return(true); } else { result = JsonConstants.Null; return(false); } }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); var arg0 = args[0]; switch (arg0.Type) { case JmesPathType.Object: { int count = 0; foreach (var item in arg0.EnumerateObject()) { ++count; } result = new DecimalValue(new Decimal(count)); return(true); } case JmesPathType.Array: result = new DecimalValue(new Decimal(arg0.GetArrayLength())); return(true); case JmesPathType.String: { byte[] bytes = Encoding.UTF32.GetBytes(arg0.GetString().ToCharArray()); result = new DecimalValue(new Decimal(bytes.Length / 4)); return(true); } default: { result = JsonConstants.Null; return(false); } } }
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); var arg0 = args[0]; switch (arg0.Type) { case JmesPathType.Number: result = new StringValue("number"); return(true); case JmesPathType.True: case JmesPathType.False: result = new StringValue("boolean"); return(true); case JmesPathType.String: result = new StringValue("string"); return(true); case JmesPathType.Object: result = new StringValue("object"); return(true); case JmesPathType.Array: result = new StringValue("array"); return(true); case JmesPathType.Null: result = new StringValue("null"); return(true); default: result = JsonConstants.Null; return(false); } }
public override bool TryEvaluate(DynamicResources resources, IValue current, out IValue value) { if (current.Type == JmesPathType.Null) { value = JsonConstants.Null; return(true); } var result = new List <IValue>(); foreach (var expr in _expressions) { IValue val; if (!expr.TryEvaluate(resources, current, out val)) { value = JsonConstants.Null; return(false); } result.Add(val); } value = new ArrayValue(result); return(true); }
protected LocatorBase(ISimpleIOC container) { Container = container; _resources = new DynamicResources(Container); }
public abstract bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue element);
public override bool TryEvaluate(DynamicResources resources, IList <IValue> args, out IValue result) { Debug.Assert(this.Arity.HasValue && args.Count == this.Arity !.Value); if (!(args[0].Type == JmesPathType.Array && args[1].Type == JmesPathType.Expression)) { result = JsonConstants.Null; return(false); } var arg0 = args[0]; if (arg0.GetArrayLength() == 0) { result = JsonConstants.Null; return(true); } var expr = args[1].GetExpression(); IValue key1; if (!expr.TryEvaluate(resources, arg0[0], out key1)) { result = JsonConstants.Null; return(false); } bool isNumber1 = key1.Type == JmesPathType.Number; bool isString1 = key1.Type == JmesPathType.String; if (!(isNumber1 || isString1)) { result = JsonConstants.Null; return(false); } var lessor = LtOperator.Instance; int index = 0; for (int i = 1; i < arg0.GetArrayLength(); ++i) { IValue key2; if (!expr.TryEvaluate(resources, arg0[i], out key2)) { result = JsonConstants.Null; return(false); } bool isNumber2 = key2.Type == JmesPathType.Number; bool isString2 = key2.Type == JmesPathType.String; if (!(isNumber2 == isNumber1 && isString2 == isString1)) { result = JsonConstants.Null; return(false); } IValue value; if (!lessor.TryEvaluate(key2, key1, out value)) { result = JsonConstants.Null; return(false); } if (value.Type == JmesPathType.True) { key1 = key2; index = i; } } result = arg0[index]; return(true); }
public abstract bool TryEvaluate(DynamicResources resources, IValue current, out IValue value);
static NativeFactory() { Type iType = typeof(T); TypeBuilder tb = DynamicResources.DefineDynamicType(TypeAttributes.Public | TypeAttributes.Sealed); tb.SetParent(iType); var ctorArgs = new[] { typeof(IntPtr) }; var baseCtor = iType.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, ctorArgs, null); var ctor = tb.DefineConstructor(MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, CallingConventions.HasThis, ctorArgs); var cil = ctor.GetILGenerator(); cil.Emit(OpCodes.Ldarg_0); cil.Emit(OpCodes.Ldarg_1); cil.Emit(OpCodes.Call, baseCtor); var procArray = tb.DefineField("m_procs", typeof(MulticastDelegate[]), FieldAttributes.Private | FieldAttributes.InitOnly); var methods = iType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); cil.Emit(OpCodes.Ldarg_0); cil.Emit(OpCodes.Ldc_I4, methods.Length); cil.Emit(OpCodes.Newarr, typeof(MulticastDelegate)); cil.Emit(OpCodes.Stfld, procArray); int index = 0; foreach (var mi in methods) { if (!mi.IsAbstract) { continue; } var import = mi.GetCustomAttribute(typeof(LibImportAttribute)) as LibImportAttribute; if (import == null) { continue; } var delType = DynamicResources.DefineDynamicType(TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.AnsiClass | TypeAttributes.AutoClass); delType.SetParent(typeof(MulticastDelegate)); var cb = delType.DefineConstructor(MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, CallingConventions.Standard, new[] { typeof(object), typeof(IntPtr) }); cb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed); var args = mi.GetParameters(); var argTypes = args.Select(p => p.ParameterType).ToArray(); MethodBuilder delInvoke = delType.DefineMethod("Invoke", MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual, CallingConventions.HasThis | mi.CallingConvention, mi.ReturnType, null); delInvoke.SetParameters(argTypes); delInvoke.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed); for (int i = 0; i < args.Length; i++) { var arg = args[i]; var marshal = arg.GetCustomAttribute <MarshalAsAttribute>(); var guid = arg.GetCustomAttribute <GuidAttribute>(); var attributes = (arg.IsIn ? ParameterAttributes.In : 0) | (arg.IsLcid ? ParameterAttributes.Lcid : 0) | (arg.IsOptional ? ParameterAttributes.Optional : 0) | (arg.IsOut ? ParameterAttributes.Out : 0) | (arg.IsRetval ? ParameterAttributes.Retval : 0) | (arg.HasDefaultValue ? ParameterAttributes.HasDefault : 0) | (marshal != null ? ParameterAttributes.HasFieldMarshal : 0); var builder = delInvoke.DefineParameter(i, attributes, arg.Name); if (marshal != null) { Guid iid = guid != null?Guid.Parse(guid.Value) : Guid.Empty; new MarshalInfo(marshal, iid).Apply(builder); } } import.Apply(delType); delType.CreateType(); /*Type del = delType.CreateType(); * var delInvoke = del.getme*/ string entryPoint = import.EntryPoint; if (entryPoint == null) { entryPoint = mi.Name; } var mb = tb.DefineMethod(mi.Name, mi.Attributes & (~MethodAttributes.Abstract), mi.ReturnType, argTypes); tb.DefineMethodOverride(mb, mi); var il = mb.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldfld, procArray); if (index <= 255) { il.Emit(OpCodes.Ldc_I4_S, (byte)index); } else { il.Emit(OpCodes.Ldc_I4, index); } il.Emit(OpCodes.Ldelem, typeof(MulticastDelegate)); il.Emit(OpCodes.Castclass, delType); for (int i = 0; i < args.Length; i++) { il.EmitLdarg(i + 1); } il.Emit(OpCodes.Tailcall); il.Emit(OpCodes.Callvirt, delInvoke); il.Emit(OpCodes.Ret); cil.Emit(OpCodes.Ldarg_0); cil.Emit(OpCodes.Ldfld, procArray); if (index <= 255) { cil.Emit(OpCodes.Ldc_I4_S, (byte)index); } else { cil.Emit(OpCodes.Ldc_I4, index); } cil.Emit(OpCodes.Ldarg_0); cil.Emit(OpCodes.Ldstr, entryPoint); cil.Emit(import.ExactSpelling ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0); cil.Emit(OpCodes.Callvirt, FindFunctionMethod.MakeGenericMethod(delType)); cil.Emit(OpCodes.Stelem, delType); index++; } cil.Emit(OpCodes.Ret); libraryType = tb.CreateType(); }
static ImplementationProxy() { var impl = DynamicResources.DefineDynamicType(TypeAttributes.Public); var saType = typeof(StaticAdapter); var adapterField = impl.DefineField("adapter", saType, FieldAttributes.Private); impl.SetParent(typeof(Type)); impl.AddInterfaceImplementation(getadapter.DeclaringType); { var mb = impl.DefineMethod(getadapter.Name, MethodAttributes.Private | MethodAttributes.Virtual | MethodAttributes.Final, saType, Type.EmptyTypes); var il = mb.GetILGenerator(); il.Emit(OpCodes.Ldfld, adapterField); il.Emit(OpCodes.Ret); impl.DefineMethodOverride(mb, getadapter); } foreach (var mi in proxyType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Where(m => !m.IsPrivate && !m.IsAssembly && m.IsVirtual && !m.IsFinal)) { if (mi.GetBaseDefinition() == finalize || mi == finalize) { continue; } var args = mi.GetParameters().Select(p => p.ParameterType).ToArray(); var mb = impl.DefineMethod(mi.Name, mi.Attributes & (~MethodAttributes.Abstract) | MethodAttributes.Final, mi.ReturnType, args); var il = mb.GetILGenerator(); var locArr = il.DeclareLocal(TypeOf <object[]> .TypeID); il.Emit(OpCodes.Ldc_I4, args.Length); il.Emit(OpCodes.Newarr, locArr.LocalType.GetElementType()); il.Emit(OpCodes.Stloc, locArr); for (int i = 0; i < args.Length; i++) { il.Emit(OpCodes.Ldloc, locArr); il.Emit(OpCodes.Ldc_I4, i); il.Emit(OpCodes.Conv_I); var arg = args[i]; il.EmitLdarg(i + 1); if (arg.IsByRef) { il.Emit(OpCodes.Ldobj, arg = arg.GetElementType()); } if (arg.IsValueType) { il.Emit(OpCodes.Box, arg); } il.Emit(OpCodes.Stelem_Ref); } il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldfld, adapterField); il.Emit(OpCodes.Ldtoken, mi); il.Emit(OpCodes.Call, methodFromHandle); il.Emit(OpCodes.Ldloc, locArr); il.Emit(OpCodes.Call, adapterCall); for (int i = 0; i < args.Length; i++) { var arg = args[i]; if (!arg.IsByRef) { continue; } arg = arg.GetElementType(); il.EmitLdarg(i + 1); il.Emit(OpCodes.Ldloc, locArr); il.Emit(OpCodes.Ldc_I4, i); il.Emit(OpCodes.Conv_I); il.Emit(OpCodes.Ldelem_Ref); il.Emit(OpCodes.Unbox_Any, arg); il.Emit(OpCodes.Stobj, arg); } if (mi.ReturnType != typeof(void)) { il.Emit(OpCodes.Castclass, mi.ReturnType); } il.Emit(OpCodes.Ret); impl.DefineMethodOverride(mb, mi); } { var ctor = impl.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new[] { typeof(StaticAdapter) }); var il = ctor.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Call, impl.BaseType.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null)); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Stfld, adapterField); il.Emit(OpCodes.Ret); } Implementation = impl.CreateType(); constructor = Hacks.GetConstructor <Func <StaticAdapter, T> >(Implementation, 0); }
internal SortByComparer(DynamicResources resources, IExpression expr) { _resources = resources; _expr = expr; }
public bool TryEvaluate(DynamicResources resources, IValue current, out IValue result) { Stack <IValue> stack = new Stack <IValue>(); IList <IValue> argStack = new List <IValue>(); IValue root_ptr = current; for (int i = _tokens.Length - 1; i >= 0; --i) { var token = _tokens[i]; switch (token.Type) { case TokenType.Literal: { stack.Push(token.GetValue()); break; } case TokenType.BeginExpressionType: { Debug.Assert(i > 0); token = _tokens[--i]; Debug.Assert(token.Type == TokenType.Expression); Debug.Assert(stack.Count != 0); stack.Pop(); stack.Push(new ExpressionValue(token.GetExpression())); break; } case TokenType.Pipe: { Debug.Assert(stack.Count != 0); root_ptr = stack.Peek(); break; } case TokenType.CurrentNode: stack.Push(root_ptr); break; case TokenType.Expression: { Debug.Assert(stack.Count != 0); var ptr = stack.Pop(); IValue val; if (!token.GetExpression().TryEvaluate(resources, ptr, out val)) { result = JsonConstants.Null; return(false); } stack.Push(val); break; } case TokenType.UnaryOperator: { Debug.Assert(stack.Count >= 1); var rhs = stack.Pop(); IValue val; if (!token.GetUnaryOperator().TryEvaluate(rhs, out val)) { result = JsonConstants.Null; return(false); } stack.Push(val); break; } case TokenType.BinaryOperator: { Debug.Assert(stack.Count >= 2); var rhs = stack.Pop(); var lhs = stack.Pop(); IValue val; if (!token.GetBinaryOperator().TryEvaluate(lhs, rhs, out val)) { result = JsonConstants.Null; return(false); } stack.Push(val); break; } case TokenType.Argument: { Debug.Assert(stack.Count != 0); argStack.Add(stack.Pop()); break; } case TokenType.Function: { if (token.GetFunction().Arity != null && token.GetFunction().Arity != argStack.Count()) { // airty error should never happen here result = JsonConstants.Null; return(false); } IValue val; if (!token.GetFunction().TryEvaluate(resources, argStack, out val)) { result = JsonConstants.Null; return(false); } argStack.Clear(); stack.Push(val); break; } default: break; } } Debug.Assert(stack.Count == 1); result = stack.Peek(); return(true); }
public override bool TryEvaluate(DynamicResources resources, IValue current, out IValue value) { if (current.Type != JmesPathType.Array) { value = JsonConstants.Null; return(true); } var start = _slice.GetStart(current.GetArrayLength()); var end = _slice.GetStop(current.GetArrayLength()); var step = _slice.Step; if (step == 0) { value = JsonConstants.Null; return(false);; } var result = new List <IValue>(); if (step > 0) { if (start < 0) { start = 0; } if (end > current.GetArrayLength()) { end = current.GetArrayLength(); } for (Int32 i = start; i < end; i += step) { IValue val; if (!this.TryApplyExpressions(resources, current[i], out val)) { value = JsonConstants.Null; return(false); } if (val.Type != JmesPathType.Null) { result.Add(val); } } } else { if (start >= current.GetArrayLength()) { start = current.GetArrayLength() - 1; } if (end < -1) { end = -1; } for (Int32 i = start; i > end; i += step) { IValue val; if (!this.TryApplyExpressions(resources, current[i], out val)) { value = JsonConstants.Null; return(false); } if (val.Type != JmesPathType.Null) { result.Add(val); } } } value = new ArrayValue(result); return(true); }