internal static bool IsInstance(object left, object right) { object o = PSObject.Base(left); object obj3 = PSObject.Base(right); Type type = obj3 as Type; if (type == null) { type = ParserOps.ConvertTo <Type>(obj3, null); if (type == null) { throw InterpreterError.NewInterpreterException(obj3, typeof(RuntimeException), null, "IsOperatorRequiresType", ParserStrings.IsOperatorRequiresType, new object[0]); } } return(((type == typeof(PSCustomObject)) && (o is PSObject)) || ((type.Equals(typeof(PSObject)) && (left is PSObject)) || type.IsInstanceOfType(o))); }
internal static ExitException GetExitException(object exitCodeObj) { int argument = 0; try { if (!LanguagePrimitives.IsNull(exitCodeObj)) { argument = ParserOps.ConvertTo <int>(exitCodeObj, PositionUtilities.EmptyExtent); } } catch (Exception exception) { CommandProcessorBase.CheckForSevereException(exception); } return(new ExitException(argument)); }
internal static RuntimeException ConvertToException(object result, IScriptExtent extent) { result = PSObject.Base(result); RuntimeException exception = result as RuntimeException; if (exception != null) { InterpreterError.UpdateExceptionErrorRecordPosition(exception, extent); exception.WasThrownFromThrowStatement = true; return(exception); } ErrorRecord errorRecord = result as ErrorRecord; if (errorRecord != null) { exception = new RuntimeException(errorRecord.ToString(), errorRecord.Exception, errorRecord) { WasThrownFromThrowStatement = true }; InterpreterError.UpdateExceptionErrorRecordPosition(exception, extent); return(exception); } Exception exception3 = result as Exception; if (exception3 != null) { errorRecord = new ErrorRecord(exception3, exception3.Message, ErrorCategory.OperationStopped, null); exception = new RuntimeException(exception3.Message, exception3, errorRecord) { WasThrownFromThrowStatement = true }; InterpreterError.UpdateExceptionErrorRecordPosition(exception, extent); return(exception); } string message = LanguagePrimitives.IsNull(result) ? "ScriptHalted" : ParserOps.ConvertTo <string>(result, PositionUtilities.EmptyExtent); exception3 = new RuntimeException(message, null); errorRecord = new ErrorRecord(exception3, message, ErrorCategory.OperationStopped, null); exception = new RuntimeException(message, exception3, errorRecord) { WasThrownFromThrowStatement = true }; exception.SetTargetObject(result); InterpreterError.UpdateExceptionErrorRecordPosition(exception, extent); return(exception); }