Spliting string

var items = stringToSplit.Split(new[] { "->" }, StringSplitOptions.None);
Advertisements

Get all classes that implement interface and are marked by custom attribute

To get all classes that implement IMyInterface interface and are marked by MyCustomAttribute we can run the following code

var typeToSearch = typeof(IMyInterface);

var types = from type in Assembly.GetExecutingAssembly().GetTypes()
                        where typeToSearch.IsAssignableFrom(type) && type.IsClass
                        let attributes = type.GetCustomAttributes(typeof (MyCustomAttribute), true)
                        select
                            new MyCustomType
                                {
                                    RegisterTo = type,
                                    Attributes = attributes.Cast<MyCustomAttribute>()
                                };