/// <summary>
    /// Applies the transformation from the reader to the writer
    /// </summary>
    /// <param name="reader"></param>
    /// <param name="writer"></param>
    public void Transform(XmlReader reader, XmlWriter writer) {
      Contract.Requires(reader != null);
      Contract.Requires(writer != null);

      while (reader.Read())
        this.WriteNodeSingle(reader, writer);
    }
示例#2
0
 public Reflexive(Map Map, string Label, int Count,int Base, int Offset, int Size,XmlReader Reader)
 {
     this.Map = Map;
     this.Label = Label;
     this.Count = Count;
     this.Base = Base;
     this.Offset = Offset;
     this.ChunkSize = Size;
     this.Reader = Reader;
     if (Base != 0)
     {
         Map.Reader.BaseStream.Position = ((Offset + Base) - Map.Index.SecondaryMagic) + 4;
         this.RawTranslation = Map.Reader.ReadInt32();
     }
     else
         this.RawTranslation = 0;
     InitializeComponent();
     for (int i = 0; i < Count; i++)
         comboBox1.Items.Add(i.ToString());
     label1.Text = Label;
     ReadControls();
     if (Count == 0)
     {
         button1.Text = "+";
         panel1.Hide();
         hidden = true;
     }
     else
     {
         comboBox1.SelectedIndex = 0;
         this.Height += panel1.Height;
     }
 }
        protected override bool HandleAttribute(XmlReader reader)
        {
            if (base.HandleAttribute(reader))
            {
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.MinimumAttribute))
            {
                HandleMinimumAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.MaximumAttribute))
            {
                HandleMaximumAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.DefaultValueAttribute))
            {
                HandleDefaultAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.ConstantAttribute))
            {
                HandleConstantAttribute(reader);
                return true;
            }

            return false;
        }
        public static KeyValuePair<string, Property> ReadXml(XmlReader reader)
        {
            var key = reader.GetAttribute("Key");
            var type = reader.GetAttribute("Type");

            reader.MoveToElement();
            reader.ReadStartElement("PropertyEntry");
            Property value = null;
            try
            {
                var t = Type.GetType(type);
                value = (Property)GetSerializer(t).Deserialize(reader);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Deserialization failed: " + ex.Message);
                Console.WriteLine("Property Key: " + key);
                Console.WriteLine("Property Type Qualified Name: " + type);
                Console.WriteLine("Stacktrace: " + ex.StackTrace);
            }

            reader.ReadEndElement();
            reader.MoveToContent();
            if (value == null)
                throw new Exception();
            return new KeyValuePair<string, Property>(key, value);
        }
 void IFlickrParsable.Load(XmlReader reader)
 {
     while (reader.MoveToNextAttribute())
     {
         switch (reader.LocalName)
         {
             case "id":
                 PhotoId = reader.Value;
                 break;
             case "ispublic":
                 IsPublic = reader.Value == "1";
                 break;
             case "iscontact":
                 IsContact = reader.Value == "1";
                 break;
             case "isfamily":
                 IsFamily = reader.Value == "1";
                 break;
             case "isfriend":
                 IsFriend = reader.Value == "1";
                 break;
         }
     }
     reader.Read();
 }
        public override void DeserializeNetwork(XmlReader xmlReader)
        {
            base.DeserializeNetwork(xmlReader);

            var expander = ControlElements[0] as SliderExpanderDouble;
            if (expander == null) return;

            var attribute = xmlReader.GetAttribute("SliderMax");
            if (attribute != null)
                expander.SliderMax = Convert.ToDouble(attribute.Replace(".", ","));

            var attribute1 = xmlReader.GetAttribute("SliderMin");
            if (attribute1 != null)
                expander.SliderMin  = Convert.ToDouble(attribute1.Replace(".", ","));

            var attribute2 = xmlReader.GetAttribute("SliderValue");
            if (attribute2 != null)
                expander.SliderValue = Convert.ToDouble(attribute2.Replace(".", ","));

            var attribute3 = xmlReader.GetAttribute("SliderStep");
            if (attribute3 != null)
                expander.SliderStep = Convert.ToDouble(attribute3.Replace(".", ","));

            var attribute4 = xmlReader.GetAttribute("IsExpanded");
            if (attribute4 != null)
                expander.IsExpanded = Convert.ToBoolean(attribute4.Replace(".", ","));
        }
示例#7
0
文件: DataURL.cs 项目: bertt/BruTile
        public override void ReadXml(XmlReader reader)
        {
            if (CheckEmptyNode(reader, "DataURL", Namespace))
                return;

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                        case "Format":
                            Format = reader.ReadElementContentAsString();
                            break;
                        case "OnlineResource":
                            OnlineResource = new OnlineResource();
                            OnlineResource.ReadXml(reader);
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                else
                {
                    reader.Read();
                }
            }
        }
示例#8
0
 public object TokenizeFromXml(XmlReader reader)
 {
     reader.ReadStartElement();
     Geometry geometry = GmlFormatter.Create().Read<Geometry>(reader);
     reader.SkipInsignificantNodes();
     return geometry;
 }
        protected override bool HandleAttribute(XmlReader reader)
        {
            if (base.HandleAttribute(reader))
            {
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.Relationship))
            {
                HandleAssociationAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.FromRole))
            {
                HandleFromRoleAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.ToRole))
            {
                HandleToRoleAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.ContainsTarget))
            {
                // EF does not support this EDM 3.0 attribute, so ignore it.
                return true;
            }

            return false;
        }
        protected override System.IdentityModel.Tokens.SecurityToken ReadTokenCore( XmlReader reader, SecurityTokenResolver tokenResolver )
        {
            if ( reader == null )
                throw new ArgumentNullException( "reader" );

            if ( reader.IsStartElement( Constants.UsernameTokenName, Constants.UsernameTokenNamespace ) )
            {
                //string id = reader.GetAttribute( Constants.IdAttributeName, Constants.WsUtilityNamespace );

                reader.ReadStartElement();

                // read the user name
                string userName = reader.ReadElementString( Constants.UsernameElementName, Constants.UsernameTokenNamespace );

                // read the password hash
                string password = reader.ReadElementString( Constants.PasswordElementName, Constants.UsernameTokenNamespace );

                // read nonce
                string nonce = reader.ReadElementString( Constants.NonceElementName, Constants.UsernameTokenNamespace );

                // read created
                string created = reader.ReadElementString( Constants.CreatedElementName, Constants.WsUtilityNamespace );

                reader.ReadEndElement();

                var info = new Info( userName, password );

                return new SecurityToken( info, nonce, created );
            }

            return DefaultInstance.ReadToken( reader, tokenResolver );
        }
示例#11
0
 /// <summary>Generates an object from its XML representation.</summary>
 /// <param name="reader">The <see cref="T:System.Xml.XmlReader" /> stream from which the object is
 /// deserialized.</param>
 public override void ReadXml(XmlReader reader)
 {
     reader.MoveToContent();
     reader.ReadStartElement();
     Descriptor = Xml.Read<Descriptor>(reader);
     Root = Xml.Read<Measure>(reader);
 }
