コード例 #1
0
        /// <summary>
        /// Deserialises an <see cref="XmlElement"/> containing security settings configuration.
        /// </summary>
        /// <param name="element">The <see cref="XmlElement"/> to deserialise.</param>
        public override void Deserialize(XmlElement element)
        {
            Type         = "External File-based";
            DefaultRight = Util.GetEnumFromElementOrAttribute <SecurityRight>("defaultRight", element);

            foreach (XmlElement ele in element.SelectNodes("files/*"))
            {
                var externalFile = new ExternalFile();
                externalFile.Deserialize(ele);
                Files.Add(externalFile);
            }

            foreach (XmlElement ele in element.SelectNodes("audit/*"))
            {
                SecurityLogger logger = Util.CreateInstanceFromXmlName <SecurityLogger>(ele.Name);
                if (logger != null)
                {
                    logger.Deserialize(ele);
                    AuditLoggers.Add(logger);
                }
            }

            XmlElement readerEl = element.SelectSingleNode("auditReader") as XmlElement;

            if (readerEl != null)
            {
                string xmlName             = readerEl.GetAttribute("type");
                SecurityAuditReader reader = Util.CreateInstanceFromXmlName <SecurityAuditReader>(xmlName);
                if (reader != null)
                {
                    reader.Deserialize(readerEl);
                    AuditReader = reader;
                }
            }

            XmlElement cacheEl = element.SelectSingleNode("cache") as XmlElement;

            if (cacheEl != null)
            {
                string        xmlName = cacheEl.GetAttribute("type");
                SecurityCache cache   = Util.CreateInstanceFromXmlName <SecurityCache>(xmlName);
                if (cache != null)
                {
                    cache.Deserialize(cacheEl);
                    Cache = cache;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Deserialises an <see cref="XmlElement"/> containing security settings configuration.
        /// </summary>
        /// <param name="element">The <see cref="XmlElement"/> to deserialise.</param>
        public override void Deserialize(XmlElement element)
        {
            Type         = "Internal";
            DefaultRight = Util.GetEnumFromElementOrAttribute <SecurityRight>("defaultRight", element);

            foreach (XmlElement ele in element.SelectNodes("users/*"))
            {
                SecurityUser user = Util.CreateInstanceFromXmlName <SecurityUser>(ele.Name);
                if (user != null)
                {
                    user.Deserialize(ele);
                    Users.Add(user);
                }
            }

            foreach (XmlElement ele in element.SelectNodes("permissions/*"))
            {
                SecurityPermission permission = Util.CreateInstanceFromXmlName <SecurityPermission>(ele.Name);
                if (permission != null)
                {
                    permission.Deserialize(ele);
                    Permissions.Add(permission);
                }
            }

            foreach (XmlElement ele in element.SelectNodes("audit/*"))
            {
                SecurityLogger logger = Util.CreateInstanceFromXmlName <SecurityLogger>(ele.Name);
                if (logger != null)
                {
                    logger.Deserialize(ele);
                    AuditLoggers.Add(logger);
                }
            }

            XmlElement readerEl = element.SelectSingleNode("auditReader") as XmlElement;

            if (readerEl != null)
            {
                string xmlName             = readerEl.GetAttribute("type");
                SecurityAuditReader reader = Util.CreateInstanceFromXmlName <SecurityAuditReader>(xmlName);
                if (reader != null)
                {
                    reader.Deserialize(readerEl);
                    AuditReader = reader;
                }
            }

            XmlElement cacheEl = element.SelectSingleNode("cache") as XmlElement;

            if (cacheEl != null)
            {
                string        xmlName = cacheEl.GetAttribute("type");
                SecurityCache cache   = Util.CreateInstanceFromXmlName <SecurityCache>(xmlName);
                if (cache != null)
                {
                    cache.Deserialize(cacheEl);
                    Cache = cache;
                }
            }
        }