private static void AppendDirectoryName(MutableString /*!*/ result, MutableString /*!*/ name) { int resultLength = result.GetCharCount(); int i; for (i = resultLength - 1; i >= 0; i--) { if (!IsDirectorySeparator(result.GetChar(i))) { break; } } if (i == resultLength - 1) { if (!IsDirectorySeparator(name.GetFirstChar())) { result.Append(DirectorySeparatorChar); } result.Append(name); } else if (IsDirectorySeparator(name.GetFirstChar())) { result.Replace(i + 1, resultLength - i - 1, name); } else { result.Append(name); } }
private object /*!*/ ReadUserClass() { object obj = UnmarshalNewObject(); bool loaded = false; int typeFlag = _reader.ReadByte(); switch (typeFlag) { case '"': MutableString msc = (obj as MutableString); if (msc != null) { msc.Replace(0, msc.Length, ReadString()); loaded = true; } break; case '/': RubyRegex rsc = (obj as RubyRegex); if (rsc != null) { RubyRegex regex = ReadRegex(); rsc.Set(regex.Pattern, regex.Options); loaded = true; } break; case '[': RubyArray asc = (obj as RubyArray); if (asc != null) { asc.AddRange(ReadArray()); loaded = true; } break; case '{': case '}': Hash hsc = (obj as Hash); if (hsc != null) { Hash hash = ReadHash(typeFlag); hsc.DefaultProc = hash.DefaultProc; hsc.DefaultValue = hash.DefaultValue; foreach (var pair in hash) { hsc.Add(pair.Key, pair.Value); } loaded = true; } break; default: break; } if (!loaded) { throw RubyExceptions.CreateArgumentError("incompatible base type"); } return(obj); }