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


C# System.UriFormatException类代码示例

本文整理汇总了C#中System.UriFormatException的典型用法代码示例。如果您正苦于以下问题:C# UriFormatException类的具体用法?C# UriFormatException怎么用?C# UriFormatException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UriFormatException类属于System命名空间,在下文中一共展示了UriFormatException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddParameter

        internal static string AddParameter(string baseUrl, string parameter, string value)
        {
            // this will get our url's properly formatted
            if (parameter == Constants.UrlParameter.Url)
            {
                try
                {
                    value = new Uri (value).ToString();
                }
                catch (UriFormatException e)
                {
                    UriFormatException ufe = new UriFormatException ("Delicious.Net was unable to parse the url \"" + value + "\".\n\n" + e);
                    throw (ufe);
                }
            }
            //value = HttpUtility.UrlEncode (value);

            // insert the '?' if needed
            int qLocation = baseUrl.LastIndexOf ('?');
            if (qLocation < 0)
            {
                baseUrl += "?";
                qLocation = baseUrl.Length - 1;
            }

            if (baseUrl.Length > qLocation + 1)
                baseUrl += "&";

            baseUrl += parameter + "=" + value;
            return baseUrl;
        }
开发者ID:jasonjef,项目名称:DeliciousNetOAuth,代码行数:31,代码来源:Utilities.cs

示例2: InitializeAndValidate

		protected override void InitializeAndValidate (Uri uri, out UriFormatException parsingError)
		{
			if (uri.Scheme == "httpx")
				parsingError = null;
			else
				base.InitializeAndValidate (uri, out parsingError);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:HttpStyleUriParserTest.cs

示例3: LinkDemand_GetObjectData_Deny_DenySerializationFormatter

		public void LinkDemand_GetObjectData_Deny_DenySerializationFormatter ()
		{
			StreamingContext sc = new StreamingContext (StreamingContextStates.All);
			UriFormatException ufe = new UriFormatException ();
			MethodInfo mi = ufe.GetType ().GetMethod ("GetObjectData");
			Assert.IsNotNull (mi, "GetObjectData");
			Assert.IsNotNull (mi.Invoke (ufe, new object[2] { null, sc }), "invoke");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:UriFormatExceptionCas.cs

示例4: Resolve

        //
        // Resolves a relative Uri object into new AbsoluteUri.
        //
        //  baseUri         - The baseUri used to resolve this Uri.
        //  relativeuri     - A relative Uri string passed by the application.
        //
        // This method returns:
        // The result Uri value used to represent a new Uri
        //
        protected virtual string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError)
        {
            if (baseUri.UserDrivenParsing)
                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, this.GetType().ToString()));

            if (!baseUri.IsAbsoluteUri)
                throw new InvalidOperationException(SR.net_uri_NotAbsolute);


            string newUriString = null;
            bool userEscaped = false;
            Uri result = Uri.ResolveHelper(baseUri, relativeUri, ref newUriString, ref userEscaped, out parsingError);

            if (parsingError != null)
                return null;

            if (result != null)
                return result.OriginalString;

            return newUriString;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:30,代码来源:UriScheme.cs

