当前位置: 首页>>代码示例>>C#>>正文


C# nsIRequest.Cancel方法代码示例

本文整理汇总了C#中nsIRequest.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# nsIRequest.Cancel方法的具体用法?C# nsIRequest.Cancel怎么用?C# nsIRequest.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nsIRequest的用法示例。


在下文中一共展示了nsIRequest.Cancel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LocationChangeEventArgs

		void nsIWebProgressListener.OnLocationChange(nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation)
		{
			Trace.TraceInformation("nsIWebProgressListener.OnLocationChange");

			var e = new LocationChangeEventArgs(aLocation.ToUri());
			Events.Raise(EventKey.LocationChange, e);
			if (e.Cancel && (aRequest != null))
			{
				aRequest.Cancel(nsResult.NS_BINDING_ABORTED);
			}
		}
开发者ID:Happy-Ferret,项目名称:dotgecko,代码行数:11,代码来源:WebBrowser.WebProgressListener.cs

示例2: RequestProgressChangeEventArgs

		void nsIWebProgressListener.OnProgressChange(nsIWebProgress aWebProgress, nsIRequest aRequest, Int32 aCurSelfProgress, Int32 aMaxSelfProgress, Int32 aCurTotalProgress, Int32 aMaxTotalProgress)
		{
			Trace.TraceInformation("nsIWebProgressListener.OnProgressChange");

			var e = new RequestProgressChangeEventArgs(aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
			Events.Raise(EventKey.RequestProgressChange, e);
			if (e.Cancel && (aRequest != null))
			{
				aRequest.Cancel(nsResult.NS_BINDING_ABORTED);
			}
		}
开发者ID:Happy-Ferret,项目名称:dotgecko,代码行数:11,代码来源:WebBrowser.WebProgressListener.cs

示例3: RequestStateChangeEventArgs

		void nsIWebProgressListener.OnStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, UInt32 aStateFlags, UInt32 aStatus)
		{
			Trace.TraceInformation("nsIWebProgressListener.OnStateChange");

			var e = new RequestStateChangeEventArgs((RequestState)aStateFlags);
			Events.Raise(EventKey.RequestStateChange, e);
			if (e.Cancel && (aRequest != null))
			{
				aRequest.Cancel(nsResult.NS_BINDING_ABORTED);
			}
		}
开发者ID:Happy-Ferret,项目名称:dotgecko,代码行数:11,代码来源:WebBrowser.WebProgressListener.cs

示例4: GeckoNavigatingEventArgs

        void nsIWebProgressListener.OnStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, int aStateFlags, int aStatus)
        {
            bool cancelled = false;

            if ((aStateFlags & nsIWebProgressListenerConstants.STATE_START) != 0 && (aStateFlags & nsIWebProgressListenerConstants.STATE_IS_NETWORK) != 0)
            {
                IsBusy = true;

                Uri uri;
                Uri.TryCreate(nsString.Get(aRequest.GetName), UriKind.Absolute, out uri);

                GeckoNavigatingEventArgs ea = new GeckoNavigatingEventArgs(uri);
                OnNavigating(ea);

                if (ea.Cancel)
                {
                    aRequest.Cancel(0);
                    cancelled = true;
                }
            }

            // maybe we'll add another event here to allow users to cancel certain content types
            //if ((aStateFlags & nsIWebProgressListenerConstants.STATE_TRANSFERRING) != 0)
            //{
            //      GeckoResponse rsp = new GeckoResponse(aRequest);
            //      if (rsp.ContentType == "application/x-executable")
            //      {
            //            // do something
            //      }
            //}

            if (cancelled || ((aStateFlags & nsIWebProgressListenerConstants.STATE_STOP) != 0 && (aStateFlags & nsIWebProgressListenerConstants.STATE_IS_NETWORK) != 0))
            {
                // clear busy state
                IsBusy = false;

                // kill any cached document and raise DocumentCompleted event
                UnloadDocument();
                OnDocumentCompleted(EventArgs.Empty);

                // clear progress bar
                OnProgressChanged(new GeckoProgressEventArgs(100, 100));

                // clear status bar
                StatusText = "";
            }
        }
开发者ID:quantum1423-dustbin,项目名称:OpenGeckoSharp,代码行数:47,代码来源:GeckoWebBrowser.cs

示例5: GeckoNavigatingEventArgs

		void nsIWebProgressListener.OnStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, int aStateFlags, int aStatus)
		{
			if ((aStateFlags & nsIWebProgressListenerConstants.STATE_START) != 0 && (aStateFlags & nsIWebProgressListenerConstants.STATE_IS_NETWORK) != 0)
			{
				IsBusy = true;
				
				GeckoNavigatingEventArgs ea = new GeckoNavigatingEventArgs(null);
				OnNavigating(ea);
				
				if (ea.Cancel)
					aRequest.Cancel(0);
			}
			
			if ((aStateFlags & nsIWebProgressListenerConstants.STATE_STOP) != 0 && (aStateFlags & nsIWebProgressListenerConstants.STATE_IS_NETWORK) != 0)
			{
				// clear busy state
				IsBusy = false;
				
				// kill any cached document and raise DocumentCompleted event
				UnloadDocument();
				OnDocumentCompleted(EventArgs.Empty);
				
				// clear progress bar
				OnProgressChanged(new GeckoProgressEventArgs(100, 100));
				
				// clear status bar
				StatusText = "";
			}
		}
