public static IEnumerable <T> CastSetMembers <T>( MgaSet mgaSet, string kind = null) where T : ISIS.GME.Common.Classes.FCO, new() { Contract.Requires(mgaSet != null); if (typeof(T) != typeof(ISIS.GME.Common.Classes.FCO)) { kind = typeof(T).Name; } if (string.IsNullOrEmpty(kind)) { // return with all kind foreach (IMgaFCO item in mgaSet.Members) { yield return(new T() { Impl = item as IMgaObject }); } } else { foreach (IMgaFCO item in mgaSet.Members) { if (item.Meta.Name == kind) { yield return(new T() { Impl = item as IMgaObject }); } } } }
public static IEnumerable <ISIS.GME.Common.Interfaces.FCO> CastSetMembers( MgaSet mgaSet, Dictionary <int, Type> dictionary) { Contract.Requires(mgaSet != null); //List<ISIS.GME.Common.Interfaces.FCO> result = new List<Interfaces.FCO>(); int metaRef; ISIS.GME.Common.Interfaces.FCO fco = null; Type t = null; foreach (IMgaFCO item in mgaSet.Members) { metaRef = item.MetaBase.MetaRef; if (dictionary.TryGetValue(metaRef, out t)) { fco = Activator.CreateInstance(t) as ISIS.GME.Common.Interfaces.FCO; (fco as ISIS.GME.Common.Classes.FCO).Impl = item as IMgaObject; yield return(fco); } } }