internal static object GetNonIndexable(object target, object[] indices) { // We want to allow: // $x[0] // and // $x[-1] // to be the same as // $x // But disallow anything else: // if in the strict mode, throw exception // otherwise, return AutomationNull.Value to signal no result if (indices.Length == 1) { var index = indices[0]; if (index != null && (LanguagePrimitives.Equals(0, index) || LanguagePrimitives.Equals(-1, index))) { return(target); } } var context = LocalPipeline.GetExecutionContextFromTLS(); if (context == null || !context.IsStrictVersion(2)) { return(AutomationNull.Value); } throw InterpreterError.NewInterpreterException(target, typeof(RuntimeException), null, "CannotIndex", ParserStrings.CannotIndex, target.GetType()); }
internal static object ContainsOperator(System.Management.Automation.ExecutionContext context, IScriptExtent errorPosition, object left, object right, bool contains, bool ignoreCase) { IEnumerator enumerator = LanguagePrimitives.GetEnumerator(left); if (enumerator != null) { while (MoveNext(context, errorPosition, enumerator)) { if (LanguagePrimitives.Equals(Current(errorPosition, enumerator), right, ignoreCase, CultureInfo.InvariantCulture)) { return(BoolToObject(contains)); } } return(BoolToObject(!contains)); } return(BoolToObject(contains == LanguagePrimitives.Equals(left, right, ignoreCase, CultureInfo.InvariantCulture))); }
internal static object GetNonIndexable(object target, object[] indices) { if (indices.Length == 1) { object second = indices[0]; if ((second != null) && (LanguagePrimitives.Equals(0, second) || LanguagePrimitives.Equals(-1, second))) { return(target); } } ExecutionContext executionContextFromTLS = LocalPipeline.GetExecutionContextFromTLS(); if ((executionContextFromTLS != null) && executionContextFromTLS.IsStrictVersion(2)) { throw InterpreterError.NewInterpreterException(target, typeof(RuntimeException), null, "CannotIndex", ParserStrings.CannotIndex, new object[] { target.GetType() }); } return(AutomationNull.Value); }
internal static bool CompareScalarNe(object lhs, object rhs, bool ignoreCase) { return(!LanguagePrimitives.Equals(lhs, rhs, ignoreCase, CultureInfo.InvariantCulture)); }