///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>standard empty constructor</summary> ////////////////////////////////////////////////////////////////////// public AtomFeedParser(IVersionAware v) : base() { //Tracing.TraceCall("constructing AtomFeedParser"); this.nameTable = new AtomParserNameTable(); this.nameTable.InitAtomParserNameTable(); this.versionInfo = new VersionInformation(v); }
/// <summary>standard constructor</summary> public AtomFeedParser(IVersionAware v) : base() { Tracing.TraceCall("constructing AtomFeedParser"); this.nameTable = new AtomParserNameTable(); this.nameTable.InitAtomParserNameTable(); this.versionInfo = new VersionInformation(v); }
/// <summary> /// retrieves the resumable URI for the rest of the operation. This will initiate the /// communication with resumable upload server by posting against the starting URI /// </summary> /// <param name="resumableUploadUri"></param> /// <param name="authentication"></param> /// <param name="entry"></param> /// <returns>The uri to be used for the rest of the operation</returns> public Uri InitiateUpload(Uri resumableUploadUri, Authenticator authentication, AbstractEntry entry) { HttpWebRequest request = PrepareRequest(resumableUploadUri, authentication, entry.MediaSource.Name, entry.MediaSource.ContentType, entry.MediaSource.ContentLength); IVersionAware v = entry as IVersionAware; if (v != null) { // need to add the version header to the request request.Headers.Add(GDataGAuthRequestFactory.GDataVersion, v.ProtocolMajor.ToString() + "." + v.ProtocolMinor.ToString()); } ISupportsEtag e = entry as ISupportsEtag; if (e != null && Utilities.IsWeakETag(e) == false) { request.Headers.Add(GDataRequestFactory.IfMatch, e.Etag); } Stream outputStream = request.GetRequestStream(); entry.SaveToXml(outputStream); outputStream.Close(); /// this is the contenttype for the xml post request.ContentType = GDataRequestFactory.DefaultContentType; WebResponse response = request.GetResponse(); return(new Uri(response.Headers["Location"])); }
private void PropagateVersionInfo() { IVersionAware v = this.factory as IVersionAware; if (v != null) { v.ProtocolMajor = this.ProtocolMajor; v.ProtocolMinor = this.ProtocolMinor; } return; }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>Event chaining. We catch this by the baseFeedParsers, which /// would not do anything with the gathered data. We pass the event up /// to the user; if the user doesn't discard it, we add the entry to our /// collection</summary> /// <param name="sender"> the object which send the event</param> /// <param name="e">FeedParserEventArguments, holds the feed entry</param> /// <returns> </returns> ////////////////////////////////////////////////////////////////////// protected void OnParsedNewEntry(object sender, FeedParserEventArgs e) { // by default, if our event chain is not hooked, add it to the collection Tracing.TraceCall("received new item notification"); Tracing.Assert(e != null, "e should not be null"); if (e == null) { throw new ArgumentNullException("e"); } if (NewAtomEntry != null) { Tracing.TraceMsg("\t calling event dispatcher"); NewAtomEntry(this, e); } // now check the return if (!e.DiscardEntry) { if (!e.CreatingEntry) { if (e.Entry != null) { // add it to the collection Tracing.TraceMsg("\t new AtomEntry found, adding to collection"); e.Entry.Service = Service; Entries.Add(e.Entry); } else if (e.Feed != null) { // parsed a feed, set ourselves to it... Tracing.TraceMsg("\t Feed parsed found, parsing is done..."); } } else { IVersionAware v = e.Entry as IVersionAware; if (v != null) { v.ProtocolMajor = ProtocolMajor; v.ProtocolMinor = ProtocolMinor; } } } if (e.DoneParsing) { BaseUriChanged(ImpliedBase); } }
/// <summary>sets the redirect to false after everything else /// is done </summary> protected override void EnsureWebRequest() { base.EnsureWebRequest(); HttpWebRequest http = this.Request as HttpWebRequest; if (http != null) { http.Headers.Remove(GDataGAuthRequestFactory.GDataVersion); // as we are doublebuffering due to redirect issues anyhow, // disallow the default buffering http.AllowWriteStreamBuffering = false; IVersionAware v = this.factory as IVersionAware; if (v != null) { // need to add the version header to the request http.Headers.Set(GDataGAuthRequestFactory.GDataVersion, v.ProtocolMajor.ToString() + "." + v.ProtocolMinor.ToString()); } // we do not want this to autoredirect, our security header will be // lost in that case http.AllowAutoRedirect = false; if (this.factory.MethodOverride && http.Method != HttpMethods.Get && http.Method != HttpMethods.Post) { // remove it, if it is already there. http.Headers.Remove(GoogleAuthentication.Override); // cache the method, because Mono will complain if we try // to open the request stream with a DELETE method. string currentMethod = http.Method; http.Headers.Set(GoogleAuthentication.Override, currentMethod); http.Method = HttpMethods.Post; // not put and delete, all is post if (currentMethod == HttpMethods.Delete) { http.ContentLength = 0; // .NET CF won't send the ContentLength parameter if no stream // was opened. So open a dummy one, and close it right after. Stream req = http.GetRequestStream(); req.Close(); } } } }
/// <summary> /// takes an object and set's the version number to the /// same as this instance /// </summary> /// <param name="arr">The array of objects the version should be applied to</param> public void ImprintVersion(ExtensionList arr) { if (arr == null) { return; } foreach (Object o in arr) { IVersionAware v = o as IVersionAware; if (v != null) { ImprintVersion(v); } } }
/// <summary> /// returns the correct app:publishing namespace to use based /// on the version information passed in. All protocols with /// version > 1 use the final version of the namespace, where /// version 1 uses the draft version. /// </summary> /// <param name="v">The versioninformation</param> /// <returns></returns> public static string AppPublishingNamespace(IVersionAware v) { int major = VersionDefaults.Major; if (v != null) { major = v.ProtocolMajor; } if (major == 1) { return(BaseNameTable.NSAppPublishing); } return(BaseNameTable.NSAppPublishingFinal); }
/// <summary> /// returns the correct opensearchnamespace to use based /// on the version information passed in. All protocols with /// version > 1 use opensearch1.1 where version 1 uses /// opensearch 1.0 /// </summary> /// <param name="v">The versioninformation</param> /// <returns></returns> public static string OpenSearchNamespace(IVersionAware v) { int major = VersionDefaults.Major; if (v != null) { major = v.ProtocolMajor; } if (major == 1) { return(BaseNameTable.NSOpenSearchRss); } return(BaseNameTable.NSOpenSearch11); }
/// <summary> /// adds value to the extensionlist. /// </summary> /// <param name="value"></param> /// <returns>returns the positin in the list after the add</returns> public int Add(IExtensionElementFactory value) { IVersionAware target = value as IVersionAware; if (target != null) { target.ProtocolMajor = this.container.ProtocolMajor; target.ProtocolMinor = this.container.ProtocolMinor; } if (value != null) { _list.Add(value); } return(_list.Count - 1); //return _list.IndexOf(value); }
/// <summary> /// takes an object and set's the version number to the /// same as this instance /// </summary> /// <param name="v"></param> public void ImprintVersion(IVersionAware v) { v.ProtocolMajor = this.majorVersion; v.ProtocolMinor = this.minorVersion; }
/// <summary>Constructor.</summary> /// <param name="v">the versioninformation to pass </param> internal ChangeVersion(IVersionAware v) { this.v = new VersionInformation(v); }
/// <summary> /// construct a versioninformation object based /// on a versionaware object /// </summary> /// <param name="v">the versioned object to copy the data from</param> /// <returns></returns> public VersionInformation(IVersionAware v) { this.majorVersion = v.ProtocolMajor; this.minorVersion = v.ProtocolMinor; }
/// <summary> /// returns the correct app:publishing namespace to use based /// on the version information passed in. All protocols with /// version > 1 use the final version of the namespace, where /// version 1 uses the draft version. /// </summary> /// <param name="v">The versioninformation</param> /// <returns></returns> public static string AppPublishingNamespace(IVersionAware v) { int major = VersionDefaults.Major; if (v != null) major = v.ProtocolMajor; if (major == 1) return BaseNameTable.NSAppPublishing; return BaseNameTable.NSAppPublishingFinal; }
/// <summary> /// construct a versioninformation object based /// on a versionaware object /// </summary> /// <param name="v">the versioned object to copy the data from</param> /// <returns></returns> public VersionInformation(IVersionAware v) { _majorVersion = v.ProtocolMajor; _minorVersion = v.ProtocolMinor; }
///////////////////////////////////////////////////////////////////////////// #endregion end of Read only accessors /// <summary> /// returns the correct opensearchnamespace to use based /// on the version information passed in. All protocols with /// version > 1 use opensearch1.1 where version 1 uses /// opensearch 1.0 /// </summary> /// <param name="v">The versioninformation</param> /// <returns></returns> public static string OpenSearchNamespace(IVersionAware v) { int major = VersionDefaults.Major; if (v != null) major = v.ProtocolMajor; if (major == 1) return BaseNameTable.NSOpenSearchRss; return BaseNameTable.NSOpenSearch11; }
/// <summary> /// this get's called out of a notification chain. It set's /// this objects version info and the extension lists. We do not /// use the property accessor to avoid the notification loop /// </summary> /// <param name="obj"></param> internal void SetVersionInfo(IVersionAware obj) { this.versionInfo = new VersionInformation(obj); this.versionInfo.ImprintVersion(this.ExtensionElements); this.versionInfo.ImprintVersion(this.ExtensionFactories); }
/// <summary> /// returns an extensionlist that belongs to a version aware /// container /// </summary> /// <param name="container"></param> public ExtensionList(IVersionAware container) { this.container = container; }