开发者ID:Happy-Ferret,项目名称:geckofx,代码行数:29,代码来源:GeckoWebBrowser.cs

示例6: unchecked

		void nsIWebProgressListener.OnStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, uint aStateFlags, int aStatus) {
			const int NS_BINDING_ABORTED = unchecked((int)0x804B0002);
			
			#region validity checks
			// The request parametere may be null
			if (aRequest == null)
				return;

			// Ignore ViewSource requests, they don't provide the URL
			// see: http://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/viewsource/nsViewSourceChannel.cpp#114
			{
				var viewSource = Xpcom.QueryInterface<nsIViewSourceChannel>( aRequest );
				if ( viewSource != null )
				{
					Marshal.ReleaseComObject( viewSource );
					return;
				}
			}
	
			#endregion validity checks

			using (var request = Gecko.Net.Request.CreateRequest(aRequest))
			{
				#region request parameters
				Uri destUri = null;
				Uri.TryCreate(request.Name, UriKind.Absolute, out destUri);
				var domWindow = aWebProgress.GetDOMWindowAttribute().Wrap(x => new GeckoWindow(x));

				/* This flag indicates that the state transition is for a request, which includes but is not limited to document requests.
				 * Other types of requests, such as requests for inline content (for example images and stylesheets) are considered normal requests.
				 */
				bool stateIsRequest = ((aStateFlags & nsIWebProgressListenerConstants.STATE_IS_REQUEST) != 0);

				/* This flag indicates that the state transition is for a document request. This flag is set in addition to STATE_IS_REQUEST.
				 * A document request supports the nsIChannel interface and its loadFlags attribute includes the nsIChannel ::LOAD_DOCUMENT_URI flag.
				 * A document request does not complete until all requests associated with the loading of its corresponding document have completed.
				 * This includes other document requests (for example corresponding to HTML <iframe> elements).
				 * The document corresponding to a document request is available via the DOMWindow attribute of onStateChange()'s aWebProgress parameter.
				 */
				bool stateIsDocument = ((aStateFlags & nsIWebProgressListenerConstants.STATE_IS_DOCUMENT) != 0);

				/* This flag indicates that the state transition corresponds to the start or stop of activity in the indicated nsIWebProgress instance.
				 * This flag is accompanied by either STATE_START or STATE_STOP, and it may be combined with other State Type Flags.
				 * 
				 * Unlike STATE_IS_WINDOW, this flag is only set when activity within the nsIWebProgress instance being observed starts or stops.
				 * If activity only occurs in a child nsIWebProgress instance, then this flag will be set to indicate the start and stop of that activity.
				 * For example, in the case of navigation within a single frame of a HTML frameset, a nsIWebProgressListener instance attached to the
				 * nsIWebProgress of the frameset window will receive onStateChange() calls with the STATE_IS_NETWORK flag set to indicate the start and
				 * stop of said navigation. In other words, an observer of an outer window can determine when activity, that may be constrained to a
				 * child window or set of child windows, starts and stops.
				 */
				bool stateIsNetwork = ((aStateFlags & nsIWebProgressListenerConstants.STATE_IS_NETWORK) != 0);

				/* This flag indicates that the state transition corresponds to the start or stop of activity in the indicated nsIWebProgress instance.
				 * This flag is accompanied by either STATE_START or STATE_STOP, and it may be combined with other State Type Flags.
				 * This flag is similar to STATE_IS_DOCUMENT. However, when a document request completes, two onStateChange() calls with STATE_STOP are generated.
				 * The document request is passed as aRequest to both calls. The first has STATE_IS_REQUEST and STATE_IS_DOCUMENT set, and the second has
				 * the STATE_IS_WINDOW flag set (and possibly the STATE_IS_NETWORK flag set as well -- see above for a description of when the STATE_IS_NETWORK
				 * flag may be set). This second STATE_STOP event may be useful as a way to partition the work that occurs when a document request completes.
				 */
				bool stateIsWindow = ((aStateFlags & nsIWebProgressListenerConstants.STATE_IS_WINDOW) != 0);
				#endregion request parameters

				#region STATE_START
				/* This flag indicates the start of a request.
				 * This flag is set when a request is initiated.
				 * The request is complete when onStateChange() is called for the same request with the STATE_STOP flag set.
				 */
				if ((aStateFlags & nsIWebProgressListenerConstants.STATE_START) != 0)
				{

					
					if (stateIsNetwork && domWindow.IsTopWindow())
					{
						IsBusy = true;

						GeckoNavigatingEventArgs ea = new GeckoNavigatingEventArgs(destUri, domWindow);
						OnNavigating(ea);

						if (ea.Cancel)
						{
							aRequest.Cancel(NS_BINDING_ABORTED);
							

							// clear busy state
							IsBusy = false;

							// clear progress bar
							OnProgressChanged(new GeckoProgressEventArgs(100, 100));

							// clear status bar
							StatusText = "";
						}
					}
					else if (stateIsDocument)
					{
						GeckoNavigatingEventArgs ea = new GeckoNavigatingEventArgs(destUri, domWindow);
						OnFrameNavigating(ea);

						if (ea.Cancel)
//.........这里部分代码省略.........
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:101,代码来源:GeckoWebBrowser.cs


注:本文中的nsIRequest.Cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。