本文整理汇总了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);
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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)));
}
示例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;
}
示例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;
}
示例9: XmlDeclaration
public XmlDeclaration(RubyContext context)
: base(context, new AttributeData())
{
_encoding = context.CreateAsciiSymbol("encoding");
_standalone = context.CreateAsciiSymbol("standalone");
_version = context.CreateAsciiSymbol("version");
}
示例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
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}