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


C# RubyContext类代码示例

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


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

示例1: RubyIO

        // TODO: hack
        public RubyIO(RubyContext/*!*/ context, StreamReader reader, StreamWriter writer, string/*!*/ modeString)
            : this(context) {
            _mode = ParseIOMode(modeString, out _preserveEndOfLines);
            _stream = new DuplexStream(reader, writer);

            ResetLineNumbersForReadOnlyFiles(context);
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:8,代码来源:RubyIO.cs

示例2: NonBlockingError

 public static Exception/*!*/ NonBlockingError(RubyContext/*!*/ context, Exception/*!*/ exception, bool isRead) {
     RubyModule waitReadable;
     if (context.TryGetModule(isRead ? typeof(WaitReadable) : typeof(WaitWritable), out waitReadable)) {
         ModuleOps.ExtendObject(waitReadable, exception);
     }
     return exception;
 }
开发者ID:ghouston,项目名称:ironlanguages,代码行数:7,代码来源:IoOps.cs

示例3: Each

 private static object Each(RubyContext/*!*/ context, object self, Proc/*!*/ block) {
     if (self is Enumerator) {
         return ((Enumerator)self).Each(context, block);
     } else {
         return RubySites.Each(context, self, block);
     }
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:Enumerable.cs

示例4: Make

        public static CompositeConversionAction Make(RubyContext context, CompositeConversion conversion) {
            switch (conversion) {
                case CompositeConversion.ToFixnumToStr:
                    return new CompositeConversionAction(conversion,
                        typeof(Union<int, MutableString>), ConvertToFixnumAction.Make(context), ConvertToStrAction.Make(context)
                    );

                case CompositeConversion.ToStrToFixnum:
                    return new CompositeConversionAction(conversion,
                        typeof(Union<MutableString, int>), ConvertToStrAction.Make(context), ConvertToFixnumAction.Make(context)
                    );

                case CompositeConversion.ToIntToI:
                    return new CompositeConversionAction(conversion,
                        typeof(IntegerValue), ConvertToIntAction.Make(context), ConvertToIAction.Make(context)
                    );

                case CompositeConversion.ToAryToInt:
                    return new CompositeConversionAction(conversion,
                        typeof(Union<IList, int>), ConvertToArrayAction.Make(context), ConvertToFixnumAction.Make(context)
                    );

                default:
                    throw Assert.Unreachable;
            }
        }
开发者ID:follesoe,项目名称:ironruby,代码行数:26,代码来源:CompositeConversionAction.cs

示例5: Delete

 public static object Delete(RubyContext/*!*/ context, object/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ name) {
     MutableString result = GetVariable(context, self, name);
     if (result != null) {
         SetVariable(context, self, name, null);
     }
     return result;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:EnvironmentSingletonOps.cs

示例6: PrecInteger

        public static object PrecInteger(
            CallSiteStorage<Func<CallSite, RubyContext, object, RubyClass, object>>/*!*/ precStorage,
            RubyContext/*!*/ context, object self) {

            var prec = precStorage.GetCallSite("prec", 1);
            return prec.Target(prec, context, self, context.GetClass(typeof(Integer)));
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:7,代码来源:Precision.cs

示例7: BindGenericParameters

 internal static RubyMemberInfo/*!*/ BindGenericParameters(RubyContext/*!*/ context, RubyMemberInfo/*!*/ info, string/*!*/ name, object[]/*!*/ typeArgs) {
     RubyMemberInfo result = info.TryBindGenericParameters(Protocols.ToTypes(context, typeArgs));
     if (result == null) {
         throw RubyExceptions.CreateArgumentError("wrong number of generic arguments for `{0}'", name);
     }
     return result;
 }
开发者ID:BrianGenisio,项目名称:ironruby,代码行数:7,代码来源:MethodOps.cs

示例8: SuperCallAction

 internal SuperCallAction(RubyContext context, RubyCallSignature signature, int lexicalScopeId)
     : base(context)
 {
     Debug.Assert(signature.HasImplicitSelf && signature.HasScope && (signature.HasBlock || signature.ResolveOnly));
     _signature = signature;
     _lexicalScopeId = lexicalScopeId;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:SuperCallAction.cs

示例9: XmlDeclaration

 public XmlDeclaration(RubyContext context)
     : base(context, new AttributeData())
 {
     _encoding = context.CreateAsciiSymbol("encoding");
     _standalone = context.CreateAsciiSymbol("standalone");
     _version = context.CreateAsciiSymbol("version");
 }
开发者ID:nrk,项目名称:ironruby-hpricot,代码行数:7,代码来源:XmlDeclaration.cs

示例10: CreateBacktrace

        public static RubyArray/*!*/ CreateBacktrace(RubyContext/*!*/ context, int skipFrames) {
#if FEATURE_STACK_TRACE
            return new RubyStackTraceBuilder(context, skipFrames).RubyTrace;
#else
            return new RubyArray();
#endif
        }
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:RubyExceptionData.cs

示例11: GetAllNames

        public static RubyArray GetAllNames(RubyContext/*!*/ context, RubyEncoding/*!*/ self)
        {
            var result = new RubyArray();

            string name = self.Name;
            result.Add(MutableString.Create(name));

            foreach (var alias in RubyEncoding.Aliases) {
                if (StringComparer.OrdinalIgnoreCase.Equals(alias.Value, name)) {
                    result.Add(MutableString.CreateAscii(alias.Key));
                }
            }

            if (self == context.RubyOptions.LocaleEncoding) {
                result.Add(MutableString.CreateAscii("locale"));
            }

            if (self == context.DefaultExternalEncoding) {
                result.Add(MutableString.CreateAscii("external"));
            }

            if (self == context.GetPathEncoding()) {
                result.Add(MutableString.CreateAscii("filesystem"));
            }

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

示例12: OpenFileStream

        private static Stream/*!*/ OpenFileStream(RubyContext/*!*/ context, string/*!*/ path, RubyFileMode mode) {
            FileMode fileMode;
            FileAccess access = FileAccess.Read;
            FileShare share = FileShare.ReadWrite;

            RubyFileMode readWriteFlags = mode & RubyFileMode.ReadWriteMask;

            if (readWriteFlags == RubyFileMode.WRONLY) {
                access = FileAccess.Write;
            } else if (readWriteFlags == RubyFileMode.RDONLY) {
                access = FileAccess.Read;
            } else if (readWriteFlags == RubyFileMode.RDWR) {
                access = FileAccess.ReadWrite;
            } else {
                throw new ArgumentException("file open mode must be one of RDONLY WRONLY or RDWR");
            }

            if ((mode & RubyFileMode.APPEND) != 0) {
                fileMode = FileMode.Append;
            } else if ((mode & RubyFileMode.CREAT) != 0) {
                fileMode = FileMode.Create;
            } else if ((mode & RubyFileMode.TRUNC) != 0) {
                fileMode = FileMode.Truncate;
            } else {
                fileMode = FileMode.Open;
            }

            if ((mode & RubyFileMode.EXCL) != 0) {
                share = FileShare.None;
            }

            return context.DomainManager.Platform.OpenInputFileStream(path, fileMode, access, share);
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:33,代码来源:File.cs

示例13: GetGroup

 public static RubyArray GetGroup(RubyContext/*!*/ context, MatchData/*!*/ self, [NotNull]Range/*!*/ range) {
     int begin, count;
     if (!IListOps.NormalizeRange(context, self.Groups.Count, range, out begin, out count)) {
         return null;
     }
     return GetGroup(context, self, begin, count);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:MatchDataOps.cs

示例14: initRuby

        private void initRuby()
        {
            ScriptRuntimeSetup runtimeSetup = ScriptRuntimeSetup.ReadConfiguration();
            var languageSetup = IronRuby.RubyHostingExtensions.AddRubySetup(runtimeSetup);

            runtimeSetup.DebugMode = false;
            runtimeSetup.PrivateBinding = false;
            runtimeSetup.HostType = typeof(RhoHost);

            languageSetup.Options["NoAdaptiveCompilation"] = false;
            languageSetup.Options["CompilationThreshold"] = 0;
            languageSetup.Options["Verbosity"] = 2;

            m_runtime = IronRuby.Ruby.CreateRuntime(runtimeSetup);
            m_engine = IronRuby.Ruby.GetEngine(m_runtime);
            m_context = (RubyContext)Microsoft.Scripting.Hosting.Providers.HostingHelpers.GetLanguageContext(m_engine);

            m_context.ObjectClass.SetConstant("RHO_WP7", 1);
            m_context.ObjectClass.AddMethod(m_context, "__rhoGetCallbackObject", new RubyLibraryMethodInfo(
                new[] { LibraryOverload.Create(new Func<System.Object, System.Int32, System.Object>(RhoKernelOps.__rhoGetCallbackObject), false, 0, 0) },
                RubyMethodVisibility.Public,
                m_context.ObjectClass
            ));
            m_context.Loader.LoadAssembly("RhoRubyLib", "rho.rubyext.rubyextLibraryInitializer", true, true);

            System.Collections.ObjectModel.Collection<string> paths = new System.Collections.ObjectModel.Collection<string>();
            paths.Add("lib");
            paths.Add("apps/app");
            m_engine.SetSearchPaths(paths);
        }
开发者ID:douglaslise,项目名称:rhodes,代码行数:30,代码来源:RhoRuby.cs

示例15: CreateDefaultTagMapping

 private static Hash CreateDefaultTagMapping(RubyContext/*!*/ context) {
     Hash taggedClasses = new Hash(context.EqualityComparer);
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:array"), context.GetClass(typeof(RubyArray)));
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:exception"), context.GetClass(typeof(Exception)));
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:hash"), context.GetClass(typeof(Hash)));
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:object"), context.GetClass(typeof(object)));
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:range"), context.GetClass(typeof(Range)));
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:regexp"), context.GetClass(typeof(RubyRegex)));
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:string"), context.GetClass(typeof(MutableString)));
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:struct"), context.GetClass(typeof(RubyStruct)));
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:sym"), context.GetClass(typeof(SymbolId)));
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:symbol"), context.GetClass(typeof(SymbolId)));
     taggedClasses.Add(MutableString.Create("tag:ruby.yaml.org,2002:time"), context.GetClass(typeof(DateTime)));
     taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:binary"), context.GetClass(typeof(MutableString)));
     taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:bool#no"), context.FalseClass);
     taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:bool#yes"), context.TrueClass);
     taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:float"), context.GetClass(typeof(Double)));
     taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:int"), context.GetClass(typeof(Integer)));
     taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:map"), context.GetClass(typeof(Hash)));
     taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:null"), context.NilClass);            
     taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:seq"), context.GetClass(typeof(RubyArray)));            
     taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:str"), context.GetClass(typeof(MutableString)));
     taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:timestamp"), context.GetClass(typeof(DateTime)));
     //Currently not supported
     //taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:omap"), ec.GetClass(typeof()));
     //taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:pairs"),//    ec.GetClass(typeof()));
     //taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:set"),//    ec.GetClass(typeof()));
     //taggedClasses.Add(MutableString.Create("tag:yaml.org,2002:timestamp#ymd'"), );
     return taggedClasses;
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:30,代码来源:RubyYaml.cs


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