示例#12
0
        public void ReadFromXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) { reader.Read(); return; }

            num = int.Parse(reader.GetAttribute("number"));

            reader.Read();
            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name == "class")
                    {
                        var sClass = new ScheduleClass();
                        sClass.ReadFromXml(reader);
                        classes.Add(sClass);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                else
                {
                    reader.Read();
                    break;
                }
            }
        }
示例#13
0
文件: User.cs 项目: liquidboy/X
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "user")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "nsid":
                    case "id":
                        UserId = reader.Value;
                        break;
                    case "username":
                        UserName = reader.Value;
                        break;
                    case "fullname":
                        FullName = reader.Value;
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            if (reader.NodeType != XmlNodeType.EndElement)
            {
                UserName = reader.ReadElementContentAsString();
                reader.Skip();
            }
        }
示例#14
0
        public bool Read(XmlReader reader)
        {
            if(reader.IsStartElement() && reader.Name == "Fixture") {
                Fixture fixture = new Fixture();

                //...Any attributes go here...
                fixture.AllowFrameSkip = bool.Parse(reader.GetAttribute("allowFrameSkip"));
                fixture.Name = reader.GetAttribute("name");
                // This needs to hold off until after channels are loaded.
                string fixtureDefinitionName = reader.GetAttribute("fixtureDefinitionName");

                if(reader.ElementsExistWithin("Fixture")) { // Entity element
                    // Channels
                    if(reader.ElementsExistWithin("Channels")) { // Container element for child entity
                        ChannelReader<OutputChannel> channelReader = new ChannelReader<OutputChannel>();
                        while(channelReader.Read(reader)) {
                            fixture.InsertChannel(channelReader.Channel);
                        }
                        reader.ReadEndElement(); // Channels
                    }

                    // With channels loaded, the fixture template reference can be set.
                    fixture.FixtureDefinitionName = fixtureDefinitionName;

                    reader.ReadEndElement(); // Fixture

                    this.Fixture = fixture;
                }
                return true;
            }
            return false;
        }
示例#15
0
		void DoSetUp(XmlReader reader, string endElement)
		{
			Stack<ICondition> conditionStack = new Stack<ICondition>();
			List<Codon> innerCodons = new List<Codon>();
			while (reader.Read()) {
				switch (reader.NodeType) {
					case XmlNodeType.EndElement:
						if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition") {
							conditionStack.Pop();
						} else if (reader.LocalName == endElement) {
							if (innerCodons.Count > 0)
								this.codons.Add(innerCodons);
							return;
						}
						break;
					case XmlNodeType.Element:
						string elementName = reader.LocalName;
						if (elementName == "Condition") {
							conditionStack.Push(Condition.Read(reader));
						} else if (elementName == "ComplexCondition") {
							conditionStack.Push(Condition.ReadComplexCondition(reader));
						} else {
							Codon newCodon = new Codon(this.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray());
							innerCodons.Add(newCodon);
							if (!reader.IsEmptyElement) {
								ExtensionPath subPath = this.AddIn.GetExtensionPath(this.Name + "/" + newCodon.Id);
								subPath.DoSetUp(reader, elementName);
							}
						}
						break;
				}
			}
			if (innerCodons.Count > 0)
				this.codons.Add(innerCodons);
		}
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "referrer")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "url":
                        Url = reader.Value;
                        break;
                    case "searchterm":
                        SearchTerm = reader.Value;
                        break;
                    case "views":
                        Views = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Skip();
        }
		/// <summary>
		/// Creates a new PolicyIdReference using the XmlReader instance provided.
		/// </summary>
		/// <param name="reader">The XmlReader positioned at the PolicyIdReference element.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public PolicyIdReferenceElementReadWrite( XmlReader reader, XacmlVersion schemaVersion )
			: base( XacmlSchema.Policy, schemaVersion )
		{
            if (reader == null) throw new ArgumentNullException("reader");
			if( reader.LocalName == PolicySchema1.PolicyIdReferenceElement.PolicyIdReference && 
				ValidateSchema( reader, schemaVersion ) )
			{
				if( reader.HasAttributes )
				{
					// Load all the attributes
					while( reader.MoveToNextAttribute() )
					{
						if( reader.LocalName == PolicyReferenceElement.Version )
						{
							_version = reader.GetAttribute( PolicyReferenceElement.Version );
						}
						else if( reader.LocalName == PolicyReferenceElement.EarliestVersion )
						{
							_earliestVersion = reader.GetAttribute( PolicyReferenceElement.EarliestVersion );
						}
						else if( reader.LocalName == PolicyReferenceElement.LatestVersion )
						{
							_latestVersion = reader.GetAttribute( PolicyReferenceElement.LatestVersion );
						}					
					}
					reader.MoveToElement();
				}
				_policyIdReference = reader.ReadElementString();
			}
			else
			{
				throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
			}
		}
示例#18
0
        /// <summary>
        /// Initializes the object with a XML reader.
        /// </summary>
        public XmlDecoder(System.Type systemType, XmlReader reader, ServiceMessageContext context)
        {
            Initialize();

            m_reader  = reader;
            m_context = context;

            string ns = null;
            string name = null;

            if (systemType != null)
            {
                XmlQualifiedName typeName = EncodeableFactory.GetXmlName(systemType);
                ns = typeName.Namespace;
                name = typeName.Name;
            }

            if (ns == null)
            {
                m_reader.MoveToContent();
                ns = m_reader.NamespaceURI;
                name = m_reader.Name;
            }

            int index = name.IndexOf(':');

            if (index != -1)
            {
                name = name.Substring(index + 1);
            }

            PushNamespace(ns);
            BeginField(name, false);
        }      
示例#19
0
文件: LibHeader.cs 项目: burstas/rmps
        public bool FromXml(XmlReader reader)
        {
            if (reader == null || reader.Name != "Lib")
            {
                return false;
            }

            if (reader.Name == "Order" || reader.ReadToDescendant("Order"))
            {
                Order = reader.ReadElementContentAsInt();
            }
            if (reader.Name == "Id" || reader.ReadToNextSibling("Id"))
            {
                Id = reader.ReadElementContentAsString();
            }
            if (reader.Name == "Name" || reader.ReadToNextSibling("Name"))
            {
                Name = reader.ReadElementContentAsString();
            }
            if (reader.Name == "Text" || reader.ReadToNextSibling("Text"))
            {
                Text = reader.ReadElementContentAsString();
            }
            if (reader.Name == "Memo" || reader.ReadToNextSibling("Memo"))
            {
                Memo = reader.ReadElementContentAsString();
            }
            return true;
        }
        protected void HandleTypeAttribute(XmlReader reader)
        {
            DebugCheck.NotNull(reader);

            string type;
            if (!Utils.GetString(Schema, reader, out type))
            {
                return;
            }

            TypeModifier typeModifier;
            Function.RemoveTypeModifier(ref type, out typeModifier, out _isRefType);

            switch (typeModifier)
            {
                case TypeModifier.Array:
                    _collectionKind = CollectionKind.Bag;
                    break;
                default:
                    Debug.Assert(
                        typeModifier == TypeModifier.None,
                        string.Format(
                            CultureInfo.CurrentCulture,
                            "Type is not valid for property {0}: {1}. The modifier for the type cannot be used in this context.", FQName,
                            reader.Value));
                    break;
            }

            if (!Utils.ValidateDottedName(Schema, reader, type))
            {
                return;
            }

            _unresolvedType = type;
        }
