Sage.Views.XsltTransform.DiscoverXsltExtensionObjects C# (CSharp) Method

DiscoverXsltExtensionObjects() private static method

private static DiscoverXsltExtensionObjects ( ) : void
return void
        private static void DiscoverXsltExtensionObjects()
        {
            extensions = new Dictionary<string, object>();
            foreach (Assembly a in Project.RelevantAssemblies.ToList())
            {
                var types = from t in a.GetTypes() where t.IsClass && !t.IsAbstract select t;

                foreach (
                    Type type in types.Where(t => t.GetCustomAttributes(typeof(XsltExtensionObjectAttribute), false).Length != 0))
                {
                    try
                    {
                        ConstructorInfo ctor = type.GetConstructor(new Type[] { });
                        object instance = ctor.Invoke(new object[] { });

                        XsltExtensionObjectAttribute attrib =
                            (XsltExtensionObjectAttribute) type.GetCustomAttributes(typeof(XsltExtensionObjectAttribute), false)[0];

                        extensions.Add(attrib.Namespace, instance);
                        log.DebugFormat("Successfully created the XSLT extension object '{0}'.", type.FullName);
                    }
                    catch (Exception ex)
                    {
                        log.ErrorFormat("Failed to create the XSLT extension object '{0}': {1}", type.FullName, ex.Message);
                    }
                }
            }
        }