ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
ImageResizer.Util.yrl Class Reference

Enapsulates a mutable (changable) site-relative URL. Note that "" is equivalent to the application root directory in YRL notation (the ~/ is implicit, always). QueryFindYrlVerifyID can be removed if external dependencies aren't allowed. It uses fbs.Articles.Index.FindPathByID() This class is designed to standardize path interpretation and conversion. More...

Public Types

enum  PathType {
  PathType.UNCPath, PathType.BackslashPath, PathType.DriveletterColonBackslashPath, PathType.img,
  PathBackslashPath, PathType.TildeForwardslashPath, PathType.ForwardslashPath, PathType.PathForwardslashPath,
  PathType.ServerForwardslashPath, PathType.File, PathType.Root, PathType.Invalid
}
 Path syntaxes, determined by patterns. More...
 

Public Member Functions

 yrl ()
 Creates a default instance of yrl which points to the application root directory. More...
 
 yrl (string path)
 
yrl Copy ()
 Creates a deep copy of the yrl More...
 
override string ToString ()
 Returns a site-root-relative path along with query paramaters More...
 
override bool Equals (object obj)
 Compares the hash codes of the two instances. More...
 
override int GetHashCode ()
 Returns a unique hash code derived from the URL property of this instance More...
 
void ChangeExtension (string newextension)
 Deletes the old extension and replaces it with the specified extension. A leading '.' is not neccesary More...
 
yrl GetNextAvailableDerivitive ()
 Returns the next unused filename similar to the current one,by incrementing (i) More...
 
string CreateAbsoluteUrl (string protocolHostnameFolder)
 Returns an absolute path to the current yrl using the specified base path More...
 

Static Public Member Functions

static yrl FromString (string path)
 Returns a yrl object from a path. Returns null if the path cannot be parsed. (Out of application bounds, or an invalid character). The tilde is an invalid character unless used as the app-relative specifier. More...
 
static yrl FromYrlString (string path)
 Creates an instance from a yrl-syntax string (virtual, but without ~/). Use FromString if you're not sure what type of syntax is used. More...
 
static yrl FromRelativePhysicalString (string path)
 
static yrl FromPhysicalString (string path)
 Creates a yrl Instance from the specified physical path. Throws an exception if the path is outside the application structure. More...
 
static string GetAppFolderName ()
 either '/' or '/folder' like '/yf' or sometimes '/folder/folder' More...
 
static string TrimStartAppFolder (string path)
 Removes the application folder from the specified path. Leaves the leading forwardslash. Assuming the Application path is /yf, this function will transform /yf/home.aspx to /home.aspx and /yf/css/john.css to /css/john.css If the application is located in '/', nothing will be done to the path. Transforms yf/home.aspx to /home.aspx, yf\home.aspx to .aspx, .aspx to .aspx Won't work if the app folder has a child directory named the same! More...
 
static string TrimStartServer (string path)
 
static PathType GetPathType (string path)
 Returns the type of path More...
 
static string NavigateUrlEncode (string text)
 
static yrl FromUri (Uri url)
 
static operator string (yrl url)
 
static operator yrl (string s)
 
static yrl Combine (yrl folder, yrl filenameOrSubdir)
 Joins two yrls. Querystrings on either are discarded. More...
 
static bool IsNullOrEmpty (yrl path)
 Returns true if the yrl is null or empty (site root) More...
 

Public Attributes

string BaseFile = ""
 The base file, usually a .aspx page. Ex. 'home.aspx' or 'admin/new.aspx'. Can also be a base directory, such as articles More...
 
NameValueCollection QueryString = new NameValueCollection()
 A collection of name/value query paramaters. Do NOT UrlEncode/Decode these! That step will be done for you. More...
 

Properties

string this[int index] [get]
 
string this[string name] [get, set]
 
int QueryID [get, set]
 yrl.QueryString["id"] Returns -1 if not found, -2 if unparseable More...
 
yrl QueryPath [get, set]
 yrl.QueryString["path"]. Returns null if not found, throws exception if not parseable. More...
 
yrl QueryDir [get, set]
 yrl.QueryString["dir"]. Returns null if not found, throws exception if not parseable. More...
 
int QueryFindID [get]
 Tries to track down the ID by looking at QueryString["id"], then QueryString["path"]. Returns -1 if unsuccessful More...
 
string Local [get]
 Returns the physical filesystem path for this yrl More...
 
string Virtual [get]
 Returns the virtual path(~/...)of the base file without query paramaters. More...
 
string VirtualURL [get]
 Returns the virtual path (~/...) of the base file with query paramaters appended. More...
 
