internal static void AddYamlProperties(RubyContext /*!*/ context, object self, Hash map, RubyArray props) { foreach (object prop in props) { string p = prop.ToString(); IDictionaryOps.SetElement( context, map, MutableString.Create(p.Substring(1)), KernelOps.InstanceVariableGet(context, self, p) ); } }
internal void AddYamlProperties(Dictionary <object, object> /*!*/ propertyMap, object obj, IList /*!*/ instanceVariableNames, bool plainNames) { foreach (object name in instanceVariableNames) { RubySymbol symbol; MutableString mstr; // MRI doesn't use a dynamic conversion: if ((symbol = name as RubySymbol) != null) { propertyMap[plainNames ? (object)symbol.GetSlice(1) : symbol] = KernelOps.InstanceVariableGet(Context, obj, symbol.ToString()); } else if ((mstr = name as MutableString) != null) { propertyMap[plainNames ? mstr.GetSlice(1) : mstr] = KernelOps.InstanceVariableGet(Context, obj, mstr.ToString()); } else { throw RubyExceptions.CreateTypeError("unexpected type {0}, expected Symbol or String", Context.GetClassDisplayName(name)); } } }