/// <summary> /// Add other savers to restore. /// </summary> /// <param name="mapParameter"></param> /// <returns></returns> internal DeclarableParameter RestoreOtherSaver(IValue mapParameter) { // Get the array type that we will use to accumulate items for sorting. This is the "key" var arrtype = mapParameter.Type.GetGenericArguments()[0].MakeArrayType(); // Get an index variable - this is the variable that the contents of the map are set to and are used in // the rest of the expression. var indexVariableType = mapParameter.Type.GetGenericArguments()[1]; if (!indexVariableType.IsArray) { throw new ArgumentException(string.Format("Unable to loop over a map that isn't a map of arrays ({0}).", mapParameter.Type.FullName)); } indexVariableType = indexVariableType.GetElementType(); // Create the saver which we will index over. var saver = new mapPlaybackInfo() { sequence = _mapRecords.Count(), mapRecords = mapParameter, sortValueTypeArray = arrtype, tempListingName = arrtype.CreateUniqueVariableName(), indexVariable = DeclarableParameter.CreateDeclarableParameterExpression(indexVariableType) }; _mapRecords.Add(saver); return(saver.indexVariable); }
/// <summary> /// Add other savers to restore. /// </summary> /// <param name="mapParameter"></param> /// <returns></returns> internal DeclarableParameter RestoreOtherSaver(IValue mapParameter) { // Get the array type that we will use to accumulate items for sorting. This is the "key" var arrtype = mapParameter.Type.GetGenericArguments()[0].MakeArrayType(); // Get an index variable - this is the variable that the contents of the map are set to and are used in // the rest of the expression. var indexVariableType = mapParameter.Type.GetGenericArguments()[1]; if (!indexVariableType.IsArray) throw new ArgumentException(string.Format("Unable to loop over a map that isn't a map of arrays ({0}).", mapParameter.Type.FullName)); indexVariableType = indexVariableType.GetElementType(); // Create the saver which we will index over. var saver = new mapPlaybackInfo() { sequence = _mapRecords.Count(), mapRecords = mapParameter, sortValueTypeArray = arrtype, tempListingName = arrtype.CreateUniqueVariableName(), indexVariable = DeclarableParameter.CreateDeclarableParameterExpression(indexVariableType) }; _mapRecords.Add(saver); return saver.indexVariable; }