Example #1
0
        public void ProcessCustomAttributeGroups()
        {
            var attributeGroupTypes = new List <Type>();

            var assemblies = XmlLayoutAssemblyHelper.GetAssemblyNames();

            var customXmlAttributeType = typeof(CustomXmlAttributeGroup);

            foreach (var assembly in assemblies)
            {
                try
                {
                    attributeGroupTypes.AddRange(Assembly.Load(assembly)
                                                 .GetTypes()
                                                 .Where(t => !t.IsAbstract && t.IsSubclassOf(customXmlAttributeType))
                                                 .ToList());
                }
                catch { }
            }

            // validate and filter out any invalid entries
            foreach (var attributeGroupType in attributeGroupTypes)
            {
                //var instance = (CustomXmlAttributeGroup)Activator.CreateInstance(attributeGroupType);\
                var instance = GetTestInstance <CustomXmlAttributeGroup>(attributeGroupType);
                if (instance.Validate())
                {
                    this.customAttributeGroupsToAdd.Add(instance);
                }
            }
        }
Example #2
0
        private static void PopulateCustomAttributeDataIfNecessary()
        {
            if (m_CustomXmlAttributeTypes == null || m_CustomXmlAttributeTypes.Count == 0)
            {
                m_CustomXmlAttributeTypes = new List <Type>();

                var assemblies = XmlLayoutAssemblyHelper.GetAssemblyNames();

                var customXmlAttributeType = typeof(CustomXmlAttribute);

                foreach (var assembly in assemblies)
                {
                    try
                    {
                        m_CustomXmlAttributeTypes.AddRange(Assembly.Load(assembly)
                                                           .GetTypes()
                                                           .Where(t => !t.IsAbstract && t.IsSubclassOf(customXmlAttributeType))
                                                           .ToList());
                    }
                    catch
                    {
                        // if Assembly.Load fails, then ignore that assembly
                    }
                }

                m_CustomAttributeTypeNames = m_CustomXmlAttributeTypes.Select(s => s.Name.Replace("Attribute", string.Empty)).ToList();
            }
        }
Example #3
0
        private static void LoadTagHandlerTypesIfNecessary()
        {
            if (m_TagHandlerTypes == null || m_TagHandlerTypes.Count == 0)
            {
                m_TagHandlerTypes = new List <Type>();
                var assemblies            = XmlLayoutAssemblyHelper.GetAssemblyNames();
                var elementTagHandlerType = typeof(ElementTagHandler);

                foreach (var assembly in assemblies)
                {
                    try
                    {
                        m_TagHandlerTypes.AddRange(Assembly.Load(assembly)
                                                   .GetTypes()
                                                   .Where(t => !t.IsAbstract && t.IsSubclassOf(elementTagHandlerType))
                                                   .ToList());
                    }
                    catch
                    {
                        // if Assembly.Load fails, then ignore that assembly
                    }
                }

                m_TagHandlerNames = m_TagHandlerTypes.Select(t => GetTagName(t)).ToList();
            }
        }
Example #4
0
        public static List <Type> GetXmlLayoutControllerTypes()
        {
            if (m_XmlLayoutControllerTypes == null || m_XmlLayoutControllerTypes.Count == 0)
            {
                var assemblies = XmlLayoutAssemblyHelper.GetAssemblyNames();
                m_XmlLayoutControllerNames = new List <string>();
                m_XmlLayoutControllerTypes = new List <Type>();
                var xmlLayoutControllerType = typeof(XmlLayoutController);

                foreach (var assembly in assemblies)
                {
                    try
                    {
                        m_XmlLayoutControllerTypes.AddRange(Assembly.Load(assembly)
                                                            .GetTypes()
                                                            .Where(t => !t.IsAbstract && t.IsSubclassOf(xmlLayoutControllerType))
                                                            .ToList());
                    }
                    catch
                    {
                        // if Assembly.Load fails, then ignore that assembly
                    }
                }

                m_XmlLayoutControllerNames = m_XmlLayoutControllerTypes.Select(t => t.Name).ToList();
            }

            return(m_XmlLayoutControllerTypes);
        }
Example #5
0
        public static void Reset()
        {
            XmlLayoutAssemblyHelper.Reset();

            m_TagHandlerTypes = null;
            m_TagHandlerNames = null;

            m_CustomXmlAttributeTypes = null;
            m_CustomXmlAttributes.Clear();
            m_CustomAttributeTypeNames = null;

            m_XmlLayoutControllerTypes = null;
            m_XmlLayoutControllerNames = null;
        }
        static void LoadAssemblies()
        {
            var assemblyNames = XmlLayoutAssemblyHelper.GetAssemblyNames();

            assemblies = new List <Assembly>();

            foreach (var assemblyName in assemblyNames)
            {
                try
                {
                    assemblies.Add(Assembly.Load(assemblyName));
                }
                catch { }
            }
        }
Example #7
0
        static List <Assembly> LoadAssemblies()
        {
            var assemblyNames = XmlLayoutAssemblyHelper.GetAssemblyNames();
            var assemblyList  = new List <Assembly>();

            foreach (var assemblyName in assemblyNames)
            {
                try
                {
                    assemblyList.Add(Assembly.Load(assemblyName));
                }
                catch { }
            }

            return(assemblyList);
        }
Example #8
0
        public static ElementTagHandler GetXmlTagHandler(string tag)
        {
            if (!m_TagHandlers.ContainsKey(tag))
            {
                LoadTagHandlerTypesIfNecessary();

                var type = m_TagHandlerTypes.FirstOrDefault(t => GetTagName(t).Equals(tag, StringComparison.OrdinalIgnoreCase));

                if (type == null)
                {
                    bool error = true;

                    // if this happens, we've failed to load tag handlers for some reason
                    if (tag == "XmlLayout")
                    {
                        Reset();
                        XmlLayoutAssemblyHelper.ClearAssemblyNames();

                        LoadTagHandlerTypesIfNecessary();

                        type = m_TagHandlerTypes.FirstOrDefault(t => GetTagName(t).Equals(tag, StringComparison.OrdinalIgnoreCase));

                        if (type != null)
                        {
                            error = false;
                        }
                    }

                    if (error)
                    {
                        Debug.LogError("[XmlLayout] Unknown tag '" + tag + "'.\r\nTag Handlers must inherit from 'ElementTagHandler', and must be named {Tag}TagHandler.");
                        return(null);
                    }
                }

                m_TagHandlers.Add(tag, (ElementTagHandler)Activator.CreateInstance(type));
            }

            return(m_TagHandlers[tag]);
        }