string NavigateURL [get]
 Returns a ~/ path designed for the Hyperlink.NavigateUrl property More...
 
string URL [get]
 Returns root-relative URL with query paramaters in the form 'articles/00001002 article.aspx' More...
 
string URLEncoded [get]
 Returns root-relative URL with query paramaters in the form 'articles/00001002%20article.aspx' More...
 
string URLHtmlEncoded [get]
 Returns root-relative URL with query paramaters in the form 'articles/00001002%20article.aspx'. Encodes special characters into HTML entities using Server.URLPathEncode More...
 
string URLAnchorTarget [get]
 Returns a domain-relative path in the form '/yf/articles/00001002%20article.aspx' More...
 
string RelativeURL [get]
 Returns relaitve URL with query paramaters in the form '../articles/00001002 article.aspx' More...
 
int ID [get]
 Returns the ID if a leading 8-digit ID is found in the base file. Returns -1 otherwise More...
 
int FirstID [get]
 Returns first leading ID found in a segment of the path. More...
 
bool FileExists [get]
 Returns true if BaseFile exists as a local file. More...
 
bool DirExists [get]
 Returns true if BaseFile exists as a local Directory. More...
 
DirectoryInfo DirInfo [get]
 Returns a DirectoryInfo object for BaseFile if it is a directory. If not, it returns the parent directory More...
 
yrl Parent [get]
 Returns a yrl of the parent directory. If the current yrl is already the root, returns null; Use More...
 
yrl Directory [get]
 Returns the directory portion of this yrl. More...
 
static yrl Root [get]
 Returns an instance of yrl that points to the application root. More...
 
static yrl Current [get]
 Returns the REAL file that is being executed. Falls back to CurrentBrowserUrl if unavailable. Unavailable if UrlRewritingNet isn't in use More...
 
static yrl CurrentBrowserURL [get]
 Retreieves the current URL from HttpContext.Current.Request.Url (pre-rewrite path) More...
 
static yrl Referrer [get]
 Returns null if unavailable More...
 
bool IsEmpty [get]
 An empty yrl signifies the application root. This verifies both the path and the querystring are empty. More...
 
bool IsRoot [get]
 Returns true if the basefile is empty (the root) (the QueryString can have data). Use IsEmpty to check that both are empty. More...
 
bool IsInRoot [get]
 Returns true if this path has no parent directory (the parent directory is the root). More...
 
string Name [get]
 Returns the name of the directory (like 'archives') if it is one, and the name of the file (like 'universal.css') if it is a file. More...
 
string NameWithoutExtension [get]
 Returns the name of BaseFile without the extension. More...
 
string PrettyTitle [get]
 Returns the filename without the ID or extension, converts underscores to spaces, and trims the string. More...
 
string FilenameWithoutIdAndExtension [get]
 Returns the filename minus path information, extensions, or Article ID. More...
 
string Extension [get]
 Returns the extension of BaseFile in the form '.aspx' More...
 
bool IsAspx [get]
 returns true if BaseFile ends with .aspx More...
 
bool HasExtension [get]
 
bool IsCodeFile [get]
 returns true if BaseFile ends with .cs or .vb More...
 
yrl FindAssociatedMarkupFile [get]
 If this is .aspx.cs or .aspx.vb file, attempts to find and return the associated .aspx file. If this is a .aspx file, returns the current instance. Otherwise, this returns null; More...
 
yrl FindAssociatedCodeFile [get]
 If this is an .aspx file, attempts to find and return an associated .aspx.cs or .aspx.vb file. If this is .aspx.cs or .aspx.vb file, returns the current instance. Otherwise, this returns null; More...
 

Detailed Description

Enapsulates a mutable (changable) site-relative URL. Note that "" is equivalent to the application root directory in YRL notation (the ~/ is implicit, always). QueryFindYrlVerifyID can be removed if external dependencies aren't allowed. It uses fbs.Articles.Index.FindPathByID() This class is designed to standardize path interpretation and conversion.

Definition at line 50 of file yrl.cs.

Member Enumeration Documentation

Path syntaxes, determined by patterns.

Enumerator
UNCPath 

\server\

BackslashPath 

A path like '.htm'

DriveletterColonBackslashPath 

A path like 'c: files'

img 

a path like 'img'

TildeForwardslashPath 

a path like '~/home.aspx'

ForwardslashPath 

a path like '/home.aspx'

PathForwardslashPath 

a path like 'img/banner.jpg'

ServerForwardslashPath 

a path like http://www.branham.org/home.aspx

File 

A filename with no path, like 'test.exe' or 'home.aspx'

Root 

Specifies the application root

Invalid 

Indeterminant form

