Open.TestHarness.Model.ViewTestClassesModule.AddFromAssembly C# (CSharp) Метод

AddFromAssembly() публичный Метод

Adds references to [ViewTestClass]'s from the given assembly.
public AddFromAssembly ( Assembly assembly, string xapFileName ) : int
assembly System.Reflection.Assembly The assembly to load from.
xapFileName string The name of the XAP file containing the class.
Результат int
        public int AddFromAssembly(Assembly assembly, string xapFileName)
        {
            // Create corresponding set of models and add to 'Classes' property.
            var list = new List<ViewTestClass>();
            foreach (var type in assembly.GetViewTestClasses())
            {
                list.Add(ViewTestClass.GetSingleton(type, xapFileName));
            }
            Classes.AddRange(list);

            // Finish up.
            var count = list.Count;
            if (count > 0) OnPropertyChanged(PropClasses);
            return count;
        }
        #endregion

Usage Example

        public void ShouldLoadClassesFromAssembly()
        {
            var module = new ViewTestClassesModule();

            PropertyChangedEventArgs args = null;
            module.PropertyChanged += (sender, e) => args = e;

            var sampleAssembly = new SampleViewTestClass1().GetType().Assembly;

            var count = module.AddFromAssembly(sampleAssembly, "File.xap");
            count.ShouldNotBe(0);
            args.PropertyName.ShouldBe(ViewTestClassesModule.PropClasses);
        }
ViewTestClassesModule