本文整理汇总了C#中Album.add方法的典型用法代码示例。如果您正苦于以下问题:C# Album.add方法的具体用法?C# Album.add怎么用?C# Album.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album.add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: diffCompareFiles
/// <summary>
/// Compare(Diff) Files
/// </summary>
/// <param name="sourcePath">Source Path</param>
/// <param name="targetPath">Target Path</param>
/// <param name="diffResult">Diff Result to Catch Exception</param>
/// <param name="result">Result Album</param>
private void diffCompareFiles(string sourcePath, string targetPath, DiffResult diffResult, Album result)
{
try
{
// Get the Source Files, Target Files, Source Metadatas:
List<string> sourceFiles = getFilesFromPath(sourcePath); // S
List<string> targetFiles = getFilesFromPath(targetPath); // T
// Check ALL Files:
foreach (string sourceFile in sourceFiles)
{
string targetFile = Album.combinePath(targetPath, getNameFromPath(sourceFile));
// Different Files: Move Source Files to Target Folder
// Move only Photo Files
if ((Video.isVideo(sourceFile) || Photo.isPhoto(sourceFile)) && different(sourceFile, targetFile, targetFiles))
{
//result.add(new Files(sourceFile));
Files tempFile = Files.getFilesObject(sourceFile);
if (tempFile != null)
result.add(tempFile);
}
}
}
catch (Exception e)
{
diffResult.uaeThrown();
}
}
示例2: getSubFoldersForRecursion
/// <summary>
/// Get Sub Folders in the Paths for Recursion
/// </summary>
/// <param name="sourcePath">Source Path</param>
/// <param name="targetPath">Target Path</param>
/// <param name="diffResult">Diff Result for Catching Exception</param>
/// <param name="result">Result Album</param>
/// <param name="recursive">Recurive Stack</param>
private void getSubFoldersForRecursion(string sourcePath, string targetPath, DiffResult diffResult, Album result, Stack<DiffStackContent> recursive)
{
try
{
List<string> sourceFolders = getSubFoldersFromPath(sourcePath);
List<string> targetFolders = getSubFoldersFromPath(targetPath);
// Check ALL Folders: Recursively Check ALL Files Inside
foreach (string sourceFolder in sourceFolders)
{
string targetFolder = Album.combinePath(targetPath, getNameFromPath(sourceFolder));
// If Target Folder Exist: Recursively Check
if (targetFolders.Exists(delegate(string tempPath) { return tempPath.ToUpper() == targetFolder.ToUpper(); }))
{
// Recursion by pushing the folder into stack
DiffStackContent temp = new DiffStackContent();
temp.source = sourceFolder;
temp.target = targetFolder;
recursive.Push(temp);
//result = append(result, compare(sourceFolder, targetFolder));
}
// If Target Folder Doesn't Exist: Add Directly
else
{
result.add(new Album(getNameFromPath(sourceFolder), sourceFolder));
}
}
}
catch (UnauthorizedAccessException uae)
{
// Record:
diffResult.uaeThrown();
}
}
示例3: compareFolders
/// <summary>
/// Folders Comparison of Comparator
/// </summary>
/// <param name="result"></param>
/// <param name="resultAlbum"></param>
/// <param name="recursive"></param>
/// <param name="sourceAlbum"></param>
/// <param name="targetAlbum"></param>
private void compareFolders(SyncResult result, Album[] resultAlbum, Stack<CompareStackContent> recursive, Album sourceAlbum, Album targetAlbum)
{
try
{
/* Get the Necessary Metadata and Folder Info */
List<string> sourceSubFolders = getSubFoldersFromPath(sourceAlbum.getPath());
List<string> targetSubFolders = getSubFoldersFromPath(targetAlbum.getPath());
List<Album> sourceSubAlbums = sourceAlbum.getSubAlbum();
List<Album> targetSubAlbums = targetAlbum.getSubAlbum();
/* Merge into a Single List */
List<string> allSubFolders = mergeLists(sourceAlbum.getPath(), targetAlbum.getPath(),
sourceSubFolders, targetSubFolders,
sourceSubAlbums, targetSubAlbums);
Album newSource, newTarget;
foreach (string subName in allSubFolders)
{
bool SF = isFileExist(subName, sourceSubFolders);
bool TF = isFileExist(subName, targetSubFolders);
bool SA = isFileExist(subName, sourceSubAlbums);
bool TA = isFileExist(subName, targetSubAlbums);
if (SF && SA && TF && TA) // 1111 = 15
{
// ALL EXIST: Recursion
// Get the New Source and Target Album
newSource = getSubAlbum(subName, sourceAlbum);
newTarget = getSubAlbum(subName, targetAlbum);
// Recursion = Push into Stack
CompareStackContent tempStackContent = new CompareStackContent();
tempStackContent.source = newSource;
tempStackContent.target = newTarget;
recursive.Push(tempStackContent);
continue;
}
else if (SF && SA && !TF && TA) // 1101 = 13
{
// TARGET DELETED: Delete Source
newSource = getSubAlbum(subName, sourceAlbum);
targetAlbum.trim(Album.combinePath(targetAlbum.getPath(), subName), Album.TRIM_ALBUM);
resultAlbum[SOURCE_DELETE].add(newSource);
continue;
}
else if (SF && !SA && TF && !TA) // 1010 = 10
{
// CREATE ALBUM METADATA: Recursion
newSource = new Album(Album.combinePath(sourceAlbum.getPath(), subName));
newTarget = new Album(Album.combinePath(targetAlbum.getPath(), subName));
// ADD TO ALBUM
sourceAlbum.add(newSource);
targetAlbum.add(newTarget);
// Recursion = Push into Stack
CompareStackContent tempStackContent = new CompareStackContent();
tempStackContent.source = newSource;
tempStackContent.target = newTarget;
recursive.Push(tempStackContent);
continue;
}
else if (SF && !SA && !TF && !TA) // 1000 = 8
{
try
{
// NEW JOB: Move Source
// POPULATE SA
populate(sourceAlbum, Album.combinePath(sourceAlbum.getPath(), subName));
// COPY ALBUM SA -> TA
populate(targetAlbum, Album.combinePath(targetAlbum.getPath(), subName), sourceAlbum);
newSource = getSubAlbum(subName, sourceAlbum);
resultAlbum[SOURCE_LATEST].add(newSource);
}
catch (UnauthorizedAccessException uae)
{
// IGNORE:
}
continue;
}
else if (!SF && SA && TF && TA) // 0111 = 7
{
// DELETE TF
newTarget = getSubAlbum(subName, targetAlbum);
//.........这里部分代码省略.........
示例4: compareFiles
/// <summary>
/// Files Comparison of Comparator
/// </summary>
/// <param name="result">SyncResult Object to catch Exception Thrown</param>
/// <param name="resultAlbum">Result Album to Store Result</param>
/// <param name="sourceAlbum">Source Album being Compared</param>
/// <param name="targetAlbum">Target Album being Compared</param>
private void compareFiles(SyncResult result, Album[] resultAlbum, Album sourceAlbum, Album targetAlbum)
{
try
{
/* Get the necessary Metadatas and Files (in string) */
List<Files> sourceMetadata = sourceAlbum.getMetadata(); // S'
List<Files> targetMetadata = targetAlbum.getMetadata(); // T'
List<string> sourceFiles = getFilesFromPath(sourceAlbum.getPath()); // S
List<string> targetFiles = getFilesFromPath(targetAlbum.getPath()); // T
/* Merge the Lists into a single List containing all filename (in string) */
List<string> listUnion = mergeLists(sourceAlbum.getPath(), targetAlbum.getPath(),
sourceFiles, targetFiles, sourceMetadata, targetMetadata);
/* Boolean values for Comparison Logic: */
bool sOne; // File exist in S
bool tOne; // File exist in T
bool sTwo; // File exist in S'
bool tTwo; // File exist in T'
bool sS; // S.File == S'.File
bool tT; // T.File == T'.File
bool ST; // S.File == T.File
/* Comparison Logic: */
foreach (string filenames in listUnion)
{
String filename = filenames;
//Console.WriteLine("file: " + filename);
if (filename.Contains(PATH_DELIMITER))
{
filename = filename.Replace(PATH_DELIMITER, "");
}
/* Get the boolean values for the first 4 variables: */
sOne = isFileExist(Album.combinePath(sourceAlbum.getPath(), filename), sourceFiles); // Source FileSystem (S) Exist
tOne = isFileExist(Album.combinePath(targetAlbum.getPath(), filename), targetFiles); // Target FileSystem (T) Exist
sTwo = isFileExist(Album.combinePath(sourceAlbum.getPath(), filename), sourceMetadata); // Source Metadata (S') Exist
tTwo = isFileExist(Album.combinePath(targetAlbum.getPath(), filename), targetMetadata); // Target Metadata (T') Exist
/* Envelope Check: */
// To Check: Use Binary of the form sOne sTwo tOne tTwo
// e.g.: if true true false true -> 1101 = 13
if (sOne && sTwo && tOne && tTwo) // 1111 = 15
{
/* Get boolean for sS tT ST */
Files sourceMTDT = getPhotoFromFilename(sourceMetadata, filename);
Files targetMTDT = getPhotoFromFilename(targetMetadata, filename);
// Use Factory Method Pattern
Files sourceFile = Files.getFilesObject(Album.combinePath(sourceAlbum.getPath(), filename));
Files targetFile = Files.getFilesObject(Album.combinePath(targetAlbum.getPath(), filename));
// Check Files Read and Write Access
if (sourceFile == null || targetFile == null)
continue;
sS = sourceFile.equals(sourceMTDT);
tT = targetFile.equals(targetMTDT);
ST = sourceFile.equals(targetFile);
/* Inner Check: */
if (sS && tT && ST) // 111 = 7
{
// EQUAL: Ignore
continue;
}
else if (sS && tT && !ST) // 110 = 6
{
/* Check for Modification Date and File Size */
checkModificationDate(resultAlbum, sourceFile, targetFile);
continue;
}
else if (sS && !tT && ST) // 101 = 5
{
// UPDATE T'
targetMTDT.update(targetFile);
continue;
}
else if (sS && !tT && !ST) // 100 = 4
{
// TARGET IS NEWER: Add target file to resultAlbum[TARGET_LATEST]
resultAlbum[TARGET_LATEST].add(targetFile);
continue;
}
else if (!sS && tT && ST) // 011 = 3
{
// UPDATE S'
sourceMTDT.update(sourceFile);
continue;
}
else if (!sS && tT && !ST) // 010 = 2
{
//.........这里部分代码省略.........
示例5: append
private Album append(Album original, Album appendix)
{
Album appended = new Album(DIFF_ALBUM_NAME, "");
/* Get Files: */
foreach (Files metadata in original.getMetadata())
{
appended.add(metadata);
}
foreach (Files metadata in appendix.getMetadata())
{
appended.add(metadata);
}
/* Get Sub Folders: */
foreach (Album subAlbum in original.getSubAlbum())
{
appended.add(subAlbum);
}
foreach (Album subAlbum in appendix.getSubAlbum())
{
appended.add(subAlbum);
}
return appended;
}
示例6: populate
private void populate(Album target, string path, Album source)
{
// Prepare the Stack for Recursion:
Stack<PopulateCopyStackContent> recursion = new Stack<PopulateCopyStackContent>();
PopulateCopyStackContent first = new PopulateCopyStackContent();
first.target = target;
first.source = source;
first.path = path;
recursion.Push(first);
do
{
// Get the Content of Stack
PopulateCopyStackContent content = recursion.Pop();
Album targetParent = content.target;
Album sourceParent = content.source;
string targetPath = content.path;
/* Create Album */
Album currTarget = new Album(targetPath);
Album currSource = getSubAlbum(getNameFromPath(targetPath), sourceParent);
/* Copy All the Files Inside */
foreach (Files file in currSource.getMetadata())
{
// (STUB): Expand for Video Files
// Use Factory Method Pattern
// Files temp = new Photo(file.getFullpath());
Files temp = Files.getFilesObject(file.getFullpath());
if (temp != null)
{
temp.setFullpath(Album.combinePath(currTarget.getPath(), temp.getFilename()));
currTarget.add(temp);
}
}
/* Copy All the Albums Inside */
foreach (Album album in currSource.getSubAlbum())
{
Album tempAlbum;
tempAlbum = new Album(album.getAlbumName(), Album.combinePath(targetPath, album.getAlbumName()));
// OLD: populate(currTarget, tempAlbum.getPath(), currSource);
// Recursion: Push into Stack
PopulateCopyStackContent temp = new PopulateCopyStackContent();
temp.target = currTarget;
temp.source = currSource;
temp.path = tempAlbum.getPath();
recursion.Push(temp);
}
targetParent.add(currTarget);
} while (recursion.Count != 0);
}