示例#21
0
 public bool ParseLogs()
 {
     try
     {
         foreach (string f in _root.Files)
         {
             _reader = new XmlTextReader(f);
             Console.WriteLine("Loading Log");
             while (_reader.Read())
             {
                 if (_reader.Name == "State")
                 {
                     Dictionary<String, String> attributes = GetAttributes();
                     _root.States.Add(new Model.PMState(attributes));
                     ParseState(_reader.ReadSubtree());
                 }
             }
         }
     }
     catch
     {
         return false;
     }
     return true;
 }
示例#22
0
        public void ReadXml(XmlReader reader)
        {
            var s = reader.ReadOuterXml();
            var x = XDocument.Parse(s);
            if (x.Root == null) return;

            foreach (var e in x.Root.Elements())
            {
                var name = e.Name.ToString();
                switch (name)
                {
                    case "List":
                        foreach (var ee in e.Elements())
                            _list.Add(Util.DeSerialize<OnlineRegPersonModel>(ee.ToString()));
                        break;
                    case "History":
                        foreach (var ee in e.Elements())
                            _history.Add(ee.Value);
                        break;
                    default:
                        Util.SetPropertyFromText(this, name, e.Value);
                        break;
                }
            }
        }
示例#23
0
        protected override void DeserializePropertyElement(XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException ("reader");

            if (reader.NamespaceURI == Schemas.UpnpSchema) {
                switch (reader.LocalName) {
                case "producer":
                    producer_list.Add (reader.ReadString ());
                    break;
                default:
                    base.DeserializePropertyElement (reader);
                    break;
                }
            } else if (reader.NamespaceURI == Schemas.DublinCoreSchema) {
                switch (reader.LocalName) {
                case "contributor":
                    contributor_list.Add (reader.ReadString ());
                    break;
                case "date":
                    Date = reader.ReadString ();
                    break;
                default:
                    base.DeserializePropertyElement (reader);
                    break;
                }
            } else {
                base.DeserializePropertyElement (reader);
            }
        }
 private static bool IsValidAttribute(XmlReader xmlReader)
 {
     return xmlReader.NamespaceURI != Globals.SerializationNamespace &&
                            xmlReader.NamespaceURI != Globals.SchemaInstanceNamespace &&
                            xmlReader.Prefix != "xmlns" &&
                            xmlReader.LocalName != "xmlns";
 }
 public static XmlNode[] ReadNodes(XmlReader xmlReader)
 {
     if (xmlReader == null)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader");
     XmlDocument doc = new XmlDocument();
     List<XmlNode> nodeList = new List<XmlNode>();
     if (xmlReader.MoveToFirstAttribute())
     {
         do
         {
             if (IsValidAttribute(xmlReader))
             {
                 XmlNode node = doc.ReadNode(xmlReader);
                 if (node == null)
                     throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
                 nodeList.Add(node);
             }
         } while (xmlReader.MoveToNextAttribute());
     }
     xmlReader.MoveToElement();
     if (!xmlReader.IsEmptyElement)
     {
         int startDepth = xmlReader.Depth;
         xmlReader.Read();
         while (xmlReader.Depth > startDepth && xmlReader.NodeType != XmlNodeType.EndElement)
         {
             XmlNode node = doc.ReadNode(xmlReader);
             if (node == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
             nodeList.Add(node);
         }
     }
     return nodeList.ToArray();
 }
        public void ReadXml(XmlReader reader)
        {
            //This method is not implemented because
            //this class is never deserialized by the client

            throw new NotImplementedException();
        }
示例#27
0
		/// <summary>
		/// Create <see cref="NewFolding"/>s for the specified document.
		/// </summary>
		public IEnumerable<NewFolding> CreateNewFoldings(TextDocument document, XmlReader reader, out int firstErrorOffset)
		{
			Stack<XmlFoldStart> stack = new Stack<XmlFoldStart>();
			List<NewFolding> foldMarkers = new List<NewFolding>();
			try {
				while (reader.Read()) {
					switch (reader.NodeType) {
						case XmlNodeType.Element:
							if (!reader.IsEmptyElement) {
								XmlFoldStart newFoldStart = CreateElementFoldStart(document, reader);
								stack.Push(newFoldStart);
							}
							break;
							
						case XmlNodeType.EndElement:
							XmlFoldStart foldStart = stack.Pop();
							CreateElementFold(document, foldMarkers, reader, foldStart);
							break;
							
						case XmlNodeType.Comment:
							CreateCommentFold(document, foldMarkers, reader);
							break;
					}
				}
				firstErrorOffset = -1;
			} catch (XmlException ex) {
				// ignore errors
				firstErrorOffset = document.GetOffset(ex.LineNumber, ex.LinePosition);
			}
			foldMarkers.Sort((a,b) => a.StartOffset.CompareTo(b.StartOffset));
			return foldMarkers;
		}
示例#28
0
 public void RetrievePartyMessage(XmlReader reader, Party party)
 {
     while (reader.Name != "Message" && reader.Read())
     {
     }
     party.Message = reader.ReadElementContentAsString();
 }
示例#29
0
 public OrnamentsForm(XmlReader r, PaletteForm paletteForm, IPaletteFormsHostForm acForm, FormStateFunctions fsf)
 {
     _isLoading = true;
     InitializeOrnamentSettingsForm(r, paletteForm, acForm, fsf);
     _fsf.SetSettingsAreSaved(this, M.HasError(_allTextBoxes), ConfirmButton, RevertToSavedButton);
     _isLoading = false;
 }
 protected override object DoDeserializeValue(XmlReader reader, bool isSimpleValue)
 {
   reader.ReadStartElement(); // Read start of enclosing element
   IFilter result = MediaItemQuery.DeserializeFilter(reader);
   reader.ReadEndElement(); // End of enclosing element
   return result;
 }
示例#31
0
        void System.Xml.Serialization.IXmlSerializable.ReadXml(Xml.XmlReader reader)
        {
            var content = reader.ReadInnerXml();

            string mediatype;

            byte[] bytes;
            ParseInternal(content, out mediatype, out bytes);

            this._MediaType = mediatype;
            this._Bytes     = bytes;
        }
示例#32
0
 public override bool CanDeserialize(System.Xml.XmlReader xmlReader)
 {
     return(true);
 }
示例#33
0
 public bool TryExtractGameSaveDescriptorFromFile(string outputFilePath, out GameSaveDescriptor gameSaveDescriptor, bool makeCurrent)
 {
     gameSaveDescriptor = null;
     if (File.Exists(outputFilePath))
     {
         Archive archive = null;
         try
         {
             archive = Archive.Open(outputFilePath, ArchiveMode.Open);
             MemoryStream stream = null;
             if (archive.TryGet(global::GameManager.GameSaveDescriptorFileName, out stream))
             {
                 XmlReaderSettings settings = new XmlReaderSettings
                 {
                     CloseInput     = true,
                     IgnoreComments = true,
                     IgnoreProcessingInstructions = true,
                     IgnoreWhitespace             = true
                 };
                 using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(stream, settings))
                 {
                     if (xmlReader.ReadToDescendant("GameSaveDescriptor"))
                     {
                         ISerializationService service = Services.GetService <ISerializationService>();
                         XmlSerializer         xmlSerializer;
                         if (service != null)
                         {
                             xmlSerializer = service.GetXmlSerializer <GameSaveDescriptor>();
                         }
                         else
                         {
                             xmlSerializer = new XmlSerializer(typeof(GameSaveDescriptor));
                         }
                         gameSaveDescriptor = (xmlSerializer.Deserialize(xmlReader) as GameSaveDescriptor);
                         gameSaveDescriptor.SourceFileName = outputFilePath;
                         if (gameSaveDescriptor.Version.Serial != Amplitude.Unity.Framework.Application.Version.Serial)
                         {
                             Diagnostics.LogError("Invalid game save; application version does not match.");
                             gameSaveDescriptor = null;
                         }
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Diagnostics.LogWarning("Exception caught: " + ex.ToString());
             gameSaveDescriptor = null;
         }
         finally
         {
             if (archive != null)
             {
                 archive.Close();
             }
         }
         if (gameSaveDescriptor != null)
         {
             if (makeCurrent)
             {
                 this.GameSaveDescriptor = gameSaveDescriptor;
             }
             return(true);
         }
     }
     return(false);
 }
示例#34
0
 /// <summary>
 /// Gets a value indicating whether an unknown element is encountered during deserialization.
 /// </summary>
 /// <returns>
 /// true when an unknown element is encountered while deserializing; otherwise, false.
 /// </returns>
 /// <param name="elementName">The name of the unknown subelement.</param>
 /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> being used for deserialization.</param>
 /// <exception cref="T:System.Configuration.ConfigurationErrorsException">The element identified by <paramref name="elementName"/> is locked.
 /// - or -
 /// One or more of the element's attributes is locked.
 /// - or -
 /// <paramref name="elementName"/> is unrecognized, or the element has an unrecognized attribute.
 /// - or -
 /// The element has a Boolean attribute with an invalid value.
 /// - or -
 /// An attempt was made to deserialize a property more than once.
 /// - or -
 /// An attempt was made to deserialize a property that is not a valid member of the element.
 /// - or -
 /// The element cannot contain a CDATA or text element.
 /// </exception>
 protected override bool OnDeserializeUnrecognizedElement(string elementName, System.Xml.XmlReader reader)
 {
     return
         (this.valueElementHelper.DeserializeUnknownElement(elementName, reader) ||
          base.OnDeserializeUnrecognizedElement(elementName, reader));
 }
示例#35
0
        /// <summary>
        /// Updates an existing <see cref="NameValueCollection" /> object from
        /// its XML representation.
        /// </summary>

        private static void UpcodeTo(XmlReader reader, NameValueCollection collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            Debug.Assert(!reader.IsEmptyElement);
            reader.Read();

            //
            // Add entries into the collection as <item> elements
            // with child <value> elements are found.
            //

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.IsStartElement("item"))
                {
                    string name   = reader.GetAttribute("name");
                    bool   isNull = reader.IsEmptyElement;

                    reader.Read(); // <item>

                    if (!isNull)
                    {
                        while (reader.NodeType != XmlNodeType.EndElement)
                        {
                            if (reader.IsStartElement("value")) // <value ...>
                            {
                                string value = reader.GetAttribute("string");
                                collection.Add(name, value);
                                if (reader.IsEmptyElement)
                                {
                                    reader.Read();
                                }
                                else
                                {
                                    reader.Read();
                                    while (reader.NodeType != XmlNodeType.EndElement)
                                    {
                                        reader.Skip();
                                    }
                                    reader.ReadEndElement();
                                }
                            }
                            else
                            {
                                reader.Skip();
                            }

                            reader.MoveToContent();
                        }

                        reader.ReadEndElement(); // </item>
                    }
                    else
                    {
                        collection.Add(name, null);
                    }
                }
                else
                {
                    reader.Skip();
                }

                reader.MoveToContent();
            }

            reader.ReadEndElement();
        }
示例#36
0
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     this.ReadXml(reader);
 }
