public override bool Addition(StackContext sctx, PValue leftOperand, PValue rightOperand, out PValue result) { result = null; if (leftOperand.Type is HashPType && rightOperand.Type is HashPType) { var pvht1 = (PValueHashtable) leftOperand.Value; var pvht2 = (PValueHashtable) rightOperand.Value; var pvht = new PValueHashtable(pvht1.Count + pvht2.Count); foreach (var pair in pvht1) pvht.Add(pair); foreach (var pair in pvht2) pvht.AddOverride(pair); result = (PValue) pvht; } return result != null; }
protected override bool InternalConvertFrom( StackContext sctx, PValue subject, bool useExplicit, out PValue result) { if (sctx == null) throw new ArgumentNullException("sctx"); if (subject == null) throw new ArgumentNullException("subject"); result = null; PValueHashtable pvht = null; var sT = subject.Type; if (sT is ObjectPType) { var os = subject.Value; var o_pvht = os as PValueHashtable; if (o_pvht != null) pvht = o_pvht; else { var id = os as IDictionary<PValue, PValue>; if (id != null) pvht = new PValueHashtable(id); else { var pvkvp = os as PValueKeyValuePair; if (pvkvp != null) { pvht = new PValueHashtable(1); pvht.Add(pvkvp); } else if (os is KeyValuePair<PValue, PValue>) { pvht = new PValueHashtable(1); pvht.Add((KeyValuePair<PValue, PValue>) os); } } } } else if (sT == Null) pvht = new PValueHashtable(); if (pvht != null) result = new PValue(pvht, this); return result != null; }