Definition at line 310 of file yrl.cs.

311  {
312  /// <summary>
313  /// \\server\share\
314  /// </summary>
315  UNCPath,
316  /// <summary>
317  /// A path like '\temp\file.htm'
318  /// </summary>
320  /// <summary>
321  /// A path like 'c:\program files\temp'
322  /// </summary>
324  /// <summary>
325  /// a path like 'img\file.img'
326  /// </summary>
327  PathBackslashPath,
328  /// <summary>
329  /// a path like '~/home.aspx'
330  /// </summary>
332  /// <summary>
333  /// a path like '/home.aspx'
334  /// </summary>
336  /// <summary>
337  /// a path like 'img/banner.jpg'
338  /// </summary>
340  /// <summary>
341  /// a path like http://www.branham.org/home.aspx
342  /// </summary>
344  /// <summary>
345  /// A filename with no path, like 'test.exe' or 'home.aspx'
346  /// </summary>
347  File,
348  /// <summary>
349  /// Specifies the application root
350  /// </summary>
351  Root,
352  /// <summary>
353  /// Indeterminant form
354  /// </summary>
355  Invalid
356  }
a path like &#39;img/banner.jpg&#39;
a path like http://www.branham.org/home.aspx
A path like &#39;.htm&#39;
a path like &#39;/home.aspx&#39;
A filename with no path, like &#39;test.exe&#39; or &#39;home.aspx&#39;
a path like &#39;~/home.aspx&#39;
static yrl Root
Returns an instance of yrl that points to the application root.
Definition: yrl.cs:780

Constructor & Destructor Documentation

ImageResizer.Util.yrl.yrl ( )
inline

Creates a default instance of yrl which points to the application root directory.

Definition at line 100 of file yrl.cs.

101  {
102  }

Member Function Documentation

void ImageResizer.Util.yrl.ChangeExtension ( string  newextension)
inline

Deletes the old extension and replaces it with the specified extension. A leading '.' is not neccesary

Parameters
newextension

Definition at line 1072 of file yrl.cs.

1073  {
1074  BaseFile = BaseFile.Remove(BaseFile.Length - this.Extension.Length, this.Extension.Length);
1075  BaseFile += "." + newextension.TrimStart(new char[] { '.' });
1076  }
string BaseFile
The base file, usually a .aspx page. Ex. &#39;home.aspx&#39; or &#39;admin/new.aspx&#39;. Can also be a base director...
Definition: yrl.cs:55
static yrl ImageResizer.Util.yrl.Combine ( yrl  folder,
yrl  filenameOrSubdir 
)
inlinestatic

Joins two yrls. Querystrings on either are discarded.

Parameters
folder
filenameOrSubdir
Returns

Definition at line 1127 of file yrl.cs.

1128  {
1129  return new yrl(folder.Local + System.IO.Path.DirectorySeparatorChar + filenameOrSubdir.BaseFile.Replace('/','\\'));
1130  }
yrl()
Creates a default instance of yrl which points to the application root directory. ...
Definition: yrl.cs:100
yrl ImageResizer.Util.yrl.Copy ( )
inline

Creates a deep copy of the yrl

Returns

Definition at line 490 of file yrl.cs.

491  {
492  yrl temp = new yrl();
493  temp.BaseFile = string.Copy(this.BaseFile);
494  foreach (string s in QueryString.Keys)
495  {
496  string value = QueryString[s];
497  temp.QueryString.Add(string.Copy(s), string.Copy(value));
498  }
499  return temp;
500  }
NameValueCollection QueryString
A collection of name/value query paramaters. Do NOT UrlEncode/Decode these! That step will be done fo...
Definition: yrl.cs:59
yrl()
Creates a default instance of yrl which points to the application root directory. ...
Definition: yrl.cs:100
yrl Copy()
Creates a deep copy of the yrl
Definition: yrl.cs:490
string ImageResizer.Util.yrl.CreateAbsoluteUrl ( string  protocolHostnameFolder)
inline

Returns an absolute path to the current yrl using the specified base path

Parameters
protocolHostnameFolderA base path like http://youngfoundations.org/ or http://localhost:2755/yf/
Returns

Definition at line 1136 of file yrl.cs.

1137  {
1138  return protocolHostnameFolder + this.URL;
1139  }
override bool ImageResizer.Util.yrl.Equals ( object  obj)
inline

Compares the hash codes of the two instances.

Parameters
obj
Returns

Definition at line 865 of file yrl.cs.

866  {
867  if (obj == null) return false;
868  return (obj.GetHashCode() == this.GetHashCode());
869  }
static yrl ImageResizer.Util.yrl.FromPhysicalString ( string  path)
inlinestatic

