Ejemplo n.º 1
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "note")
            {
                Helper.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    NoteId = reader.Value;
                    break;

                case "author":
                    AuthorId = reader.Value;
                    break;

                case "authorname":
                    AuthorName = reader.Value;
                    break;

                case "x":
                    XPosition = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "y":
                    YPosition = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "w":
                    Width = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "h":
                    Height = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                default:
                    Helper.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            NoteText = reader.ReadContentAsString();

            reader.Skip();
        }
Ejemplo n.º 2
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "comment")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    CommentId = reader.Value;
                    break;

                case "author":
                    AuthorUserId = reader.Value;
                    break;

                case "authorname":
                    AuthorUserName = reader.Value;
                    break;

                case "permalink":
                    Permalink = reader.Value;
                    break;

                case "datecreate":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "iconserver":
                    IconServer = reader.Value;
                    break;

                case "iconfarm":
                    IconFarm = reader.Value;
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            CommentHtml = reader.ReadContentAsString();

            reader.Skip();
        }
Ejemplo n.º 3
0
        void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.MoveToAttribute("Name"))
            {
                _name = reader.ReadContentAsString();
            }
            if (reader.MoveToAttribute("Direction"))
            {
                _direction = (ParameterDirection)reader.ReadContentAsInt();
            }
            Type type = null;

            if (reader.MoveToAttribute("Type"))
            {
                var typeString = reader.ReadContentAsString();
                if (!string.IsNullOrEmpty(typeString))
                {
                    type = Type.GetType(typeString, true);
                }
            }
            reader.MoveToElement();
            if (!reader.IsEmptyElement)
            {
                if (type == typeof(byte[]))
                {
                    var content = (string)reader.ReadElementContentAs(typeof(string), null);
                    _value = Convert.FromBase64String(content);
                }
                else
                {
                    _value = reader.ReadElementContentAs(type, null);
                }
            }
            else
            {
                reader.Skip();
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Lê os dados serializados.
 /// </summary>
 /// <param name="reader"></param>
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.MoveToAttribute("name"))
     {
         Name = reader.ReadContentAsString();
     }
     if (reader.MoveToAttribute("Description"))
     {
         Description = reader.ReadContentAsString();
     }
     reader.MoveToElement();
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "Versions" && !reader.IsEmptyElement)
             {
                 reader.ReadStartElement();
                 while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                 {
                     if (reader.LocalName == "EntityTypeVersion")
                     {
                         var version = new EntityTypeVersion();
                         ((System.Xml.Serialization.IXmlSerializable)version).ReadXml(reader);
                         Versions.Add(version);
                     }
                     else
                     {
                         reader.Skip();
                     }
                 }
                 reader.ReadEndElement();
             }
         }
         reader.ReadEndElement();
     }
 }
Ejemplo n.º 5
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            XmlSerializer serializer;

            if (!reader.Read())
            {
                return;
            }

            reader.ReadStartElement("type");
            _type = (VariantType)reader.ReadContentAsInt();
            reader.ReadEndElement();

            reader.ReadStartElement("value");

            switch (_type)
            {
            case VariantType.Int:
                _valueInt = reader.ReadContentAsInt();
                break;

            case VariantType.Long:
                _valueLong = reader.ReadContentAsLong();
                break;

            case VariantType.ULong:
                _valueULong = (ulong)reader.ReadContentAsLong();
                break;

            case VariantType.Double:
                _valueDouble = (double)reader.ReadContentAsDouble();
                break;

            case VariantType.String:
                _valueString = reader.ReadContentAsString();
                break;

            case VariantType.ByteString:
                serializer      = new XmlSerializer(typeof(byte[]));
                _valueByteArray = (byte[])serializer.Deserialize(reader);
                break;

            case VariantType.BitStream:
                serializer      = new XmlSerializer(typeof(BitwiseStream));
                _valueBitStream = (BitwiseStream)serializer.Deserialize(reader);
                break;
            }

            reader.ReadEndElement();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Reads the XML and populate the inner value.
        /// </summary>
        /// <param name="reader">XmlReader.</param>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToContent();
            var isEmptyElement = reader.IsEmptyElement;

            reader.ReadStartElement();
            if (!isEmptyElement)
            {
                var str = reader.ReadContentAsString();
                _isZero = str == "0";
                _value  = Parse(str);

                reader.ReadEndElement();
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Lê os dados serializados.
 /// </summary>
 /// <param name="reader"></param>
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.MoveToAttribute("identifier"))
     {
         Identifier = reader.ReadContentAsString();
     }
     if (reader.MoveToAttribute("validation"))
     {
         Validation = reader.ReadContentAsString();
     }
     if (reader.MoveToAttribute("inputRulesGroupUid"))
     {
         InputRulesGroupUid = Guid.Parse(reader.ReadContentAsString());
     }
     if (reader.MoveToAttribute("reloadSettings"))
     {
         ReloadSettings = reader.ReadContentAsBoolean();
     }
     if (reader.MoveToAttribute("copyValue"))
     {
         ReloadSettings = reader.ReadContentAsBoolean();
     }
     reader.MoveToElement();
 }
    public void ReadXml(System.Xml.XmlReader reader)
    {
        reader.MoveToContent();

        Boolean isEmptyElement = reader.IsEmptyElement;         // (1)

        reader.ReadStartElement();
        if (!isEmptyElement)         // (1)
        {
            var      str = reader.ReadContentAsString();
            string[] sa  = str.Split(' ');
            Amount       = double.Parse(sa[0]);
            CurrencyCode = sa[1];
            reader.ReadEndElement();
        }
    }
