Example #1
0
        public static Hash /*!*/ CreateSubclass(ConversionStorage <IDictionary <object, object> > /*!*/ toHash, ConversionStorage <IList> /*!*/ toAry,
                                                RubyClass /*!*/ self, object listOrHash)
        {
            var toHashSite = toHash.GetSite(TryConvertToHashAction.Make(toHash.Context));
            var hash       = toHashSite.Target(toHashSite, listOrHash);

            if (hash != null)
            {
                return(CreateSubclass(self, hash));
            }

            var toArySite = toAry.GetSite(TryConvertToArrayAction.Make(toAry.Context));
            var array     = toArySite.Target(toArySite, listOrHash);

            if (array != null)
            {
                return(CreateSubclass(toAry, self, array));
            }

            throw RubyExceptions.CreateArgumentError("odd number of arguments for Hash");
        }
Example #2
0
 public static void TryConvertToOptions(ConversionStorage <IDictionary <object, object> > /*!*/ toHash,
                                        ref IDictionary <object, object> options, ref object param1, ref object param2)
 {
     if (options == null && param1 != Missing.Value)
     {
         var toHashSite = toHash.GetSite(TryConvertToHashAction.Make(toHash.Context));
         if (param2 != Missing.Value)
         {
             options = toHashSite.Target(toHashSite, param2);
             if (options != null)
             {
                 param2 = Missing.Value;
             }
         }
         else
         {
             options = toHashSite.Target(toHashSite, param1);
             if (options != null)
             {
                 param1 = Missing.Value;
             }
         }
     }
 }
Example #3
0
        public static IDictionary <object, object> TryConvert(ConversionStorage <IDictionary <object, object> > /*!*/ toHash, RubyClass /*!*/ self, object obj)
        {
            var site = toHash.GetSite(TryConvertToHashAction.Make(toHash.Context));

            return(site.Target(site, obj));
        }