本文整理汇总了C#中RubyContext.ReportWarning方法的典型用法代码示例。如果您正苦于以下问题:C# RubyContext.ReportWarning方法的具体用法?C# RubyContext.ReportWarning怎么用?C# RubyContext.ReportWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RubyContext
的用法示例。
在下文中一共展示了RubyContext.ReportWarning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetEnvironmentVariable
private static void SetEnvironmentVariable(RubyContext/*!*/ context, string/*!*/ name, string value) {
context.DomainManager.Platform.SetEnvironmentVariable(name, value);
#if !SILVERLIGHT
if (name == "TZ") {
TimeZone zone;
if (RubyTime.TryParseTimeZone(value, out zone)) {
RubyTime._CurrentTimeZone = zone;
} else {
context.ReportWarning(String.Format(CultureInfo.InvariantCulture,
"`{0}' is not a valid time zone specification; using the current time zone `{1}'",
value,
RubyTime._CurrentTimeZone.StandardName
));
}
}
#endif
}
示例2: TryParseEncoding
public static RubyEncoding TryParseEncoding(RubyContext/*!*/ context, string/*!*/ str) {
try {
return context.GetRubyEncoding(str);
} catch (ArgumentException) {
context.ReportWarning(String.Format("Unsupported encoding {0} ignored", str));
return null;
}
}
示例3: Index
public static RubyArray/*!*/ Index(RubyContext/*!*/ context, object/*!*/ self, [NotNull]params object[]/*!*/ keys) {
context.ReportWarning("ENV.indexes is deprecated; use ENV.values_at");
return ValuesAt(context, self, keys);
}
示例4: GetClassObsolete
public static RubyClass/*!*/ GetClassObsolete(RubyContext/*!*/ context, object self) {
context.ReportWarning("Object#type will be deprecated; use Object#class");
return context.GetClassOf(self);
}
示例5: GetId
public static object GetId(RubyContext/*!*/ context, object self) {
context.ReportWarning("Object#id will be deprecated; use Object#object_id");
return GetObjectId(context, self);
}
示例6: ToFloat
public static double ToFloat(RubyContext/*!*/ context, BigInteger/*!*/ self) {
try {
return self.ToFloat64();
} catch (OverflowException) {
// If the BigInteger is too big for a float then we return infinity.
context.ReportWarning("Bignum out of Float range");
return self.Sign > 0 ? Double.PositiveInfinity : Double.NegativeInfinity;
}
}
示例7: ReportParametersIgnoredWarning
private static void ReportParametersIgnoredWarning(RubyContext/*!*/ context, object encoding) {
context.ReportWarning((encoding != Missing.Value) ? "flags and encoding ignored" : "flags ignored");
}
示例8: SetValue
//.........这里部分代码省略.........
// exceptions:
case GlobalVariableId.CurrentException:
context.SetCurrentException(value);
return;
case GlobalVariableId.CurrentExceptionBacktrace:
context.SetCurrentExceptionBacktrace(value);
return;
// input:
case GlobalVariableId.LastInputLine:
if (scope == null) {
throw ReadOnlyError(name);
}
scope.GetInnerMostClosureScope().LastInputLine = value;
return;
case GlobalVariableId.LastInputLineNumber:
context.InputProvider.LastInputLineNumber = RequireType<int>(value, name, "Fixnum");
return;
case GlobalVariableId.CommandLineArguments:
case GlobalVariableId.InputFileName:
throw ReadOnlyError(name);
// output:
case GlobalVariableId.OutputStream:
context.StandardOutput = RequireWriteProtocol(context, value, name);
return;
case GlobalVariableId.ErrorOutputStream:
context.StandardErrorOutput = RequireWriteProtocol(context, value, name);
break;
case GlobalVariableId.InputStream:
context.StandardInput = value;
return;
// separators:
case GlobalVariableId.InputContent:
throw ReadOnlyError(name);
case GlobalVariableId.InputSeparator:
context.InputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.OutputSeparator:
context.OutputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.StringSeparator:
// type not enforced:
context.StringSeparator = value;
return;
case GlobalVariableId.ItemSeparator:
context.ItemSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
// loader:
case GlobalVariableId.LoadedFiles:
case GlobalVariableId.LoadPath:
throw ReadOnlyError(name);
// misc:
case GlobalVariableId.SafeLevel:
context.SetSafeLevel(RequireType<int>(value, name, "Fixnum"));
return;
case GlobalVariableId.Verbose:
context.Verbose = value;
return;
case GlobalVariableId.CommandLineProgramPath:
context.CommandLineProgramPath = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.KCode:
#if !SILVERLIGHT
if (context.RubyOptions.Compatibility == RubyCompatibility.Ruby18) {
// MRI calls to_str; we don't do that, it's inconsistent with other globals.
// If some app depends on this behavior, it will fail gracefully:
context.KCode = RubyEncoding.GetKCodingByNameInitial(RequireType<MutableString>(value, name, "String").GetFirstChar());
Utils.Log(String.Format("Set to {0}", context.KCode), "KCODE");
return;
}
#endif
context.ReportWarning("variable $KCODE is no longer effective");
return;
case GlobalVariableId.ChildProcessExitStatus:
throw ReadOnlyError(name);
default:
throw Assert.Unreachable;
}
}
示例9: Indexes
public static object Indexes(RubyContext/*!*/ context, IList/*!*/ self, [NotNull]params object[] args) {
context.ReportWarning("Array#indexes and Array#indices are deprecated; use Array#values_at");
return GetIndicesAsNestedArrays(context, self, args);
}
示例10: Index
public static RubyArray/*!*/ Index(RubyContext/*!*/ context, object/*!*/ self,
[DefaultProtocol, NotNull, NotNullItems]params MutableString[]/*!*/ keys) {
context.ReportWarning("ENV.indexes is deprecated; use ENV.values_at");
return ValuesAt(context, self, keys);
}
示例11: ReadInputCharacter
public static object ReadInputCharacter(UnaryOpStorage/*!*/ getcStorage, RubyContext/*!*/ context, object self) {
context.ReportWarning("getc is obsolete; use STDIN.getc instead");
var site = getcStorage.GetCallSite("getc", 0);
return site.Target(site, context, context.StandardInput);
}
示例12: ConvertFixnumToSymbol
[Emitted] // ProtocolConversionAction
public static string/*!*/ ConvertFixnumToSymbol(RubyContext/*!*/ context, int value) {
context.ReportWarning("do not use Fixnums as Symbols");
SymbolId result;
if (TryConvertFixnumToSymbol(value, out result)) {
return SymbolTable.IdToString(result);
} else {
throw RubyExceptions.CreateArgumentError(String.Format("{0} is not a symbol", value));
}
}
示例13: SetValue
public override void SetValue(RubyContext/*!*/ context, RubyScope scope, string/*!*/ name, object value) {
switch (_id) {
// regex:
case GlobalVariableId.MatchData:
if (scope == null) {
throw ReadOnlyError(name);
}
scope.GetInnerMostClosureScope().CurrentMatch = (value != null) ? RequireType<MatchData>(value, name, "MatchData") : null;
return;
case GlobalVariableId.MatchLastGroup:
case GlobalVariableId.PreMatch:
case GlobalVariableId.PostMatch:
case GlobalVariableId.EntireMatch:
throw ReadOnlyError(name);
// exceptions:
case GlobalVariableId.CurrentException:
context.SetCurrentException(value);
return;
case GlobalVariableId.CurrentExceptionBacktrace:
context.SetCurrentExceptionBacktrace(value);
return;
// input:
case GlobalVariableId.LastInputLine:
if (scope == null) {
throw ReadOnlyError(name);
}
scope.GetInnerMostClosureScope().LastInputLine = value;
return;
case GlobalVariableId.LastInputLineNumber:
context.InputProvider.LastInputLineNumber = RequireType<int>(value, name, "Fixnum");
return;
case GlobalVariableId.CommandLineArguments:
case GlobalVariableId.InputFileName:
throw ReadOnlyError(name);
// output:
case GlobalVariableId.OutputStream:
context.StandardOutput = RequireWriteProtocol(context, value, name);
return;
case GlobalVariableId.ErrorOutputStream:
context.StandardErrorOutput = RequireWriteProtocol(context, value, name);
break;
case GlobalVariableId.InputStream:
context.StandardInput = value;
return;
// separators:
case GlobalVariableId.InputContent:
throw ReadOnlyError(name);
case GlobalVariableId.InputSeparator:
context.InputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.OutputSeparator:
context.OutputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.StringSeparator:
// type not enforced:
context.StringSeparator = value;
return;
case GlobalVariableId.ItemSeparator:
context.ItemSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
// loader:
case GlobalVariableId.LoadedFiles:
case GlobalVariableId.LoadPath:
throw ReadOnlyError(name);
// misc:
case GlobalVariableId.SafeLevel:
context.SetSafeLevel(RequireType<int>(value, name, "Fixnum"));
return;
case GlobalVariableId.Verbose:
context.Verbose = value;
return;
case GlobalVariableId.CommandLineProgramPath:
context.CommandLineProgramPath = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.KCode:
context.ReportWarning("variable $KCODE is no longer effective");
//.........这里部分代码省略.........
示例14: AddEncoding
public IOInfo AddEncoding(RubyContext/*!*/ context, MutableString/*!*/ encoding) {
if (!encoding.IsAscii()) {
context.ReportWarning(String.Format("Unsupported encoding {0} ignored", encoding.ToAsciiString(false)));
return this;
}
if (HasEncoding) {
throw RubyExceptions.CreateArgumentError("encoding specified twice");
}
string[] parts = encoding.ToString().Split(':');
return new IOInfo(
_mode,
TryParseEncoding(context, parts[0]),
(parts.Length > 1) ? TryParseEncoding(context, parts[1]) : null
);
}
示例15: Fetch
public static object Fetch(RubyContext/*!*/ context, BlockParam outOfRangeValueProvider, IList/*!*/ list, [DefaultProtocol]int index, [Optional]object defaultValue) {
int oldIndex = index;
if (InRangeNormalized(list, ref index)) {
return list[index];
}
if (outOfRangeValueProvider != null) {
if (defaultValue != Missing.Value) {
context.ReportWarning("block supersedes default value argument");
}
object result;
outOfRangeValueProvider.Yield(oldIndex, out result);
return result;
}
if (defaultValue == Missing.Value) {
throw RubyExceptions.CreateIndexError("index " + index + " out of array");
}
return defaultValue;
}