Ejemplo n.º 9
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "tag")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    TagId = reader.Value;
                    break;

                case "author":
                    AuthorId = reader.Value;
                    break;

                case "authorname":
                    AuthorName = reader.Value;
                    break;

                case "raw":
                    Raw = reader.Value;
                    break;

                case "machine_tag":
                    IsMachineTag = reader.Value == "1";
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            TagText = reader.ReadContentAsString();

            reader.Skip();
        }
Ejemplo n.º 10
0
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.MoveToAttribute("Alias"))
     {
         _alias = reader.ReadContentAsString();
     }
     reader.MoveToElement();
     reader.ReadStartElement();
     if (!reader.IsEmptyElement || reader.HasAttributes)
     {
         reader.ReadStartElement();
         _term = ConditionalTerm.GetConditionalTerm(reader);
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     reader.ReadEndElement();
 }
Ejemplo n.º 11
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "exif")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "tagspace":
                    TagSpace = reader.Value;
                    break;

                case "tagspaceid":
                    TagSpaceId = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "tag":
                    Tag = reader.Value;
                    break;

                case "label":
                    Label = reader.Value;
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            if (reader.NodeType == System.Xml.XmlNodeType.Text)
            {
                Text = reader.ReadContentAsString();
                reader.Read();
            }
        }
Ejemplo n.º 12
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "score":
                    Score = reader.ReadContentAsInt();
                    break;
                }
            }

            reader.Read();

            if (reader.NodeType == System.Xml.XmlNodeType.Text)
            {
                Tag = reader.ReadContentAsString();
            }

            reader.Read();
        }
Ejemplo n.º 13
0
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.MoveToAttribute("FileName"))
     {
         FileName = reader.ReadContentAsString();
     }
     reader.MoveToElement();
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement();
         var info = new AssemblyInfo();
         ((System.Xml.Serialization.IXmlSerializable)info).ReadXml(reader);
         this.Info = info;
         reader.ReadEndElement();
     }
     else
     {
         this.Info = null;
         reader.Skip();
     }
 }
Ejemplo n.º 14
0
        public void ReadXmlComponentAvailableInterfaces(System.Xml.XmlReader reader, DanuComponent comp)
        {
            reader.Read();

            while (reader.Read())
            {
                if (!reader.Name.Equals("Interface") && !reader.Name.Equals("Available_Interfaces"))
                {
                    DanuInterfaceObject io = GetInterface(reader.ReadContentAsString());
                    foreach (EshuInterface ioEshu in comp.Specification.Interfaces)
                    {
                        if (ioEshu.Name.Equals(io.Name))
                        {
                            io.Eshu = ioEshu;
                        }
                    }
                    comp.Interfaces.Add(io);
                }
            }

            reader.Close();
        }