Creates a yrl Instance from the specified physical path. Throws an exception if the path is outside the application structure.

Parameters
path
Returns

Definition at line 228 of file yrl.cs.

229  {
230  string temp = path;
231  string localapproot = HostingEnvironment.MapPath("~").TrimEnd(new char[] { '/', '\\', '~' });
232 
233  if (temp.StartsWith(localapproot, StringComparison.OrdinalIgnoreCase))
234  {
235  temp = temp.Remove(0, localapproot.Length);
236  }
237  else
238  {
239  return null;
240  //throw new Exception("The specified path \"" + path + "\" is outside the bounds of the application (\"" + localapproot + "\")and cannot be handled!");
241  }
242  temp = temp.TrimStart(new char[] { '/', '\\', '~' }).Replace('\\', '/');
243 
244  return FromYrlString(temp);
245  }
static yrl FromYrlString(string path)
Creates an instance from a yrl-syntax string (virtual, but without ~/). Use FromString if you&#39;re not ...
Definition: yrl.cs:173
static yrl ImageResizer.Util.yrl.FromRelativePhysicalString ( string  path)
inlinestatic

Parameters
path
Returns

Definition at line 215 of file yrl.cs.

216  {
217  string temp = path;
218  if (temp[0] != '\\') temp = "\\" + temp;
219  temp = TrimStartAppFolder(temp);
220  string newpath = HostingEnvironment.MapPath("~") + temp;
221  return FromPhysicalString(newpath);
222  }
static string TrimStartAppFolder(string path)
Removes the application folder from the specified path. Leaves the leading forwardslash. Assuming the Application path is /yf, this function will transform /yf/home.aspx to /home.aspx and /yf/css/john.css to /css/john.css If the application is located in &#39;/&#39;, nothing will be done to the path. Transforms yf/home.aspx to /home.aspx, yf\home.aspx to .aspx, .aspx to .aspx Won&#39;t work if the app folder has a child directory named the same!
Definition: yrl.cs:263
static yrl FromPhysicalString(string path)
Creates a yrl Instance from the specified physical path. Throws an exception if the path is outside t...
Definition: yrl.cs:228
static yrl ImageResizer.Util.yrl.FromString ( string  path)
inlinestatic

Returns a yrl object from a path. Returns null if the path cannot be parsed. (Out of application bounds, or an invalid character). The tilde is an invalid character unless used as the app-relative specifier.

Parameters
pathA path Each query paramater will be UrlDecoded.
Returns

Definition at line 123 of file yrl.cs.

124  {
125  //crashes on ~$lioFlatFile.rtf
126  PathType pathtype = GetPathType(path);
127  if (pathtype == PathType.Root) return yrl.Root;
128 
129  //OSX Mono uses physical paths in the unix style - fools the comparison. So, to handle physical paths right, we have to try that first.
130 
131  yrl test = FromPhysicalString(path);
132  if (test != null) return test;
133 
134  if (pathtype == PathType.File || pathtype == PathType.PathForwardslashPath)
135  {
136  return FromYrlString(path);
137  }
138 
139  if (pathtype == PathType.ForwardslashPath)
140  {
141  return FromYrlString(TrimStartAppFolder(path).TrimStart(new char[] { '/' }));
142  }
143  if (pathtype == PathType.ServerForwardslashPath)
144  {
145  int tilde = path.IndexOf('~');
146  if (tilde > 0)
147  {
148  return FromYrlString(TrimStartAppFolder(TrimStartServer(path).TrimStart(new char[] { '~', '/' })).TrimStart(new char[] { '/' }));
149  }
150  else
151  return FromYrlString(TrimStartAppFolder(TrimStartServer(path)).TrimStart(new char[] { '/' }));
152  }
153  if (pathtype == PathType.TildeForwardslashPath)
154  {
155  //return FromYrlString(TrimStartAppFolder(path.TrimStart(new char[] { '~', '/' })).TrimStart(new char[] { '/' }));
156  return FromYrlString(path.TrimStart(new char[] { '~', '/' }));
157  }
158  if (pathtype == PathType.DriveletterColonBackslashPath)
159  {
160  return FromPhysicalString(path);
161  }
162  if (pathtype == PathType.BackslashPath || pathtype == PathType.PathBackslashPath)
163  {
164  return FromRelativePhysicalString(path);
165  }
166  return null;
167  }
static string TrimStartAppFolder(string path)
Removes the application folder from the specified path. Leaves the leading forwardslash. Assuming the Application path is /yf, this function will transform /yf/home.aspx to /home.aspx and /yf/css/john.css to /css/john.css If the application is located in &#39;/&#39;, nothing will be done to the path. Transforms yf/home.aspx to /home.aspx, yf\home.aspx to .aspx, .aspx to .aspx Won&#39;t work if the app folder has a child directory named the same!
Definition: yrl.cs:263
static yrl FromRelativePhysicalString(string path)
Definition: yrl.cs:215
yrl()
Creates a default instance of yrl which points to the application root directory. ...
Definition: yrl.cs:100
static PathType GetPathType(string path)
Returns the type of path
Definition: yrl.cs:362
static yrl FromPhysicalString(string path)
Creates a yrl Instance from the specified physical path. Throws an exception if the path is outside t...
Definition: yrl.cs:228
static yrl FromYrlString(string path)
Creates an instance from a yrl-syntax string (virtual, but without ~/). Use FromString if you&#39;re not ...
Definition: yrl.cs:173
static yrl Root
Returns an instance of yrl that points to the application root.
Definition: yrl.cs:780
PathType
Path syntaxes, determined by patterns.
Definition: yrl.cs:310
static yrl ImageResizer.Util.yrl.FromYrlString ( string  path)
inlinestatic

