当前位置: 首页>>代码示例>>C#>>正文


C# RespondToStorage类代码示例

本文整理汇总了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);
 }
开发者ID:nrk,项目名称:ironruby-hpricot,代码行数:10,代码来源:Hpricot.cs

示例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;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:12,代码来源:ObjectSpace.cs

示例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;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:18,代码来源:IOWrapper.cs

示例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)));
     }
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:8,代码来源:RangeOps.cs

示例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;
        }
开发者ID:aceptra,项目名称:ironruby,代码行数:13,代码来源:KernelOps.cs

示例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);
        }
开发者ID:ghouston,项目名称:ironlanguages,代码行数:7,代码来源:IoOps.cs

示例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);
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:26,代码来源:IoOps.cs

示例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));
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:11,代码来源:MutableStringOps.cs

示例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();
                }
            }
        }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:17,代码来源:RubyYaml.cs

示例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)));
 }
开发者ID:andreakn,项目名称:ironruby,代码行数:4,代码来源:Protocols.cs

示例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;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:16,代码来源:MutableStringOps.cs

示例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;
        }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:21,代码来源:RubyYaml.cs

示例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;
        }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:14,代码来源:RubyYaml.cs

示例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;
 }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:13,代码来源:RubyYaml.cs

示例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;
        }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:12,代码来源:RubyYaml.cs


注:本文中的RespondToStorage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。