Ejemplo n.º 15
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "usage":
                    Usage = reader.ReadContentAsInt();
                    break;

                case "predicate":
                    PredicateName = reader.Value;
                    break;

                case "namespace":
                    NamespaceName = reader.Value;
                    break;

                case "first_added":
                    DateFirstAdded = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "last_added":
                    DateLastUsed = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;
                }
            }

            reader.Read();

            if (reader.NodeType == System.Xml.XmlNodeType.Text)
            {
                ValueText = reader.ReadContentAsString();
            }

            reader.Read();
        }
Ejemplo n.º 16
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "url")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "type":
                        UrlType = reader.Value;
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            Url = reader.ReadContentAsString();

            reader.Skip();
        }
Ejemplo n.º 17
0
 void IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     reader.ReadStartElement();
     if (reader.IsEmptyElement)
     {
         reader.Skip();
     }
     else
     {
         reader.ReadStartElement();
         this.Role = reader.ReadContentAsString();
         reader.ReadEndElement();
     }
     if (!reader.IsEmptyElement)
     {
         var element = FromXml(reader);
         Permissions.FromXml(element);
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Lê os dados serializados.
 /// </summary>
 /// <param name="reader"></param>
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.MoveToAttribute("name"))
     {
         Name = reader.ReadContentAsString();
     }
     if (reader.MoveToAttribute("startDate"))
     {
         StartDate = reader.ReadContentAsDateTime();
     }
     if (reader.MoveToAttribute("customization"))
     {
         CustomizationName = reader.ReadContentAsString();
     }
     if (reader.MoveToAttribute("type"))
     {
         var type = reader.ReadContentAsString();
         Type = !string.IsNullOrEmpty(type) ? new Reflection.TypeName(reader.ReadContentAsString()) : null;
     }
     reader.MoveToElement();
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "Properties" && !reader.IsEmptyElement)
             {
                 reader.ReadStartElement();
                 while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                 {
                     if (reader.LocalName == "EntityTypeVersionProperty")
                     {
                         var property = new EntityTypeVersionProperty();
                         ((System.Xml.Serialization.IXmlSerializable)property).ReadXml(reader);
                         Properties.Add(property);
                     }
                     else
                     {
                         reader.Skip();
                     }
                 }
                 reader.ReadEndElement();
             }
             else if (reader.LocalName == "Events" && !reader.IsEmptyElement)
             {
                 reader.ReadStartElement();
                 while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                 {
                     if (reader.LocalName == "EntityTypeVersionEvent")
                     {
                         var versionEvent = new EntityTypeVersionEvent();
                         ((System.Xml.Serialization.IXmlSerializable)versionEvent).ReadXml(reader);
                         Events.Add(versionEvent);
                     }
                     else
                     {
                         reader.Skip();
                     }
                 }
                 reader.ReadEndElement();
             }
             else
             {
                 reader.Skip();
             }
         }
         reader.ReadEndElement();
     }
 }
Ejemplo n.º 19
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "note")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "photo_id":
                    break;

                case "id":
                    NoteId = reader.Value;
                    break;

                case "author":
                    AuthorId = reader.Value;
                    break;

                case "authorname":
                    AuthorName = reader.Value;
                    break;

                case "authorrealname":
                    AuthorRealName = reader.Value;
                    break;

                case "authorispro":
                    AuthorIsPro = reader.Value == "1";
                    break;

                case "pro_badge":
                    AuthorProBadgeStyle = reader.Value;
                    break;

                case "authorisdeleted":
                    AuthorIsDeleted = reader.Value == "1";
                    break;

                case "x":
                    XPosition = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "y":
                    YPosition = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "w":
                    Width = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "h":
                    Height = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            NoteText = reader.ReadContentAsString();

            reader.Skip();
        }