Creates an instance from a yrl-syntax string (virtual, but without ~/). Use FromString if you're not sure what type of syntax is used.

Parameters
path
Returns

Definition at line 173 of file yrl.cs.

174  {
175  if (path.Length == 0) return yrl.Root;
176  yrl temp = new yrl();
177  int firstdelimiter = path.IndexOfAny(new char[] { '?', '&' });
178  if (firstdelimiter < 0) firstdelimiter = path.Length;
179  if (path.IndexOfAny(new char[] { '/', '\\', '~', ':' }) == 0) return null;
180 
181  //throw new Exception("The specified path \"" + path + "\" starts with an invalid character! yrl paths cannot begin with any sort of slash, tilde, or colon!");
182  temp.BaseFile = path.Substring(0, firstdelimiter);
183 
184  string querystring = "";
185  if (firstdelimiter < path.Length) querystring = path.Substring(firstdelimiter, path.Length - firstdelimiter);
186  if (querystring.Length > 0)
187  {
188  string[] pairs = querystring.Split(new char[] { '?', '&' }, StringSplitOptions.RemoveEmptyEntries);
189  foreach (string s in pairs)
190  {
191  string[] namevalue = s.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
192  if (namevalue.Length == 2)
193  {
194  temp.QueryString[HttpUtility.UrlDecode(namevalue[0])] =
195  HttpUtility.UrlDecode(namevalue[1]);
196  }
197  else
198  {
199  //No value, so we set a blank value
200  //Setting a null value would be confusing, as that is how we determine
201  //whether a certain paramater exists
202  temp.QueryString[HttpUtility.UrlDecode(namevalue[0])] = "";
203  //throw new Exception("The specified path \"" + path + "\" contains a query paramater pair \"" + s + "\" that does not parse!");
204  }
205  }
206  }
207  return temp;
208 
209  }
yrl()
Creates a default instance of yrl which points to the application root directory. ...
Definition: yrl.cs:100
static yrl Root
Returns an instance of yrl that points to the application root.
Definition: yrl.cs:780
static string ImageResizer.Util.yrl.GetAppFolderName ( )
inlinestatic

either '/' or '/folder' like '/yf' or sometimes '/folder/folder'

Returns

Definition at line 250 of file yrl.cs.

251  {
252 
253  return HostingEnvironment.ApplicationVirtualPath;
254  }
override int ImageResizer.Util.yrl.GetHashCode ( )
inline

Returns a unique hash code derived from the URL property of this instance

Returns

Definition at line 874 of file yrl.cs.

875  {
876  return URL.ToLower().GetHashCode();
877  }
override int GetHashCode()
Returns a unique hash code derived from the URL property of this instance
Definition: yrl.cs:874
yrl ImageResizer.Util.yrl.GetNextAvailableDerivitive ( )
inline

Returns the next unused filename similar to the current one,by incrementing (i)

Returns

Definition at line 1083 of file yrl.cs.

