Exemplo n.º 1
0
        /// <summary>
        /// Gets the type of the section object.
        /// </summary>
        /// <param name="config"></param>
        /// <param name="sectionName"></param>
        /// <returns></returns>
        private void ExtractDyanamicConfigSectionObjectType(XmlNode node)
        {
            Type sectionType = null;

            if (node != null)
            {
                string assemblyName = null;
                string className    = null;
                bool   isArray      = false;
                string sectionid    = null;

                foreach (XmlAttribute attribute in node.Attributes)
                {
                    if (attribute.Name.ToLower() == "assembly")
                    {
                        assemblyName = attribute.Value;
                    }

                    if (attribute.Name.ToLower() == "class")
                    {
                        className = attribute.Value;
                    }

                    if (attribute.Name.ToLower() == "section-id")
                    {
                        sectionid = attribute.Value;
                    }

                    if (attribute.Name.ToLower() == "is-array")
                    {
                        isArray = Boolean.Parse(attribute.Value);
                    }
                }

                if (className == null || sectionid == null)
                {
                    return;
                }
                //Assembly qualified name ; for ref: http://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname.aspx


                string assebmlyQualifiedName = null;
                if (assemblyName != null)
                {
                    assebmlyQualifiedName = className + "," + assemblyName;
                }
                else
                {
                    assebmlyQualifiedName = className;
                }

                sectionType = Type.GetType(assebmlyQualifiedName, true, true);

                if (sectionType != null && !string.IsNullOrEmpty(sectionid))
                {
                    _dynamicSectionTypeMap[sectionid] = new DynamicConfigType(sectionType, isArray);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the type of the section object.
        /// </summary>
        /// <param name="config"></param>
        /// <param name="sectionName"></param>
        /// <returns></returns>
        private void ExtractDyanamicConfigSectionObjectType(XmlNode node)
        {
            Type sectionType = null;
            if (node != null)
            {
                string assemblyName = null;
                string className = null;
                bool isArray = false;
                string sectionid = null;

                foreach (XmlAttribute attribute in node.Attributes)
                {
                    if (attribute.Name.ToLower() == "assembly")
                        assemblyName = attribute.Value;
                    
                    if (attribute.Name.ToLower() == "class")
                        className = attribute.Value;

                    if (attribute.Name.ToLower() == "section-id")
                        sectionid = attribute.Value;

                    if (attribute.Name.ToLower() == "is-array")
                        isArray = Boolean.Parse(attribute.Value);
                }

                if (className == null || sectionid == null)
                    return;
                //Assembly qualified name ; for ref: http://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname.aspx


                string assebmlyQualifiedName = null;
                if (assemblyName != null)
                    assebmlyQualifiedName = className + "," + assemblyName;
                else
                    assebmlyQualifiedName = className; 

                sectionType = Type.GetType(assebmlyQualifiedName,true,true);
                
                if (sectionType != null && !string.IsNullOrEmpty(sectionid))
                {
                    _dynamicSectionTypeMap[sectionid] = new DynamicConfigType(sectionType, isArray);
                }
            }
        }