public static void Main(string[] args) { NumberList<int> itemList = new NumberList<int>(); itemList.insertItem (1); itemList.insertItem (2); itemList.insertItem (3); itemList.insertItem (4); itemList.insertItem (5); itemList.insertItem (6); itemList.insertItem (7); Console.WriteLine(itemList.Count); if (itemList.containsItem (1)) { itemList.deleteitem (1); } Console.WriteLine(itemList.Count); itemList.clearAllItems (); Console.WriteLine(itemList.Count); }
private string FormatNumberList(NumberList comment) { return formatInlineList(comment.Items, "<ol>{0}</ol>", "<li>{0}{1}</li>", "{0}", "{0}"); }
private NumberList CreateNumberList(JToken item) { IEnumerable<decimal> values = item["values"].Select(p => (decimal)p); var result = new NumberList(values.Cast<object>().ToList()); result.DebugInfo = GetDebugInfo(item); return result; }
/// <summary> /// Load the specified Encog object from an XML reader. /// </summary> /// <param name="xmlIn">The XML reader to use.</param> /// <returns>The loaded object.</returns> public IEncogPersistedObject Load(ReadXML xmlIn) { int neuronCount = 0; int x = 0; int y = 0; String threshold = null; IActivationFunction activation = null; String end = xmlIn.LastTag.Name; double biasActivation = 1; while (xmlIn.ReadToTag()) { if (xmlIn.IsIt(BasicLayerPersistor.TAG_ACTIVATION, true)) { xmlIn.ReadToTag(); String type = xmlIn.LastTag.Name; activation = LoadActivation(type, xmlIn); } else if (xmlIn.IsIt(BasicLayerPersistor.PROPERTY_NEURONS, true)) { neuronCount = xmlIn.ReadIntToTag(); } else if (xmlIn.IsIt(BasicLayerPersistor.PROPERTY_THRESHOLD, true)) { threshold = xmlIn.ReadTextToTag(); } else if (xmlIn.IsIt(BasicLayerPersistor.PROPERTY_X, true)) { x = xmlIn.ReadIntToTag(); } else if (xmlIn.IsIt(BasicLayerPersistor.PROPERTY_Y, true)) { y = xmlIn.ReadIntToTag(); } else if (xmlIn.IsIt(BasicLayerPersistor.PROPERTY_BIAS_ACTIVATION, true)) { biasActivation = double.Parse(xmlIn.ReadTextToTag()); } else if (xmlIn.IsIt(end, false)) { break; } } if (neuronCount > 0) { BasicLayer layer; if (threshold == null) { layer = new BasicLayer(activation, false, neuronCount); } else { double[] t = NumberList.FromList(CSVFormat.EG_FORMAT, threshold); layer = new BasicLayer(activation, true, neuronCount); for (int i = 0; i < t.Length; i++) { layer.BiasWeights[i] = t[i]; } } layer.X = x; layer.Y = y; layer.BiasActivation = biasActivation; return(layer); } return(null); }
public void IsFilter_OutPutsListContainsAString() { Assert.AreEqual("ping-pong", NumberList.Filter(5)); }
public void Filter_ReturnsAstringOfInt() { Assert.AreEqual("10", NumberList.Filter(10)); }
string FormatNumberList(NumberList comment) { return(formatInlineList(comment.Items, "<ol>{0}</ol>", "<li>{0}{1}</li>", "{0}", "{0}")); }
static void HandleElapsed(object sender, System.Timers.ElapsedEventArgs e) { System.Collections.Generic.Dictionary <string, string> dConfig = new System.Collections.Generic.Dictionary <string, string> (); if (!System.IO.Directory.Exists("dyndata")) { System.IO.Directory.CreateDirectory("dyndata"); } bool Enable = false; string ConnectionStatus = "Unbekannt"; string PossibleConnectionTypes = "Unbekannt"; string ConnectionType = "Unbekannt"; string Name = "Unbekannt"; uint Uptime = 0; uint UpstreamMaxBitRate = 0; uint DownstreamMaxBitRate = 0; string LastConnectionError = ""; uint IdleDisconnectTime = 0; bool RSIPAvailable = false; string UserName = "******"; bool NATEnabled = false; string ExternalIPAddress = "0.0.0.0"; string DNSServers = "0.0.0.0"; string MACAddress = "::::"; string ConnectionTrigger = "Unbekannt"; string LastAuthErrorInfo = ""; ushort MaxCharsUsername = 0; ushort MinCharsUsername = 0; string AllowedCharsUsername = "******"; ushort MaxCharsPassword = 0; ushort MinCharsPassword = 0; string AllowedCharsPassword = "******"; string TransportType = "Unbekannt"; string RouteProtocolRx = "Unbekannt"; string PPPoEServiceName = "Unbekannt"; string RemoteIPAddress = "0.0.0.0"; string PPPoEACName = "Unbekannt"; bool DNSEnabled = false; bool DNSOverrideAllowed = false; try { Wanpppconn1 service = new Wanpppconn1("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]); service.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]); service.GetInfo(out Enable, out ConnectionStatus, out PossibleConnectionTypes, out ConnectionType, out Name, out Uptime, out UpstreamMaxBitRate, out DownstreamMaxBitRate, out LastConnectionError, out IdleDisconnectTime, out RSIPAvailable, out UserName, out NATEnabled, out ExternalIPAddress, out DNSServers, out MACAddress, out ConnectionTrigger, out LastAuthErrorInfo, out MaxCharsUsername, out MinCharsUsername, out AllowedCharsUsername, out MaxCharsPassword, out MinCharsPassword, out AllowedCharsPassword, out TransportType, out RouteProtocolRx, out PPPoEServiceName, out RemoteIPAddress, out PPPoEACName, out DNSEnabled, out DNSOverrideAllowed); dConfig.Clear(); dConfig.Add("Enable", Enable.ToString()); dConfig.Add("ConnectionStatus", ConnectionStatus.ToString()); dConfig.Add("PossibleConnectionTypes", PossibleConnectionTypes.ToString()); dConfig.Add("ConnectionType", ConnectionType.ToString()); dConfig.Add("Name", Name.ToString()); dConfig.Add("Uptime", System.DateTime.Now.AddSeconds(Uptime).ToString()); dConfig.Add("UpstreamMaxBitRate", UpstreamMaxBitRate.ToString()); dConfig.Add("DownstreamMaxBitRate", DownstreamMaxBitRate.ToString()); dConfig.Add("LastConnectionError", LastConnectionError.ToString()); dConfig.Add("IdleDisconnectTime", IdleDisconnectTime.ToString()); dConfig.Add("RSIPAvailable", RSIPAvailable.ToString()); dConfig.Add("UserName", UserName.ToString()); dConfig.Add("NATEnabled", NATEnabled.ToString()); dConfig.Add("ExternalIPAddress", ExternalIPAddress.ToString()); dConfig.Add("DNSServers", DNSServers.ToString()); dConfig.Add("MACAddress", MACAddress.ToString()); dConfig.Add("ConnectionTrigger", ConnectionTrigger.ToString()); dConfig.Add("LastAuthErrorInfo", LastAuthErrorInfo.ToString()); dConfig.Add("MaxCharsUsername", MaxCharsUsername.ToString()); dConfig.Add("MinCharsUsername", MinCharsUsername.ToString()); dConfig.Add("AllowedCharsUsername", AllowedCharsUsername.ToString()); dConfig.Add("MaxCharsPassword", MaxCharsPassword.ToString()); dConfig.Add("MinCharsPassword", MinCharsPassword.ToString()); dConfig.Add("AllowedCharsPassword", AllowedCharsPassword.ToString()); dConfig.Add("TransportType", TransportType.ToString()); dConfig.Add("RouteProtocolRx", RouteProtocolRx.ToString()); dConfig.Add("PPPoEServiceName", PPPoEServiceName.ToString()); dConfig.Add("RemoteIPAddress", RemoteIPAddress.ToString()); dConfig.Add("PPPoEACName", PPPoEACName.ToString()); dConfig.Add("DNSEnabled", DNSEnabled.ToString()); dConfig.Add("DNSOverrideAllowed", DNSOverrideAllowed.ToString()); FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/wanppp.info"); } catch (Exception ex) { FeuerwehrCloud.Helper.Logger.WriteLine(FeuerwehrCloud.Helper.Helper.GetExceptionDescription(ex)); } System.Net.WebClient WC = new WebClient(); FritzTR064.Generated.Tam cTam = new Tam("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]); cTam.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]); string TamList; for (ushort i = 0; i < 5; i++) { ushort Index; bool abEnable; string abName; bool TAMRunning; ushort Stick; ushort Status; cTam.GetInfo(i, out abEnable, out abName, out TAMRunning, out Stick, out Status); dConfig.Clear(); dConfig.Add("Enable", abEnable.ToString()); dConfig.Add("Name", abName.ToString()); dConfig.Add("TAMRunning", TAMRunning.ToString()); dConfig.Add("Stick", Stick.ToString()); dConfig.Add("Status", Status.ToString()); if (abEnable == true) { cTam.GetMessageList(i, out TamList); WC.Credentials = cTam.SoapHttpClientProtocol.Credentials; WC.DownloadFile(TamList, "dyndata/tam" + i.ToString() + ".xml"); } FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/tam.info"); } FritzTR064.Generated.Contact c = new Contact("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]); c.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]); string calllist; string DectIDList; string HandsetName; ushort PhonebookID; bool cEnable; string cStatus; string LastConnect; string Url; string ServiceId; string Username; dConfig.Clear(); c.GetCallList(out calllist); WC.Credentials = c.SoapHttpClientProtocol.Credentials; WC.DownloadFile(calllist, "dyndata/calllist.xml"); try { c.GetInfo(out cEnable, out cStatus, out LastConnect, out Url, out ServiceId, out UserName, out Name); dConfig.Add("Enable", cEnable.ToString()); dConfig.Add("Status", cStatus.ToString()); dConfig.Add("LastConnect", LastConnect.ToString()); dConfig.Add("Url", Url.ToString()); dConfig.Add("ServiceId", ServiceId.ToString()); dConfig.Add("Name", Name.ToString()); if (cEnable) { c.GetDECTHandsetList(out DectIDList); for (ushort DectID = 1; DectID < 10; DectID++) { c.GetDECTHandsetInfo(DectID, out HandsetName, out PhonebookID); dConfig.Add("DectID", DectID.ToString()); dConfig.Add("HandsetName-" + DectID.ToString(), HandsetName.ToString()); dConfig.Add("PhonebookID-" + DectID.ToString(), PhonebookID.ToString()); } } // c.GetInfoByIndex(); // c.GetNumberOfEntries(); // c.GetPhonebook(); // c.GetPhonebookList(); } catch (Exception ex) { FeuerwehrCloud.Helper.Logger.WriteLine(FeuerwehrCloud.Helper.Helper.GetExceptionDescription(ex)); } FritzTR064.Generated.Wandslifconfig1 w1 = new Wandslifconfig1("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]); w1.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]); //FritzTR064.Generated.Wandsllinkconfig1 w2 = new Wandsllinkconfig1(()); bool wandslIFEnable; string dslStatus; string DataPath; uint UpstreamCurrRate; uint DownstreamCurrRate; uint UpstreamMaxRate; uint DownstreamMaxRate; uint UpstreamNoiseMargin; uint DownstreamNoiseMargin; uint UpstreamAttenuation; uint DownstreamAttenuation; string ATURVendor; string ATURCountry; ushort UpstreamPower; ushort DownstreamPower; w1.GetInfo(out wandslIFEnable, out dslStatus, out DataPath, out UpstreamCurrRate, out DownstreamCurrRate, out UpstreamMaxRate, out DownstreamMaxRate, out UpstreamNoiseMargin, out DownstreamNoiseMargin, out UpstreamAttenuation, out DownstreamAttenuation, out ATURVendor, out ATURCountry, out UpstreamPower, out DownstreamPower); dConfig.Clear(); dConfig.Add("wandslIFEnable", wandslIFEnable.ToString()); dConfig.Add("Status", dslStatus.ToString()); dConfig.Add("DataPath", DataPath.ToString()); dConfig.Add("UpstreamCurrRate", UpstreamCurrRate.ToString()); dConfig.Add("DownstreamCurrRate", DownstreamCurrRate.ToString()); dConfig.Add("UpstreamMaxRate", UpstreamMaxRate.ToString()); dConfig.Add("DownstreamMaxRate", DownstreamMaxRate.ToString()); dConfig.Add("UpstreamNoiseMargin", UpstreamNoiseMargin.ToString()); dConfig.Add("DownstreamNoiseMargin", DownstreamNoiseMargin.ToString()); dConfig.Add("UpstreamAttenuation", UpstreamAttenuation.ToString()); dConfig.Add("DownstreamAttenuation", DownstreamAttenuation.ToString()); dConfig.Add("ATURVendor", ATURVendor.ToString()); dConfig.Add("ATURCountry", ATURCountry.ToString()); dConfig.Add("UpstreamPower", UpstreamPower.ToString()); dConfig.Add("DownstreamPower", DownstreamPower.ToString()); FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/wandsl.info"); FritzTR064.Generated.Wlanconfig1 wlc = new Wlanconfig1("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]); wlc.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]); string wlStatus; bool wlEnable; string MaxBitRate; byte Channel; string SSID; string BeaconType; bool MACAddressControlEnabled; string Standard; string BSSID; string BasicEncryptionModes; string BasicAuthenticationMode; byte MaxCharsSSID; byte MinCharsSSID; string AllowedCharsSSID; byte MinCharsPSK; byte MaxCharsPSK; string AllowedCharsPSK; wlc.GetInfo(out wlEnable, out wlStatus, out MaxBitRate, out Channel, out SSID, out BeaconType, out MACAddressControlEnabled, out Standard, out BSSID, out BasicEncryptionModes, out BasicAuthenticationMode, out MaxCharsSSID, out MinCharsSSID, out AllowedCharsSSID, out MinCharsPSK, out MaxCharsPSK, out AllowedCharsPSK); dConfig.Clear(); dConfig.Add("Enable", wlEnable.ToString()); dConfig.Add("Status", wlStatus.ToString()); dConfig.Add("MaxBitRate", MaxBitRate.ToString()); dConfig.Add("Channel", Channel.ToString()); dConfig.Add("SSID", SSID.ToString()); dConfig.Add("BeaconType", BeaconType.ToString()); dConfig.Add("MACAddressControlEnabled", MACAddressControlEnabled.ToString()); dConfig.Add("Standard", Standard.ToString()); dConfig.Add("BSSID", BSSID.ToString()); dConfig.Add("BasicEncryptionModes", BasicEncryptionModes.ToString()); dConfig.Add("BasicAuthenticationMode", BasicAuthenticationMode.ToString()); dConfig.Add("MaxCharsSSID", MaxCharsSSID.ToString()); dConfig.Add("MinCharsSSID", MinCharsSSID.ToString()); dConfig.Add("AllowedCharsSSID", AllowedCharsSSID.ToString()); dConfig.Add("MinCharsPSK", MinCharsPSK.ToString()); dConfig.Add("MaxCharsPSK", MaxCharsPSK.ToString()); dConfig.Add("AllowedCharsPSK", AllowedCharsPSK.ToString()); FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/wlan.info"); FritzTR064.Generated.Voip voip1 = new Voip("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]); voip1.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]); string NumberList; bool FaxT38Enable; string VoiceCoding; string ClientList; ushort ExistingVoIPNumbers; string PhoneName; uint NumberOfNumbers; ushort NumberOfClients; ushort MaxVoipNumbers; voip1.GetInfo(out FaxT38Enable, out VoiceCoding); voip1.GetClients(out ClientList); voip1.GetExistingVoIPNumbers(out ExistingVoIPNumbers); voip1.DialGetConfig(out PhoneName); voip1.GetNumbers(out NumberList); voip1.GetNumberOfNumbers(out NumberOfNumbers); voip1.GetNumberOfClients(out NumberOfClients); voip1.GetMaxVoIPNumbers(out MaxVoipNumbers); dConfig.Clear(); dConfig.Add("NumberList", NumberList.ToString()); dConfig.Add("FaxT38Enable", FaxT38Enable.ToString()); dConfig.Add("VoiceCoding", VoiceCoding.ToString()); dConfig.Add("ClientList", ClientList.ToString()); dConfig.Add("ExistingVoIPNumbers", ExistingVoIPNumbers.ToString()); dConfig.Add("PhoneName", PhoneName.ToString()); dConfig.Add("NumberOfNumbers", NumberOfNumbers.ToString()); dConfig.Add("NumberOfClients", NumberOfClients.ToString()); dConfig.Add("MaxVoipNumbers", MaxVoipNumbers.ToString()); FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/phone.info"); string ManufacturerName; string ManufacturerOUI; string ModelName; string Description; string ProductClass; string SerialNumber; string SoftwareVersion; string HardwareVersion; string SpecVersion; string ProvisioningCode; uint UpTime; string DeviceLog; FritzTR064.Generated.Deviceinfo DevInfo = new Deviceinfo("https://" + NetConfig["Gateway"] + ":" + NetConfig["GW-SSL-Port"]); DevInfo.SoapHttpClientProtocol.Credentials = new NetworkCredential(NetConfig["TR064-Username"], NetConfig["FRITZPass"]); DevInfo.GetInfo(out ManufacturerName, out ManufacturerOUI, out ModelName, out Description, out ProductClass, out SerialNumber, out SoftwareVersion, out HardwareVersion, out SpecVersion, out ProvisioningCode, out UpTime, out DeviceLog); dConfig.Clear(); dConfig.Add("ManufacturerName", ManufacturerName.ToString()); dConfig.Add("ManufacturerOUI", ManufacturerOUI.ToString()); dConfig.Add("ModelName", ModelName.ToString()); dConfig.Add("Description", Description.ToString()); dConfig.Add("ProductClass", ProductClass.ToString()); dConfig.Add("SerialNumber", SerialNumber.ToString()); dConfig.Add("SoftwareVersion", SoftwareVersion.ToString()); dConfig.Add("HardwareVersion", HardwareVersion.ToString()); dConfig.Add("SpecVersion", SpecVersion.ToString()); dConfig.Add("ProvisioningCode", ProvisioningCode.ToString()); dConfig.Add("UpTime", UpTime.ToString()); dConfig.Add("DeviceLog", DeviceLog.ToString()); FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/DeviceInfo.info"); //FritzTR064.Generated.Contact //dConfig.Add("",xxxxxx.ToString()); System.Diagnostics.Process P; P = new System.Diagnostics.Process() { StartInfo = { FileName = NetConfig ["fing"], Arguments = " -n " + NetConfig ["Gateway"] + "/24 -r 1 --session " + System.IO.Path.Combine(System.Environment.CurrentDirectory, "network.fing") + " -o table,csv," + System.IO.Path.Combine(System.Environment.CurrentDirectory, "network.csv"), UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true } }; P.Start(); P.WaitForExit(10000); P = new System.Diagnostics.Process() { StartInfo = { FileName = "/usr/local/bin/lsusb", WorkingDirectory = "/tmp/", UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true } }; P.Start(); string lsusb = P.StandardOutput.ReadToEnd(); int USBCount = lsusb.Split(new [] { "\n" }, StringSplitOptions.RemoveEmptyEntries).Length; P.WaitForExit(10000); dConfig.Clear(); dConfig.Add("Count", USBCount.ToString()); FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/usb.info"); P = new System.Diagnostics.Process() { StartInfo = { FileName = "/Users/systemiya-apple/i2cdetect.sh", WorkingDirectory = "/tmp/", UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true } }; P.Start(); string lsi2c = P.StandardOutput.ReadToEnd(); P.WaitForExit(10000); dConfig.Clear(); string[] i2C = lsi2c.Split(new [] { "--" }, StringSplitOptions.RemoveEmptyEntries); int I2Ccount = 116 - (i2C.Length - 2); dConfig.Add("Count", I2Ccount.ToString()); FeuerwehrCloud.Helper.AppSettings.Save(dConfig, "dyndata/i2c.info"); }
/// <summary> /// Create a LMA trainer. /// </summary> /// /// <param name="method">The method to use.</param> /// <param name="training">The training data to use.</param> /// <param name="argsStr">The arguments to use.</param> /// <returns>The newly created trainer.</returns> public IMLTrain Create(IMLMethod method, IMLDataSet training, String argsStr) { if (!(method is SOMNetwork)) { throw new EncogError( "Neighborhood training cannot be used on a method of type: " + method.GetType().FullName); } IDictionary <String, String> args = ArchitectureParse.ParseParams(argsStr); var holder = new ParamsHolder(args); double learningRate = holder.GetDouble( MLTrainFactory.PropertyLearningRate, false, 0.7d); String neighborhoodStr = holder.GetString( MLTrainFactory.PropertyNeighborhood, false, "rbf"); String rbfTypeStr = holder.GetString( MLTrainFactory.PropertyRBFType, false, "gaussian"); RBFEnum t; if (rbfTypeStr.Equals("Gaussian", StringComparison.InvariantCultureIgnoreCase)) { t = RBFEnum.Gaussian; } else if (rbfTypeStr.Equals("Multiquadric", StringComparison.InvariantCultureIgnoreCase)) { t = RBFEnum.Multiquadric; } else if (rbfTypeStr.Equals("InverseMultiquadric", StringComparison.InvariantCultureIgnoreCase)) { t = RBFEnum.InverseMultiquadric; } else if (rbfTypeStr.Equals("MexicanHat", StringComparison.InvariantCultureIgnoreCase)) { t = RBFEnum.MexicanHat; } else { t = RBFEnum.Gaussian; } INeighborhoodFunction nf = null; if (neighborhoodStr.Equals("bubble", StringComparison.InvariantCultureIgnoreCase)) { nf = new NeighborhoodBubble(1); } else if (neighborhoodStr.Equals("rbf", StringComparison.InvariantCultureIgnoreCase)) { String str = holder.GetString( MLTrainFactory.PropertyDimensions, true, null); int[] size = NumberList.FromListInt(CSVFormat.EgFormat, str); nf = new NeighborhoodRBF(size, t); } else if (neighborhoodStr.Equals("rbf1d", StringComparison.InvariantCultureIgnoreCase)) { nf = new NeighborhoodRBF1D(t); } if (neighborhoodStr.Equals("single", StringComparison.InvariantCultureIgnoreCase)) { nf = new NeighborhoodSingle(); } var result = new BasicTrainSOM((SOMNetwork)method, learningRate, training, nf); if (args.ContainsKey(MLTrainFactory.PropertyIterations)) { int plannedIterations = holder.GetInt( MLTrainFactory.PropertyIterations, false, 1000); double startRate = holder.GetDouble( MLTrainFactory.PropertyStartLearningRate, false, 0.05d); double endRate = holder.GetDouble( MLTrainFactory.PropertyEndLearningRate, false, 0.05d); double startRadius = holder.GetDouble( MLTrainFactory.PropertyStartRadius, false, 10); double endRadius = holder.GetDouble( MLTrainFactory.PropertyEndRadius, false, 1); result.SetAutoDecay(plannedIterations, startRate, endRate, startRadius, endRadius); } return(result); }
public override double Add(string stringNumberInput) { if (string.IsNullOrEmpty(stringNumberInput)) { return(0); } stringNumberInput = PrepInputString(stringNumberInput); NumberString = stringNumberInput; int splitter; if (stringNumberInput.StartsWith(CustomDelimiterIdentifier)) { splitter = stringNumberInput.IndexOf("\n", StringComparison.Ordinal); if (splitter == 3) { NumberString = stringNumberInput.Substring(4); FormatString = stringNumberInput.Substring(2, 1); StringNumberDelimiters.Add(FormatString); } else { splitter = stringNumberInput.IndexOf("]\n", StringComparison.Ordinal); if (splitter == -1) { NumberString = stringNumberInput; } else { NumberString = stringNumberInput.Substring(splitter + 2); FormatString = stringNumberInput.Substring(3, splitter - 3); var additionalDeliminators = FormatString.Split(FormatDelimiter.ToArray(), StringSplitOptions.RemoveEmptyEntries); if (additionalDeliminators.Length > 1) { throw new Exception("Too many custom delimiters!"); } StringNumberDelimiters.AddRange(additionalDeliminators); } } } else { NumberString = stringNumberInput; } ValueList = NumberString.Split(StringNumberDelimiters.ToArray(), StringSplitOptions.None).ToList(); NumberList = (from x in ValueList select GetDouble(x)).ToList(); var negativeNumberList = (from x in NumberList where x < 0 select x).ToList(); if (negativeNumberList.Any()) { throw new NegativeNumberException(negativeNumberList); } NumberList = NumberList.Where(x => IsLessThanOrEqualTo(1000, x)).ToList(); Result = NumberList.Sum(); Debug.WriteLine(NumberString); Debug.WriteLine(GetResultFormula("+")); Debug.WriteLine(Result); return(Result); }