示例#1
0
文件: HashOps.cs 项目: ltwlf/IronSP
 public static Hash /*!*/ InitializeCopy(RubyContext /*!*/ context, Hash /*!*/ self, [NotNull] Hash /*!*/ source)
 {
     self.Mutate();
     self.DefaultProc  = source.DefaultProc;
     self.DefaultValue = source.DefaultValue;
     IDictionaryOps.ReplaceData(self, source);
     return(self);
 }
示例#2
0
文件: HashOps.cs 项目: ltwlf/IronSP
        public static Hash /*!*/ Replace(RubyContext /*!*/ context, Hash /*!*/ self, [DefaultProtocol, NotNull] IDictionary <object, object> /*!*/ other)
        {
            if (Object.ReferenceEquals(self, other))
            {
                return(self);
            }

            self.Mutate();

            Hash otherHash = other as Hash;

            if (otherHash != null)
            {
                self.DefaultValue = otherHash.DefaultValue;
                self.DefaultProc  = otherHash.DefaultProc;
            }
            return(IDictionaryOps.ReplaceData(self, other));
        }
示例#3
0
文件: HashOps.cs 项目: ltwlf/IronSP
        public static object Shift(CallSiteStorage <Func <CallSite, Hash, object, object> > /*!*/ storage, Hash /*!*/ self)
        {
            self.Mutate();

            if (self.Count == 0)
            {
                var site = storage.GetCallSite("default", 1);
                return(site.Target(site, self, null));
            }

            IEnumerator <KeyValuePair <object, object> > e = self.GetEnumerator();

            e.MoveNext();
            KeyValuePair <object, object> pair = e.Current;

            self.Remove(pair.Key);

            return(IDictionaryOps.MakeArray(pair));
        }
示例#4
0
 public static Hash /*!*/ Replace(RubyContext /*!*/ context, Hash /*!*/ self, [DefaultProtocol, NotNull] IDictionary <object, object> /*!*/ other)
 {
     self.Mutate();
     return(IDictionaryOps.ReplaceData(self, other));
 }
示例#5
0
文件: HashOps.cs 项目: ltwlf/IronSP
 public static object SetDefaultValue(RubyContext /*!*/ context, Hash /*!*/ self, object value)
 {
     self.Mutate();
     self.DefaultProc = null;
     return(self.DefaultValue = value);
 }