• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# BinaryOpStorage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BinaryOpStorage的典型用法代码示例。如果您正苦于以下问题:C# BinaryOpStorage类的具体用法?C# BinaryOpStorage怎么用?C# BinaryOpStorage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BinaryOpStorage类属于命名空间,在下文中一共展示了BinaryOpStorage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Initialize

        public void Initialize(BinaryOpStorage/*!*/ comparisonStorage,
            RubyContext/*!*/ context, object begin, object end, bool excludeEnd) {

            if (_initialized) {
                throw RubyExceptions.CreateNameError("`initialize' called twice");
            }

            // Range tests whether the items can be compared, and uses that to determine if the range is valid
            // Only a non-existent <=> method or a result of nil seems to trigger the exception.
            object compareResult;

            var site = comparisonStorage.GetCallSite("<=>");
            try {
                compareResult = site.Target(site, begin, end);
            } catch (Exception) {
                compareResult = null;
            }

            if (compareResult == null) {
                throw RubyExceptions.CreateArgumentError("bad value for range");
            }

            _begin = begin;
            _end = end;
            _excludeEnd = excludeEnd;
            _initialized = true;
        }
开发者ID:rafacv,项目名称:iron_languages,代码行数:27,代码来源:Range.cs


示例2: Abort

        public static void Abort(BinaryOpStorage/*!*/ writeStorage, object/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ message)
        {
            var site = writeStorage.GetCallSite("write", 1);
            site.Target(site, writeStorage.Context.StandardErrorOutput, message);

            Exit(self, 1);
        }
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:KernelOps.cs


