* IUriData.cs, UriData.cs: New. Initial cut at UriParser protocol.
authorRaja R Harinath <harinath@hurrynot.org>
Mon, 9 Feb 2009 18:13:30 +0000 (18:13 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Mon, 9 Feb 2009 18:13:30 +0000 (18:13 -0000)
svn path=/trunk/mcs/; revision=126358

mcs/class/System/System.dll.sources
mcs/class/System/System/ChangeLog
mcs/class/System/System/IUriData.cs [new file with mode: 0644]
mcs/class/System/System/UriData.cs [new file with mode: 0644]

index f78a22117670b53395a07d3166ee3caeb11264a3..22b891384b3cbda812cfc860c492012bd6c5a632 100644 (file)
@@ -998,3 +998,5 @@ System.Runtime.InteropServices.ComTypes/IEnumSTATDATA.cs
 System.Runtime.InteropServices.ComTypes/STATDATA.cs
 System.Runtime.InteropServices.ComTypes/STGMEDIUM.cs
 System.Runtime.InteropServices.ComTypes/TYMED.cs
+System/IUriData.cs
+System/UriData.cs
index 853ad0463581fd020a712e7fe45a8f18b7dcd6fa..47862e9477e91f188c8ffd3ef65b35d6a0775cc8 100644 (file)
@@ -1,5 +1,7 @@
 2009-02-09  Raja R Harinath  <harinath@hurrynot.org>
 
+       * IUriData.cs, UriData.cs: New.  Initial cut at UriParser protocol.
+
        Make UriParser available in the NET_1_1 build
        * UriParser.cs: Make visible as internal class in the NET_1_1 build.
        * UriComponents.cs, UriFormats.cs, DefaultUriParser.cs: Likewise.
diff --git a/mcs/class/System/System/IUriData.cs b/mcs/class/System/System/IUriData.cs
new file mode 100644 (file)
index 0000000..86289d0
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// System.IUriData interface
+//
+// Author:
+//     Raja R Harinath <harinath@hurrynot.org>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections;
+using System.Globalization;
+using System.Security.Permissions;
+using System.Text;
+
+namespace System {
+       interface IUriData {
+               string AbsolutePath { get; }
+               string AbsoluteUri { get; }
+               string AbsoluteUri_SafeUnescaped { get; }
+               string Authority { get; }
+               string Fragment { get; }
+               string Host { get; }
+               string PathAndQuery { get; }
+               string StrongPort { get; }
+               string Query { get; }
+               string UserInfo { get; }
+       }
+}
diff --git a/mcs/class/System/System/UriData.cs b/mcs/class/System/System/UriData.cs
new file mode 100644 (file)
index 0000000..d23ce33
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// System.UriData class
+//
+// Author:
+//     Raja R Harinath <harinath@hurrynot.org>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections;
+using System.Globalization;
+using System.Security.Permissions;
+using System.Text;
+
+namespace System {
+       class UriData : IUriData {
+               Uri uri;
+               UriParser parser;
+
+               public UriData (Uri uri, UriParser parser)
+               {
+                       this.uri = uri;
+                       this.parser = parser;
+               }
+
+               string Lookup (ref string cache, UriComponents components)
+               {
+                       return Lookup (ref cache, components, uri.UserEscaped ? UriFormat.Unescaped : UriFormat.UriEscaped);
+               }
+
+               string Lookup (ref string cache, UriComponents components, UriFormat format)
+               {
+                       if (cache == null)
+                               cache = parser.GetComponents (uri, components, format);
+                       return cache;
+               }
+
+               string absolute_path;
+               public string AbsolutePath {
+                       get { return Lookup ( ref absolute_path, UriComponents.Path | UriComponents.KeepDelimiter);
+                       }
+               }
+
+               string absolute_uri;
+               public string AbsoluteUri {
+                       get { return Lookup (ref absolute_uri, UriComponents.AbsoluteUri); }
+               }
+
+               string absolute_uri_unescaped;
+               public string AbsoluteUri_SafeUnescaped {
+                       get { return Lookup (ref absolute_uri_unescaped, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped); }
+               }
+
+               string authority;
+               public string Authority {
+                       get { return Lookup (ref authority, UriComponents.Host | UriComponents.Port); }
+               }
+
+               string fragment;
+               public string Fragment {
+                       get { return Lookup (ref fragment, UriComponents.Fragment | UriComponents.KeepDelimiter); }
+               }
+
+               string host;
+               public string Host {
+                       get { return Lookup (ref host, UriComponents.Host); }
+               }
+
+               string path_and_query;
+               public string PathAndQuery {
+                       get { return Lookup (ref path_and_query, UriComponents.PathAndQuery); }
+               }
+
+               string strong_port;
+               public string StrongPort {
+                       get { return Lookup (ref strong_port, UriComponents.StrongPort); }
+               }
+
+               string query;
+               public string Query {
+                       get { return Lookup (ref query, UriComponents.Query | UriComponents.KeepDelimiter); }
+               }
+
+               string user_info;
+               public string UserInfo {
+                       get { return Lookup (ref user_info, UriComponents.UserInfo); }
+               }
+       }
+}