private void SetContext(ITypeDescriptorContext context) { if (context != null && context.PropertyDescriptor != null) { this.Filter = context.PropertyDescriptor.Attributes[typeof(ImageFilterAttribute)] as ImageFilterAttribute; } else { this.Filter = null; } if (this.Filter == null) { this.Filter = new ImageFilterAttribute(ImageKind.Image); } this.ImageFilePaths = null; if (context != null && context.Instance != null) { ISolution solution = null; if (this.provider == null) { solution = Package.GetGlobalService(typeof(ISolution)) as ISolution; } else { solution = this.provider.GetService <ISolution>(); } this.ImageFilePaths = solution.Items.Traverse(item => item.Items) .Where(item => item.Kind == ItemKind.Item && this.Filter.Extensions.Any(ext => ext.Equals(Path.GetExtension(item.PhysicalPath), StringComparison.OrdinalIgnoreCase))) .Select(item => item.PhysicalPath); } }
private void SetContext(ITypeDescriptorContext context) { if (context != null && context.PropertyDescriptor != null) { this.Filter = context.PropertyDescriptor.Attributes[typeof(ImageFilterAttribute)] as ImageFilterAttribute; } else { this.Filter = null; } if (this.Filter == null) { this.Filter = new ImageFilterAttribute(ImageKind.Image); } this.ImageFilePaths = null; if (context != null && context.Instance != null) { ISolution solution = null; if (this.provider == null) { solution = Package.GetGlobalService(typeof(ISolution)) as ISolution; } else { solution = this.provider.GetService<ISolution>(); } this.ImageFilePaths = solution.Items.Traverse(item => item.Items) .Where(item => item.Kind == ItemKind.Item && this.Filter.Extensions.Any(ext => ext.Equals(Path.GetExtension(item.PhysicalPath), StringComparison.OrdinalIgnoreCase))) .Select(item => item.PhysicalPath); } }