示例3: Equal

        public static bool Equal(BinaryOpStorage/*!*/ equals, decimal self, object other) {
            if (other is decimal) {
                return self == (decimal)other;
            }

            // Call == on the right operand like Float#== does
            return Protocols.IsEqual(equals, other, self);
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:8,代码来源:DecimalOps.cs


示例4: PrintFormatted

 public static void PrintFormatted(
     StringFormatterSiteStorage/*!*/ storage,
     ConversionStorage<MutableString>/*!*/ stringCast,
     BinaryOpStorage/*!*/ writeStorage,
     object/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ format, params object[]/*!*/ args)
 {
     KernelOps.PrintFormatted(storage, stringCast, writeStorage, null, self, format, args);
 }
开发者ID:TerabyteX,项目名称:main,代码行数:8,代码来源:PrintOps.cs


示例5: Print

        public static void Print(BinaryOpStorage/*!*/ writeStorage, object self, object value) {
            Protocols.Write(writeStorage, self, value ?? MutableString.CreateAscii("nil"));

            MutableString delimiter = writeStorage.Context.OutputSeparator;
            if (delimiter != null) {
                Protocols.Write(writeStorage, self, delimiter);
            }
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:8,代码来源:PrintOps.cs


示例6: Abs

 public static object Abs(BinaryOpStorage/*!*/ lessThanStorage, UnaryOpStorage/*!*/ minusStorage, object self)
 {
     var lessThan = lessThanStorage.GetCallSite("<");
     if (RubyOps.IsTrue(lessThan.Target(lessThan, self, 0))) {
         var minus = minusStorage.GetCallSite("[email protected]");
         return minus.Target(minus, self);
     }
     return self;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:9,代码来源:Numeric.cs


示例7: ToYamlProperties

 public static RubyArray/*!*/ ToYamlProperties(
     BinaryOpStorage/*!*/ comparisonStorage,
     BinaryOpStorage/*!*/ lessThanStorage,
     BinaryOpStorage/*!*/ greaterThanStorage,
     RubyContext/*!*/ context, object self) {
     return ArrayOps.SortInPlace(comparisonStorage, lessThanStorage, greaterThanStorage, context, 
         null, KernelOps.InstanceVariables(context, self)
     );
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:9,代码来源:BuiltinsOps.cs


示例8: 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


示例9: Putc

        public static MutableString/*!*/ Putc(BinaryOpStorage/*!*/ writeStorage, object self, [NotNull]MutableString/*!*/ val) {
            if (val.IsEmpty) {
                throw RubyExceptions.CreateTypeError("can't convert String into Integer");
            }

            // writes a single byte into the output stream:
            var c = MutableString.CreateBinary(val.GetBinarySlice(0, 1));
            Protocols.Write(writeStorage, self, c);
            return val;
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:10,代码来源:PrintOps.cs


示例10: 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


示例11: Contains

        public static object Contains(CallSiteStorage<EachSite>/*!*/ each, BinaryOpStorage/*!*/ equals, object self, object value)
        {
            object result = ScriptingRuntimeHelpers.BooleanToObject(false);

            Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
                if (Protocols.IsEqual(equals, item, value)) {
                    result = ScriptingRuntimeHelpers.BooleanToObject(true);
                    return selfBlock.Break(result);
                }
                return null;
            }));

            return result;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:14,代码来源:Enumerable.cs


示例12: Count

        public static int Count(CallSiteStorage<EachSite>/*!*/ each, BinaryOpStorage/*!*/ equals, BlockParam comparer, object self, object value)
        {
            if (comparer != null) {
                each.Context.ReportWarning("given block not used");
            }

            int result = 0;
            Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
                if (Protocols.IsEqual(equals, item, value)) {
                    result++;
                }
                return null;
            }));
            return result;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:15,代码来源:Enumerable.cs


示例13: Equal

        public static bool Equal(BinaryOpStorage/*!*/ compareStorage, object self, object other)
        {
            if (self == other) {
                return true;
            }

            // calls method_missing:
            var compare = compareStorage.GetCallSite("<=>");

            object compareResult;
            try {
                compareResult = compare.Target(compare, self, other);
            } catch (SystemException) {
                // catches StandardError (like rescue)
                return false;
            }

            return compareResult is int && (int)compareResult == 0;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:19,代码来源:Comparable.cs


示例14: SysWrite

 public static int SysWrite(BinaryOpStorage/*!*/ writeStorage, ConversionStorage<MutableString>/*!*/ tosConversion,
     RubyContext/*!*/ context, RubyIO/*!*/ self, object obj) {
     return SysWrite(writeStorage, tosConversion, context, self, Protocols.ConvertToString(tosConversion, obj));
 }
开发者ID:ghouston,项目名称:ironlanguages,代码行数:4,代码来源:IoOps.cs


示例15: CopyStream

        public static object CopyStream(
            ConversionStorage<MutableString>/*!*/ toPath, ConversionStorage<int>/*!*/ toInt, RespondToStorage/*!*/ respondTo,
            BinaryOpStorage/*!*/ writeStorage, CallSiteStorage<Func<CallSite, object, object, object, object>>/*!*/ readStorage,
            RubyClass/*!*/ self, object src, object dst, [DefaultParameterValue(-1)]int count, [DefaultParameterValue(-1)]int src_offset) {

            if (count < -1) {
                throw RubyExceptions.CreateArgumentError("count should be >= -1");
            }

            if (src_offset < -1) {
                throw RubyExceptions.CreateArgumentError("src_offset should be >= -1");
            }

            RubyIO srcIO = src as RubyIO;
            RubyIO dstIO = dst as RubyIO;
            Stream srcStream = null, dstStream = null;
            var context = toPath.Context;
            CallSite<Func<CallSite, object, object, object>> writeSite = null;
            CallSite<Func<CallSite, object, object, object, object>> readSite = null;

            try {
                if (srcIO == null || dstIO == null) {
                    var toPathSite = toPath.GetSite(TryConvertToPathAction.Make(toPath.Context));
                    var srcPath = toPathSite.Target(toPathSite, src);
                    if (srcPath != null) {
                        srcStream = new FileStream(context.DecodePath(srcPath), FileMode.Open, FileAccess.Read);
                    } else {
                        readSite = readStorage.GetCallSite("read", 2);
                    }

                    var dstPath = toPathSite.Target(toPathSite, dst);
                    if (dstPath != null) {
                        dstStream = new FileStream(context.DecodePath(dstPath), FileMode.Truncate);
                    } else {
                        writeSite = writeStorage.GetCallSite("write", 1);
                    }
                } else {
                    srcStream = srcIO.GetReadableStream();
                    dstStream = dstIO.GetWritableStream();
                }

                if (src_offset != -1) {
                    if (srcStream == null) {
                        throw RubyExceptions.CreateArgumentError("cannot specify src_offset for non-IO");
                    }
                    srcStream.Seek(src_offset, SeekOrigin.Current);
                }

                MutableString userBuffer = null;
                byte[] buffer = null;

                long bytesCopied = 0;
                long remaining = (count < 0) ? Int64.MaxValue : count;
                int minBufferSize = 16 * 1024;
                
                if (srcStream != null) {
                    buffer = new byte[Math.Min(minBufferSize, remaining)];
                }

                while (remaining > 0) {
                    int bytesRead;
                    int chunkSize = (int)Math.Min(minBufferSize, remaining);
                    if (srcStream != null) {
                        userBuffer = null;
                        bytesRead = srcStream.Read(buffer, 0, chunkSize);
                    } else {
                        userBuffer = MutableString.CreateBinary();
                        bytesRead = Protocols.CastToFixnum(toInt, readSite.Target(readSite, src, chunkSize, userBuffer));
                    }
                    
                    if (bytesRead <= 0) {
                        break;
                    }

                    if (dstStream != null) {
                        if (userBuffer != null) {
                            dstStream.Write(userBuffer, 0, bytesRead);
                        } else {
                            dstStream.Write(buffer, 0, bytesRead);
                        }
                    } else {
                        if (userBuffer == null) {
                            userBuffer = MutableString.CreateBinary(bytesRead).Append(buffer, 0, bytesRead);
                        } else {
                            userBuffer.SetByteCount(bytesRead);
                        }
                        writeSite.Target(writeSite, dst, userBuffer);
                    }
                    bytesCopied += bytesRead;
                    remaining -= bytesRead;
                }
                return Protocols.Normalize(bytesCopied);

            } finally {
                if (srcStream != null) {
                    srcStream.Close();
                }
                if (dstStream != null) {
                    dstStream.Close();
                }
//.........这里部分代码省略.........
开发者ID:ghouston,项目名称:ironlanguages,代码行数:101,代码来源:IoOps.cs


示例16: Equals

 public static bool Equals(RespondToStorage/*!*/ respondToStorage, BinaryOpStorage/*!*/ equalsStorage, string/*!*/ self, object other) {
     return MutableStringOps.Equals(respondToStorage, equalsStorage, self, other);
 }
开发者ID:atczyc,项目名称:ironruby,代码行数:3,代码来源:ClrStringOps.cs


示例17: Sort

        public static object Sort(
            CallSiteStorage<EachSite>/*!*/ each, 
            BinaryOpStorage/*!*/ comparisonStorage,
            BinaryOpStorage/*!*/ lessThanStorage,
            BinaryOpStorage/*!*/ greaterThanStorage,
            BlockParam keySelector, object self) {

            return ArrayOps.SortInPlace(comparisonStorage, lessThanStorage, greaterThanStorage, keySelector, ToArray(each, self));
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:9,代码来源:Enumerable.cs


示例18: GetMinimum

 public static object GetMinimum(
     CallSiteStorage<EachSite>/*!*/ each, 
     BinaryOpStorage/*!*/ compareStorage,
     BinaryOpStorage/*!*/ lessThanStorage,
     BinaryOpStorage/*!*/ greaterThanStorage,
     BlockParam comparer, object self) {
     return GetExtreme(each, compareStorage, lessThanStorage, greaterThanStorage, comparer, self, 1/*look for min*/);
 }
开发者ID:Hank923,项目名称:ironruby,代码行数:8,代码来源:Enumerable.cs


示例19: CoerceAndApply

        /// <summary>
        /// Applies given operator on coerced values and returns the result.
        /// </summary>
        /// <exception cref="TypeError">
        /// "coerce" method is not defined, throws a subclass of SystemException, or returns something other than a pair of objects.
        /// </exception>
        public static object CoerceAndApply(BinaryOpStorage/*!*/ coercionStorage, BinaryOpStorage/*!*/ binaryOpStorage, 
            string/*!*/ binaryOp, object self, object other) {

            object result;
            if (TryCoerceAndApply(coercionStorage, binaryOpStorage, binaryOp, self, other, out result)) {
                return result;
            }

            throw RubyExceptions.MakeCoercionError(coercionStorage.Context, other, self);
        }
开发者ID:nieve,项目名称:ironruby,代码行数:16,代码来源:Protocols.cs


示例20: Grep

        public static RubyArray Grep(CallSiteStorage<EachSite>/*!*/ each, BinaryOpStorage/*!*/ caseEquals, 
            BlockParam action, object self, object pattern) {

            RubyArray result = new RubyArray();
            var site = caseEquals.GetCallSite("===");

            Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
                if (RubyOps.IsTrue(site.Target(site, pattern, item))) {
                    if (action != null) {
                        if (action.Yield(item, out item)) {
                            return item;
                        }
                    }
                    result.Add(item);
                }
                return null;
            }));

            return result;
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:20,代码来源:Enumerable.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BinaryOperator类代码示例发布时间:2022-05-24
下一篇:
C# BinaryOp类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap