本文整理汇总了C#中IronRuby.Builtins.RubyEncoding类的典型用法代码示例。如果您正苦于以下问题:C# RubyEncoding类的具体用法?C# RubyEncoding怎么用?C# RubyEncoding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RubyEncoding类属于IronRuby.Builtins命名空间,在下文中一共展示了RubyEncoding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: CreateKCoding
private static RubyEncoding/*!*/ CreateKCoding(int codepage, RubyEncoding/*!*/ realEncoding) {
#if SILVERLIGHT
return new RubyEncoding(new UTF8Encoding(false, false), new UTF8Encoding(false, true), realEncoding);
#else
return new RubyEncoding(KCoding.Create(codepage, false), KCoding.Create(codepage, true), realEncoding);
#endif
}
示例3: RubyMethodBody
internal RubyMethodBody(MethodDeclaration/*!*/ ast, MSA.SymbolDocumentInfo document, RubyEncoding/*!*/ encoding) {
Assert.NotNull(ast, encoding);
_ast = ast;
_document = document;
_encoding = encoding;
}
示例4: GetMutableString
public MutableString/*!*/ GetMutableString(RubyEncoding/*!*/ encoding) {
string str = _value as string;
if (str != null) {
return MutableString.Create(str, encoding);
} else {
return MutableString.CreateBinary((byte[])_value, encoding);
}
}
示例5: StringLiteral
internal StringLiteral(object/*!*/ value, RubyEncoding/*!*/ encoding, SourceSpan location)
: base(location)
{
Debug.Assert(value is string || value is byte[]);
Debug.Assert(encoding != null);
_value = value;
_encoding = encoding;
}
示例6: Inspect
public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, RubyEncoding/*!*/ self) {
// TODO: to_s overridden
MutableString result = MutableString.CreateMutable(context.GetIdentifierEncoding());
result.Append("#<");
result.Append(context.GetClassDisplayName(self));
result.Append(':');
result.Append(self.Name);
result.Append('>');
return result;
}
示例7: Inspect
public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, RubyEncoding/*!*/ self) {
// TODO: to_s overridden
MutableString result = MutableString.CreateMutable();
result.Append("#<");
result.Append(RubyUtils.GetClassName(context, self));
result.Append(':');
result.Append(self.Name);
result.Append(">");
return result;
}
示例8: RubyIO
public RubyIO(RubyContext/*!*/ context) {
ContractUtils.RequiresNotNull(context, "context");
_context = context;
_fileDescriptor = -1;
_stream = null;
// TODO (encoding): enable setting
_externalEncoding = RubyEncoding.Binary;
_internalEncoding = null;
}
示例9: RubyConstructor
public RubyConstructor(RubyGlobalScope/*!*/ scope, NodeProvider/*!*/ nodeProvider)
: base(nodeProvider, scope) {
_encoding = RubyEncoding.GetRubyEncoding(nodeProvider.Encoding);
_newSite = CallSite<Func<CallSite, RubyModule, object, object, object, object>>.Create(
RubyCallAction.Make(scope.Context, "new", RubyCallSignature.WithImplicitSelf(3))
);
_yamlInitializeSite = CallSite<Func<CallSite, object, object, Hash, object>>.Create(
RubyCallAction.Make(scope.Context, "yaml_initialize", RubyCallSignature.WithImplicitSelf(3))
);
}
示例10: RubyInputProvider
internal RubyInputProvider(RubyContext/*!*/ context, ICollection<string>/*!*/ arguments, RubyEncoding/*!*/ encoding) {
Assert.NotNull(context, encoding);
Assert.NotNullItems(arguments);
_context = context;
var args = new RubyArray();
foreach (var arg in arguments) {
ExpandArgument(args, arg, encoding);
}
_commandLineArguments = args;
_lastInputLineNumber = 1;
_singleton = new object();
}
示例11: AstGenerator
private MSA.Expression _sourcePathConstant; // lazy
internal AstGenerator(RubyContext/*!*/ context, RubyCompilerOptions/*!*/ options, MSA.SymbolDocumentInfo document, RubyEncoding/*!*/ encoding,
bool printInteractiveResult) {
Assert.NotNull(context, options, encoding);
_context = context;
_compilerOptions = options;
_debugCompiler = Snippets.Shared.SaveSnippets;
_debugMode = context.DomainManager.Configuration.DebugMode;
_traceEnabled = context.RubyOptions.EnableTracing;
_document = document;
_encoding = encoding;
_profiler = context.RubyOptions.Profile ? Profiler.Instance : null;
_savingToDisk = context.RubyOptions.SavePath != null;
_printInteractiveResult = printInteractiveResult;
}
示例12: AstGenerator
internal AstGenerator(RubyCompilerOptions/*!*/ options, SourceUnit/*!*/ sourceUnit, RubyEncoding/*!*/ encoding,
bool debugCompiler, bool debugMode, bool traceEnabled, bool profilerEnabled, bool savingToDisk) {
Assert.NotNull(options, encoding, sourceUnit);
_context = (RubyContext)sourceUnit.LanguageContext;
_compilerOptions = options;
_debugCompiler = debugCompiler;
_debugMode = debugMode;
_traceEnabled = traceEnabled;
_sourceUnit = sourceUnit;
_document = sourceUnit.Document;
_encoding = encoding;
_profiler = profilerEnabled ? Profiler.Instance : null;
_savingToDisk = savingToDisk;
}
示例13: ExpandArgument
private void ExpandArgument(RubyArray/*!*/ args, string/*!*/ arg, RubyEncoding/*!*/ encoding) {
if (arg.IndexOf('*') != -1 || arg.IndexOf('?') != -1) {
bool added = false;
foreach (string path in Glob.GlobResults(_context.DomainManager.Platform, arg, 0)) {
args.Add(MutableString.Create(path, encoding));
added = true;
}
if (!added) {
args.Add(MutableString.Create(arg, encoding));
}
} else {
args.Add(MutableString.Create(arg, encoding));
}
}
示例14: RubyOptions
public RubyOptions(IDictionary<string, object>/*!*/ options)
: base(options)
{
_arguments = GetStringCollectionOption(options, "Arguments") ?? EmptyStringCollection;
_localeEncoding = GetOption(options, "LocaleEncoding", RubyEncoding.UTF8);
_defaultEncoding = GetOption<RubyEncoding>(options, "DefaultEncoding", null);
_mainFile = GetOption(options, "MainFile", (string)null);
_verbosity = GetOption(options, "Verbosity", 1);
_debugVariable = GetOption(options, "DebugVariable", false);
_enableTracing = GetOption(options, "EnableTracing", false);
_savePath = GetOption(options, "SavePath", (string)null);
_loadFromDisk = GetOption(options, "LoadFromDisk", false);
_profile = GetOption(options, "Profile", false);
_noAssemblyResolveHook = GetOption(options, "NoAssemblyResolveHook", false);
_requirePaths = GetStringCollectionOption(options, "RequiredPaths", ';', ',');
_hasSearchPaths = GetOption<object>(options, "SearchPaths", null) != null;
_standardLibraryPath = GetOption(options, "StandardLibrary", (string)null);
_applicationBase = GetOption(options, "ApplicationBase", (string)null);
}
示例15: AstGenerator
internal AstGenerator(RubyContext/*!*/ context, RubyCompilerOptions/*!*/ options, MSA.SymbolDocumentInfo document, RubyEncoding/*!*/ encoding,
bool printInteractiveResult) {
Assert.NotNull(context, options, encoding);
_context = context;
_compilerOptions = options;
_debugMode = context.DomainManager.Configuration.DebugMode;
_traceEnabled = context.RubyOptions.EnableTracing;
_document = document;
_sequencePointClearance = (document != null) ? Ast.ClearDebugInfo(document) : null;
_encoding = encoding;
_encodingConstant = Ast.Constant(encoding);
_profiler = context.RubyOptions.Profile ? Profiler.Instance : null;
_savingToDisk = context.RubyOptions.SavePath != null;
_printInteractiveResult = printInteractiveResult;
#if SILVERLIGHT
_debugCompiler = false;
#else
_debugCompiler = Snippets.Shared.SaveSnippets;
#endif
}