Ejemplo n.º 20
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            // Initialization
            XmlSerializer valueSerializer = new XmlSerializer(typeof(JointDictionary));

            _is3DData = Boolean.Parse(reader.GetAttribute(__3DDataAttributeName));

            bool wasEmpty = reader.IsEmptyElement;

            reader.Read();

            if (wasEmpty)
            {
                return;
            }

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                reader.ReadStartElement("annotation");

                int key;
                if (reader.Name.Equals("frame-number"))
                {
                    reader.Read();
                    key = reader.ReadContentAsInt();
                }
                else
                {
                    reader.Read();
                    reader.ReadStartElement("name");
                    FileInfo info     = new FileInfo(reader.ReadContentAsString());
                    String   to_parse = info.Name.Remove(info.Name.IndexOf('.'));

                    // Remove optional suffixes after a dash
                    if (to_parse.IndexOf("-") != -1)
                    {
                        to_parse = to_parse.Remove(to_parse.IndexOf("-"));
                    }

                    try
                    {
                        key = Int32.Parse(to_parse);
                    }
                    catch (Exception)
                    {
                        throw new Exception("The xml-file must only contain file references to files with numbers as names.");
                    }
                    reader.ReadEndElement();
                }
                reader.ReadEndElement();

                Dictionary <int, JointDictionary> user_information =
                    new Dictionary <int, JointDictionary>();
                while (reader.IsStartElement())
                {
                    int user = Int32.Parse(reader.GetAttribute("UserID"));
                    reader.ReadStartElement("annorect");
                    JointDictionary joints = (JointDictionary)valueSerializer.Deserialize(reader);
                    if (joints.Is3DData != Is3DData)
                    {
                        throw new Exception("Inconsisten 2D/3D data format.");
                    }
                    reader.ReadEndElement();

                    // For compatibility...
                    if (reader.Name.Equals("x1"))
                    {
                        reader.Skip();
                        reader.Skip();
                        reader.Skip();
                        reader.Skip();
                    }
                    reader.ReadEndElement();
                    user_information.Add(user, joints);
                }

                this.Add(key, user_information);


                reader.ReadEndElement();
                reader.MoveToContent();
            }
            reader.ReadEndElement();
        }
