本文整理汇总了C#中Network类的典型用法代码示例。如果您正苦于以下问题:C# Network类的具体用法?C# Network怎么用?C# Network使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Network类属于命名空间,在下文中一共展示了Network类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrivenNode
public DrivenNode(NodeDefinition nd, Network net, int instnc)
: base(nd, net, instnc)
{
visualNotificationDeferrals = 0;
visualsNeedNotification = false;
handlingLongMessage = false;
}
示例2: GenerateWif
private static string GenerateWif(Key key, string password, Network network)
{
var vch = key.ToBytes();
//Compute the Bitcoin address (ASCII),
var addressBytes = Encoders.ASCII.DecodeData(key.PubKey.GetAddress(network).ToWif());
// and take the first four bytes of SHA256(SHA256()) of it. Let's call this "addresshash".
var addresshash = Hashes.Hash256(addressBytes).ToBytes().SafeSubarray(0, 4);
var derived = SCrypt.BitcoinComputeDerivedKey(Encoding.UTF8.GetBytes(password), addresshash);
var encrypted = EncryptKey(vch, derived);
var version = network.GetVersionBytes(Base58Type.ENCRYPTED_SECRET_KEY_NO_EC);
byte flagByte = 0;
flagByte |= 0x0C0;
flagByte |= (key.IsCompressed ? (byte)0x20 : (byte)0x00);
var bytes = version
.Concat(new[] { flagByte })
.Concat(addresshash)
.Concat(encrypted).ToArray();
return Encoders.Base58Check.EncodeData(bytes);
}
示例3: EdgesTest
public void EdgesTest()
{
Network network = new Network();
NetworkEdge networkEdge;
network.Nodes.Add();
network.Nodes.Add();
Assert.AreEqual(2, network.Nodes.Count);
for (int i = 0; i < 5; i++)
{
networkEdge = network.Edges.Add(network.Nodes[0], network.Nodes[1]);
Assert.IsNotNull(networkEdge);
//Проверим, существует ли другие вершины или дуги с таким же индексом.
CheckNetworkObjectId(networkEdge);
}
Assert.AreEqual(5, network.Edges.Count);
network.Edges.RemoveAt(0);
network.Edges.RemoveAt(1);
Assert.AreEqual(3, network.Edges.Count);
network.Nodes.RemoveAt(0);
Assert.AreEqual(1, network.Nodes.Count);
network.Nodes.Add();
Assert.AreEqual(2, network.Nodes.Count);
networkEdge = network.Edges.Add(network.Nodes[0], network.Nodes[1]);
Assert.IsNotNull(networkEdge);
CheckNetworkObjectId(networkEdge);
}
示例4: NodeServerTester
public NodeServerTester(Network network = null)
{
int retry = 0;
network = network ?? Network.TestNet;
while(true)
{
try
{
var a = _Rand.Next(4000, 60000);
var b = _Rand.Next(4000, 60000);
_Server1 = new NodeServer(network, internalPort: a);
_Server1.AllowLocalPeers = true;
_Server1.ExternalEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1").MapToIPv6Ex(), a);
_Server1.Listen();
_Server2 = new NodeServer(network, internalPort: b);
_Server2.AllowLocalPeers = true;
_Server2.ExternalEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1").MapToIPv6Ex(), b);
_Server2.Listen();
break;
}
catch(Exception)
{
if(_Server1 != null)
_Server1.Dispose();
if(_Server2 != null)
_Server2.Dispose();
retry++;
if(retry == 5)
throw;
}
}
}
示例5: Base58Data
protected Base58Data(byte[] rawBytes, Network network)
{
if(network == null)
throw new ArgumentNullException("network");
_Network = network;
SetData(rawBytes);
}
示例6: BoostCaract
public static void BoostCaract(Network.WorldClient client, int type)
{
Engines.Stats.SingleStats Stat = client.Character.Stats.GetStats(type);
if (client.Character.CaractPoint <= 0)
return;
Database.Records.BreedRecord breed = Helper.BreedHelper.GetBreed(client.Character.Breed);
if (breed == null)
return;
Engines.Breeds.StatFloor floor = breed.Engine.GetFloorForValue((Enums.StatsTypeEnum)type, Stat.Base);
if (floor == null)
return;
if (client.Character.CaractPoint < floor.Cost)
return;
Stat.Base += floor.Value;
client.Character.CaractPoint -= floor.Cost;
if ((Enums.StatsTypeEnum)type == Enums.StatsTypeEnum.Life)
client.Character.CurrentLife += floor.Value;
}
示例7: Bot_OnMessage
void Bot_OnMessage(Network n, Irc.IrcEventArgs e)
{
if (IsMatch("^autoop \\?$", e.Data.Message)) {
AnswerWithNotice(n, e, FormatBold("Use of AutoOp plugin:"));
AnswerWithNotice(n, e, "No remote commands available. All configuration has to be done manually in the Configuration.xml.");
}
}
示例8: Run
public static void Run()
{
var trainingSets = GenerateTrainingSets(100);
Network network;
double error = 0;
do
{
Console.WriteLine("Optimizing...");
network = new Network(trainingSets[0].Inputs.Length, 2, 10, trainingSets[0].Outputs.Length);
network.Weights = BruteOptimizer.OptimizeMulti(network, trainingSets);
error = network.Error(trainingSets, network.Weights);
Console.WriteLine("Error from last optimization attempt: " + error);
} while (error > 3);
Console.WriteLine("Optimization complete!");
while (true)
{
Console.Write("Enter space-separated inputs: ");
var inputs = Console.ReadLine().Split(' ');
if (inputs.Length == 1)
{
break;
}
var inputArray = new double[] { double.Parse(inputs[0].Trim()), double.Parse(inputs[1].Trim()) };
Console.WriteLine(network.Pulse(inputArray)[0]);
}
}
示例9: LightContentDialog
public LightContentDialog(HueLamp light, Network network)
{
this.InitializeComponent();
this.light = light;
this.network = network;
this.DataContext = light;
}
示例10: MainPage
public MainPage()
{
this.InitializeComponent();
Network network = new Network();
var mainViewModel = new MainViewModel();
mainViewModel.MenuItems.Add(new SimpleNavMenuItem
{
Label = "Lights",
DestinationPage = typeof(LightsPage),
Symbol = (Symbol)Convert.ToChar(""),
Arguments = network
});
mainViewModel.MenuItems.Add(new SimpleNavMenuItem
{
Label = "Room",
DestinationPage = typeof(RoomPage),
Symbol = Symbol.Street,
Arguments = network
});
mainViewModel.MenuItems.Add(new SimpleNavMenuItem
{
Label = "Settings",
DestinationPage = typeof(SettingsPage),
Symbol = Symbol.Setting,
Arguments = network
});
DataContext = mainViewModel;
}
示例11: GetWrappedBase58
public static string GetWrappedBase58(string base58, Network network)
{
var coloredVersion = network.GetVersionBytes(Base58Type.COLORED_ADDRESS);
var inner = Encoders.Base58Check.DecodeData(base58);
inner = inner.Skip(coloredVersion.Length).ToArray();
return Encoders.Base58Check.EncodeData(inner);
}
示例12: PrefixForNetwork
public static char PrefixForNetwork(Network network) {
switch(network) {
case Network.Bitcoin:
return '1';
case Network.Testnet:
return '2';
case Network.Friendly:
return 'F';
case Network.Litecoin:
return 'L';
case Network.Namecoin:
return 'N';
case Network.Fairbrix:
return 'f';
case Network.GeistGeld:
return 'g';
case Network.I0coin:
return 'j';
case Network.Solidcoin:
return 's';
case Network.Tenebrix:
return 't';
default:
throw new ArgumentException(String.Format("No known network prefix for network {0}", network));
}
}
示例13: Bot_OnMessage
void Bot_OnMessage(Network network, Irc.IrcEventArgs e)
{
if (IsMatch("^seen \\?$", e.Data.Message)) {
AnswerWithNotice(network, e, FormatBold("Use of Seen plugin:"));
AnswerWithNotice(network, e, FormatItalic("seen <nick>") + " - Displays information when the Bot last saw <nick>.");
}
else if (IsMatch("^seen (?<nick>.*)$", e.Data.Message)) {
SeenInfo i = FindName(network.Name, Matches["nick"].ToString(), l);
if (i == null)
Answer(network, e, "I never saw " + Matches["nick"].ToString() + " before.");
else if (i.Ident == e.Data.Ident)
Answer(network, e, "Looking for yourself, eh?");
else {
string hour = "hours";
string minute = "minutes";
TimeSpan t = (TimeSpan)(DateTime.Now - i.Date);
if (t.TotalHours == 1)
hour = "hour";
if (t.Minutes == 1)
minute = "minute";
Answer(network, e, "I saw " + Matches["nick"].ToString() + " " + Convert.ToInt16(t.TotalHours).ToString() + " " + hour + " and " + t.Minutes.ToString() + " " + minute + " ago, " + i.Text + ".");
}
}
NewSeen(network.Name, e.Data.Nick, e.Data.Ident, "on " + e.Data.Channel + ", saying " + e.Data.Message);
}
示例14: AddRemoveNode
public AddRemoveNode(NodeChangeType nodeChangeType, Node node, Node parent1, Node parent2, List<Node> outputs, Network network)
{
if (node == null)
throw new ArgumentNullException("node");
if (parent1 == null)
throw new ArgumentNullException("parent1");
if (parent2 == null)
throw new ArgumentNullException("parent2");
if (outputs == null)
throw new ArgumentNullException("output");
//if (node == parent1 || node == parent2 || node == outputs || //TODO: FIX THIS checker
// parent1 == parent2 || parent1 == outputs || parent2 == outputs)
// throw new ArgumentException();
nodeChangeType_ = nodeChangeType;
node_ = node;
parent1_ = parent1;
parent2_ = parent2;
outputs_ = outputs;
network_ = network;
// NODE: it is only way I was able to create to make parent 2 children stay in same order after revert
parent2NodeToInsertAfter_ = null;
if (nodeChangeType == NodeChangeType.Remove)
{
LinkedListNode<Node> parent2LinkedListNodeToInsertAfter = parent2_.Outputs.Find(node_).Previous;
if (parent2LinkedListNodeToInsertAfter != null)
{
parent2NodeToInsertAfter_ = parent2_.Outputs.Find(node_).Previous.Value;
}
}
}
示例15: addnetwork_button_Click
protected void addnetwork_button_Click(object sender, EventArgs e)
{
if (addnetwork_name.Text != "" && addnetwork_pattern.Text != "")
{
String name = addnetwork_name.Text;
bool exists = false;
for (int i = 0; i < Results.Items.Count; i++)
{
if(Results.Items[i].Text.Equals(name) ){
exists = true;
break;
}
}
if(exists) {
addnetwork_label.Text = "Network already exists!";
}
else {
Network network = new Network(addnetwork_name.Text.ToString(), addnetwork_pattern.Text.ToString());
Network savedNetwork = NetworkDataService.addNetwork(network);
// Results.Items.Add(new ListItem(savedNetwork.name, savedNetwork.id.ToString()));
addnetwork_label.Text = "Network Added Successfully!";
}
}
else
{
addnetwork_label.Text = "Please fill in both fields";
}
}