1084  {
1085  yrl newfilename = this.Copy();
1086  if (newfilename.FileExists)
1087  {
1088 
1089  //This section here just looks for the next unused filname in the form
1090  // oldfilename (1).oldextension
1091  // This way, if the same file is uploaded 5 times it will appear as
1092  // file.txt
1093  // file (1).txt
1094  // file (2).txt
1095  // file (3).txt
1096  // file (4).txt
1097  string minusext = newfilename.Parent.Local +
1098  System.IO.Path.DirectorySeparatorChar +
1099  newfilename.NameWithoutExtension;
1100 
1101  for (int i = 1; i < 100; i++)
1102  {
1103  if (!System.IO.File.Exists(minusext + " (" + i.ToString() + ")" + newfilename.Extension))
1104  {
1105  newfilename = new yrl(minusext + " (" + i.ToString() + ")" + newfilename.Extension);
1106  break;
1107  }
1108  }
1109  }
1110  return newfilename;
1111  }
yrl()
Creates a default instance of yrl which points to the application root directory. ...
Definition: yrl.cs:100
static PathType ImageResizer.Util.yrl.GetPathType ( string  path)
inlinestatic

Returns the type of path

Parameters
path
Returns

Definition at line 362 of file yrl.cs.

363  {
364  if (path == null) return PathType.Invalid;
365  if (path.Trim(new char[] { '\\', '/', '~' }).Length == 0) return PathType.Root;
366  int firstbackslash = path.IndexOf('\\');
367  int firstforwardslash = path.IndexOf('/');
368  int firsttilde = path.IndexOf('~');
369  int firstcolon = path.IndexOf(':');
370  int firstdoubleforwardslash = path.IndexOf("//");
371  if (firstbackslash == 0 && path[1] == '\\')
372  {
373  return PathType.UNCPath;
374  }
375  if (firstbackslash == 0 && firstforwardslash < 0 && firstcolon < 0)
376  {
377  return PathType.BackslashPath;
378  }
379  if (firstcolon == 1 && firstbackslash == 2)
380  {
381  return PathType.DriveletterColonBackslashPath;
382  }
383  if (firstcolon < 0 && firstbackslash > 0 && firstforwardslash < 0)
384  {
385  return PathType.PathBackslashPath;
386  }
387  if (firsttilde == 0 && firstforwardslash == 1)
388  {
389  return PathType.TildeForwardslashPath;
390  }
391  if (firstforwardslash == 0 && firsttilde != 0 && firstdoubleforwardslash < 0)
392  {
393  return PathType.ForwardslashPath;
394  }
395  if (firstcolon > 0 && firstdoubleforwardslash > 0 && firsttilde != 0)
396  {
397  return PathType.ServerForwardslashPath;
398  }
399  if (firsttilde != 0 && firstforwardslash < 0 && firstbackslash < 0 && firstcolon < 0)
400  {
401  return PathType.File;
402  }
403  if (firstforwardslash > 0)
404  {
405  return PathType.PathForwardslashPath;
406  }
407  return PathType.Invalid;
408  }
static bool ImageResizer.Util.yrl.IsNullOrEmpty ( yrl  path)
inlinestatic

Returns true if the yrl is null or empty (site root)

Parameters
path
Returns

Definition at line 1145 of file yrl.cs.

1146  {
1147  if (path == null) return true;
1148  if (path.IsEmpty) return true;
1149  return false;
1150  }
static string ImageResizer.Util.yrl.NavigateUrlEncode ( string  text)
inlinestatic

Parameters
text
Returns

Definition at line 594 of file yrl.cs.

595  {
596 
597  return text.Replace("/", "%2f").Replace("?","%3f").Replace("&","&amp;").Replace(" ","%20");
598  }
override string ImageResizer.Util.yrl.ToString ( )
inline

Returns a site-root-relative path along with query paramaters

Returns

Definition at line 506 of file yrl.cs.

507  {
508  StringBuilder path = new StringBuilder();
509  path.Append(BaseFile);
510  if (QueryString.Count > 0)
511  {
512  path.Append('?');
513  foreach (string key in QueryString.Keys)
514  {
515  string value = QueryString[key];
516 
517  path.Append(HttpUtility.UrlEncode(key));
518  path.Append('=');
519  path.Append(HttpUtility.UrlEncode(value));
520  path.Append('&');
521  }
522  if (path[path.Length - 1] == '&') path.Remove(path.Length - 1, 1);
523  }
524  return path.ToString();
525  }
NameValueCollection QueryString
A collection of name/value query paramaters. Do NOT UrlEncode/Decode these! That step will be done fo...
Definition: yrl.cs:59
string BaseFile
The base file, usually a .aspx page. Ex. &#39;home.aspx&#39; or &#39;admin/new.aspx&#39;. Can also be a base director...
Definition: yrl.cs:55
static string ImageResizer.Util.yrl.TrimStartAppFolder ( string  path)
inlinestatic

Removes the application folder from the specified path. Leaves the leading forwardslash. Assuming the Application path is /yf, this function will transform /yf/home.aspx to /home.aspx and /yf/css/john.css to /css/john.css If the application is located in '/', nothing will be done to the path. Transforms yf/home.aspx to /home.aspx, yf\home.aspx to .aspx, .aspx to .aspx Won't work if the app folder has a child directory named the same!

