Beispiel #1
0
        public static Hash /*!*/ CreateHash(RubyClass /*!*/ self, [NotNull] params object[] items)
        {
            // arg0: hash or first elem
            // argk: (k-1)th elem
            int itemCount = items.Length;

            IDictionary <object, object> hash = null;

            if (itemCount == 0 || itemCount == 1 && (hash = items[0] as IDictionary <object, object>) != null)
            {
                Hash newHash = _CreateHashSite.Target(_CreateHashSite, self.Context, self);
                return(hash != null?IDictionaryOps.ReplaceData(newHash, hash) : newHash);
            }

            if (itemCount % 2 != 0)
            {
                throw new ArgumentException("odd number of arguments for Hash");
            }

            return(RubyUtils.MakeHash(self.Context, items));
        }