/// <summary> /// Prevents a default instance of the <see cref="SampleFactory"/> class from being created. /// </summary> private SampleFactory() { if (!SeeingSharpApplication.IsInitialized) { return; } // Create and register viewmodel for performance analyziation PerformanceAnalysisViewModel performanceAnalyzisViewModel = new PerformanceAnalysisViewModel(); SeeingSharpApplication.Current.RegisterSingleton(performanceAnalyzisViewModel); // Query for all sample types m_sampleTypes = new List <Tuple <SampleDescription, Type> >(); foreach (Type actSampleType in SeeingSharpApplication.Current.TypeQuery .GetTypesByContract(typeof(SampleBase))) { SampleInfoAttribute actInfoAttrib = actSampleType.GetTypeInfo().GetCustomAttribute <SampleInfoAttribute>(); if (actInfoAttrib == null) { continue; } m_sampleTypes.Add(Tuple.Create( new SampleDescription(actInfoAttrib, actSampleType), actSampleType)); } m_sampleTypes.Sort(new Comparison <Tuple <SampleDescription, Type> >( (left, right) => left.Item1.OrderID.CompareTo(right.Item1.OrderID))); }
/// <summary> /// Initializes a new instance of the <see cref="SampleDescription"/> class. /// </summary> /// <param name="attrib">The attribute.</param> /// <param name="sampleClass">The class behind the sample.</param> public SampleDescription(SampleInfoAttribute attrib, Type sampleClass) { attrib.EnsureNotNull(nameof(attrib)); attrib.Category.EnsureNotNullOrEmpty(nameof(attrib.Category)); attrib.Name.EnsureNotNullOrEmpty(nameof(attrib.Name)); sampleClass.EnsureNotNull(nameof(sampleClass)); m_attrib = attrib; m_sampleClass = sampleClass; }