Dictionary <string, IResource> IGetResourceContents.Execute(IEnumerable <string> resourceIds) { //There is an implicit assumption here that all resource ids check out and that //there is no duplicates var resources = new Dictionary <string, IResource>(); if (this.Parent.SiteVersion >= new Version(2, 2)) { Trace.TraceInformation("[GetResources]: Using optimal code path provided by 2.2 Resource Service APIs"); MgStringCollection ids = new MgStringCollection(); foreach (var rid in resourceIds) { ids.Add(rid); } //Use the magic of reflection to call newer APIs even though we're referencing //and older assembly System.Reflection.MethodInfo mi = _resSvc.GetType().GetMethod("GetResourceContents"); MgStringCollection result = (MgStringCollection)mi.Invoke(_resSvc, new object[] { ids, null }); int rcount = ids.GetCount(); for (int i = 0; i < rcount; i++) { var resId = ids.GetItem(i); using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(result.GetItem(i)))) { var resType = ResourceIdentifier.GetResourceTypeAsString(resId); IResource r = ObjectFactory.Deserialize(resType, ms); r.ResourceID = resId; resources.Add(resId, r); } } } else { //TODO: Maybe use a ThreadPool in conjunction with cloned connections? Trace.TraceInformation("[GetResources]: Using non-optimal code path provided by pre-2.2 Resource Service APIs"); foreach (var rid in resourceIds) { resources.Add(rid, this.Parent.ResourceService.GetResource(rid)); } } return(resources); }