Parameters
path
Returns

Definition at line 263 of file yrl.cs.

264  {
265  string appfoldername = GetAppFolderName();
266  if (appfoldername.Length <= 1) return path;
267 
268  //Remove /appfolder
269  if (path.StartsWith(appfoldername, StringComparison.InvariantCultureIgnoreCase))
270  return path.Remove(0, appfoldername.Length);
271 
272  //remove apppfolder
273  string appfolderwithoutslash = appfoldername.TrimStart(new char[] { '/' });
274  if (path.StartsWith(appfolderwithoutslash, StringComparison.InvariantCultureIgnoreCase))
275  return path.Remove(0, appfolderwithoutslash.Length);
276 
277  //remove \appfolder
278  string appfolderwithbackslash = appfoldername.Replace('/', '\\');
279  if (path.StartsWith(appfolderwithbackslash, StringComparison.InvariantCultureIgnoreCase))
280  return path.Remove(0, appfolderwithbackslash.Length);
281 
282  //remove ~/appfolder
283  string appfolderwithtilde = '~' + appfoldername;
284  if (path.StartsWith(appfolderwithtilde, StringComparison.InvariantCultureIgnoreCase))
285  return path.Remove(0, appfolderwithtilde.Length);
286  //return result
287  return path;
288  }
static string GetAppFolderName()
either &#39;/&#39; or &#39;/folder&#39; like &#39;/yf&#39; or sometimes &#39;/folder/folder&#39;
Definition: yrl.cs:250

Member Data Documentation

string ImageResizer.Util.yrl.BaseFile = ""

The base file, usually a .aspx page. Ex. 'home.aspx' or 'admin/new.aspx'. Can also be a base directory, such as articles

Definition at line 55 of file yrl.cs.

Referenced by ImageResizer.Util.yrl.Combine().

NameValueCollection ImageResizer.Util.yrl.QueryString = new NameValueCollection()

A collection of name/value query paramaters. Do NOT UrlEncode/Decode these! That step will be done for you.

Definition at line 59 of file yrl.cs.

Property Documentation

yrl ImageResizer.Util.yrl.Current
staticget

Returns the REAL file that is being executed. Falls back to CurrentBrowserUrl if unavailable. Unavailable if UrlRewritingNet isn't in use

Definition at line 810 of file yrl.cs.

yrl ImageResizer.Util.yrl.CurrentBrowserURL
staticget

Retreieves the current URL from HttpContext.Current.Request.Url (pre-rewrite path)

Definition at line 829 of file yrl.cs.

yrl ImageResizer.Util.yrl.Directory
get

Returns the directory portion of this yrl.

Definition at line 763 of file yrl.cs.

bool ImageResizer.Util.yrl.DirExists
get

Returns true if BaseFile exists as a local Directory.

Definition at line 722 of file yrl.cs.

DirectoryInfo ImageResizer.Util.yrl.DirInfo
get

Returns a DirectoryInfo object for BaseFile if it is a directory. If not, it returns the parent directory

Definition at line 732 of file yrl.cs.

string ImageResizer.Util.yrl.Extension
get

Returns the extension of BaseFile in the form '.aspx'

Definition at line 986 of file yrl.cs.

bool ImageResizer.Util.yrl.FileExists
get

Returns true if BaseFile exists as a local file.

Definition at line 711 of file yrl.cs.

Referenced by ImageResizer.Util.yrl.GetNextAvailableDerivitive().

string ImageResizer.Util.yrl.FilenameWithoutIdAndExtension
get

Returns the filename minus path information, extensions, or Article ID.

Definition at line 963 of file yrl.cs.

yrl ImageResizer.Util.yrl.FindAssociatedCodeFile
get

If this is an .aspx file, attempts to find and return an associated .aspx.cs or .aspx.vb file. If this is .aspx.cs or .aspx.vb file, returns the current instance. Otherwise, this returns null;

Definition at line 1049 of file yrl.cs.

yrl ImageResizer.Util.yrl.FindAssociatedMarkupFile
get

If this is .aspx.cs or .aspx.vb file, attempts to find and return the associated .aspx file. If this is a .aspx file, returns the current instance. Otherwise, this returns null;

Definition at line 1027 of file yrl.cs.

int ImageResizer.Util.yrl.FirstID
get

Returns first leading ID found in a segment of the path.

Definition at line 685 of file yrl.cs.

int ImageResizer.Util.yrl.ID
get

Returns the ID if a leading 8-digit ID is found in the base file. Returns -1 otherwise

