public void GenerateBAModelWithAging(int n, int m0, int m, double v) { RunWithProgressBar(() => { var network = _networkGenerator.GenerateBarabasiAlbertModelWithAging(n, m0, m, v); var wrapper = new NetworkWrapper($"BA_{BACounter++}", network, network.GetIncidenceMatrix()); Networks.Add(wrapper); OnNetworkAdd?.Invoke(wrapper); }); }
public void AddNetwork() { var network = new NetworkElement() { Name = "New Server" }; Networks.Add(network); SelectedNetwork = network; }
void FindNetworks() { Dictionary <string, List <Tuple <Wlan.WlanAvailableNetwork, WlanClient.WlanInterface> > > hashedNetworks = new Dictionary <string, List <Tuple <Wlan.WlanAvailableNetwork, WlanClient.WlanInterface> > >(); foreach (WlanClient.WlanInterface wlanIface in WlanClient.Instance.Interfaces) { try { Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList(0); foreach (Wlan.WlanAvailableNetwork network in networks) { string ssid = Helper.GetStringForSSID(network.dot11Ssid); if (!string.IsNullOrEmpty(ssid)) { List <Tuple <Wlan.WlanAvailableNetwork, WlanClient.WlanInterface> > networksForSSID; if (!hashedNetworks.TryGetValue(ssid, out networksForSSID)) { hashedNetworks[ssid] = networksForSSID = new List <Tuple <Wlan.WlanAvailableNetwork, WlanClient.WlanInterface> >(); } networksForSSID.Add(new Tuple <Wlan.WlanAvailableNetwork, WlanClient.WlanInterface>(network, wlanIface)); } } } catch { // the network interface might be disabled - wrapper throws an exception in that case when getting the available networks } } Networks.Clear(); foreach (var ssidNetwork in hashedNetworks.OrderByDescending(hn => hn.Value.Max(n => n.Item1.wlanSignalQuality))) { var networkInfo = ssidNetwork.Value.OrderByDescending(n => n.Item1.wlanSignalQuality).First(); var network = networkInfo.Item1; if (network.networkConnectable) { string readableSSID = Helper.GetStringForSSID(network.dot11Ssid); if (string.IsNullOrWhiteSpace(readableSSID)) { readableSSID = "No SSID"; } ListItem item = new ListItem(Consts.KEY_NAME, readableSSID, false); item.Selected = (network.flags & Wlan.WlanAvailableNetworkFlags.Connected) == Wlan.WlanAvailableNetworkFlags.Connected; item.AdditionalProperties["SignalStrength"] = network.wlanSignalQuality / 100.0f; item.AdditionalProperties["Secure"] = network.securityEnabled; item.AdditionalProperties["HasProfile"] = (network.flags & Wlan.WlanAvailableNetworkFlags.HasProfile) == Wlan.WlanAvailableNetworkFlags.HasProfile; item.AdditionalProperties["Network"] = network; item.AdditionalProperties["Interface"] = networkInfo.Item2; Networks.Add(item); } } Networks.FireChange(); }
private static Network AddNetwork(Network network) { Network existingItem = Networks.FirstOrDefault(x => x.Id == network.Id); if (existingItem != null) { return(existingItem); } Networks.Add(network); return(network); }
public AuthorizedNetworksViewModel(AuthorizedNetworksWindow owner, DatabaseInstance instance) { _owner = owner; foreach (var network in GetAuthorizedNetworks(instance)) { Networks.Add(network); } Result = null; SaveCommand = new ProtectedCommand(OnSaveCommand); AddNetwork = new ProtectedCommand(OnAddNetwork); }
private void AddNetwork(Network network) { DispatchService.Invoke(() => { Networks.Add(network); if (!IsNetworkSelected) { Network = Networks.FirstOrDefault(); } }); }
public void LoadNetwork(string path, int rowsToSkip) { RunWithProgressBar(() => { var(network, incidenceMatrix) = _networkFileLoader.LoadNetwork(path, rowsToSkip); string fileName = Path.GetFileNameWithoutExtension(path); var wrapper = new NetworkWrapper(fileName, network, incidenceMatrix); Networks.Add(wrapper); OnNetworkAdd?.Invoke(wrapper); }); }
public void CreateNetworkFromCommunity(string networkName, string communityName) { var network = GetNetwork(networkName); var community = network.Communities.Single(e => e.Id.ToString() == communityName); // cloning because new nodes must be used var newNetwork = new Network(community.Nodes).Clone(); var newNetworkWrapper = new NetworkWrapper($"{networkName} - {communityName}", newNetwork, newNetwork.GetIncidenceMatrix()); Networks.Add(newNetworkWrapper); OnNetworkAdd?.Invoke(newNetworkWrapper); }
public async Task ScanAsync() { if (WiFiAdapter != null) { await WiFiAdapter.ScanAsync(); ScanTimestamp = WiFiAdapter.NetworkReport.Timestamp.ToString("MM-dd hh:mm:ss"); Networks.Clear(); foreach (var n in WiFiAdapter.NetworkReport.AvailableNetworks) { Networks.Add(n); } } else { throw new InvalidOperationException("Cannot scan WiFi signal without WiFi adapter."); } }
public void AddInstance(NetworkModel nNetworkInstance) { int currentInputsCounts = nNetworkInstance.Layers[0]; int currentOutputsCount = nNetworkInstance.Layers[nNetworkInstance.Layers.Length - 1]; if (!IsStrict) { if (Networks.Count == 0 && StorageConstraints is null) { StorageConstraints = new NetworkStorageConstraints(currentInputsCounts, currentOutputsCount); } if (currentInputsCounts != StorageConstraints.InputsCount || currentOutputsCount != StorageConstraints.OutputsCount) { throw new ArgumentException("Invalid network properties"); } } Networks.Add(nNetworkInstance); OnPropertyChanged(nameof(Networks)); }
public async Task <Networks> GetAllCities() { Networks networks = new Networks(); Dictionary <string, string> test = new Dictionary <string, string>(); dynamic dObj = await CustomHttpRequest.Instance.GetAllNetworksData(); for (int i = 0; i < dObj["networks"].Count; i++) { Network network = new Network(); network.CityNumber = i + 1; if (dObj["networks"][i].company == null) { network.Company = null; } else if (dObj["networks"][i].company.Type.ToString() == "Array") { for (int j = 0; j < dObj["networks"][i].company.Count; j++) { network.Company.Add(dObj["networks"][i].company[j].Value.ToString()); } } else { network.Company.Add(dObj["networks"][i].company.Value.ToString()); } network.Href = dObj["networks"][i].href.Value.ToString(); network.Id = dObj["networks"][i].id.Value.ToString(); network.Name = dObj["networks"][i].name.Value.ToString(); network.Location.City = dObj["networks"][i].location.city.Value.ToString(); network.Location.Latitude = Convert.ToDouble(dObj["networks"][i].location.latitude.Value.ToString()); network.Location.Longitude = Convert.ToDouble(dObj["networks"][i].location.longitude.Value.ToString()); network.Location.Country = dObj["networks"][i].location.country.Value.ToString(); if (test.Keys.ToList().Where(k => k == network.FixedName).Count() == 0) { test.Add(network.FixedName, "a"); networks.Add(network); } } return(networks); }
/// <summary> /// This method initializes the network. /// You can join the network as a node, and contribute to decentralization, or hook yourself to the network as an /// external user. /// To create a node, set the MyAddress parameter with your web address.If MyAddress is not set then you are an external /// user. /// </summary> /// <param name="entryPoints">The list of permanent access points nodes, to access the network</param> /// <param name="networkName">The name of the infrastructure. For tests we recommend using "testnet"</param> /// <param name="myNode">Data related to your node. If you do not want to create the node, omit this parameter</param> public NetworkConnection(IEnumerable <Node> entryPoints, string networkName = "testnet", NodeInitializer myNode = null) : base(myNode?.VirtualDevice) { //if (VirtualDevice != null) //{ // //base = new Device() { VirtualDevice = VirtualDevice }; //} Networks.Add(this); Communication = new Communication(this); Protocol = new Protocol(this); PipelineManager = new PipelineManager(this); MappingNetwork = new MappingNetwork(this); var entry = new List <Node>(entryPoints as Node[] ?? entryPoints.ToArray()); NodeList = new NodeList(this); if (myNode != null) { MyNode = new Node(myNode); MyNode.Ip = VirtualDevice?.Ip ?? MyNode.DetectIp(); var count = entry.Count; entry.RemoveAll(x => x.Address == MyNode.Address || x.Ip == MyNode.Ip); _imEntryPoint = count != entry.Count; ThisNode = new InfoNode(MyNode); NodeList.Add(MyNode); } entry.ForEach(x => x.DetectIp()); NodeList.AddRange(entry); NetworkName = networkName; //Setup.NetworkConnection.MyAddress = MyAddress; //Setup.NetworkConnection.NetworkName = NetworkName; //if (EntryPoints != null) // Setup.NetworkConnection.EntryPoints = EntryPoints; #pragma warning disable CS0618 // 'NetworkConnection.OnReceivesHttpRequest' è obsoleto: 'We recommend using this method from the Device class because each device could handle multiple networks' OnReceivesHttpRequest = base.OnReceivesHttpRequest; //Is ok! Don't worry #pragma warning restore CS0618 // 'NetworkConnection.OnReceivesHttpRequest' è obsoleto: 'We recommend using this method from the Device class because each device could handle multiple networks' OnlineDetection.WaitForInternetConnection(); }
/// <summary> /// Called when the user clicks the Add Authorized Network button. This ensures that the /// IP address entred is valid and an IPv4 address. It then adds the network to the /// current list and resets in the input fields. /// </summary> private void OnAddNetwork() { IPAddress address; if (!IPAddress.TryParse(NetworkValue, out address) || address.AddressFamily != AddressFamily.InterNetwork) { // TODO(talarico): Use form handler to detect errors before the user clicks. UserPromptUtils.ErrorPrompt( Resources.AuthorizedNetworksWindowInvalidCidrFormatErrorMessage, Resources.AuthorizedNetworksWindowInvalidCidrFormatErrorTitle); return; } AclEntry acl = new AclEntry() { Name = NetworkName, Value = NetworkValue }; Networks.Add(new AuthorizedNetworkModel(acl, newNetwork: true)); NetworkValue = ""; NetworkName = ""; }
private void AddNetwork(InProcessNetwork network) { Contract.Requires(!Networks.Contains(network)); Networks.Add(this); }
public void AddObjectsToNetwork(string networkName) { if (Networks.Contains(networkName)) { return; } Networks.Add(networkName); bool addToHash = networkName == Name; // Do we not have a Type cache? if (TypeCache == null) { // Create the type cache, and populate it this time around TypeCache = new List <Type>(); // Get all the currently loaded assemblies Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { // Get the Types in this assembly Type[] types = assembly.Types().ToArray(); foreach (Type type in types) { // If this type a ToffeeStructure? if (type.HasAttribute <ToffeeStructureAttribute>()) { ToffeeStructureAttribute attribute = type.Attribute <ToffeeStructureAttribute>(); if (attribute.NetworkName == networkName) { AddStructure(type, addToHash); } TypeCache.Add(type); } // If this type a ToffeeClass? if (type.HasAttribute <ToffeeClassAttribute>()) { ToffeeClassAttribute attribute = type.Attribute <ToffeeClassAttribute>(); if (attribute.NetworkName == networkName) { AddClass(type, addToHash); } TypeCache.Add(type); } // If this type a ToffeeService? else if (type.HasAttribute <ToffeeServiceAttribute>()) { ToffeeServiceAttribute attribute = type.Attribute <ToffeeServiceAttribute>(); if (attribute.NetworkName == networkName) { AddService(type, addToHash); } TypeCache.Add(type); } } } } else { // We already have a cache of types that are usable to Toffee foreach (Type type in TypeCache) { // If this type a ToffeeStructure? if (type.HasAttribute <ToffeeStructureAttribute>()) { ToffeeStructureAttribute attribute = type.Attribute <ToffeeStructureAttribute>(); if (attribute.NetworkName == networkName) { AddStructure(type, addToHash); } } // If this type a ToffeeClass? if (type.HasAttribute <ToffeeClassAttribute>()) { ToffeeClassAttribute attribute = type.Attribute <ToffeeClassAttribute>(); if (attribute.NetworkName == networkName) { AddClass(type, addToHash); } } // If this type a ToffeeService? else if (type.HasAttribute <ToffeeServiceAttribute>()) { ToffeeServiceAttribute attribute = type.Attribute <ToffeeServiceAttribute>(); if (attribute.NetworkName == networkName) { AddService(type, addToHash); } } } } }