This repository has been archived by the owner on Mar 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completed API change to support Locations
- Loading branch information
Scott Muc
committed
Aug 26, 2009
1 parent
c85ad7d
commit af02288
Showing
12 changed files
with
117 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.IO; | ||
|
||
namespace Secretary | ||
{ | ||
public class LocalLocation : Location | ||
{ | ||
|
||
public override IFile CreateFileInstance(string basePath, string fileName) | ||
{ | ||
var fullPath = Combine(basePath, fileName); | ||
return new LocalFileReference(fullPath); | ||
} | ||
|
||
public override IFolder CreateFolderInstance(string basePath) | ||
{ | ||
return new LocalFolderReference(basePath); | ||
} | ||
|
||
public override string Combine(string firstPart, string secondPart) | ||
{ | ||
return Path.Combine(firstPart, secondPart); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,12 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace Secretary | ||
{ | ||
public class Location | ||
public abstract class Location | ||
{ | ||
public static readonly Location Web = new Location("Web", | ||
(basePath, fileName) => | ||
{ | ||
var fullPath = basePath + "/" + fileName; | ||
return new HttpFileReference(fullPath); | ||
}, | ||
basePath => new HttpFolderReference(basePath) | ||
); | ||
|
||
public static readonly Location Local = new Location("Local", | ||
(basePath, fileName) => | ||
{ | ||
var fullPath = Path.Combine(basePath, fileName); | ||
return new LocalFileReference(fullPath); | ||
}, | ||
basePath => new LocalFolderReference(basePath) | ||
); | ||
|
||
|
||
public Location(string name, Func<string, string, IFile> fileFactoryMethod, Func<string, IFolder> folderFactoryMethod) | ||
{ | ||
Name = name; | ||
CreateFileInstance = fileFactoryMethod; | ||
CreateFolderInstance = folderFactoryMethod; | ||
} | ||
|
||
public Func<string, string, IFile> CreateFileInstance; | ||
public Func<string, IFolder> CreateFolderInstance; | ||
|
||
public string Name { get; private set; } | ||
public static readonly Location Web = new WebLocation(); | ||
public static readonly Location Local = new LocalLocation(); | ||
|
||
public override string ToString() | ||
{ | ||
return "Location." + Name; | ||
} | ||
public abstract IFile CreateFileInstance(string basePath, string fileName); | ||
public abstract IFolder CreateFolderInstance(string basePath); | ||
public abstract string Combine(string firstPart, string secondPart); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Secretary | ||
{ | ||
public class WebLocation : Location | ||
{ | ||
public override IFile CreateFileInstance(string basePath, string fileName) | ||
{ | ||
var fullPath = Combine(basePath, fileName); | ||
return new HttpFileReference(fullPath); | ||
} | ||
|
||
public override IFolder CreateFolderInstance(string basePath) | ||
{ | ||
return new HttpFolderReference(basePath); | ||
} | ||
|
||
public override string Combine(string firstPart, string secondPart) | ||
{ | ||
return firstPart.TrimEnd('/') + "/" + secondPart.TrimStart('/'); | ||
} | ||
} | ||
} |