Пример #1
0
        internal static XmlOnlineRecord Deserialize( XmlReader xmlReader, Version version )
        {
            if( xmlReader.NodeType != XmlNodeType.Element
                || xmlReader.Name != ElementName )
                throw new ApplicationException( "Needs an OnlineTransaction node to deserialize an online transaction object." );

            XmlOnlineRecord otrans = new XmlOnlineRecord();

            if( xmlReader.GetAttribute( "id" ) != null )
                otrans.Id = int.Parse( xmlReader.GetAttribute( "id" ) );
            if( xmlReader.GetAttribute( "lineItemId" ) != null )
                otrans.LineItemId = int.Parse( xmlReader.GetAttribute( "lineItemId" ) );
            if( xmlReader.GetAttribute( "source" ) != null )
                otrans.OnlineSource = xmlReader.GetAttribute( "source" );

            while( xmlReader.Read() )
            {
                switch( xmlReader.NodeType )
                {
                    case XmlNodeType.Element:
                        switch( xmlReader.Name.ToLower() )
                        {
                            case "source":
                                otrans.OnlineSource = xmlReader.ReadString();
                                break;
                            case "id":
                                otrans.Id = Int32.Parse( xmlReader.ReadString() );
                                break;
                            case "bankid":
                                otrans.BankId = xmlReader.ReadString();
                                break;
                            case "number":
                                otrans.Number = xmlReader.ReadString();
                                break;
                            case "date":
                                otrans.Date = DateTime.Parse( xmlReader.ReadString() );
                                break;
                            case "sequence":
                                otrans.Sequence = int.Parse( xmlReader.ReadString() );
                                break;
                            case "description":
                                otrans.Description = xmlReader.ReadString();
                                break;
                            case "amount":
                                otrans.Amount = Decimal.Parse( xmlReader.ReadString() );
                                break;
                            default:
                                break;
                        }
                        break;
                    case XmlNodeType.EndElement:
                        if( xmlReader.Name == ElementName )
                            return otrans;
                        break;
                }
            }

            return otrans;
        }
Пример #2
0
 public override void SetOnlineRecord( IOnlineRecord otrans )
 {
     if( otrans == null )
     {
         this.onlineRecord = null;
         this.OnlineRecordId = null;
         return;
     }
     if( !(otrans is XmlOnlineRecord) )
         throw new ArgumentOutOfRangeException( "Must be an XmlOnlineRecord" );
     this.OnlineRecordId = otrans.Id;
     this.onlineRecord = (XmlOnlineRecord)otrans;
 }
Пример #3
0
 /// <summary>Create a new OnlineRecord object.</summary>
 public IOnlineRecord NewOnlineRecord()
 {
     XmlOnlineRecord otrans = new XmlOnlineRecord();
     otrans.Id = this.nextOnlineRecordId++;
     this.records.Add( otrans.Id, otrans );
     return otrans;
 }