Ejemplo n.º 21
0
        protected override CloudArgs AnalysisData(System.Xml.XmlReader reader)
        {
            if (_webClient.ResponseHeaders != null)
            {
                string date = _webClient.ResponseHeaders["Date"];
                if (date != null)
                {
                    DateTime serverTime = DateTime.Parse(date);
                    TimeInterval = DateTime.Now.Subtract(serverTime).Ticks;
                }
            }

            var args = new CloudArgs();

            args.Datas = new List <CloudDataInfo>();
            while (reader.Read())
            {
                if (reader.Name == "root")
                {
                    if (Method == HttpMethod.Get)
                    {
                        reader.MoveToAttribute("etag");
                        Etag = reader.ReadContentAsString();
                    }
                    reader.MoveToAttribute("ret");
                    int ret = reader.ReadContentAsInt();
                    reader.MoveToAttribute("msg");
                    string msg = reader.ReadContentAsString();
                    if (ret == 0)
                    {
                        args.message = msg;
                        return(args);
                    }
                }
                if (reader.Name == Type)
                {
                    while (reader.Read())
                    {
                        if (reader.Name == "Item")
                        {
                            try
                            {
                                var infoSync = new CloudDataInfo();

                                if (reader.MoveToAttribute("UUID"))
                                {
                                    infoSync.UUID = reader.ReadContentAsString();
                                }

                                if (reader.MoveToAttribute("Device"))
                                {
                                    infoSync.Device = reader.ReadContentAsInt();
                                }

                                if (reader.MoveToAttribute("DeviceHistory"))
                                {
                                    infoSync.DeviceHistory = reader.ReadContentAsInt();
                                }

                                if (reader.MoveToAttribute("Id"))
                                {
                                    infoSync.Id = reader.ReadContentAsInt();
                                }
                                //reader.MoveToAttribute("ClId");
                                //infoSync.ClId = reader.ReadContentAsInt();
                                if (reader.MoveToAttribute("Name"))
                                {
                                    infoSync.Name = reader.ReadContentAsString();
                                }

                                if (reader.MoveToAttribute("SubName"))
                                {
                                    infoSync.SubName = reader.ReadContentAsString();
                                }

                                if (reader.MoveToAttribute("SubId"))
                                {
                                    infoSync.SubId = reader.ReadContentAsInt();
                                }

                                if (reader.MoveToAttribute("Pos"))
                                {
                                    infoSync.Pos = reader.ReadContentAsInt();
                                }

                                if (reader.MoveToAttribute("Duration"))
                                {
                                    infoSync.Duration = reader.ReadContentAsInt();
                                }

                                if (reader.MoveToAttribute("ModifyTime"))
                                {
                                    infoSync.ModifyTime = reader.ReadContentAsLong();
                                }
                                //reader.MoveToAttribute("Property");
                                //infoSync.Property = reader.ReadContentAsInt();
                                //reader.MoveToAttribute("VideoType");
                                //infoSync.VideoType = reader.ReadContentAsInt();
                                //reader.MoveToAttribute("Bt");
                                //infoSync.Bt = reader.ReadContentAsInt();
                                //reader.MoveToAttribute("Mode");
                                //infoSync.Mode = reader.ReadContentAsInt();
                                args.Datas.Add(infoSync);
                            }
                            catch { }
                        }
                    }
                }
            }
            return(args);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Lê os dados serializados.
        /// </summary>
        /// <param name="reader"></param>
        void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.MoveToAttribute("uid"))
            {
                Uid = Guid.Parse(reader.ReadContentAsString());
            }
            if (reader.MoveToAttribute("name"))
            {
                Name = reader.ReadContentAsString();
            }
            if (reader.MoveToAttribute("type"))
            {
                Type = (InputValidateType)Enum.Parse(typeof(InputValidateType), reader.ReadContentAsString());
            }
            reader.MoveToElement();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.IsEmptyElement && !reader.HasAttributes)
                    {
                        reader.Skip();
                        continue;
                    }
                    switch (reader.LocalName)
                    {
                    case "CheckDigits":
                        CheckDigits = ReadElement <InputValidateCheckDigits>(reader);
                        break;

                    case "Default":
                        Default = ReadElement <InputValidateDefault>(reader);
                        break;

                    case "Customization":
                        Customization = ReadElement <InputValidateCustomization>(reader);
                        break;

                    case "IndexedValues":
                    {
                        reader.ReadStartElement();
                        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                        {
                            if (reader.LocalName == "InputValidateIndexedValue")
                            {
                                var value = new InputValidateIndexedValue();
                                ((System.Xml.Serialization.IXmlSerializable)value).ReadXml(reader);
                                IndexedValues.Add(value);
                            }
                            else
                            {
                                reader.Skip();
                            }
                        }
                        reader.ReadEndElement();
                    }
                    break;

                    case "Length":
                        Length = ReadElement <InputValidateLength>(reader);
                        break;

                    case "Mask":
                        Mask = ReadElement <InputValidateMask>(reader);
                        break;

                    case "Range":
                        Range = ReadElement <InputValidateRange>(reader);
                        break;

                    case "ValidChars":
                        ValidChars = ReadElement <InputValidateValidChars>(reader);
                        break;

                    case "Group":
                        Group = ReadElement <InputValidateGroup>(reader);
                        break;

                    case "Values":
                    {
                        reader.ReadStartElement();
                        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                        {
                            if (reader.LocalName == "InputValidateValue")
                            {
                                var value = new InputValidateValue();
                                ((System.Xml.Serialization.IXmlSerializable)value).ReadXml(reader);
                                Values.Add(value);
                            }
                            else
                            {
                                reader.Skip();
                            }
                        }
                        reader.ReadEndElement();
                    }
                    break;

                    default:
                        reader.Skip();
                        break;
                    }
                }
                reader.ReadEndElement();
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Lê os dados do XML.
        /// </summary>
        /// <param name="reader"></param>
        void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToAttribute("ActionId");
            ActionId = reader.ReadContentAsInt();
            reader.MoveToAttribute("Type");
            var typeString = reader.ReadContentAsString();

            Type = (PersistenceActionType)Enum.Parse(typeof(PersistenceActionType), typeString);
            reader.MoveToAttribute("EntityFullName");
            EntityFullName = reader.ReadContentAsString();
            reader.MoveToAttribute("ProviderName");
            ProviderName = reader.ReadContentAsString();
            reader.MoveToAttribute("RowVersion");
            var RowVersionString = reader.ReadContentAsString();

            if (!string.IsNullOrEmpty(RowVersionString))
            {
                RowVersion = long.Parse(RowVersionString);
            }
            else
            {
                RowVersion = null;
            }
            if (reader.MoveToAttribute("CommandTimeout"))
            {
                var timeout = 0;
                if (int.TryParse(reader.ReadContentAsString(), out timeout))
                {
                    CommandTimeout = timeout;
                }
            }
            reader.MoveToElement();
            reader.ReadStartElement();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("Parameters", Namespaces.Data);
                var parameters = new List <PersistenceParameter>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "Parameter")
                    {
                        var parameter = new PersistenceParameter();
                        ((System.Xml.Serialization.IXmlSerializable)parameter).ReadXml(reader);
                        parameters.Add(parameter);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                Parameters = new PersistenceParameterCollection(parameters);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                var conditional = new Colosoft.Query.ConditionalContainer();
                ((System.Xml.Serialization.IXmlSerializable)conditional).ReadXml(reader);
                this.Conditional = conditional;
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("AlternativeActions");
                var actions = new List <PersistenceAction>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "PersistenceAction")
                    {
                        var persistenceAction = new PersistenceAction();
                        ((System.Xml.Serialization.IXmlSerializable)persistenceAction).ReadXml(reader);
                        actions.Add(persistenceAction);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                AlternativeActions.AddRange(actions);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("BeforeActions");
                var actions = new List <PersistenceAction>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "PersistenceAction")
                    {
                        var persistenceAction = new PersistenceAction();
                        ((System.Xml.Serialization.IXmlSerializable)persistenceAction).ReadXml(reader);
                        actions.Add(persistenceAction);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                BeforeActions.AddRange(actions);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("AfterActions");
                var actions = new List <PersistenceAction>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "PersistenceAction")
                    {
                        var persistenceAction = new PersistenceAction();
                        ((System.Xml.Serialization.IXmlSerializable)persistenceAction).ReadXml(reader);
                        actions.Add(persistenceAction);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                AfterActions.AddRange(actions);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            _storedProcedureName = ReadItem <Colosoft.Query.StoredProcedureName>(reader, "StoredProcedureName");
            if (!reader.IsEmptyElement)
            {
                var query = new Colosoft.Query.QueryInfo();
                ((System.Xml.Serialization.IXmlSerializable)query).ReadXml(reader);
                this.Query = query;
            }
            else
            {
                reader.Skip();
            }
            reader.ReadEndElement();
        }