示例#37
0
 /// <summary>
 /// Reads XML from the configuration file.
 /// </summary>
 /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> that reads from the configuration file.</param>
 /// <param name="serializeCollectionKey">true to serialize only the collection key properties; otherwise, false.</param>
 /// <exception cref="T:System.Configuration.ConfigurationErrorsException">The element to read is locked.
 /// - or -
 /// An attribute of the current node is not recognized.
 /// - or -
 /// The lock status of the current node cannot be determined.
 /// </exception>
 protected override void DeserializeElement(System.Xml.XmlReader reader, bool serializeCollectionKey)
 {
     base.DeserializeElement(reader, serializeCollectionKey);
     this.valueElementHelper.CompleteValueElement(reader);
 }
示例#38
0
    public static IEnumerable <GameSaveDescriptor> GetListOfGameSaveDescritors(string path)
    {
        if (string.IsNullOrEmpty(path))
        {
            yield break;
        }
        if (!Directory.Exists(path))
        {
            yield break;
        }
        ISerializationService serializationService = Services.GetService <ISerializationService>();

        if (serializationService == null)
        {
            yield break;
        }
        XmlSerializer serializer = serializationService.GetXmlSerializer <GameSaveDescriptor>();
        List <string> fileNames  = new List <string>();

        fileNames.AddRange(Directory.GetFiles(path, "*.zip"));
        fileNames.AddRange(Directory.GetFiles(path, "*.sav"));
        Archive            archive            = null;
        GameSaveDescriptor gameSaveDescriptor = null;

        foreach (string fileName in fileNames)
        {
            gameSaveDescriptor = null;
            try
            {
                archive = Archive.Open(fileName, ArchiveMode.Open);
                MemoryStream stream = null;
                if (archive.TryGet(global::GameManager.GameSaveDescriptorFileName, out stream))
                {
                    XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
                    {
                        IgnoreComments   = true,
                        IgnoreWhitespace = true,
                        CloseInput       = true
                    };
                    using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(stream, xmlReaderSettings))
                    {
                        if (reader.ReadToDescendant("GameSaveDescriptor"))
                        {
                            gameSaveDescriptor = (serializer.Deserialize(reader) as GameSaveDescriptor);
                            gameSaveDescriptor.SourceFileName = fileName;
                            if (gameSaveDescriptor.Version.Serial != Amplitude.Unity.Framework.Application.Version.Serial)
                            {
                                gameSaveDescriptor = null;
                            }
                        }
                    }
                }
            }
            catch
            {
                gameSaveDescriptor = null;
            }
            finally
            {
                if (archive != null)
                {
                    archive.Close();
                }
            }
            if (gameSaveDescriptor != null)
            {
                yield return(gameSaveDescriptor);
            }
        }
        yield break;
    }
        /// <summary>
        /// Load the out xml from the XmlReader.
        /// </summary>
        /// <param name="xmlReader"></param>
        /// <remarks>The XmlReader not be moved.</remarks>
        internal void LoadOuterXml(System.Xml.XmlReader xmlReader)
        {
            switch (xmlReader.NodeType)
            {
            case XmlNodeType.None:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.None);
                break;

            case XmlNodeType.XmlDeclaration:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.XmlDeclaration);

                Value = xmlReader.Value;     // version='1.0'
                break;

            case XmlNodeType.Element:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.Element);
                break;

            case XmlNodeType.EndElement:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.EndElement);
                break;

            case XmlNodeType.Notation:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.Notation);
                break;

            case XmlNodeType.Attribute:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.Attribute);
                break;

            case XmlNodeType.Text:
                Value       = xmlReader.Value;
                RawOuterXml = xmlReader.Value;
                break;

            case XmlNodeType.CDATA:
                Value       = xmlReader.Value;
                RawOuterXml = Invariant($"<![CDATA[{xmlReader.Value}]]>");
                break;

            case XmlNodeType.SignificantWhitespace:
                Value       = xmlReader.Value;
                RawOuterXml = xmlReader.Value;
                break;

            case XmlNodeType.Whitespace:
                break;     // O15:#3024890, OpenXmlMiscNode ignores the Whitespace NodeType.

            case XmlNodeType.ProcessingInstruction:
                Value       = xmlReader.Value;
                RawOuterXml = Invariant($"<?{xmlReader.Name} {xmlReader.Value}?>");
                break;

            case XmlNodeType.Comment:
                Value       = xmlReader.Value;
                RawOuterXml = Invariant($"<!--{xmlReader.Value}-->");
                break;

            case XmlNodeType.Document:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.Document);
                break;

            case XmlNodeType.DocumentType:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.DocumentType);
                break;

            case XmlNodeType.EntityReference:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.EntityReference);
                RawOuterXml = xmlReader.Name;
                break;

            case XmlNodeType.Entity:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.Entity);
                break;

            case XmlNodeType.DocumentFragment:
            case XmlNodeType.EndEntity:
            default:
                Debug.Assert(false, xmlReader.NodeType.ToString());
                break;
            }
        }
