I want to define an "IFile" interface that includes an array of key / value metadata pairs. When receiving or installing these key / value pairs, the IFile developer must be able to take action. What would be the best way to do this? I see three methods:
Method 1) Get / Set the dictionary object:
public interface IFile
{
...
Dictionary<String, String> GetMetadata();
void SetMetadata(Dictionary<String, String> metadata);
}
Method 2) Use the dictionary directly:
public interface IFile
{
...
Dictionary Metadata();
}
and in the implementation of IFile, a legacy version of the Dictionary that acts on get / set can be provided.
Method 3) Avoid a complete dictionary and provide your own interface, for example:
public interface IMetadata
{
String GetValue(String key);
void SetValue(String key, String value);
Boolean Contains(String key);
void Delete(String key);
...
}
public interface IFile
{
...
IMetadata Metadata();
}
3, , . . 3, , .
, , , , . , , " " !
,