public static Counters ToYarn(Counters counters) { if (counters == null) { return(null); } Counters yCntrs = recordFactory.NewRecordInstance <Counters>(); yCntrs.AddAllCounterGroups(new Dictionary <string, CounterGroup>()); foreach (CounterGroup grp in counters) { CounterGroup yGrp = recordFactory.NewRecordInstance <CounterGroup>(); yGrp.SetName(grp.GetName()); yGrp.SetDisplayName(grp.GetDisplayName()); yGrp.AddAllCounters(new Dictionary <string, Counter>()); foreach (Counter cntr in grp) { Counter yCntr = recordFactory.NewRecordInstance <Counter>(); yCntr.SetName(cntr.GetName()); yCntr.SetDisplayName(cntr.GetDisplayName()); yCntr.SetValue(cntr.GetValue()); yGrp.SetCounter(yCntr.GetName(), yCntr); } yCntrs.SetCounterGroup(yGrp.GetName(), yGrp); } return(yCntrs); }