Definition at line 661 of file yrl.cs.

bool ImageResizer.Util.yrl.IsAspx
get

returns true if BaseFile ends with .aspx

Definition at line 996 of file yrl.cs.

bool ImageResizer.Util.yrl.IsCodeFile
get

returns true if BaseFile ends with .cs or .vb

Definition at line 1014 of file yrl.cs.

bool ImageResizer.Util.yrl.IsEmpty
get

An empty yrl signifies the application root. This verifies both the path and the querystring are empty.

Definition at line 895 of file yrl.cs.

Referenced by ImageResizer.Util.yrl.IsNullOrEmpty().

bool ImageResizer.Util.yrl.IsInRoot
get

Returns true if this path has no parent directory (the parent directory is the root).

Definition at line 917 of file yrl.cs.

bool ImageResizer.Util.yrl.IsRoot
get

Returns true if the basefile is empty (the root) (the QueryString can have data). Use IsEmpty to check that both are empty.

Definition at line 907 of file yrl.cs.

string ImageResizer.Util.yrl.Local
get

Returns the physical filesystem path for this yrl

Returns

Definition at line 532 of file yrl.cs.

Referenced by ImageResizer.Util.yrl.Combine().

string ImageResizer.Util.yrl.Name
get

Returns the name of the directory (like 'archives') if it is one, and the name of the file (like 'universal.css') if it is a file.

Definition at line 929 of file yrl.cs.

string ImageResizer.Util.yrl.NameWithoutExtension
get

Returns the name of BaseFile without the extension.

Definition at line 942 of file yrl.cs.

string ImageResizer.Util.yrl.NavigateURL
get

Returns a ~/ path designed for the Hyperlink.NavigateUrl property

Definition at line 566 of file yrl.cs.

yrl ImageResizer.Util.yrl.Parent
get

Returns a yrl of the parent directory. If the current yrl is already the root, returns null; Use

Definition at line 746 of file yrl.cs.

string ImageResizer.Util.yrl.PrettyTitle
get

Returns the filename without the ID or extension, converts underscores to spaces, and trims the string.

Definition at line 953 of file yrl.cs.

yrl ImageResizer.Util.yrl.QueryDir
getset

yrl.QueryString["dir"]. Returns null if not found, throws exception if not parseable.

Definition at line 453 of file yrl.cs.

int ImageResizer.Util.yrl.QueryFindID
get

Tries to track down the ID by looking at QueryString["id"], then QueryString["path"]. Returns -1 if unsuccessful

Definition at line 470 of file yrl.cs.

int ImageResizer.Util.yrl.QueryID
getset

yrl.QueryString["id"] Returns -1 if not found, -2 if unparseable

Definition at line 417 of file yrl.cs.

yrl ImageResizer.Util.yrl.QueryPath
getset

yrl.QueryString["path"]. Returns null if not found, throws exception if not parseable.

Definition at line 438 of file yrl.cs.

yrl ImageResizer.Util.yrl.Referrer
staticget

Returns null if unavailable

Definition at line 848 of file yrl.cs.

string ImageResizer.Util.yrl.RelativeURL
get

Returns relaitve URL with query paramaters in the form '../articles/00001002 article.aspx'

Definition at line 647 of file yrl.cs.

yrl ImageResizer.Util.yrl.Root
staticget

Returns an instance of yrl that points to the application root.

Definition at line 780 of file yrl.cs.

string ImageResizer.Util.yrl.URL
get

Returns root-relative URL with query paramaters in the form 'articles/00001002 article.aspx'

Definition at line 604 of file yrl.cs.

string ImageResizer.Util.yrl.URLAnchorTarget
get

Returns a domain-relative path in the form '/yf/articles/00001002%20article.aspx'

Definition at line 636 of file yrl.cs.

string ImageResizer.Util.yrl.URLEncoded
get

Returns root-relative URL with query paramaters in the form 'articles/00001002%20article.aspx'

Returns

Definition at line 616 of file yrl.cs.

string ImageResizer.Util.yrl.URLHtmlEncoded
get

Returns root-relative URL with query paramaters in the form 'articles/00001002%20article.aspx'. Encodes special characters into HTML entities using Server.URLPathEncode

Definition at line 625 of file yrl.cs.

string ImageResizer.Util.yrl.Virtual
get

Returns the virtual path(~/...)of the base file without query paramaters.

Definition at line 543 of file yrl.cs.

string ImageResizer.Util.yrl.VirtualURL
get

Returns the virtual path (~/...) of the base file with query paramaters appended.

Definition at line 555 of file yrl.cs.


The documentation for this class was generated from the following file: