/// <summary> /// Constructor with UNC /// </summary> /// <param name="path">The share name - UNC</param> public NetworkShare( String path ) { String hostName = ""; // check if the UNC is valid unc = (String) path.Clone(); if( path.StartsWith( @"\\" ) ) { path = path.Remove( 0, 2 ); int i = path.IndexOf( @"\" ); if( i < 0 ) { goto _abort; } hostName = path.Substring( 0, path.IndexOf( @"\" ) ); path = path.Remove( 0, i ); if( path == null || path.Length < 1 ) { goto _abort; } // remove the first "\" remotePath = (String) path.Remove( 0, 1 ); if( remotePath == null || remotePath.Length < 1 ) { goto _abort; } goto _ok; } _abort: throw new Exception( "Invalid UNC path: " + unc ); _ok: { host = new NetworkHost( hostName, 0 /* dummy */ ); } }
/// <summary>Parses hex string representing an Ethernet MAC address to the enternal format. Ethernet /// address has to contain 12 hex characters (1-9 or A-F) to be parsed correctly. Special formatting is /// ignored so both 0000.0010.0000 and 00-00-00-10-00-00 will be parsed ok. /// </summary> /// <param name="value">Ethernet address represented as a string. /// </param> public override void Set(System.String value) { if (value == null || value.Length <= 0) { throw new ArgumentException("Invalid argument. String is empty."); } string workString = (string)value.Clone(); for (int cnt = 0; cnt < value.Length; cnt++) { if (!Char.IsNumber(workString[cnt]) && Char.ToUpper(workString[cnt]) != 'A' && Char.ToUpper(workString[cnt]) != 'B' && Char.ToUpper(workString[cnt]) != 'C' && Char.ToUpper(workString[cnt]) != 'D' && Char.ToUpper(workString[cnt]) != 'E' && Char.ToUpper(workString[cnt]) != 'F') { workString.Remove(cnt, 1); cnt -= 1; } } if (workString.Length != 12) { throw new ArgumentException("Invalid Ethernet address format."); } int pos = 0; int bufpos = 0; while (pos + 2 < workString.Length) { string val = workString.Substring(pos, 2); byte v = Byte.Parse(val, NumberStyles.HexNumber); _data[bufpos++] = v; pos += 2; } }
public static String parseSCTags(String text) { int sc_start_index = -1; int sc_end_index = -1; String text_to_upper = ""; String message = (String)text.Clone(); sc_start_index = message.IndexOf(SC_START_TAG); int start_text_index = -1; while (sc_start_index != -1) { sc_end_index = message.IndexOf(SC_END_TAG); if (sc_end_index == -1) { Console.WriteLine("NO CLOSING SC TAG FOUND IN A VERSE: " + message); return message; } start_text_index = sc_start_index + SC_START_TAG.Length; text_to_upper = message.Substring(start_text_index, sc_end_index - start_text_index); message = message.Remove(sc_start_index, (sc_end_index - sc_start_index) + SC_END_TAG.Length); message = message.Insert(sc_start_index, text_to_upper.ToUpper()); sc_start_index = message.IndexOf(SC_START_TAG); } return message; }
private String m_InternalName; // The access key of this group #endregion Fields #region Constructors public CommandGroup(String InternalName, String DisplayName , CommandManger CommandManager) { m_InternalName = InternalName.Clone() as String; m_DisplayName = DisplayName.Clone() as String; m_Commands = new FRList<String>(); m_CommandManager = CommandManager; }
public IrcLine(IrcClient client, String prefix, String command, String[] parameters) { this.client = client; this.prefix = prefix; this.command = command; parameters = (String[])parameters.Clone(); Int32.TryParse(command, out numeric); }
/// <summary> /// Initializes a new instance of the <see cref="BoundedBroydenFletcherGoldfarbShannoInnerStatus"/> class with the inner /// status values from the original FORTRAN L-BFGS implementation. /// </summary> /// /// <param name="isave">The isave L-BFGS status argument.</param> /// <param name="dsave">The dsave L-BFGS status argument.</param> /// <param name="lsave">The lsave L-BFGS status argument.</param> /// <param name="csave">The csave L-BFGS status argument.</param> /// <param name="work">The work L-BFGS status argument.</param> /// public BoundedBroydenFletcherGoldfarbShannoInnerStatus( int[] isave, double[] dsave, bool[] lsave, String csave, double[] work) { this.Integers = (int[])isave.Clone(); this.Doubles = (double[])dsave.Clone(); this.Booleans = (bool[])lsave.Clone(); this.Strings = (string)csave.Clone(); this.Work = (double[])work.Clone(); }
public RawLogItemConfiguratorWindow GenerateConfigurationList(String[] sampleLogLine) { SampleLogLine = (String[])sampleLogLine.Clone(); for(int logItemIndex = 0; logItemIndex < sampleLogLine.Length; logItemIndex += 1) { CreateLogItemCandidate(logItemIndex, sampleLogLine[logItemIndex]); } this.ShowDialog(); return this; }
/// <summary> /// Retourne le lien d'un article contenu dans sa description /// </summary> /// <param name="description">description contenant le lien</param> /// <returns>lien de l'article</returns> protected String GetLinkToDescription(String description) { // DECLARATION String linkTmp, resultLink; StringBuilder linkBuf; int indexStart, indexEnd; Char[] linkToCharArray; // INITIALISATION resultLink = null; linkBuf = new StringBuilder(); // on clone la description linkTmp = (String) description.Clone(); // on remplace les caracteres "<" par le charactere "<" // "<" charactere hexa de "<" linkTmp = description.Replace(">", "<"); // on remplace les caracteres ">" par le charactere ">" // ">" charactere hexa de ">" linkTmp = description.Replace(">", ">"); // on remplace les caracteres """ par le charactere """ // """ charactere hexa de """ //linkTmp = description.Replace(""", "\""); // on recupere le texte contenu dans les balises <a> </a> indexStart = description.IndexOf("<a"); indexEnd = description.IndexOf("</a>"); if ((indexStart != -1) && (indexEnd != -1)) { linkTmp = linkTmp.Substring(indexStart, indexEnd - indexStart); // on verifie que les balises <a> contiennent le mot cle "href" if (linkTmp.Contains("href")) { linkToCharArray = linkTmp.ToCharArray(); for (int i = (linkTmp.IndexOf('"') + 1); linkToCharArray[i] != '"'; i++) { linkBuf.Append(linkToCharArray[i]); } } resultLink = linkBuf.ToString(); } return resultLink; }
public CustomPropertyGroup(String n,String p) { name = filepath = null; if (n != null) { name = (String)n.Clone(); } ; if (p != null) { filepath = (String)p.Clone() ; } customproperties = new SerializableDictionary(); }
public ProcessorThread(System.String daImageFileName, Accusoft.ImagXpressSdk.ImageXView daViewer, System.Windows.Forms.Label daLabel, System.Int32 daSize, ImagXpress daImagXpress) { //set our references to these objects this.myReferenceToMyViewer = daViewer; this.myReferenceToMyLabel = daLabel; this.daImagXpress = daImagXpress; //since we do not need to pass back the filename, we can clone it to eliminate cross thread fears this.myImageFileName = (string)daImageFileName.Clone(); //types such as System.Int32 are not real objects, so no cross thread fears. this.myResize = daSize; }
/** * returns the canonized form of the given link */ public String canonize(String link) { String modifiedLink = (String)link.Clone(); String[] prefixOfLink = modifiedLink.Split(":// ".Split(' '),StringSplitOptions.RemoveEmptyEntries); if (prefixOfLink.Length != 2) { modifiedLink = prefix + "://" + modifiedLink; } if (modifiedLink[modifiedLink.Length - 1] == '/') modifiedLink = modifiedLink.Remove(modifiedLink.Length - 1); return modifiedLink; }
public void Substitute(String reqId, TextWriter output) { // Read in the template file StringBuilder sb = new StringBuilder(""); try { Assembly _assembly = Assembly.GetExecutingAssembly(); StreamReader sr = new StreamReader(_assembly.GetManifestResourceStream("RefactoringExample.template.html")); String line; while (((line = sr.ReadLine()) != "") && (line != null)) sb = new StringBuilder(sb + line + "\n"); sr.Close(); } catch (Exception e) { } SourceTemplate = sb.ToString(); try { String template = (string)SourceTemplate.Clone(); // Substitute for %CODE% int templateSplitBegin = template.IndexOf("%CODE%"); int templateSplitEnd = templateSplitBegin + 6; String templatePartOne = template.Substring(0, templateSplitBegin); String templatePartTwo = template.Substring(templateSplitEnd, template.Length - 1); _code = reqId.ToString(); template = templatePartOne + _code + templatePartTwo; // Substitute for %ALTCODE% templateSplitBegin = template.IndexOf("%ALTCODE%"); templateSplitEnd = templateSplitBegin + 9; templatePartOne = template.Substring(0, templateSplitBegin); templatePartTwo = template.Substring(templateSplitEnd, template.Length - 1); _altcode = _code.Substring(0, 4) + "-" + _code.Substring(4, 4); output.Write(templatePartOne + _altcode + templatePartTwo); } catch (Exception e) { Console.WriteLine("Error in substitute()"); } output.Flush(); output.Close(); }
static StackObject *Clone_6(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.String instance_of_this_method = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.Clone(); object obj_result_of_this_method = result_of_this_method; if (obj_result_of_this_method is CrossBindingAdaptorType) { return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true)); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true)); }
public LLETextBox(Vector2 position, Texture2D bgTexture, Texture2D cursorImg, String text, SpriteFont font, int maxLength, OnClickEvent clickEvent) : base(position, bgTexture, font, "", clickEvent) { mCursorImg = cursorImg; mText = (string)text.Clone(); mMaxLength = maxLength; setFontColors(Color.Black, Color.Black, Color.Gray); setColors(Color.DarkGray, Color.LightGray, Color.Gray); mIndex = -1; mHasFocus = false; mCursorColor = Color.Black; adjustCursor(); }
public void setUserName(String uname) { userName = (String)uname.Clone(); }
public void setPassword(String pwd) { password = (String)pwd.Clone(); }
public void setIpAddress(String ip) { ipAddress = (String)ip.Clone(); }
public void setDatabase(String db) { database = (String)db.Clone(); }
// Create the union of two string lists. internal static String[] Union(String[] list1, String[] list2, bool clone) { if(list1 == null) { if(list2 == null || !clone) { return list2; } else { return (String[])(list2.Clone()); } } else if(list2 == null) { return list1; } int count = list1.Length; foreach(String s1 in list2) { if(!((IList)list1).Contains(s1)) { ++count; } } if(count == 0) { return null; } String[] list = new String [count]; count = list1.Length; Array.Copy(list1, 0, list, 0, count); foreach(String s2 in list2) { if(!((IList)list1).Contains(s2)) { list[count++] = s2; } } return list; }
private bool buildMultiStopTree(String origin, String dest, String[] remainingNodes, String endDay, String day, ref TreeNode<String> current, TreeNode<String> previous) { if (remainingNodes.Length == 0) { if ((pathsForOriginDest(previous.Value, current.Value, day, 0).Count > 0) && (current.Value.ToLower().Equals(dest.ToLower()))) { if (endDay == null) { return true; } else if (day.ToLower().Equals(endDay.ToLower())) { return true; } else { return false; } } else { return false; } } if (previous != null) { if (pathsForOriginDest(previous.Value, current.Value, day, 0).Count == 0) { return false; } } // obviously if those fail, something has to be done bool something = false; String currentDay = (String)day.Clone(); if (previous != null) { Route[] rtes = routesForParameters(previous.Value, current.Value); if (rtes.Length > 0) { Route rte = rtes[0]; Flight[] flts = rte.flightsForTime(new FlightTime(0, 0, false), day, 0); foreach (Flight flt in flts) { if (flt.Arrival.nextDay) { currentDay = FlightTime.dayByAddingDays(currentDay, 1); break; } } currentDay = FlightTime.dayByAddingDays(currentDay, 1); } else { return false; } } TreeNode<String> node; for (int i = 0; i < remainingNodes.Length; i++) { node = new TreeNode<string>(remainingNodes[i]); if (buildMultiStopTree(origin, dest, remainingByTakingOut(remainingNodes, remainingNodes[i]), endDay, currentDay, ref node, current)) { current.Children.Add(node); if (!something) { something = true; } } } return something; }
public void SetColumnsName(String[] columnsName) { _columnsName = (String[])columnsName.Clone(); }
/// <summary> /// Adds an IPAddress to the cache /// </summary> public static IPAddress AddToCache( String ip ) { IPAddress ipAddr = IPAddress.Parse( ip ); cache.Add( ip.Clone(), ipAddr ); return ipAddr; }
/// <summary> /// Opens the INI file at the given path and enumerates the values in the IniParser. /// </summary> /// <param name="ini">Path to INI file or INI contents.</param> /// <param name="isContents"></param> /// <param name="encoding">File encoding</param> public IniFile(String ini, bool isContents = false, Encoding encoding=null) { TextReader iniFile; String currentRoot = null; _iniFilePath = ini; if (!File.Exists(ini)) { var tmp = Path.GetFullPath(ini); if (!String.IsNullOrEmpty(tmp) && File.Exists(tmp)) ini = tmp; } if (isContents || !File.Exists(ini)) { iniFile = new StringReader((String) ini.Clone()); ini = Path.GetTempFileName(); ConfigurationFile = ini; } else { iniFile = new StreamReader(ini, encoding ?? Encoding.Default); ConfigurationFile = ini; } try { var strLine = iniFile.ReadLine(); while (strLine != null) { strLine = strLine.Trim(); if (!strLine.StartsWith(";") && strLine.Length > 1) { if (strLine.StartsWith("[") && strLine.EndsWith("]")) { currentRoot = strLine.Substring(1, strLine.Length - 2); } else { var keyPair = strLine.Split(new char[] {'='}, 2); SectionPair sectionPair; String value = null; sectionPair.Section = currentRoot; sectionPair.Key = keyPair[0]; if (keyPair.Length > 1) value = keyPair[1]; _keyPairs.Add(sectionPair, value); } } strLine = iniFile.ReadLine(); } } catch (Exception ex) { throw ex; } finally { iniFile.Close(); } /*} else throw new FileNotFoundException("Unable to locate " + iniPath);*/ }
public ArgumentReader(String[] args) { this.args = args.Clone() as String[]; currentArg = 0; }
// recursive magic to build the tree of flight paths private bool buildFlightTree(ref TreeNode<Flight> node, TreeNode<Flight> previous, Route[] routes, Route dest, int nextDestIndex, String day, int tolerance) { if (node.Value.Route == dest) { // success return true; } else { TreeNode<Flight> currentNode; bool something = false; Flight[] connecting = connectingForFlight(node.Value, routes[nextDestIndex].Destination, day, tolerance); String currentDay = (String)day.Clone(); if (node.Value.Arrival.nextDay) { currentDay = FlightTime.dayByAddingDays(day, 1); } foreach (Flight flt in connecting) { currentNode = new TreeNode<Flight>(flt); int ndi = nextDestIndex + 1; if (ndi >= routes.Length) { ndi = routes.Length - 1; } if (buildFlightTree(ref currentNode, node, routes, dest, ndi, currentDay, tolerance)) { node.Children.Add(currentNode); if (!something) { something = true; } } } return something; } }
public void AddResult(ResultData r) { Boolean match = false; int indx = -1; foreach (MainResults MaRe in results) { //match = (MaRe.Latitude == r.Latitude && MaRe.Longitude == r.Longitude); match = (MaRe.OrganizationLocationID == r.OrganizationLocationID); if (match) { indx = results.IndexOf(MaRe); break; } } if (!match) { MainResults mr = new MainResults(); mr.TaxID = new String[] { r.TaxID }; mr.NPI = new String[] { r.NPI }; mr.PracticeName = r.PracticeName; mr.ProviderName = new String[] { r.ProviderName }; mr.PracticeRangeMin = String.Format("{0:c0}", decimal.Parse(r.RangeMin)); mr.RangeMin = new String[] { r.RangeMin }; mr.PracticeRangeMax = String.Format("{0:c0}", decimal.Parse(r.RangeMax)); mr.RangeMax = new String[] { r.RangeMax }; mr.PracticeYourCostMin = String.Format("{0:c0}", decimal.Parse(r.YourCostMin)); mr.YourCostMin = new String[] { r.YourCostMin }; mr.PracticeYourCostMax = String.Format("{0:c0}", decimal.Parse(r.YourCostMax)); mr.YourCostMax = new String[] { r.YourCostMax }; mr.Latitude = r.Latitude; mr.Longitude = r.Longitude; mr.OrganizationLocationID = r.OrganizationLocationID; mr.LocationAddress1 = r.LocationAddress1; mr.LocationCity = r.LocationCity; mr.LocationState = r.LocationState; mr.LocationZip = r.LocationZip; mr.Distance = r.Distance; mr.NumericDistance = r.NumericDistance; mr.PracticeFairPrice = r.FairPrice; mr.FairPrice = new Boolean[] { r.FairPrice }; mr.HGRecognized = new Int32[] { r.HGRecognized }; switch (r.HGRecognized) { case -1: mr.PracticeHGRecognized = "N/A"; break; case 0: mr.PracticeHGRecognized = "0/1 Physicians"; break; case 1: mr.PracticeHGRecognized = "1/1 Physicians"; break; default: mr.PracticeHGRecognized = "N/A"; break; } mr.PracticeAvgRating = r.HGOverallRating; mr.HGOverallRating = new Double[] { r.HGOverallRating }; mr.HGPatientCount = new int[] { r.HGPatientCount }; results.Add(mr); } else { MainResults mr = results[indx]; String[] s = new String[mr.TaxID.Length + 1]; mr.TaxID.CopyTo(s, 0); s[s.Length - 1] = r.TaxID; mr.TaxID = (String[])s.Clone(); mr.NPI.CopyTo(s, 0); s[s.Length - 1] = r.NPI; mr.NPI = (String[])s.Clone(); mr.ProviderName.CopyTo(s, 0); s[s.Length - 1] = r.ProviderName; mr.ProviderName = (String[])s.Clone(); mr.RangeMin.CopyTo(s, 0); s[s.Length - 1] = r.RangeMin; mr.RangeMin = (String[])s.Clone(); mr.PracticeRangeMin = String.Format("{0:c0}", ((double.Parse(mr.PracticeRangeMin.Replace("$", "")) + double.Parse(r.RangeMin)) / 2.0)); mr.RangeMax.CopyTo(s, 0); s[s.Length - 1] = r.RangeMax; mr.RangeMax = (String[])s.Clone(); mr.PracticeRangeMax = String.Format("{0:c0}", ((double.Parse(mr.PracticeRangeMax.Replace("$", "")) + double.Parse(r.RangeMax)) / 2.0)); mr.YourCostMin.CopyTo(s, 0); s[s.Length - 1] = r.YourCostMin; mr.YourCostMin = (String[])s.Clone(); mr.PracticeYourCostMin = String.Format("{0:c0}", ((double.Parse(mr.PracticeYourCostMin.Replace("$", "")) + double.Parse(r.YourCostMin)) / 2.0)); mr.YourCostMax.CopyTo(s, 0); s[s.Length - 1] = r.YourCostMax; mr.YourCostMax = (String[])s.Clone(); mr.PracticeYourCostMax = String.Format("{0:c0}", ((double.Parse(mr.PracticeYourCostMax.Replace("$", "")) + double.Parse(r.YourCostMax)) / 2.0)); Boolean[] b = new Boolean[mr.FairPrice.Length + 1]; mr.FairPrice.CopyTo(b, 0); b[b.Length - 1] = r.FairPrice; mr.FairPrice = (Boolean[])b.Clone(); if (!mr.PracticeFairPrice && r.FairPrice) { mr.PracticeFairPrice = r.FairPrice; } Int32[] i32 = new Int32[mr.HGRecognized.Length + 1]; mr.HGRecognized.CopyTo(i32, 0); i32[i32.Length - 1] = r.HGRecognized; mr.HGRecognized = (Int32[])i32.Clone(); switch (r.HGRecognized) { case -1: //Do Nothing break; case 0: if (mr.PracticeHGRecognized == "N/A") { mr.PracticeHGRecognized = "0/0 Physicians"; } String[] str0 = mr.PracticeHGRecognized.Replace("Physicians", "").Trim().Split('/'); mr.PracticeHGRecognized = String.Format("{0}/{1} Physicians", str0[0], (Convert.ToInt32(str0[1]) + 1).ToString()); break; case 1: if (mr.PracticeHGRecognized == "N/A") { mr.PracticeHGRecognized = "0/0 Physicians"; } String[] str1 = mr.PracticeHGRecognized.Replace("Physicians", "").Trim().Split('/'); mr.PracticeHGRecognized = String.Format("{0}/{1} Physicians", (Convert.ToInt32(str1[0]) + 1).ToString(), (Convert.ToInt32(str1[1]) + 1).ToString()); break; default: break; } Double[] d = new Double[mr.HGOverallRating.Length + 1]; mr.HGOverallRating.CopyTo(d, 0); d[d.Length - 1] = r.HGOverallRating; mr.HGOverallRating = (Double[])d.Clone(); mr.PracticeAvgRating = ((mr.PracticeAvgRating + r.HGOverallRating) / 2.0); int[] i = new int[mr.HGPatientCount.Length + 1]; mr.HGPatientCount.CopyTo(i, 0); i[i.Length - 1] = r.HGPatientCount; mr.HGPatientCount = (int[])i.Clone(); results[indx] = mr; } }
public void SetText(String character, String txt) { ReplaceCharactersInText(ref txt); _txt = txt; this.character = GetCharacterForID(character); text = (String)_txt.Clone(); Vector2 v = new Vector2(); FitText(ref text, out v); size.Y = v.Y + 18 < 96 ? 96 : v.Y + 18; textSize = v; ReGenFBO(); position.Y = Main.WindowHeight - 100 - size.Y; }
//Vérifie qu'un des mot est présent dans la chaîne, si oui renvoi true, sinon false bool textePresent(String chaine, String[] mots) { //Clonage dans une variable de la chaine en minuscule string chaineL = ((String)chaine.Clone()).ToLower(); foreach (string mot in mots) { if (chaineL.Contains(mot.ToLower())) { return true; } } return false; }
private void UseGraphHistory(ref List<String> HistoryList, ConsoleKeyInfo? myInput) { #region Data int CountHistoricalEntries = HistoryList.Count; #endregion if (!CountHistoricalEntries.Equals(0)) { #region Data switch (myInput.Value.Key) { case ConsoleKey.UpArrow: if (PositionInHistory.CompareTo(CountHistoricalEntries - 1) <= 0) { //get the current history entry ActualHistoricCommand = HistoryList[CountHistoricalEntries - PositionInHistory - 1]; //reset the InputLine ResetInputLineAndString(); //print actutal entry in history Write(ActualHistoricCommand); //update InputString InputString = ActualHistoricCommand.Clone().ToString(); //update PositionInHistory PositionInHistory++; }//is there a command left? else { //leave InputLine as it is --> there should be a command already //reset the InputLine ResetInputLineAndString(); //print actutal entry in history Write(ActualHistoricCommand); //update InputString InputString = ActualHistoricCommand.Clone().ToString(); } break; case ConsoleKey.DownArrow: if ((PositionInHistory - 1).CompareTo(0) > 0) { //get the previous history entry ActualHistoricCommand = HistoryList[CountHistoricalEntries - PositionInHistory + 1]; //reset the InputLine ResetInputLineAndString(); //print actutal entry in history Write(ActualHistoricCommand); //update InputString InputString = ActualHistoricCommand.Clone().ToString(); //update PositionInHistory PositionInHistory--; }//is there a command left? else { //leave InputLine as it is --> there should be a command already //reset the InputLine ResetInputLineAndString(); //print actutal entry in history Write(ActualHistoricCommand); //update InputString InputString = ActualHistoricCommand.Clone().ToString(); } break; } #endregion currentCursorPosWithinCommand = InputString.Length; }//more than 1 history entry? }
// returns flights that match parameters public Flight[] flightsForTime(FlightTime flttime, String fltday, int tolerance) { // day index, 0 is monday, etc. // tolerance is in minutes // returns null if not found ArrayList flights = new ArrayList(0); FlightTime time = (FlightTime)flttime.Clone(); String day = (String)fltday.Clone(); if (time.nextDay) { day = FlightTime.dayByAddingDays(day, 1); time.nextDay = false; } time.addMinutes(tolerance); foreach (Flight flt in __flights) { if (flt.hasFlightAtTime(time, day)) { flights.Add(flt); } } return (Flight[])flights.ToArray(typeof(Flight)); }
public virtual bool runTest() { Console.Error.WriteLine( s_strTFPath +" "+ s_strTFName +" ,for "+ s_strClassMethod +" ,Source ver "+ s_strDtTmVer ); String strLoc="Loc_000oo"; String strBaseLoc; StringBuilder sblMsg = new StringBuilder( 99 ); int inCountErrors = 0; int inErrorBits = 0; int inCountTestcases = 0; int[] in4Arr1Orig = null; int[] in4Arr1Newer = null; Object[] objArr1Orig = null; Object[] objArr1Newer = null; String[] strArr1Orig = null; String[] strArr1Newer = null; try { LABEL_860_GENERAL: do { strLoc="Loc_110dt"; in4Arr1Orig = new int[3]; for ( int ia = 0 ;ia < in4Arr1Orig.Length ;ia++ ) { in4Arr1Orig[ia] = ia + 100; } in4Arr1Newer = (int[])in4Arr1Orig.Clone(); ++inCountTestcases; if ( in4Arr1Orig == in4Arr1Newer ) { ++inCountErrors; Console.WriteLine( s_strTFAbbrev +"Err_408rh!" ); } ++inCountTestcases; for ( int ia = 0 ;ia < in4Arr1Orig.Length;ia++ ) { if ( in4Arr1Orig[ia] != in4Arr1Newer[ia] ) { ++inCountErrors; Console.WriteLine( s_strTFAbbrev +"Err_855bx! ia=="+ ia +" ,in4Arr1Newer[ia]=="+ in4Arr1Newer[ia] ); } if ( (inErrorBits & 0x1) != 0 ) { break; } else { inErrorBits |= 0x1; } } strLoc="Loc_113ek"; in4Arr1Orig = new int[0]; for ( int ia = 0 ;ia < in4Arr1Orig.Length;ia++ ) { in4Arr1Orig[ia] = ia; } in4Arr1Newer = (int[])in4Arr1Orig.Clone(); ++inCountTestcases; if ( in4Arr1Orig == in4Arr1Newer ) { ++inCountErrors; Console.WriteLine( s_strTFAbbrev +"Err_265wv!" ); } ++inCountTestcases; for ( int ia = 0 ;ia < in4Arr1Newer.Length; ia++ ) { if ( in4Arr1Orig[ia] != in4Arr1Newer[ia] ) { ++inCountErrors; Console.WriteLine( s_strTFAbbrev +"Err_773bf! ia=="+ ia +" ,in4Arr1Newer[ia]=="+ in4Arr1Newer[ia] ); } if ( (inErrorBits & 0x8) != 0 ) { break; } else { inErrorBits |= 0x8; } } strLoc="Loc_120yt"; objArr1Orig = new Object[3]; for ( int ia = 0 ;ia < objArr1Orig.Length;ia++ ) { objArr1Orig[ia] = ia; } objArr1Newer = (Object[])objArr1Orig.Clone(); ++inCountTestcases; if ( objArr1Orig == objArr1Newer ) { ++inCountErrors; Console.WriteLine( s_strTFAbbrev +"Err_816os!" ); } ++inCountTestcases; for ( int ia = 0 ;ia < objArr1Orig.Length;ia++ ) { if ( objArr1Orig[ia] != objArr1Newer[ia] ) { ++inCountErrors; Console.WriteLine( s_strTFAbbrev +"Err_004mr! ia=="+ ia +" ,objArr1Newer[ia]=="+ objArr1Newer[ia] ); } if ( (inErrorBits & 0x2) != 0 ) { break; } else { inErrorBits |= 0x2; } } strLoc="Loc_142gr"; strArr1Orig = new String[3]; for ( int ia = 0 ;ia < strArr1Orig.Length; ia++ ) { strArr1Orig[ia] = ia.ToString(); } strArr1Newer = (String[])strArr1Orig.Clone(); ++inCountTestcases; if ( strArr1Orig == strArr1Newer ) { ++inCountErrors; Console.WriteLine( s_strTFAbbrev +"Err_167qi!" ); } ++inCountTestcases; for ( int ia = 0 ;ia < strArr1Orig.Length; ia++ ) { if ( strArr1Orig[ia].Equals( strArr1Newer[ia] ) != true ) { ++inCountErrors; Console.WriteLine( s_strTFAbbrev +"Err_456kz! ia=="+ ia +" ,strArr1Newer[ia]=="+ strArr1Newer[ia] ); } if ( (inErrorBits & 0x4) != 0 ) { break; } else { inErrorBits |= 0x4; } } } while ( false ); } catch( Exception exc_general ) { ++inCountErrors; Console.WriteLine( s_strTFAbbrev +"Error Err_8888yyy! strLoc=="+ strLoc +" ,exc_general=="+ exc_general ); } if ( inCountErrors == 0 ) { Console.Error.WriteLine( "paSs. "+ s_strTFPath +" "+ s_strTFName +" ,inCountTestcases=="+ inCountTestcases ); return true; } else { Console.Error.WriteLine( "FAiL! "+ s_strTFPath +" "+ s_strTFName +" ,inCountErrors=="+ inCountErrors +" ,BugNums?: "+ s_strActiveBugNums ); return false; } }
private void GetActuallSecurityParameter(String[] SecurityGroupParameter, out String[] SecurityGroups, out String[] SecurityGroupsShort) { if (SecurityGroupParameter != null) { SecurityGroups = (String[]) SecurityGroupParameter.Clone(); SecurityGroupsShort = (String[]) SecurityGroupParameter.Clone(); int Index = 0; while (Index < SecurityGroupsShort.Length) { if (SecurityGroupsShort[Index] == "Internet") SecurityGroupsShort[Index] = "_In"; if (SecurityGroupsShort[Index] == "Delegierte") SecurityGroupsShort[Index] = "_De"; if (SecurityGroupsShort[Index] == "ProfisPart") SecurityGroupsShort[Index] = "_PP"; if (SecurityGroupsShort[Index] == "ProfisFull") SecurityGroupsShort[Index] = "_PF"; Index++; } } else { SecurityGroups = new String[] {"Internet", "Delegierte", "ProfisPart", "ProfisFull"}; SecurityGroupsShort = new String[] {"_In", "_De", "_PP", "_PF"}; } }
/** * This method returns the match level of the given wordlist according to a * certain formula. */ public int getMatchLevel(String wordList,CategorizerOptions parameters) { char[] separators = {' ', '\t', '\n'}; int numOfWords = Math.Max(1, wordList.Split(separators).Length); int numOfKeywords = Math.Max(1, keywordList.Count); int nonZero = 0; double sumOfhistogram = 0; double threshold = Math.Max(2.0, ((numOfWords * parameters.BETA) / numOfKeywords)); // keywordList and wordList are copied to a new arrays so that we won't change them(the originals) List<String> keywordListCopied = new List<string>(keywordList); String wordListCopied = (String)wordList.Clone(); // Transforming the keywordListCopied and wordListCopied to canonical form //keywordListCopied.ForEach(canonicForm); canonicForm(ref wordListCopied); //wordListCopied = wordListCopied.ToLower(); int[] histogram = new int[numOfKeywords]; //Initialising the histogram array to zeros for (int i = 0; i < numOfKeywords; i++) { histogram[i] = 0; } foreach (String keyword in keywordListCopied) { Regex objPattern = new Regex(keyword.ToLower()); int count = objPattern.Matches(wordListCopied,0).Count; int index = keywordListCopied.IndexOf(keyword); if (count != 0 && histogram[index] == 0) nonZero++; if (histogram[index] < threshold) { int add = Math.Min(histogram[index] + count, (int)threshold) - histogram[index]; histogram[index] = histogram[index] + add; sumOfhistogram = sumOfhistogram + add; } } double nonZeroBonus = (nonZero * parameters.GAMMA) / numOfKeywords; nonZeroBonus = Math.Min(parameters.NONZERO_MAX_EFFECT, nonZeroBonus); double matchPercent = (sumOfhistogram * parameters.ALPHA) / numOfWords; matchPercent = Math.Min(parameters.MATCH_MAX_EFFECT, matchPercent); double total = parameters.MAX_MATCH_LEVEL * (nonZeroBonus + matchPercent) / (parameters.MATCH_MAX_EFFECT + parameters.NONZERO_MAX_EFFECT); if (numOfWords < parameters.MIN_WORDS_LIMIT) { total = parameters.MIN_WORDS_PENLTY * total; } StreamWriter sw = null; if (LogDebuggerControl.getInstance().debugCategorization) { if (!parameters.isRank) { sw = new StreamWriter("_DEBUG_INFO_CATEGORIZER@" + System.Threading.Thread.CurrentThread.ManagedThreadId + ".txt", true); sw.WriteLine(" ***** DATA FOR REQUEST ************************************************* "); //sw.WriteLine(" .CONTENT WORDS: "); //sw.WriteLine(wordListCopied.ToString()); sw.WriteLine(" .NUM OF WORDS: "); sw.WriteLine(numOfWords.ToString()); sw.WriteLine(" .KEY WORDS: "); sw.WriteLine(keywordListCopied.ToString()); sw.WriteLine(" .NUM OF KEY WORDS: "); sw.WriteLine(numOfKeywords.ToString()); sw.WriteLine(" .THRESOLD PARAM: "); sw.WriteLine(threshold.ToString()); sw.WriteLine(" .SUM OF HISTOGRAM: "); sw.WriteLine(sumOfhistogram.ToString()); sw.WriteLine(" .NONZERO PARAM: "); sw.WriteLine(nonZero.ToString()); sw.WriteLine(" .HISTOGRAM DATA:"); for (int j = 0; j < numOfKeywords; j++) { sw.WriteLine(" .[" + keywordList[j] + "] -> " + histogram[j].ToString()); } sw.WriteLine(" .NON-ZERO BONUS: "); sw.WriteLine(nonZeroBonus.ToString()); sw.WriteLine(" .MATCH PERCENT: "); sw.WriteLine(matchPercent.ToString()); sw.WriteLine(" .TOTAL TRUST: "); sw.WriteLine(total.ToString()); sw.WriteLine(" * END ****************************************************************** "); sw.Close(); } } if (LogDebuggerControl.getInstance().debugCategorizationInRanker && LogDebuggerControl.getInstance().debugRanker) { if (parameters.isRank) { sw = new StreamWriter("DataForRank" + System.Threading.Thread.CurrentThread.ManagedThreadId + ".txt", true); sw.WriteLine(" ***** DATA FOR Categorizer ************************************************* "); //sw.WriteLine(" .CONTENT WORDS: "); //sw.WriteLine(wordListCopied.ToString()); sw.WriteLine(" .NUM OF WORDS: "); sw.WriteLine(numOfWords.ToString()); //String[] wordListSplited = wordListCopied.Split(separators); //for (int k = 0; k < numOfWords;k++ ) //{ // sw.WriteLine(" .[" + k + "] -> " + wordListSplited[k]); //} sw.WriteLine(" .KEY WORDS: "); sw.WriteLine(keywordListCopied.ToString()); sw.WriteLine(" .NUM OF KEY WORDS: "); sw.WriteLine(numOfKeywords.ToString()); sw.WriteLine(" .THRESOLD PARAM: "); sw.WriteLine(threshold.ToString()); sw.WriteLine(" .SUM OF HISTOGRAM: "); sw.WriteLine(sumOfhistogram.ToString()); sw.WriteLine(" .NONZERO PARAM: "); sw.WriteLine(nonZero.ToString()); sw.WriteLine(" .HISTOGRAM DATA:"); for (int j = 0; j < numOfKeywords; j++) { sw.WriteLine(" .[" + keywordList[j] + "] -> " + histogram[j].ToString()); } sw.WriteLine(" .NON-ZERO BONUS: "); sw.WriteLine(nonZeroBonus.ToString()); sw.WriteLine(" .MATCH PERCENT: "); sw.WriteLine(matchPercent.ToString()); sw.WriteLine(" .TOTAL TRUST: "); sw.WriteLine(total.ToString()); sw.WriteLine(" * END ****************************************************************** "); sw.Close(); } } return Convert.ToInt32(total); }