Ejemplo n.º 24
0
        public static IObjectList <T> ImportFromXML <T>(System.Xml.XmlReader reader, Siaqodb siaqodb)
        {
            ObjectTable obTable = new ObjectTable();

            reader.Read();
            reader.ReadStartElement("SiaqodbObjects");
            SqoTypeInfo            ti         = siaqodb.GetSqoTypeInfo <T>();
            bool                   colFinish  = false;
            ObjectRow              currentRow = null;
            int                    index      = 0;
            Dictionary <int, Type> members    = new Dictionary <int, Type>();

            while (reader.Read())
            {
                if (reader.IsStartElement() && reader.Name == "objects")
                {
                    colFinish = true;
                }

                if (reader.IsStartElement() && !colFinish)
                {
                    reader.MoveToFirstAttribute();
                    //string type = reader.Value;
                    Type t = Type.GetType(reader.Value);
                    reader.MoveToElement();

                    reader.ReadStartElement();
                    string columnName = reader.ReadContentAsString();
                    if (columnName == "OID")
                    {
                        throw new SiaqodbException("OID is set only internally, cannot be imported");
                    }
                    obTable.Columns.Add(columnName, index);
                    if (t.IsGenericType())
                    {
                        Type genericTypeDef = t.GetGenericTypeDefinition();
                        if (genericTypeDef == typeof(Nullable <>))
                        {
                            t = t.GetGenericArguments()[0];
                        }
                    }
                    members.Add(index, t);
                    index++;
                }
                if (reader.IsStartElement() && reader.Name == "object")
                {
                    currentRow = obTable.NewRow();
                    obTable.Rows.Add(currentRow);
                    index = 0;
                }
                if (reader.IsStartElement() && reader.Name == "memberValue")
                {
                    ReadMemberValue(currentRow, reader, index, members);
                    index++;
                    while (reader.Name == "memberValue")
                    {
                        ReadMemberValue(currentRow, reader, index, members);
                        index++;
                    }
                }
            }
            return(ObjectTableHelper.CreateObjectsFromTable <T>(obTable, ti));
        }
