public NetworkInfo Clone() { NetworkInfo clone = new NetworkInfo(); clone.NetworkName = this.NetworkName; foreach (KeyValuePair<string, TrustedNodeInfo> pair in this.TrustedNodes) { // XXX: pair.Value should be cloned too! clone.TrustedNodes.Add(pair.Key, pair.Value); } clone.Memos.AddRange(memos); return clone; }
public NetworkInfo Clone() { NetworkInfo clone = new NetworkInfo(); clone.NetworkName = this.NetworkName; foreach (KeyValuePair <string, TrustedNodeInfo> pair in this.TrustedNodes) { // XXX: pair.Value should be cloned too! clone.TrustedNodes.Add(pair.Key, pair.Value); } clone.Memos.AddRange(memos); return(clone); }
public SettingsCreator(string fileName) { // Create settings file Settings settings = new Settings (); settings.FileName = fileName; Console.Write("NickName = "); settings.NickName = Console.ReadLine(); Console.Write("\nReal Name = "); settings.RealName = Console.ReadLine(); Console.Write("\nGenerating keypair...."); System.Security.Cryptography.RSACryptoServiceProvider newKey; newKey = new System.Security.Cryptography.RSACryptoServiceProvider (2048); settings.SetKey(newKey.ToXmlString(true)); Console.Write("Done!\n\nNow you need to define a network.\n\n"); NetworkInfo networkInfo = new NetworkInfo(); Console.Write("Network Name = "); networkInfo.NetworkName = Console.ReadLine(); settings.Networks.Add(networkInfo); Console.WriteLine("All done, saving settings now!"); if (fileName.IndexOf(Path.DirectorySeparatorChar) > -1) { settings.DataPath = fileName.Substring(0, fileName.LastIndexOf(Path.DirectorySeparatorChar)); } else { settings.DataPath = Environment.CurrentDirectory; } settings.SaveSettings(); Console.WriteLine("WARNING: The first person who connects to me will become the admin!"); }
private static void AddNetwork(NetworkInfo networkInfo) { foreach (Network thisNetwork in networks) { if (thisNetwork.NetworkID == networkInfo.NetworkID) { throw new Exception("That network has already been added."); } } Network network = Network.FromNetworkInfo(networkInfo); networks.Add(network); /* if (!fileSystem.RootDirectory.HasSubdirectory(network.NetworkID)) { Directory directory = fileSystem.RootDirectory.CreateSubdirectory(network.NetworkID); directory.Requested = true; } */ if (NetworkAdded != null) { NetworkAdded (network); } network.Start (); }
internal static Network FromNetworkInfo(NetworkInfo networkInfo) { Network network = new Network (networkInfo.NetworkName); foreach (TrustedNodeInfo node in networkInfo.TrustedNodes.Values) { network.AddTrustedNode(node); } foreach (MemoInfo m in networkInfo.Memos) { var memoInfo = m; memoInfo.FromNodeID = Core.MyNodeID; network.PostMemo(new Memo(network, memoInfo)); } return network; }