I suggest something like this:
public abstract class DataSeed {
// const, but can be used in any descendant class
protected const String DRIVE = "http://mydriveurl";
// _context ... should not be initialize again after it (constructor)
protected Context Context {
get; // in case of C# 6.0+ we can drop the set
}
// _context should be initialized in the derived class constructor
protected DataSeed(Context context) {
if (null == context)
throw new ArgumentNullException("context",
"context should be initialized in the derived class constructor");
// C# 6.0+ feature: assigning to read only property within a costructor
Context = context;
}
// _languages is a list that cannot be changed:
// if you insist on list, IReadOnlyList<string> is a possible choice
// if "cannot be changed" dominates - IReadOnlyCollection<string>
// static: it seems that you don't want to have _languages per each instance
protected static readonly IReadOnlyCollection<String> _languages =
new List<String> { "en", "fr" }.AsReadOnly();
}
Edit: in case of C# 5.0- as Abion47 pointeed out in the comments we can ensure that _context
can't be assigned but in the constructor with a help of readonly
// _context ... should not be initialize again after it (constructor)
private readonly Context _context;
protected Context Context {
get {
return _context;
}
}
// _context should be initialized in the derived class constructor
protected DataSeed(Context context) {
if (null == context)
throw new ArgumentNullException("context",
"context should be initialized in the derived class constructor");
// assigning to read only field within a costructor
_context = context;
}