Ejemplo n.º 25
0
        private RSACryptoServiceProvider GetRSACryptoServiceProvider(string variableName)
        {
            string serializedKey = GetRecordedVariable(variableName);

            System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(new StringReader(serializedKey));
            xmlReader.Read();
            if (xmlReader.Name != "RSAKeyValue")
            {
                throw new System.Xml.XmlException();
            }
            xmlReader.Read();

            RSAParameters parameters = new RSAParameters();

            while (xmlReader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (xmlReader.Name)
                {
                case "Modulus":
                {
                    xmlReader.Read();
                    if (xmlReader.NodeType != System.Xml.XmlNodeType.Text)
                    {
                        throw new System.Xml.XmlException();
                    }
                    parameters.Modulus = Convert.FromBase64String(xmlReader.ReadContentAsString());
                    xmlReader.Read();
                }
                break;

                case "Exponent":
                {
                    xmlReader.Read();
                    if (xmlReader.NodeType != System.Xml.XmlNodeType.Text)
                    {
                        throw new System.Xml.XmlException();
                    }
                    parameters.Exponent = Convert.FromBase64String(xmlReader.ReadContentAsString());
                    xmlReader.Read();
                }
                break;

                case "P":
                {
                    xmlReader.Read();
                    if (xmlReader.NodeType != System.Xml.XmlNodeType.Text)
                    {
                        throw new System.Xml.XmlException();
                    }
                    parameters.P = Convert.FromBase64String(xmlReader.ReadContentAsString());
                    xmlReader.Read();
                }
                break;

                case "Q":
                {
                    xmlReader.Read();
                    if (xmlReader.NodeType != System.Xml.XmlNodeType.Text)
                    {
                        throw new System.Xml.XmlException();
                    }
                    parameters.Q = Convert.FromBase64String(xmlReader.ReadContentAsString());
                    xmlReader.Read();
                }
                break;

                case "DP":
                {
                    xmlReader.Read();
                    if (xmlReader.NodeType != System.Xml.XmlNodeType.Text)
                    {
                        throw new System.Xml.XmlException();
                    }
                    parameters.DP = Convert.FromBase64String(xmlReader.ReadContentAsString());
                    xmlReader.Read();
                }
                break;

                case "DQ":
                {
                    xmlReader.Read();
                    if (xmlReader.NodeType != System.Xml.XmlNodeType.Text)
                    {
                        throw new System.Xml.XmlException();
                    }
                    parameters.DQ = Convert.FromBase64String(xmlReader.ReadContentAsString());
                    xmlReader.Read();
                }
                break;

                case "InverseQ":
                {
                    xmlReader.Read();
                    if (xmlReader.NodeType != System.Xml.XmlNodeType.Text)
                    {
                        throw new System.Xml.XmlException();
                    }
                    parameters.InverseQ = Convert.FromBase64String(xmlReader.ReadContentAsString());
                    xmlReader.Read();
                }
                break;

                case "D":
                {
                    xmlReader.Read();
                    if (xmlReader.NodeType != System.Xml.XmlNodeType.Text)
                    {
                        throw new System.Xml.XmlException();
                    }
                    parameters.D = Convert.FromBase64String(xmlReader.ReadContentAsString());
                    xmlReader.Read();
                }
                break;

                default:
                    throw new System.Xml.XmlException();
                }
            }

            var returnValue = new RSACryptoServiceProvider();

            returnValue.ImportParameters(parameters);
            return(returnValue);
        }
