S
shapper
Hello,
I am trying to create a File Queue class with 5 methods: Add, Remove,
Update, Get and Commit.
Basically Add, Remove and Update do exactly that do the list.
Get finds if there is a file with that file name in the list and
returns its content (Byte[])
Commit calls a FileService to take the actions for all files in the
list.
I am holding the files as follows:
private IDictionary<String, KeyValuePair<String, Byte[]>> _files;
Which means:
private IDictionary<Action, KeyValuePair<Filename, Content>> _files;
Action can be Create, Delete and Update and based on this value a
different method on the service is used.
1. But I think the keys need to be unique so Action will not be.
2. I am also having some problem with Get method.
Anyway, could someone help me out with this?
Maybe I am creating this class in a wrong way?
public class FileQueue {
private String _path;
private IDictionary<String, KeyValuePair<String, Byte[]>> _files;
public FileQueue(String path) {
if (String.IsNullOrEmpty(path))
throw new ArgumentNullException("path", "Path cannot be
null");
_path = path;
} // FileQueue
public void Add(Byte[] content, String filename) {
_files.Add("Create", new KeyValuePair<String, Byte[]>(filename,
content));
} // Add
public void Get(String filename) {
if (_files.Values.Contains ??????
} // Get
public void Remove(String filename) {
_files.Add("Delete", new KeyValuePair<String, Byte[]>(filename,
null));
} // Remove
public void Update(Byte[] content, String filename) {
_files.Add("Update", new KeyValuePair<String, Byte[]>(filename,
content));
} // Update
} // FileQueue
Thank You,
Miguel
I am trying to create a File Queue class with 5 methods: Add, Remove,
Update, Get and Commit.
Basically Add, Remove and Update do exactly that do the list.
Get finds if there is a file with that file name in the list and
returns its content (Byte[])
Commit calls a FileService to take the actions for all files in the
list.
I am holding the files as follows:
private IDictionary<String, KeyValuePair<String, Byte[]>> _files;
Which means:
private IDictionary<Action, KeyValuePair<Filename, Content>> _files;
Action can be Create, Delete and Update and based on this value a
different method on the service is used.
1. But I think the keys need to be unique so Action will not be.
2. I am also having some problem with Get method.
Anyway, could someone help me out with this?
Maybe I am creating this class in a wrong way?
public class FileQueue {
private String _path;
private IDictionary<String, KeyValuePair<String, Byte[]>> _files;
public FileQueue(String path) {
if (String.IsNullOrEmpty(path))
throw new ArgumentNullException("path", "Path cannot be
null");
_path = path;
} // FileQueue
public void Add(Byte[] content, String filename) {
_files.Add("Create", new KeyValuePair<String, Byte[]>(filename,
content));
} // Add
public void Get(String filename) {
if (_files.Values.Contains ??????
} // Get
public void Remove(String filename) {
_files.Add("Delete", new KeyValuePair<String, Byte[]>(filename,
null));
} // Remove
public void Update(Byte[] content, String filename) {
_files.Add("Update", new KeyValuePair<String, Byte[]>(filename,
content));
} // Update
} // FileQueue
Thank You,
Miguel