本文整理汇总了C#中RubyContext类的典型用法代码示例。如果您正苦于以下问题:C# RubyContext类的具体用法?C# RubyContext怎么用?C# RubyContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RubyContext类属于命名空间,在下文中一共展示了RubyContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: ToClass
public static RubyClass ToClass(RubyContext/*!*/ context, Type/*!*/ self)
{
if (self.IsInterface()) {
RubyExceptions.CreateTypeError("Cannot convert a CLR interface to a Ruby class");
}
return context.GetClass(self);
}
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:TypeOps.cs
示例17: RubyRepresenter
public RubyRepresenter(RubyContext/*!*/ context, Serializer/*!*/ serializer, YamlOptions/*!*/ opts)
: base(serializer, opts) {
_context = context;
_objectToYamlMethod = context.GetClass(typeof(object)).ResolveMethod("to_yaml", VisibilityContext.AllVisible).Info;
_TagUri =
CallSite<Func<CallSite, object, object>>.Create(
RubyCallAction.Make(context, "taguri", RubyCallSignature.WithImplicitSelf(0))
);
_ToYamlStyle =
CallSite<Func<CallSite, object, object>>.Create(
RubyCallAction.Make(context, "to_yaml_style", RubyCallSignature.WithImplicitSelf(0))
);
_ToYamlNode =
CallSite<Func<CallSite, object, RubyRepresenter, object>>.Create(
RubyCallAction.Make(context, "to_yaml_node", RubyCallSignature.WithImplicitSelf(1))
);
_ToYaml =
CallSite<Func<CallSite, object, RubyRepresenter, object>>.Create(
RubyCallAction.Make(context, "to_yaml", RubyCallSignature.WithImplicitSelf(0))
);
_ToYamlProperties =
CallSite<Func<CallSite, object, object>>.Create(
RubyCallAction.Make(context, "to_yaml_properties", RubyCallSignature.WithImplicitSelf(0))
);
}
开发者ID:atczyc,项目名称:ironruby,代码行数:30,代码来源:RubyRepresenter.cs
示例18: ToChr
public static MutableString/*!*/ ToChr(RubyContext/*!*/ context, object self) {
int intSelf = Protocols.CastToFixnum(context, self);
if (intSelf < 0 || intSelf > 255) {
throw RubyExceptions.CreateRangeError(String.Format("{0} out of char range", intSelf));
}
return MutableString.CreateBinary(new byte[] { (byte)intSelf });
}
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:Integer.cs
示例19: SelectOverload
internal static RubyMemberInfo/*!*/ SelectOverload(RubyContext/*!*/ context, RubyMemberInfo/*!*/ info, string/*!*/ name, object[]/*!*/ typeArgs) {
RubyMemberInfo result = info.TrySelectOverload(Protocols.ToTypes(context, typeArgs));
if (result == null) {
throw RubyExceptions.CreateArgumentError("no overload of `{0}' matches given parameter types", name);
}
return result;
}
开发者ID:BrianGenisio,项目名称:ironruby,代码行数:7,代码来源:MethodOps.cs
示例20: IOWrapper
public IOWrapper(RubyContext/*!*/ context, object io, bool canRead, bool canWrite, bool canSeek, bool canFlush, bool canBeClosed, int bufferSize) {
Assert.NotNull(context);
_writeSite = CallSite<Func<CallSite, object, object, object>>.Create(
RubyCallAction.Make(context, "write", RubyCallSignature.WithImplicitSelf(1))
);
_readSite = CallSite<Func<CallSite, object, object, object>>.Create(
RubyCallAction.Make(context, "read", RubyCallSignature.WithImplicitSelf(1))
);
_seekSite = CallSite<Func<CallSite, object, object, object, object>>.Create(
RubyCallAction.Make(context, "seek", RubyCallSignature.WithImplicitSelf(2))
);
_tellSite = CallSite<Func<CallSite, object, object>>.Create(
RubyCallAction.Make(context, "tell", RubyCallSignature.WithImplicitSelf(0))
);
_obj = io;
_canRead = canRead;
_canWrite = canWrite;
_canSeek = canSeek;
_canFlush = canFlush;
_canBeClosed = canBeClosed;
_buffer = new byte[bufferSize];
_writePos = 0;
_readPos = 0;
_readLen = 0;
}
开发者ID:jschementi,项目名称:iron,代码行数:28,代码来源:IOWrapper.cs
注:本文中的RubyContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论