public override bool Compare(Operator op, object b, out bool result) { result = false; switch (op) { case Operator.Equals: { if (!(b is HarloweDatamap)) { return(false); } var bMap = (HarloweDatamap)b; result = new HashSet <string>(Dictionary.Keys).SetEquals(bMap.Dictionary.Keys) && new HashSet <StoryVar>(Dictionary.Values).SetEquals(bMap.Dictionary.Values); break; } case Operator.Contains: { result = this.ContainsKey(StoryVar.ConvertTo <string>(b)); break; } } return(true); }
public StoryVar text(params StoryVar[] vals) { var buffer = new StringBuilder(); foreach (StoryVar val in HarloweSpread.Flatten(vals)) { buffer.Append(StoryVar.ConvertTo <string>(val, false)); } return(buffer.ToString()); }
public override StoryVar GetMember(string container, StoryVar member) { // Special case when member is an array if (member.Value is HarloweArray) { var memberArray = (HarloweArray)member.Value; var buffer = new char[memberArray.Length]; for (int i = 0; i < memberArray.Length; i++) { buffer[i] = GetMember(container, StoryVar.ConvertTo <int>(memberArray.Values[i])).ToString()[0]; } return(new string(buffer)); } int index; if (HarloweUtils.TryPositionToIndex(member, container.Length, out index)) { return(new StoryVar(container[index].ToString())); } return(base.GetMember(container, member)); }
public StoryVar number(StoryVar val) { return(StoryVar.ConvertTo <double>(val, false)); }