本文整理汇总了C#中RubyContext.TaintObjectBy方法的典型用法代码示例。如果您正苦于以下问题:C# RubyContext.TaintObjectBy方法的具体用法?C# RubyContext.TaintObjectBy怎么用?C# RubyContext.TaintObjectBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RubyContext
的用法示例。
在下文中一共展示了RubyContext.TaintObjectBy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToJson
public static MutableString ToJson(RubyContext context, IList self, GeneratorState state, int? depth)
{
MutableString result;
if (state == null) {
result = MutableString.CreateMutable(2 + Math.Max(self.Count * 4, 0), RubyEncoding.UTF8);
result.Append('[');
context.TaintObjectBy<Object>(result, self);
if (self.Count > 0) {
for (int i = 0; i < self.Count; i++) {
Object element = self[i];
result.Append(Generator.ToJson(context, element, null, 0));
context.TaintObjectBy<Object>(result, element);
if (i < self.Count - 1) {
result.Append(',');
}
}
}
result.Append(']');
}
else {
result = Transform(context, self, state, depth.HasValue ? depth.Value : 0);
}
return context.TaintObjectBy<MutableString>(result, self);
}
示例2: ToA
public static RubyArray/*!*/ ToA(RubyContext/*!*/ context, object self)
{
RubyArray result = new RubyArray();
result.Add(self);
return context.TaintObjectBy(result, self);
}
示例3: Transform
private static MutableString Transform(RubyContext context, IList self, GeneratorState state, int depth)
{
MutableString result = MutableString.CreateMutable(2 + Math.Max(self.Count * 4, 0), RubyEncoding.UTF8);
byte[] indentUnit = state.Indent.ToByteArray();
byte[] shift = Helpers.Repeat(indentUnit, depth + 1);
byte[] arrayNl = state.ArrayNl.ToByteArray();
byte[] delim = new byte[1 + arrayNl.Length];
delim[0] = (byte)',';
Array.Copy(arrayNl, 0, delim, 1, arrayNl.Length);
state.CheckMaxNesting(depth + 1);
context.TaintObjectBy<Object>(result, self);
if (state.CheckCircular) {
state.Remember(context, self);
result.Append('[');
result.Append(arrayNl);
if (self.Count > 0) {
for (int i = 0; i < self.Count; i++) {
Object element = self[i];
if (state.Seen(context, element)) {
Helpers.ThrowCircularDataStructureException("circular data structures not supported!");
}
context.TaintObjectBy<Object>(result, element);
if (i > 0) {
result.Append(delim);
}
result.Append(shift);
result.Append(Generator.ToJson(context, element, state, depth + 1));
}
// TODO: this might be needed outside of the count check for compat
if (arrayNl.Length != 0) {
result.Append(arrayNl);
result.Append(shift, 0, depth * indentUnit.Length);
}
}
result.Append(']');
state.Forget(context, self);
}
else {
result.Append('[');
result.Append(arrayNl);
if (self.Count > 0) {
for (int i = 0; i < self.Count; i++) {
Object element = self[i];
context.TaintObjectBy<Object>(result, element);
if (i > 0) {
result.Append(delim);
}
result.Append(shift);
result.Append(Generator.ToJson(context, element, state, depth + 1));
}
// TODO: this might be needed outside of the count check for compatibility
if (arrayNl.Length != 0) {
result.Append(arrayNl);
result.Append(shift, 0, depth * indentUnit.Length);
}
}
result.Append(']');
}
return result;
}
示例4: Reopen
public static StringIO/*!*/ Reopen(RubyContext/*!*/ context, [NotNull]StringIO/*!*/ self, [NotNull]StringIO/*!*/ other) {
self.SetContent(other._content);
self._mode = other._mode;
self._lineNumber = other._lineNumber;
self._position = other._position;
// TODO: this seems to be MRI bug
// Shouldn't StringIO's taint be always same as the underlying string's taint?
context.TaintObjectBy(self, other);
return self;
}
示例5: ToA
public static RubyArray/*!*/ ToA(RubyContext/*!*/ context, object self) {
// Return an array that contains self
RubyArray result = new RubyArray(new object[] { self });
return context.TaintObjectBy(result, self);
}
示例6: Duplicate
public static object/*!*/ Duplicate(
CallSiteStorage<Func<CallSite, RubyContext, object, object, object>>/*!*/ initializeCopyStorage,
CallSiteStorage<Func<CallSite, RubyContext, RubyClass, object>>/*!*/ allocateStorage,
RubyContext/*!*/ context, object self) {
object result;
if (!RubyUtils.TryDuplicateObject(initializeCopyStorage, allocateStorage, context, self, false, out result)) {
throw RubyExceptions.CreateTypeError(String.Format("can't dup {0}", RubyUtils.GetClassName(context, self)));
}
return context.TaintObjectBy(result, self);
}