private void LoadWizards(IVsTemplateWizardData wizardData) { var wizardElements = from coordinator in wizardData.Elements where coordinator.Name.Equals(@"CoordinatedWizards", StringComparison.OrdinalIgnoreCase) from wizardNode in coordinator.ChildNodes.OfType <XmlElement>() where wizardNode.LocalName == @"WizardExtension" select new { Assembly = wizardNode.ChildNodes .OfType <XmlElement>() .Where(node => node.LocalName == @"Assembly") .Select(node => node.InnerText) .FirstOrDefault(), TypeName = wizardNode.ChildNodes .OfType <XmlElement>() .Where(node => node.LocalName == @"FullClassName") .Select(node => node.InnerText) .FirstOrDefault(), }; foreach (var wizardElement in wizardElements.Where(element => !string.IsNullOrEmpty(element.Assembly) && !string.IsNullOrEmpty(element.TypeName))) { tracer.Verbose(Resources.CoordinatorTemplateWizard_LoadingWizardType, wizardElement.TypeName, wizardElement.Assembly); try { var asm = Assembly.Load(wizardElement.Assembly); try { var type = asm.GetType(wizardElement.TypeName, true); if (!typeof(IWizard).IsAssignableFrom(type)) { tracer.Error((string)Resources.CoordinatorTemplateWizard_NotIWizard, type.FullName); } else { this.wizards.Add((IWizard)Activator.CreateInstance(type)); } } catch (Exception te) { tracer.Error(te, Resources.CoordinatorTemplateWizard_FailedToLoadType, wizardElement.TypeName, wizardElement.Assembly); } } catch (Exception ae) { tracer.Error(ae, Resources.CoordinatorTemplateWizard_FailedToLoadAssembly, wizardElement.Assembly); } } }
private void LoadWizards(IVsTemplateWizardData wizardData) { var wizardElements = from coordinator in wizardData.Elements where coordinator.Name.Equals(@"CoordinatedWizards", StringComparison.OrdinalIgnoreCase) from wizardNode in coordinator.ChildNodes.OfType<XmlElement>() where wizardNode.LocalName == @"WizardExtension" select new { Assembly = wizardNode.ChildNodes .OfType<XmlElement>() .Where(node => node.LocalName == @"Assembly") .Select(node => node.InnerText) .FirstOrDefault(), TypeName = wizardNode.ChildNodes .OfType<XmlElement>() .Where(node => node.LocalName == @"FullClassName") .Select(node => node.InnerText) .FirstOrDefault(), }; foreach (var wizardElement in wizardElements.Where(element => !string.IsNullOrEmpty(element.Assembly) && !string.IsNullOrEmpty(element.TypeName))) { tracer.Verbose(Resources.CoordinatorTemplateWizard_LoadingWizardType, wizardElement.TypeName, wizardElement.Assembly); try { var asm = Assembly.Load(wizardElement.Assembly); try { var type = asm.GetType(wizardElement.TypeName, true); if (!typeof(IWizard).IsAssignableFrom(type)) tracer.Error((string)Resources.CoordinatorTemplateWizard_NotIWizard, type.FullName); else this.wizards.Add((IWizard)Activator.CreateInstance(type)); } catch (Exception te) { tracer.Error(te, Resources.CoordinatorTemplateWizard_FailedToLoadType, wizardElement.TypeName, wizardElement.Assembly); } } catch (Exception ae) { tracer.Error(ae, Resources.CoordinatorTemplateWizard_FailedToLoadAssembly, wizardElement.Assembly); } } }