Wrong scope for my nested classes?
I'm fairly new to C# and programming in general. At work I monitor a very
large list of servers and websites associated with the application running
on the servers. Generally each application has a cluster of servers behind
it and roughly 6-10 different web-pages. So what I did was I created a
Servers class that will take in a server's name(s) and control the urls
that are associated with it. Now here's the part I'm struggling with. Each
url is going to have two values associated with it: the physical url and
the status of the url (online/offline). I came up with two ways of
handling this: either I create a 2D array (or list) OR create a url
subclass. The subclass method seemed like it would be better since I
thought accessing all the methods of the subclass would be easy... Well
right now I can't call them at all outside of the Servers class. This
makes me think I have an issue with the scope of the classes/methods.
Here's my Servers.cs code... What am I doing wrong?
public class Server
{
public List<string> serverNames = new List<string>();
public List<object> urlList = new List<object>();
public string[][] urlArr = new string[1][];
public Server()
{
}
public Server(string nm)
{
serverNames.Add(nm);
}
public void setName(string newName)
{
serverNames.Add(newName);
}
public void addUrl(string newUrl)
{
Server.Url url = new Server.Url(newUrl);
urlList.Add(url);
url.SetStatus(false);
}
protected class Url
{
public string url;
public bool status;
public Url()
{
}
public Url(string URL)
{
url = URL;
}
public void SetStatus(bool stat)
{
status = stat;
}
public bool ReturnStatus()
{
return status;
}
}
}
No comments:
Post a Comment