本文整理汇总了C#中RespondToStorage类的典型用法代码示例。如果您正苦于以下问题:C# RespondToStorage类的具体用法?C# RespondToStorage怎么用?C# RespondToStorage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RespondToStorage类属于命名空间,在下文中一共展示了RespondToStorage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Scan
public static Object Scan(ConversionStorage<MutableString>/*!*/ toMutableStringStorage, RespondToStorage/*!*/ respondsTo,
BinaryOpStorage/*!*/ readIOStorage, BlockParam block, RubyModule/*!*/ self, Object/*!*/ source, Hash/*!*/ options)
{
Object elementContent;
if (!self.TryGetConstant(null, "ElementContent", out elementContent) && !(elementContent is Hash)) {
throw new Exception("Hpricot::ElementContent is missing or it is not an Hash");
}
var scanner = new HpricotScanner(toMutableStringStorage, readIOStorage, block);
return scanner.Scan(source, options, elementContent as Hash);
}
示例2: DefineFinalizer
public static object DefineFinalizer(RespondToStorage/*!*/ respondTo, BinaryOpStorage/*!*/ call, RubyModule/*!*/ self, object obj, object finalizer)
{
if (!Protocols.RespondTo(respondTo, finalizer, "call")) {
throw RubyExceptions.CreateArgumentError("finalizer should be callable (respond to :call)");
}
respondTo.Context.SetInstanceVariable(obj, FinalizerInvoker.InstanceVariableName, new FinalizerInvoker(call.GetCallSite("call"), finalizer));
RubyArray result = new RubyArray(2);
result.Add(0);
result.Add(finalizer);
return result;
}
示例3: IOWrapper
public IOWrapper(RubyContext/*!*/ context, object io, bool canRead, bool canWrite, bool canSeek, bool canFlush, bool canClose, int bufferSize)
{
Assert.NotNull(context);
_context = context;
_respondToStorage = new RespondToStorage(_context);
_io = io;
_canRead = canRead;
_canWrite = canWrite;
_canSeek = canSeek;
_canFlush = canFlush;
_canClose = canClose;
_buffer = new byte[bufferSize];
_writePos = 0;
_readPos = 0;
_readLen = 0;
}
示例4: CheckBegin
/// <summary>
/// Check that the object responds to "succ".
/// </summary>
private static void CheckBegin(RespondToStorage/*!*/ respondToStorage, object begin) {
if (!Protocols.RespondTo(respondToStorage, begin, "succ")) {
throw RubyExceptions.CreateTypeError(String.Format("can't iterate from {0}", respondToStorage.Context.GetClassName(begin)));
}
}
示例5: RaiseException
public static void RaiseException(RespondToStorage/*!*/ respondToStorage, UnaryOpStorage/*!*/ storage0, BinaryOpStorage/*!*/ storage1,
CallSiteStorage<Action<CallSite, Exception, RubyArray>>/*!*/ setBackTraceStorage,
object self, object/*!*/ obj, [Optional]object arg, [Optional]RubyArray backtrace) {
Exception exception = CreateExceptionToRaise(respondToStorage, storage0, storage1, setBackTraceStorage, obj, arg, backtrace);
#if DEBUG && !SILVERLIGHT
if (RubyOptions.UseThreadAbortForSyncRaise) {
RubyUtils.RaiseAsyncException(Thread.CurrentThread, exception);
}
#endif
// rethrow semantics, preserves the backtrace associated with the exception:
throw exception;
}
示例6: CreateIOWrapper
// TODO: 1.9 only
// bytes -> Enumerable::Enumerator
// lines -> Enumerable::Enumerator
public static IOWrapper/*!*/ CreateIOWrapper(RespondToStorage/*!*/ respondToStorage, object io, FileAccess access) {
return CreateIOWrapper(respondToStorage, io, access, 0x1000);
}
示例7: CreateIOWrapper
//sysseek
//syswrite
#endregion
internal static IOWrapper/*!*/ CreateIOWrapper(RespondToStorage/*!*/ respondToStorage,
RubyContext/*!*/ context, object io, FileAccess access) {
bool canRead, canWrite, canSeek;
if (access == FileAccess.Read || access == FileAccess.ReadWrite) {
canRead = Protocols.RespondTo(respondToStorage, context, io, "read");
} else {
canRead = false;
}
if (access == FileAccess.Write || access == FileAccess.ReadWrite) {
canWrite = Protocols.RespondTo(respondToStorage, context, io, "write");
} else {
canWrite = false;
}
canSeek = Protocols.RespondTo(respondToStorage, context, io, "seek") && Protocols.RespondTo(respondToStorage, context, io, "tell");
return new IOWrapper(context, io, canRead, canWrite, canSeek);
}
示例8: Equals
public static bool Equals(RespondToStorage/*!*/ respondToStorage, BinaryOpStorage/*!*/ equalsStorage,
object/*!*/ self, object other) {
// Self is object so that we can reuse this method.
if (!Protocols.RespondTo(respondToStorage, other, "to_str")) {
return false;
}
var equals = equalsStorage.GetCallSite("==");
return Protocols.IsTrue(equals.Target(equals, other, self));
}
示例9: Load
public static object Load(ConversionStorage<MutableString>/*!*/ toStr, RespondToStorage/*!*/ respondTo,
RubyScope/*!*/ scope, RubyModule/*!*/ self, object io) {
try {
foreach (object obj in MakeConstructor(scope.GlobalScope, GetStream(toStr, respondTo, io))) {
return obj;
}
return null;
} catch (Exception e) {
throw RubyExceptions.CreateArgumentError(e, e.Message);
} finally {
RubyIO rio = io as RubyIO;
if (rio != null) {
rio.Close();
}
}
}
示例10: RespondTo
public static bool RespondTo(RespondToStorage/*!*/ respondToStorage, object target, string/*!*/ methodName) {
var site = respondToStorage.GetCallSite();
return IsTrue(site.Target(site, target, SymbolTable.StringToId(methodName)));
}
示例11: UpTo
public static object UpTo(
ConversionStorage<MutableString>/*!*/ stringCast,
RespondToStorage/*!*/ respondToStorage,
BinaryOpStorage/*!*/ comparisonStorage,
BinaryOpStorage/*!*/ lessThanStorage,
BinaryOpStorage/*!*/ greaterThanStorage,
BinaryOpStorage/*!*/ equalsStorage,
UnaryOpStorage/*!*/ succStorage,
BlockParam block, MutableString/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ endString) {
RangeOps.Each(stringCast, respondToStorage, comparisonStorage, lessThanStorage, greaterThanStorage, equalsStorage, succStorage,
block, new Range(self, endString, false)
);
return self;
}
示例12: ParseDocuments
public static object ParseDocuments(ConversionStorage<MutableString>/*!*/ toStr, RespondToStorage/*!*/ respondTo,
BlockParam block, RubyModule/*!*/ self, object io) {
foreach (Node obj in MakeComposer(self.Context, GetStream(toStr, respondTo, io))) {
// TODO: the enumerator shouldn't return null:
if (obj == null) {
return null;
}
if (block == null) {
throw RubyExceptions.NoBlockGiven();
}
object result;
if (block.Yield(obj, out result)) {
return result;
}
}
return null;
}
示例13: GetStream
private static Stream/*!*/ GetStream(ConversionStorage<MutableString>/*!*/ toStr, RespondToStorage/*!*/ respondTo, object port) {
var toStrSite = toStr.GetSite(TryConvertToStrAction.Make(toStr.Context));
MutableString str = toStrSite.Target(toStrSite, port);
if (str != null) {
return new MutableStringStream(str);
}
IOWrapper wrapper = RubyIOOps.CreateIOWrapper(respondTo, port, FileAccess.Read);
if (!wrapper.CanRead) {
throw RubyExceptions.CreateTypeError("instance of IO needed");
}
return wrapper;
}
示例14: Parse
public static object Parse(ConversionStorage<MutableString>/*!*/ toStr, RespondToStorage/*!*/ respondTo, RubyModule/*!*/ self, object io) {
using (Stream stream = GetStream(toStr, respondTo, io)) {
foreach (Node obj in MakeComposer(self.Context, stream)) {
// TODO: the enumerator shouldn't return null:
if (obj == null) {
break;
}
return obj;
}
}
return ScriptingRuntimeHelpers.False;
}
示例15: LoadStream
public static object LoadStream(ConversionStorage<MutableString>/*!*/ toStr, RespondToStorage/*!*/ respondTo,
UnaryOpStorage/*!*/ newStorage, BinaryOpStorage/*!*/ addStorage, RubyScope/*!*/ scope,
RubyModule/*!*/ self, object io) {
RubyConstructor rc = MakeConstructor(scope.GlobalScope, GetStream(toStr, respondTo, io));
// TODO: only if io was converted to a string:
io = CreateDefaultStream(newStorage, scope, self);
AddDocumentsToStream(addStorage, rc, io);
return io;
}