示例#40
0
        public static List <XmlReadInstructions> AnalyseXmlReader(System.Xml.XmlReader reader, bool globalUniqueColumnNames)
        {
            var root    = new Node();
            var current = root;

            var resultSets = new Dictionary <string, Node>();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    current = current.SubElement(reader.Name);
                    if (reader.HasAttributes)
                    {
                        reader.MoveToFirstAttribute();
                        do
                        {
                            current.Attribute(reader.Name);
                        } while (reader.MoveToNextAttribute());
                        reader.MoveToElement();
                    }
                    if (current.CurrentCount > 1)
                    {
                        string xpath = current.AbsXPath;
                        if (!resultSets.ContainsKey(xpath))
                        {
                            resultSets[xpath]    = current;
                            current.IsRepetetive = true;
                        }
                    }
                    if (reader.IsEmptyElement)
                    {
                        current = current.Parent;
                    }
                    break;

                case XmlNodeType.Text:
                    if (!String.IsNullOrWhiteSpace(reader.Value))
                    {
                        current.HasText = true;
                    }
                    break;

                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.ProcessingInstruction:
                case XmlNodeType.Comment:
                    continue;

                case XmlNodeType.EndElement:
                    current = current.Parent;
                    break;
                }
            }

            // remove repetetive parents. Remains only innermost repetetives
            foreach (var resultSet in resultSets.Values.ToList())
            {
                var node = resultSet;
                node = node.Parent;
                while (node != null && !node.IsRepetetive)
                {
                    node = node.Parent;
                }
                if (node != null)
                {
                    resultSets.Remove(node.AbsXPath);
                    node.IsRepetetive = false;
                }
            }

            if (!resultSets.Any())
            {
                resultSets["/"] = root;
            }

            var res             = new List <XmlReadInstructions>();
            var addedColumns    = new HashSet <string>();
            var collectionNames = new HashSet <string>();

            foreach (var resultSet in resultSets.Values)
            {
                var instruction = new XmlReadInstructions();
                instruction.XPath = resultSet.AbsXPath ?? "/";

                string collectionName = resultSet.Name;
                if (collectionNames.Contains(collectionName))
                {
                    int index = 2;
                    while (collectionNames.Contains(collectionName + index))
                    {
                        index++;
                    }
                    collectionName = collectionName + index;
                }
                instruction.CollectionName = collectionName;

                if (!globalUniqueColumnNames)
                {
                    addedColumns.Clear();
                }

                CollectColumns(instruction, root, addedColumns, resultSet);
                if (resultSet != root)
                {
                    CollectColumns(instruction, resultSet, addedColumns, resultSet);
                }

                res.Add(instruction);
            }

            return(res);
        }
示例#41
0
 void IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     throw new System.NotImplementedException();
 }
        private void LoadAttributes(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "name":
                    Description = reader.Value;
                    break;

                case "place_id":
                    PlaceId = reader.Value;
                    break;

                case "place_url":
                    PlaceUrl = reader.Value;
                    break;

                case "place_type_id":
                    PlaceType = (PlaceType)reader.ReadContentAsInt();
                    break;

                case "place_type":
                    PlaceType = (PlaceType)Enum.Parse(typeof(PlaceType), reader.Value, true);
                    break;

                case "woeid":
                    WoeId = reader.Value;
                    break;

                case "woe_name":
                    WoeName = reader.Value;
                    break;

                case "latitude":
                    Latitude = reader.ReadContentAsDouble();
                    break;

                case "longitude":
                    Longitude = reader.ReadContentAsDouble();
                    break;

                case "accuracy":
                    Accuracy = (GeoAccuracy)reader.ReadContentAsInt();
                    break;

                case "context":
                    Context = (GeoContext)reader.ReadContentAsInt();
                    break;

                case "timezone":
                    TimeZone = reader.Value;
                    break;

                case "has_shapedata":
                    HasShapeData = reader.Value == "1";
                    break;

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

            reader.Read();
        }