Ejemplo n.º 26
0
        private void OnParseWork(Object state)
        {
            try
            {
                AdDescriptor adDescriptor = null;

                System.IO.Stream stream = state as System.IO.Stream;

                System.Xml.XmlReaderSettings readerSettings = new System.Xml.XmlReaderSettings();
                readerSettings.IgnoreWhitespace             = true;
                readerSettings.IgnoreComments               = true;
                readerSettings.IgnoreProcessingInstructions = true;

                System.Xml.XmlReader reader = System.Xml.XmlReader.Create(stream, readerSettings);

                Dictionary <string, string> adInfo = new Dictionary <string, string>();
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        if (reader.Name == "error")
                        {
                            string errorCode    = reader.GetAttribute("code");
                            string errorMessage = string.Empty;

                            // read past the name
                            reader.Read();

                            // read the contents
                            switch (reader.NodeType)
                            {
                            case System.Xml.XmlNodeType.CDATA:
                            case System.Xml.XmlNodeType.Text:
                                errorMessage = reader.ReadContentAsString();
                                break;
                            }

                            if (this.errorCallback != null)
                            {
                                this.errorCallback(this, errorCode, errorMessage);

                                Cancel();
                            }

                            // no need to parse anything else
                            break;
                        }
                        else if (reader.Name == "ad")
                        {
                            string adType = reader.GetAttribute("type");

                            adInfo["type"] = adType;

                            // read each child node (passing ad node first)
                            while (reader.Read())
                            {
                                if (reader.IsStartElement() == false)
                                {
                                    if ((reader.NodeType == System.Xml.XmlNodeType.EndElement) && (reader.Name == "ad"))
                                    {
                                        // done with the descriptor
                                        break;
                                    }

                                    // advance to start of next descriptor property
                                    continue;
                                }

                                string name = reader.Name;

                                // read past the name
                                reader.Read();

                                // read the content which may be text or cdata from the ad server
                                string value = null;
                                switch (reader.NodeType)
                                {
                                case System.Xml.XmlNodeType.CDATA:
                                case System.Xml.XmlNodeType.Text:
                                    value = reader.ReadContentAsString();
                                    break;
                                }

                                if ((string.IsNullOrEmpty(name) == false) && (string.IsNullOrEmpty(value) == false))
                                {
                                    adInfo[name] = value;
                                }
                            }

                            adDescriptor = new AdDescriptor(adInfo);

                            // no need to parse anything else
                            break;
                        }
                    }
                }

                if (this.completedCallback != null)
                {
                    this.completedCallback(this, adDescriptor);
                }
            }
            catch (Exception ex)
            {
                if (this.failedCallback != null)
                {
                    this.failedCallback(this, ex);
                }
            }

            Cancel();
        }
Ejemplo n.º 27
0
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     reader.MoveToAttribute("ActionId");
     ActionId = reader.ReadContentAsInt();
     reader.MoveToAttribute("Success");
     Success = bool.Parse(reader.ReadContentAsString());
     reader.MoveToAttribute("AffectedRows");
     AffectedRows = reader.ReadContentAsInt();
     reader.MoveToAttribute("RowVersion");
     RowVersion = reader.ReadContentAsLong();
     reader.MoveToElement();
     reader.ReadStartElement();
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("FailureMessage");
         FailureMessage = reader.ReadString();
         reader.ReadEndElement();
     }
     else
     {
         FailureMessage = null;
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("Result");
         Result = reader.ReadContentAsObject();
         reader.ReadEndElement();
     }
     else
     {
         Result = null;
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("Parameters", Namespaces.Data);
         var parameters = new List <PersistenceParameter>();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "Parameter")
             {
                 var parameter = new PersistenceParameter();
                 ((System.Xml.Serialization.IXmlSerializable)parameter).ReadXml(reader);
                 parameters.Add(parameter);
             }
             else
             {
                 reader.Skip();
             }
         }
         Parameters = parameters.ToArray();
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("AlternativeActions", Namespaces.Data);
         var actions = new List <PersistenceActionResult>();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "PersistenceActionResult")
             {
                 var action = new PersistenceActionResult();
                 ((System.Xml.Serialization.IXmlSerializable)action).ReadXml(reader);
                 actions.Add(action);
             }
             else
             {
                 reader.Skip();
             }
         }
         AlternativeActions = actions.ToArray();
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("BeforeActions", Namespaces.Data);
         var actions = new List <PersistenceActionResult>();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "PersistenceActionResult")
             {
                 var action = new PersistenceActionResult();
                 ((System.Xml.Serialization.IXmlSerializable)action).ReadXml(reader);
                 actions.Add(action);
             }
             else
             {
                 reader.Skip();
             }
         }
         BeforeActions = actions.ToArray();
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("AfterActions", Namespaces.Data);
         var actions = new List <PersistenceActionResult>();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "PersistenceActionResult")
             {
                 var action = new PersistenceActionResult();
                 ((System.Xml.Serialization.IXmlSerializable)action).ReadXml(reader);
                 actions.Add(action);
             }
             else
             {
                 reader.Skip();
             }
         }
         AfterActions = actions.ToArray();
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     reader.ReadEndElement();
 }