示例5: InitializeAndValidate

		protected override void InitializeAndValidate (Uri uri, out UriFormatException parsingError)
		{
			throw new NotImplementedException ();
			// base.InitializeAndValidate (uri, out parsingError);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:5,代码来源:LdapStyleUriParserTest.cs

示例6: InitializeAndValidate

		protected override void InitializeAndValidate (Uri uri, out UriFormatException parsingError)
		{
			base.InitializeAndValidate (uri, out parsingError);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:4,代码来源:GenericUriParserTest.cs

示例7: InitializeUri

        //
        private void InitializeUri(ParsingError err, UriKind uriKind, out UriFormatException e)
        {
            if (err == ParsingError.None)
            {
                if (IsImplicitFile)
                {
                    // V1 compat VsWhidbey#252282
                    // A relative Uri wins over implicit UNC path unless the UNC path is of the form "\\something" and 
                    // uriKind != Absolute
                    if (
#if !PLATFORM_UNIX
                        NotAny(Flags.DosPath) &&
#endif // !PLATFORM_UNIX
                        uriKind != UriKind.Absolute &&
                       (uriKind == UriKind.Relative || (m_String.Length >= 2 && (m_String[0] != '\\' || m_String[1] != '\\'))))

                    {
                        m_Syntax = null; //make it be relative Uri
                        m_Flags &= Flags.UserEscaped; // the only flag that makes sense for a relative uri
                        e = null;
                        return;
                        // Otheriwse an absolute file Uri wins when it's of the form "\\something"
                    }
                    //
                    // VsWhidbey#423805 and V1 compat issue
                    // We should support relative Uris of the form c:\bla or c:/bla
                    //
#if !PLATFORM_UNIX
                    else if (uriKind == UriKind.Relative && InFact(Flags.DosPath))
                    {
                        m_Syntax = null; //make it be relative Uri
                        m_Flags &= Flags.UserEscaped; // the only flag that makes sense for a relative uri
                        e = null;
                        return;
                        // Otheriwse an absolute file Uri wins when it's of the form "c:\something"
                    }
#endif // !PLATFORM_UNIX
                }
            }
            else if (err > ParsingError.LastRelativeUriOkErrIndex)
            {
                //This is a fatal error based solely on scheme name parsing
                m_String = null; // make it be invalid Uri
                e = GetException(err);
                return;
            }

            //
            //
            //
            bool hasUnicode = false;

            // Is there unicode ..
            if ((!s_ConfigInitialized) && CheckForConfigLoad(m_String)){
                InitializeUriConfig();
            }

            m_iriParsing = (s_IriParsing && ((m_Syntax == null) || m_Syntax.InFact(UriSyntaxFlags.AllowIriParsing)));
            
            if (m_iriParsing && 
                (CheckForUnicode(m_String) || CheckForEscapedUnreserved(m_String))) {
                m_Flags |= Flags.HasUnicode;
                hasUnicode = true;
                // switch internal strings
                m_originalUnicodeString = m_String; // original string location changed
            }

            if (m_Syntax != null)
            {
                if (m_Syntax.IsSimple)
                {
                    if ((err = PrivateParseMinimal()) != ParsingError.None)
                    {
                        if (uriKind != UriKind.Absolute && err <= ParsingError.LastRelativeUriOkErrIndex)
                        {
                            // RFC 3986 Section 5.4.2 - http:(relativeUri) may be considered a valid relative Uri.
                            m_Syntax = null; // convert to relative uri
                            e = null;
                            m_Flags &= Flags.UserEscaped; // the only flag that makes sense for a relative uri
                        }
                        else
                            e = GetException(err);
                    }
                    else if (uriKind == UriKind.Relative)
                    {
                        // Here we know that we can create an absolute Uri, but the user has requested only a relative one
                        e = GetException(ParsingError.CannotCreateRelative);
                    }
                    else
                        e = null;
                    // will return from here

                    if (m_iriParsing && hasUnicode){
                        // In this scenario we need to parse the whole string 
                        EnsureParseRemaining();
                    }
                }
                else
                {
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:UriExt.cs

示例8: ResolveHelper

 internal static Uri ResolveHelper(Uri baseUri, Uri relativeUri, ref string newUriString, ref bool userEscaped, out UriFormatException e)
 {
     e = null;
     string relativeStr = string.Empty;
     if (relativeUri != null)
     {
         if (relativeUri.IsAbsoluteUri)
         {
             return relativeUri;
         }
         relativeStr = relativeUri.OriginalString;
         userEscaped = relativeUri.UserEscaped;
     }
     else
     {
         relativeStr = string.Empty;
     }
     if ((relativeStr.Length > 0) && (IsLWS(relativeStr[0]) || IsLWS(relativeStr[relativeStr.Length - 1])))
     {
         relativeStr = relativeStr.Trim(_WSchars);
     }
     if (relativeStr.Length == 0)
     {
         newUriString = baseUri.GetParts(UriComponents.AbsoluteUri, baseUri.UserEscaped ? UriFormat.UriEscaped : UriFormat.SafeUnescaped);
         return null;
     }
     if (((relativeStr[0] == '#') && !baseUri.IsImplicitFile) && baseUri.Syntax.InFact(UriSyntaxFlags.MayHaveFragment))
     {
         newUriString = baseUri.GetParts(UriComponents.HttpRequestUrl | UriComponents.UserInfo, UriFormat.UriEscaped) + relativeStr;
         return null;
     }
     if (((relativeStr[0] == '?') && !baseUri.IsImplicitFile) && baseUri.Syntax.InFact(UriSyntaxFlags.MayHaveQuery))
     {
         newUriString = baseUri.GetParts(UriComponents.Path | UriComponents.SchemeAndServer | UriComponents.UserInfo, UriFormat.UriEscaped) + relativeStr;
         return null;
     }
     if (((relativeStr.Length >= 3) && ((relativeStr[1] == ':') || (relativeStr[1] == '|'))) && (IsAsciiLetter(relativeStr[0]) && ((relativeStr[2] == '\\') || (relativeStr[2] == '/'))))
     {
         if (baseUri.IsImplicitFile)
         {
             newUriString = relativeStr;
             return null;
         }
         if (baseUri.Syntax.InFact(UriSyntaxFlags.AllowDOSPath))
         {
             string str2;
             if (baseUri.InFact(Flags.AuthorityFound))
             {
                 str2 = baseUri.Syntax.InFact(UriSyntaxFlags.PathIsRooted) ? ":///" : "://";
             }
             else
             {
                 str2 = baseUri.Syntax.InFact(UriSyntaxFlags.PathIsRooted) ? ":/" : ":";
             }
             newUriString = baseUri.Scheme + str2 + relativeStr;
             return null;
         }
     }
     ParsingError err = GetCombinedString(baseUri, relativeStr, userEscaped, ref newUriString);
     if (err != ParsingError.None)
     {
         e = GetException(err);
         return null;
     }
     if (newUriString == baseUri.m_String)
     {
         return baseUri;
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:70,代码来源:Uri.cs

示例9: InitializeAndValidate

 protected override void InitializeAndValidate(Uri uri, out UriFormatException parsingError)
 {
     // TODO: check UIDVALIDITY, UID, SECTION, PARTIAL, etc.
       base.InitializeAndValidate(uri, out parsingError);
 }
开发者ID:pengyancai,项目名称:cs-util,代码行数:5,代码来源:ImapStyleUriParser.cs

示例10: InitializeAndValidate

 protected override void InitializeAndValidate(Uri uri, out UriFormatException parsingError)
 {
     parsingError = null;
 }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:4,代码来源:PackUriParser.cs

示例11: Resolve

 protected virtual string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError)
 {
     if (baseUri.UserDrivenParsing)
     {
         throw new InvalidOperationException(SR.GetString("net_uri_UserDrivenParsing", new object[] { base.GetType().FullName }));
     }
     if (!baseUri.IsAbsoluteUri)
     {
         throw new InvalidOperationException(SR.GetString("net_uri_NotAbsolute"));
     }
     string newUriString = null;
     bool userEscaped = false;
     Uri uri = Uri.ResolveHelper(baseUri, relativeUri, ref newUriString, ref userEscaped, out parsingError);
     if (parsingError != null)
     {
         return null;
     }
     if (uri != null)
     {
         return uri.OriginalString;
     }
     return newUriString;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:UriParser.cs

示例12: OnConnect

		/// <summary>
		/// Connects to the service to retrieve fields information.
		/// </summary>
		/// <param name="commandParameter"></param>
		private void OnConnect(object commandParameter)
		{
			if (!CanConnect(commandParameter)) return;
			try
			{
                bool savedConfiguration = commandParameter as string == Constants.SAVED_CONFIGURATION;
                if (!savedConfiguration)
    				Reset();

				IsBusy = true;

				initializedAction = (f) =>
				{
					IsConnected = true;
					if (f == null || f.LayerInfo == null || f.LayerInfo.Fields == null)
						Error = new Exception(Resources.Strings.LayerInfoMissing);
					if (IsTable)
					{
						UseServiceRenderer = false;
						AutoPinResults = false;
						AutoZoomToResults = false;
					}
					OnPropertyChanged("QueryTitle");
					OnPropertyChanged("Fields");
					OnPropertyChanged("HasResults");
					OnPropertyChanged("IsTable");
					OnPropertyChanged("IsConnectionValid");
					AddChanged();

                    if (!savedConfiguration)
                        InitalizeOutFields();
                    else
                        initializeExpressions();
				};

				var url = !ServiceUrl.StartsWith("http") ? string.Format("http://{0}", ServiceUrl) : ServiceUrl;

				resultLayer = new FeatureLayer()
				{
					DisableClientCaching = true,
					Url = url
				};
				if (UseProxy && !string.IsNullOrEmpty(ProxyUrl))
					resultLayer.ProxyUrl = ProxyUrl;

				// Subscribes to initialized event and initializes layer.
				resultLayer.InitializationFailed += ResultLayer_InitializationFailed;
				resultLayer.Initialized += ResultLayer_Initialized;

				resultLayer.Initialize();
			}
			catch (Exception ex)
			{
				IsConnected = true;
				IsBusy = false;
				if (ex is UriFormatException)
				{
					Error = new UriFormatException(string.Format(Resources.Strings.UriFormatError, ServiceUrl), ex);
				}
				else
				{
					Error = new Exception(string.Format(Resources.Strings.UnableToAccess, ServiceUrl), ex);
				}
			}
		}
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:69,代码来源:QueryViewModel.cs

示例13: Resolve

    protected virtual new string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError)
    {
      Contract.Requires(baseUri != null);

      parsingError = default(UriFormatException);

      return default(string);
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:8,代码来源:System.UriParser.cs

示例14: InitializeAndValidate

    protected virtual new void InitializeAndValidate(Uri uri, out UriFormatException parsingError)
    {
      Contract.Requires(uri != null);

      parsingError = default(UriFormatException);
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:6,代码来源:System.UriParser.cs

示例15: CreateHelper

 internal static Uri CreateHelper(string uriString, bool dontEscape, UriKind uriKind, ref UriFormatException e)
 {
     if ((uriKind < UriKind.RelativeOrAbsolute) || (uriKind > UriKind.Relative))
     {
         throw new ArgumentException(System.SR.GetString("net_uri_InvalidUriKind", new object[] { uriKind }));
     }
     UriParser syntax = null;
     Flags hostNotParsed = Flags.HostNotParsed;
     ParsingError err = ParseScheme(uriString, ref hostNotParsed, ref syntax);
     if (dontEscape)
     {
         hostNotParsed |= Flags.HostNotParsed | Flags.UserEscaped;
     }
     if (err != ParsingError.None)
     {
         if ((uriKind != UriKind.Absolute) && (err <= ParsingError.EmptyUriString))
         {
             return new Uri(hostNotParsed & (Flags.HostNotParsed | Flags.UserEscaped), null, uriString);
         }
         return null;
     }
     Uri uri = new Uri(hostNotParsed, syntax, uriString);
     try
     {
         uri.InitializeUri(err, uriKind, out e);
         if (e == null)
         {
             return uri;
         }
         return null;
     }
     catch (UriFormatException exception)
     {
         e = exception;
         return null;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:37,代码来源:Uri.cs


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