internal static ICloneSurrogate GetSurrogateFor(TypeInfo type)
 {
     if (surrogates == null)
     {
         surrogates =
             CoheeApp.GetAvailCoheeTypes(typeof(ICloneSurrogate))
             .Select(t => t.CreateInstanceOf())
             .OfType <ICloneSurrogate>()
             .NotNull()
             .ToList();
         surrogates.StableSort((s1, s2) => s1.Priority - s2.Priority);
     }
     for (int i = 0; i < surrogates.Count; i++)
     {
         if (surrogates[i].MatchesType(type))
         {
             return(surrogates[i]);
         }
     }
     return(null);
 }
        private static void GatherAvailable()
        {
            availableCodecs = new List <IImageCodec>();
            foreach (TypeInfo imageCodecType in CoheeApp.GetAvailCoheeTypes(typeof(IImageCodec)))
            {
                if (imageCodecType.IsAbstract)
                {
                    continue;
                }
                if (imageCodecType.IsInterface)
                {
                    continue;
                }

                IImageCodec codec = imageCodecType.CreateInstanceOf() as IImageCodec;
                if (codec != null)
                {
                    availableCodecs.Add(codec);
                }
            }
            availableCodecs.StableSort((a, b) => b.Priority > a.Priority ? 1 : -1);
        }