ReadXml() public method

public ReadXml ( System reader, Type payloadType ) : void
reader System
payloadType System.Type
return void
        public void DoWork(IRequest request)
        {
            // If an asyncState object already exists, an exception is thrown as the performer only accepts
            // one call after each other. The Request receiver has to manage a queued execution.

            // Before calling the performers execution implementation method a new AsyncState object is created
            // and set to an initial tracking state.

            lock (_asyncStateObj)
            {
                if (null != _asyncStateObj.Tracking)
                    throw new InvalidOperationException("The performer cannot be executed because it is already running.");

                SyncTracking tracking = new SyncTracking();
                tracking.ElapsedSeconds = 1;
                tracking.Phase = TrackingPhase.INIT;
                tracking.PhaseDetail = "Tracking Id was: " + _requestContext.TrackingId.ToString();
                tracking.PollingMillis = 100;
                tracking.RemainingSeconds = 100;

                _asyncStateObj.Tracking = tracking;
            }

            // *** Initialization for the async execution ***
            // - Read Feed from request stream.
            // - Read trackingId from request URL

            // convert tracking ID from request to type Guid
            string strTrackingId = request.Uri.TrackingID;
            if (String.IsNullOrEmpty(strTrackingId))
                throw new RequestException("TrackingId is missing");

            GuidConverter converter = new GuidConverter();
            this.TrackingId = (Guid)converter.ConvertFrom(strTrackingId);

            //read feed
            SyncFeed feed = new SyncFeed();
            XmlReader reader = XmlReader.Create(request.Stream);
            feed.ReadXml(reader, ResourceKindHelpers.GetPayloadType(_requestContext.ResourceKind));

            // *** Do work asynchronously ***
            _asyncPerformer = new InternalAsyncPerformer(this);
            _asyncPerformer.DoWork(_requestContext.Config, feed);

            // *** set the tracking to the request response ***
            this.GetTrackingState(request);
        }
        public void DoWork(IRequest request)
        {
            if (request.ContentType != Sage.Common.Syndication.MediaType.Atom)
                throw new RequestException("Atom content type expected");

            //read feed
            string resourceKindName = _requestContext.ResourceKind.ToString();
            SyncFeed feed = new SyncFeed();
            XmlReader reader = XmlReader.Create(request.Stream);
            feed.ReadXml(reader, ResourceKindHelpers.GetPayloadType(_requestContext.ResourceKind));

            /* iterate through all entries and store result information */
            ISyncResultInfoStore syncResultInfoStore = RequestReceiver.NorthwindAdapter.StoreLocator.GetSyncResultStore(_requestContext.SdataContext);

            int noOfEntries = feed.Entries.Count;
            string endpoint = string.Empty;
            try
            {
                endpoint = new RequestContext(new Sage.Common.Syndication.SDataUri(feed.Id)).OriginEndPoint;
            }
            catch { }

            SyncResultEntryInfo[] syncResultEntries = new SyncResultEntryInfo[noOfEntries];
            for (int i = 0; i < noOfEntries; i++)
            {
                SyncFeedEntry entry = (SyncFeedEntry)feed.Entries[i];
                string httpMethod = entry.HttpMethod;
                int httpStatus = -1;
                if (Enum.IsDefined(typeof(HttpStatusCode), entry.HttpStatusCode.ToString()))
                    httpStatus = (int)Enum.Parse(typeof(HttpStatusCode), entry.HttpStatusCode.ToString(), true);
                string httpLocation = entry.HttpLocation;
                string httpMessage = entry.HttpMessage;
                string diagnosisXml = XmlSerializationHelpers.SerializeObjectToXml(entry.Diagnoses);
                string payloadXml = XmlSerializationHelpers.SerializeObjectToXml(entry.Payload);

                syncResultEntries[i] = new SyncResultEntryInfo(httpMethod, httpStatus, httpLocation, httpMessage, diagnosisXml, payloadXml, DateTime.Now, endpoint);
            }

            syncResultInfoStore.Add(resourceKindName, syncResultEntries);
        }