private IMetric ActivateMetrics(string metric, Dictionary <string, string> args) { ObjectHandle handle; try { handle = Activator.CreateInstance(typeof(IMetric).Assembly.FullName, "WebAnalytics.Model.Metrics." + metric); } catch (Exception) { return(null); } //return the wrapped object IMetric m = (IMetric)handle.Unwrap(); try { //Send the arguments that was appended to the URI and let each metric strip the arguments of what it may need to compute its metric value. m.SetParameters(args); } catch (KeyNotFoundException) { throw new Exception("Metric cannot be computed without arguments"); } catch (NotImplementedException) { //no op } return(m); }