示例#43
0
 /// <summary>
 /// Read xml
 /// </summary>
 /// <param name="reader">Reader</param>
 public void ReadXml(System.Xml.XmlReader reader)
 {
     value = reader.ReadElementString();
 }
示例#44
0
 private static ComplexValue InnerDeserialize(Context context, System.Xml.XmlReader reader)
 {
     return(new ComplexValue(double.Parse(reader.ReadElementString("Real"), Context.NumberFormat),
                             double.Parse(reader.ReadElementString("Imag"), Context.NumberFormat)));
 }
示例#45
0
 internal WorkflowMarkupElementEventArgs(System.Xml.XmlReader reader)
 {
     this.reader = reader;
 }
示例#46
0
    public IEnumerable <GameSaveDescriptor> GetListOfGameSaveDescritors(bool withAutoSave)
    {
        string path = global::Application.GameSaveDirectory;

        if (string.IsNullOrEmpty(path))
        {
            yield break;
        }
        if (!Directory.Exists(path))
        {
            yield break;
        }
        ISerializationService serializationService = Services.GetService <ISerializationService>();

        if (serializationService == null)
        {
            yield break;
        }
        XmlSerializer   serializer      = serializationService.GetXmlSerializer <GameSaveDescriptor>();
        DirectoryInfo   directory       = new DirectoryInfo(path);
        List <FileInfo> compatibleFiles = new List <FileInfo>();

        compatibleFiles.AddRange(directory.GetFiles("*.zip"));
        compatibleFiles.AddRange(directory.GetFiles("*.sav"));
        FileInfo[] files = (from f in compatibleFiles
                            orderby f.LastWriteTime descending
                            select f).ToArray <FileInfo>();
        Archive            archive            = null;
        GameSaveDescriptor gameSaveDescriptor = null;
        XmlReaderSettings  xmlReaderSettings  = new XmlReaderSettings
        {
            CloseInput     = true,
            IgnoreComments = true,
            IgnoreProcessingInstructions = true,
            IgnoreWhitespace             = true
        };

        for (int i = 0; i < files.Length; i++)
        {
            gameSaveDescriptor = null;
            string fileName = files[i].FullName;
            try
            {
                archive = Archive.Open(fileName, ArchiveMode.Open);
                MemoryStream stream = null;
                if (archive.TryGet(global::GameManager.GameSaveDescriptorFileName, out stream))
                {
                    using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(stream, xmlReaderSettings))
                    {
                        if (reader.ReadToDescendant("GameSaveDescriptor"))
                        {
                            gameSaveDescriptor = (serializer.Deserialize(reader) as GameSaveDescriptor);
                            gameSaveDescriptor.SourceFileName = fileName;
                            if (gameSaveDescriptor.Version.Serial != Amplitude.Unity.Framework.Application.Version.Serial)
                            {
                                gameSaveDescriptor = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Exception exception = ex;
                Diagnostics.LogWarning("Exception caught: " + exception.ToString());
                gameSaveDescriptor = null;
            }
            finally
            {
                if (archive != null)
                {
                    archive.Close();
                }
            }
            if (gameSaveDescriptor != null && gameSaveDescriptor.Closed)
            {
                gameSaveDescriptor = null;
            }
            if (gameSaveDescriptor != null && (withAutoSave || !gameSaveDescriptor.Title.StartsWith(global::GameManager.AutoSaveFileName)))
            {
                yield return(gameSaveDescriptor);
            }
        }
        yield break;
    }
示例#47
0
 protected override bool OnDeserializeUnrecognizedElement(string elementName, System.Xml.XmlReader reader)
 {
     return(base.OnDeserializeUnrecognizedElement(elementName, reader));
 }
示例#48
0
 protected override System.IdentityModel.Tokens.SecurityToken ReadTokenCore(System.Xml.XmlReader reader, SecurityTokenResolver tokenResolver)
 {
     throw new NotImplementedException();
 }
示例#49
0
 protected override bool CanReadTokenCore(System.Xml.XmlReader reader)
 {
     throw new NotImplementedException();
 }
示例#50
0
    public GameSaveDescriptor GetMostRecentGameSaveDescritor()
    {
        string gameSaveDirectory = global::Application.GameSaveDirectory;

        if (string.IsNullOrEmpty(gameSaveDirectory))
        {
            return(null);
        }
        if (!Directory.Exists(gameSaveDirectory))
        {
            return(null);
        }
        ISerializationService service = Services.GetService <ISerializationService>();

        if (service == null)
        {
            return(null);
        }
        List <string>   list     = null;
        IRuntimeService service2 = Services.GetService <IRuntimeService>();

        if (service2 != null)
        {
            Diagnostics.Assert(service2.Runtime != null);
            Diagnostics.Assert(service2.Runtime.RuntimeModules != null);
            list = (from runtimeModule in service2.Runtime.RuntimeModules
                    select runtimeModule.Name).ToList <string>();
        }
        DirectoryInfo   directoryInfo = new DirectoryInfo(gameSaveDirectory);
        List <FileInfo> list2         = new List <FileInfo>();

        list2.AddRange(directoryInfo.GetFiles("*.zip"));
        list2.AddRange(directoryInfo.GetFiles("*.sav"));
        FileInfo[] array = (from f in list2
                            orderby f.LastWriteTime descending
                            select f).ToArray <FileInfo>();
        GameSaveDescriptor gameSaveDescriptor = null;

        if (array != null)
        {
            foreach (FileInfo fileInfo in array)
            {
                Archive archive = null;
                try
                {
                    archive = Archive.Open(fileInfo.FullName, ArchiveMode.Open);
                    MemoryStream stream = null;
                    if (archive.TryGet(global::GameManager.GameSaveDescriptorFileName, out stream))
                    {
                        XmlReaderSettings settings = new XmlReaderSettings
                        {
                            CloseInput     = true,
                            IgnoreComments = true,
                            IgnoreProcessingInstructions = true,
                            IgnoreWhitespace             = true
                        };
                        using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(stream, settings))
                        {
                            if (xmlReader.ReadToDescendant("GameSaveDescriptor"))
                            {
                                XmlSerializer xmlSerializer = service.GetXmlSerializer <GameSaveDescriptor>();
                                gameSaveDescriptor = (xmlSerializer.Deserialize(xmlReader) as GameSaveDescriptor);
                                gameSaveDescriptor.SourceFileName = fileInfo.FullName;
                                if (gameSaveDescriptor.Version.Serial != Amplitude.Unity.Framework.Application.Version.Serial)
                                {
                                    gameSaveDescriptor = null;
                                }
                                if (gameSaveDescriptor != null)
                                {
                                    if (gameSaveDescriptor.RuntimeModules == null)
                                    {
                                        if (service2 != null)
                                        {
                                            if (list.Count != 1 || !(list[0] == service2.VanillaModuleName))
                                            {
                                                gameSaveDescriptor = null;
                                            }
                                        }
                                        else
                                        {
                                            gameSaveDescriptor = null;
                                        }
                                    }
                                    else
                                    {
                                        List <string> list3 = list.Except(gameSaveDescriptor.RuntimeModules).ToList <string>();
                                        List <string> list4 = gameSaveDescriptor.RuntimeModules.Except(list).ToList <string>();
                                        if (list3.Count + list4.Count != 0)
                                        {
                                            gameSaveDescriptor = null;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Diagnostics.LogWarning("Exception caught: " + ex.ToString());
                    gameSaveDescriptor = null;
                }
                finally
                {
                    if (archive != null)
                    {
                        archive.Close();
                    }
                }
                if (gameSaveDescriptor != null)
                {
                    break;
                }
            }
        }
        return(gameSaveDescriptor);
    }
 public override void Load(System.Xml.XmlReader xmlReader)
 {
     base.Load(xmlReader);
 }
示例#52
0
 protected override System.IdentityModel.Tokens.SecurityKeyIdentifierClause ReadKeyIdentifierClauseCore(System.Xml.XmlReader reader)
 {
     throw new NotImplementedException();
 }
示例#53
0
 private static LiteralValue InnerDeserialize(Context context, System.Xml.XmlReader reader)
 {
     return(new LiteralValue(reader.ReadString()));
 }
示例#54
0
 protected override bool CanReadKeyIdentifierCore(System.Xml.XmlReader reader)
 {
     throw new NotImplementedException();
 }
示例#55
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     XmlDictionaryReader xmlReader = XmlDictionaryReader.CreateDictionaryReader(reader);
     string data = xmlReader.ReadString();
 }
        public override SMSCommunicationHistoryCBE SendSMS(SMSCommunicationHistoryCBE sms)
        {
            LogMessage("Using Mobiduite SMS gateway for sending message.");
            #region Variables
            string createdURL   = "";
            string mobileNumber = sms.MobileNumber;
            string messageBody  = sms.MessageBody;

            string userName = "******";
            string password = "******";
            string sender   = "IMS";
            string dr_url   = "http://103.119.145.130:5555/VaaaN/IndonesiaMLFFApi/ResponseSMS";
            // Andrew Tan mobile number 082246492815 (Indonesia)

            #endregion

            #region Send SMS to Mobile phone
            try
            {
                sms.ReferenceNo = Constants.SMSTranscationId(sms.EntryId);
                LogMessage("Trying to send message to customer mobile number. Mobile No.:" + mobileNumber);
                createdURL = "http://webapps.imitra.com:29003/sms_applications/smsb/api_mt_send_message.php?";
                string data = "data=<bulk_sending>" +
                              "<username>" + userName + "</username>" +
                              "<password>" + password + "</password>" +
                              "<priority>high</priority>" +
                              "<sender>" + sender + "</sender>" +
                              "<dr_url>" + dr_url + "</dr_url>" +
                              "<allowduplicate>1</allowduplicate>" +
                              "<data_packet>" +
                              "<packet>" +
                              "<msisdn>" + mobileNumber + "</msisdn>" +
                              "<sms>" + messageBody + "</sms>" +
                              "<is_long_sms>N</is_long_sms>" +
                              "</packet>" +
                              "</data_packet>" +
                              "</bulk_sending>";

                // Create request
                HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);
                myReq.Method      = "POST";
                myReq.ContentType = "application/x-www-form-urlencoded";//important

                // Send data with request
                byte[] bytes = Encoding.UTF8.GetBytes(data);
                myReq.ContentLength = bytes.Length;

                using (Stream putStream = myReq.GetRequestStream())
                {
                    putStream.Write(bytes, 0, bytes.Length);
                }

                // Get response from the SMS Gateway Server and read the answer
                HttpWebResponse        myResp           = (HttpWebResponse)myReq.GetResponse();
                System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
                string responseString = respStreamReader.ReadToEnd();
                respStreamReader.Close();
                myResp.Close();

                // Check response value
                System.IO.MemoryStream ms     = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseString));
                System.Xml.XmlReader   reader = System.Xml.XmlReader.Create(ms);

                string statusCode = "";

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name == "status_code")
                        {
                            reader.Read();
                            statusCode = Convert.ToString(reader.Value);
                            try
                            {
                                sms.ResponseCode = Convert.ToInt32(statusCode);
                                LogMessage("Response status code is " + statusCode + ".");
                            }
                            catch (Exception ex)
                            {
                                LogMessage("error in convert status code is " + statusCode + ".");
                            }
                        }
                        if (reader.Name == "transaction_id")
                        {
                            reader.Read();
                            sms.TransactionId = Convert.ToString(reader.Value);
                            LogMessage("Response transactionId is " + sms.TransactionId + ".");
                        }
                    }
                }

                if (statusCode == "2200")
                {
                    sms.SentStatus = (int)VaaaN.MLFF.Libraries.CommonLibrary.Constants.SMSSentStatus.Sent;
                }

                sms.GatewayResponse = responseString;

                LogMessage("Response:" + responseString);
                LogMessage("Message sent successfully to mobile.");
            }
            catch (Exception ex)
            {
                //if sending request or getting response is not successful the SMS Gateway Server may do not run
                LogMessage("Failed to send message to customer." + ex.Message);
            }
            #endregion

            return(sms);
        }
示例#57
0
 private Ingestion DeserializeEntityTypes(System.Xml.XmlReader reader)
 {
     return(DeserializeEntityTypes(XElement.Parse(reader.ReadOuterXml())));
 }
        public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToContent();
            reader.ReadStartElement();

            Name     = reader.ReadElementString("Name", "");
            MyEffect = ResourceManager.Instance.LoadEffect(reader.ReadElementString("EffectPath", ""));

            uint      normColor  = 0xFFFF0F0F;
            uint      blackColor = 0xFF000000;
            Texture2D defDiff    = null;

            if (!ResourceManager.Instance.Textures.TryGetValue("DefaultDiffuse", out defDiff))
            {
                defDiff = new Texture2D(TrashSoupGame.Instance.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                defDiff.SetData <uint>(new uint[] { blackColor });
                ResourceManager.Instance.Textures.Add("DefaultDiffuse", defDiff);
            }
            Texture2D defNrm = null;

            if (!ResourceManager.Instance.Textures.TryGetValue("DefaultNormal", out defNrm))
            {
                defNrm = new Texture2D(TrashSoupGame.Instance.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                defNrm.SetData <uint>(new uint[] { normColor });
                ResourceManager.Instance.Textures.Add("DefaultNormal", defNrm);
            }
            TextureCube defCbc = null;

            if (!ResourceManager.Instance.TexturesCube.TryGetValue("DefaultCube", out defCbc))
            {
                defCbc = new TextureCube(TrashSoupGame.Instance.GraphicsDevice, 1, false, SurfaceFormat.Color);
                defCbc.SetData <uint>(CubeMapFace.NegativeX, new uint[] { blackColor });
                defCbc.SetData <uint>(CubeMapFace.PositiveX, new uint[] { blackColor });
                defCbc.SetData <uint>(CubeMapFace.NegativeY, new uint[] { blackColor });
                defCbc.SetData <uint>(CubeMapFace.PositiveY, new uint[] { blackColor });
                defCbc.SetData <uint>(CubeMapFace.NegativeZ, new uint[] { blackColor });
                defCbc.SetData <uint>(CubeMapFace.PositiveZ, new uint[] { blackColor });
                ResourceManager.Instance.TexturesCube.Add("DefaultCube", defCbc);
            }

            DiffuseMap = ResourceManager.Instance.LoadTexture(reader.ReadElementString("DiffusePath", ""));
            if (reader.Name == "NormalPath")
            {
                NormalMap = ResourceManager.Instance.LoadTexture(reader.ReadElementString("NormalPath", ""));
            }
            if (reader.Name == "CubePath")
            {
                CubeMap = ResourceManager.Instance.LoadTextureCube(reader.ReadElementString("CubePath", ""));
            }

            reader.ReadStartElement("DiffuseColor");
            DiffuseColor = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                       reader.ReadElementContentAsFloat("Y", ""),
                                       reader.ReadElementContentAsFloat("Z", ""));
            reader.ReadEndElement();

            reader.ReadStartElement("SpecularColor");
            SpecularColor = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                        reader.ReadElementContentAsFloat("Y", ""),
                                        reader.ReadElementContentAsFloat("Z", ""));
            reader.ReadEndElement();

            Glossiness = reader.ReadElementContentAsFloat("Glossiness", "");

            reader.ReadStartElement("ReflectivityColor");
            ReflectivityColor = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                            reader.ReadElementContentAsFloat("Y", ""),
                                            reader.ReadElementContentAsFloat("Z", ""));
            reader.ReadEndElement();

            ReflectivityBias = reader.ReadElementContentAsFloat("ReflectivityBias", "");
            Transparency     = reader.ReadElementContentAsFloat("Transparency", "");
            PerPixelLighting = reader.ReadElementContentAsBoolean("PerPixelLighting", "");
            RecieveShadows   = reader.ReadElementContentAsBoolean("ReceiveShadows", "");
            Unlit            = reader.ReadElementContentAsBoolean("Unlit", "");

            AssignParamsInitialize();

            if (this.GetType() == typeof(Material))
            {
                reader.ReadEndElement();
            }
        }
        /// <summary>
        /// Load the out xml from the XmlReader.
        /// </summary>
        /// <param name="xmlReader"></param>
        /// <remarks>The XmlReader not be moved.</remarks>
        internal void LoadOuterXml(System.Xml.XmlReader xmlReader)
        {
            switch (xmlReader.NodeType)
            {
            case XmlNodeType.None:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.None);
                break;

            case XmlNodeType.XmlDeclaration:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.XmlDeclaration);
                // this.RawOuterXml = String.Format("<?xml version='1.0'?>");
                this.Value = xmlReader.Value;     // version='1.0'
                break;

            case XmlNodeType.Element:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.Element);
                break;

            case XmlNodeType.EndElement:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.EndElement);
                break;

            case XmlNodeType.Notation:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.Notation);
                break;

            case XmlNodeType.Attribute:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.Attribute);
                break;

            case XmlNodeType.Text:
                this.Value       = xmlReader.Value;
                this.RawOuterXml = xmlReader.Value;
                break;

            case XmlNodeType.CDATA:
                this.Value       = xmlReader.Value;
                this.RawOuterXml = String.Format(CultureInfo.InvariantCulture, "<![CDATA[{0}]]>", xmlReader.Value);
                break;

            case XmlNodeType.SignificantWhitespace:
                this.Value       = xmlReader.Value;
                this.RawOuterXml = xmlReader.Value;
                break;

            case XmlNodeType.Whitespace:
                break;     // O15:#3024890, OpenXmlMiscNode ignores the Whitespace NodeType.

            case XmlNodeType.ProcessingInstruction:
                this.Value       = xmlReader.Value;
                this.RawOuterXml = String.Format(CultureInfo.InvariantCulture, "<?{0} {1}?>", xmlReader.Name, xmlReader.Value);
                break;

            case XmlNodeType.Comment:
                this.Value       = xmlReader.Value;
                this.RawOuterXml = String.Format(CultureInfo.InvariantCulture, "<!--{0}-->", xmlReader.Value);
                break;

            case XmlNodeType.Document:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.Document);
                break;

            case XmlNodeType.DocumentType:
                // this.RawOuterXml = String.Format(CultureInfo.InvariantCulture, "<!DOCTYPE {0} [{1}]", xmlReader.Name, xmlReader.Value);
                Debug.Assert(xmlReader.NodeType != XmlNodeType.DocumentType);
                break;

            case XmlNodeType.EntityReference:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.EntityReference);
                this.RawOuterXml = xmlReader.Name;
                break;

            case XmlNodeType.Entity:
                Debug.Assert(xmlReader.NodeType != XmlNodeType.Entity);
                break;

            case XmlNodeType.DocumentFragment:
            case XmlNodeType.EndEntity:
            default:
                Debug.Assert(false, xmlReader.NodeType.ToString());
                break;
            }
        }
