public static void Deserialize(XmlDictionaryReader reader, out IList <DirectoryControl> controls, bool mustBePresent, bool fullChecks)
        {
            string str  = null;
            string str1 = null;
            bool   flag;

            byte[] numArray = null;
            controls = new List <DirectoryControl>();
            if (mustBePresent || reader.IsStartElement("controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
            {
                reader.ReadFullStartElement("controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory");
                while (reader.IsStartElement("control", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
                {
                    string attribute  = reader.GetAttribute("type");
                    string attribute1 = reader.GetAttribute("criticality");
                    reader.Read();
                    if (!reader.IsStartElement("controlValue", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
                    {
                        numArray = null;
                    }
                    else
                    {
                        string attribute2 = reader.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance");
                        if (attribute2 != null)
                        {
                            XmlUtility.SplitPrefix(attribute2, out str, out str1);
                            numArray = reader.ReadElementContentAsBase64();
                        }
                        else
                        {
                            throw new ArgumentException();
                        }
                    }
                    if (!string.Equals("true", attribute1))
                    {
                        flag = false;
                    }
                    else
                    {
                        flag = true;
                    }
                    DirectoryControl directoryControl = new DirectoryControl(attribute, numArray, flag, true);
                    controls.Add(directoryControl);
                    reader.Read();
                }
                return;
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 2
0
        private static void Deserialize(XmlReader reader, bool useInternStrings, out object value, out Type type)
        {
            string        str  = null;
            string        str1 = null;
            object        array;
            object        obj  = null;
            List <object> objs = null;
            int           num  = 0;

            type  = null;
            value = null;
            while (reader.IsStartElement("value", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
            {
                num++;
                if (num > 1 && objs == null)
                {
                    objs = new List <object>();
                    objs.Add(obj);
                }
                string attribute = reader.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance");
                XmlUtility.SplitPrefix(attribute, out str, out str1);
                type = ADValueSerializer._typeMappingToClr[str1];
                obj  = reader.ReadElementContentAs(type, null, "value", "http://schemas.microsoft.com/2008/1/ActiveDirectory");
                if (objs == null)
                {
                    continue;
                }
                if (!useInternStrings || !(type == typeof(string)))
                {
                    objs.Add(obj);
                }
                else
                {
                    objs.Add(string.Intern((string)obj));
                }
            }
            object objPointer = value;

            if (objs == null)
            {
                array = obj;
            }
            else
            {
                array = objs.ToArray();
            }
            objPointer = array;
        }