示例#60
0
        public override int Read(System.Xml.XmlReader reader)
        {
            int sequence = 0;

            while (reader.Read())
            {
                if ((reader.NodeType == XmlNodeType.Comment) ||
                    (reader.NodeType == XmlNodeType.Whitespace))
                {
                    continue;
                }

                if (sequence == 0)
                {
                    if ((string.Compare(reader.Name, _InnerName) != 0) ||
                        (reader.NodeType != XmlNodeType.Element) ||
                        (reader.IsEmptyElement))
                    {
                        if (string.Compare(_InnerName, "seriesAuthor") == 0)
                        {
                            if ((string.Compare(reader.Name, Name) == 0) &&
                                (reader.NodeType == XmlNodeType.EndElement))
                            {
                                _InnerName = null;

                                return(0);
                            }

                            int ret = aECGElement.ReadOne(this, reader);

                            if (ret != 0)
                            {
                                return((ret > 0) ? 2 + ret : ret);
                            }

                            continue;
                        }
                        else
                        {
                            return(1);
                        }
                    }

                    sequence++;
                }
                else if (sequence == 1)
                {
                    int ret = aECGElement.ReadOne(this, reader);

                    if (ret != 0)
                    {
                        return((ret > 0) ? 2 + ret : ret);
                    }

                    if ((string.Compare(reader.Name, _InnerName) == 0) &&
                        (reader.NodeType == XmlNodeType.EndElement))
                    {
                        sequence++;
                    }
                }
                else
                {
                    if ((string.Compare(reader.Name, Name) != 0) ||
                        (reader.NodeType != XmlNodeType.EndElement) ||
                        reader.IsEmptyElement)
                    {
                        return(2);
                    }

                    return(0);
                }
            }

            return(-1);
        }