public void OnPageLoaded(IEController controller, string url) { foreach (var scriptIndex in ScriptIndexes) { if (url.StartsWith(scriptIndex.Item2)) { var filePath = $"./Macro/Scripts/{scriptIndex.Item1}"; if (!File.Exists(filePath)) { Console.WriteLine($"스크립트 파일이 없습니다: {filePath}"); continue; } var js = string.Empty; foreach (var line in File.ReadAllLines(filePath)) { var l = line.Trim() + ' '; if (l.Contains("//")) { // '//'주석 처리 코드 l = StringFunction.before(l, "//"); } js += l; } Console.WriteLine($"Run Script:\n\t{js}"); controller.RunScript(js); } } }
public DownloadRequest(string url, StringFunction stringFunc, int priority = 1) { Url = url; stringFunction = stringFunc; isByte = false; Priority = priority; }
public Bll_Ok3w_Article(System.Web.UI.Page objPage) { string txtPath = objPage.Server.MapPath(""); string RetFile = txtPath + "\\a.txt"; if (File.Exists(RetFile)) { string[] s = File.ReadAllLines(RetFile); if (s.Length > 0) { dt_Ok3w_Article = new DataTable(); dt_Ok3w_Article.Columns.Add("id", System.Type.GetType("System.Int32")); dt_Ok3w_Article.Columns.Add("ClassID"); dt_Ok3w_Article.Columns.Add("title"); dt_Ok3w_Article.Columns.Add("comefrom"); foreach (string si in s) { string desStr = StringFunction.DesDecrypt(si); DataRow dr = dt_Ok3w_Article.NewRow(); string[] reV = desStr.Split(';'); dr["id"] = reV[0]; dr["ClassID"] = reV[1]; dr["title"] = reV[2]; dr["comefrom"] = reV[3]; dt_Ok3w_Article.Rows.Add(dr); } } } }
public LightStringFunctionDataFieldInfo(DataEntityMapping mapping, StringFunction function, object callObject, params object [] argsObjects) : base(mapping) { if (callObject == null) { throw new ArgumentNullException(nameof(callObject)); } if (function == StringFunction.ToLower || function == StringFunction.ToUpper || function == StringFunction.Trim) { if (argsObjects != null && argsObjects.Length > 0) { throw new ArgumentNullException(nameof(argsObjects)); } } if (function == StringFunction.Replace) { if (argsObjects == null || argsObjects.Length != 2) { throw new ArgumentNullException(nameof(argsObjects)); } } if (function == StringFunction.Substring || function == StringFunction.IndexOf) { if (argsObjects == null || argsObjects.Length > 2) { throw new ArgumentNullException(nameof(argsObjects)); } } _function = function; _callObject = callObject; _argsObjects = argsObjects; }
public void IsNumericStringInvalidInputReturnFalse() { string[] testCases = new string[] { "123a", "!", "x", "1>1", "0|", "8654q73", "[]", "+", "-", "=" }; foreach (string text in testCases) { Assert.IsFalse(StringFunction.IsNumeric(text)); } }
public void IsNumericStringValidInputReturnTrue() { string[] testCases = new string[] { "123", "7", "999", "11", "0", "865473" }; foreach (string text in testCases) { Assert.IsTrue(StringFunction.IsNumeric(text)); } }
void _createItem(S_T_ISODefine isoDefine, Dictionary <string, object> parent, List <Dictionary <string, object> > result, string EngineeringInfoID) { var db = SQLHelper.CreateSqlHelper(isoDefine.ConnName); if (String.IsNullOrWhiteSpace(isoDefine.TableName)) { return; } var sql = "select * from " + isoDefine.TableName + " where EngineeringInfoID='" + EngineeringInfoID + "'"; var dt = db.ExecuteDataTable(sql); if (String.IsNullOrEmpty(isoDefine.NameFieldInfo) && !dt.Columns.Contains("Name")) { throw new Formula.Exceptions.BusinessValidationException("【" + isoDefine.Name + "】定义配置中,数据源SQL必须定义NAME列"); } parent.SetValue("FileCount", dt.Rows.Count); foreach (DataRow row in dt.Rows) { var formItem = FormulaHelper.DataRowToDic(row); formItem.SetValue("ParentID", isoDefine.ID); formItem.SetValue("ID", row["ID"].ToString()); formItem.SetValue("Type", "ISOForm"); formItem.SetValue("FormTmpCode", isoDefine.FormCode); formItem.SetValue("CanDelete", isoDefine.CanAddNewForm); var enumDefList = new List <Dictionary <string, object> >(); if (!String.IsNullOrEmpty(isoDefine.EnumFieldInfo)) { enumDefList = JsonHelper.ToList(isoDefine.EnumFieldInfo); } string name = StringFunction.ReplaceRegString(isoDefine.NameFieldInfo, FormulaHelper.DataRowToDic(row), enumDefList); formItem.SetValue("Name", name); if (!String.IsNullOrWhiteSpace(isoDefine.LinkFormUrl)) { var url = ""; if (isoDefine.LinkFormUrl.IndexOf("?") >= 0) { url = isoDefine.LinkFormUrl + "&ID=" + row["ID"].ToString() + ""; } else { url = isoDefine.LinkFormUrl + "?ID=" + row["ID"].ToString() + ""; } url += "&FuncType=View"; var urlParams = url.Split('?')[1].Split('&'); foreach (var paramsString in urlParams) { if (paramsString.Split('=')[0].ToLowerInvariant() == "flowcode") { url = url.Replace(paramsString, ""); } } formItem.SetValue("LinkUrl", url); } result.Add(formItem); } }
static void Main() { string numbers = Console.ReadLine(); int[] splitNumbers = StringFunction.SplitBySpace(numbers); int sum = StringFunction.Sum(splitNumbers); Console.WriteLine(sum); }
public void IsValidRangeValidInputReturnTrue() { bool[] testRange = new bool[] { StringFunction.IsValidRange("1", "20"), StringFunction.IsValidRange("A", "Z"), StringFunction.IsValidRange("a", "z") }; foreach (bool test in testRange) { Assert.IsTrue(test); } }
public void ExtractRangesExpectedBehavior() { string text = "abcd7-11tyya-h224bI-M*()&-%$"; string expectedText = "abcdtyy224b*()&%$"; string expectedRanges = "7891011abcdefghIJKLM-"; string actualRanges = ""; List <string> ranges = StringFunction.ExtractRanges(ref text); foreach (string s in ranges) { actualRanges += s; } Assert.AreEqual(expectedText, text); Assert.AreEqual(expectedRanges, actualRanges); }
public void MethodOne() { StringFunction myDelegate = delegate(string str) { if (string.IsNullOrWhiteSpace(str)) { return(0); } return(str.Count(char.IsLetterOrDigit)); }; int result = myDelegate("Hello there!"); Console.WriteLine("The result is: " + result); }
public void SameLetterValidInputReturnTrue() { bool[] testCases = new bool[] { StringFunction.SameLetter('a', 'A'), StringFunction.SameLetter('Q', 'q'), StringFunction.SameLetter('T', 'T'), StringFunction.SameLetter('x', 'x'), StringFunction.SameLetter('B', 'b'), StringFunction.SameLetter('u', 'U') }; foreach (bool test in testCases) { Assert.IsTrue(test); } }
public void SameLetterInvalidInputReturnFalse() { bool[] testCases = new bool[] { StringFunction.SameLetter('g', 'A'), StringFunction.SameLetter('Q', 'i'), StringFunction.SameLetter('T', 'n'), StringFunction.SameLetter('x', 'y'), StringFunction.SameLetter('B', 'l'), StringFunction.SameLetter('u', 'W') }; foreach (bool test in testCases) { Assert.IsFalse(test); } }
public void EnumerateFromRangeValidInputReturnList() { List <string>[] testCases = new List <string>[] { StringFunction.EnumerateFromRange("1", "10"), StringFunction.EnumerateFromRange("a", "z"), StringFunction.EnumerateFromRange("A", "Z"), StringFunction.EnumerateFromRange("a", "j"), StringFunction.EnumerateFromRange("k", "z"), StringFunction.EnumerateFromRange("A", "J"), StringFunction.EnumerateFromRange("K", "Z"), }; List <string>[] expected = new List <string>[] { new List <string> { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }, new List <string> { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }, new List <string> { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }, new List <string> { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" }, new List <string> { "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }, new List <string> { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }, new List <string> { "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }, }; for (int i = 0; i < testCases.Length; i++) { Assert.IsTrue(expected[i].SequenceEqual(testCases[i])); } }
public void IsValidRangeInvalidInputReturnFalse() { bool[] testRange = new bool[] { StringFunction.IsValidRange("1", "z"), StringFunction.IsValidRange("a", "7"), StringFunction.IsValidRange("~", "?"), StringFunction.IsValidRange("z", "r"), StringFunction.IsValidRange("a", "Z"), StringFunction.IsValidRange("A", "z"), StringFunction.IsValidRange("1", "@"), StringFunction.IsValidRange("q", "*") }; foreach (bool test in testRange) { Assert.IsFalse(test); } }
public void EnumerateFromRangeInvalidInputReturnNull() { List <string>[] testCases = new List <string>[] { StringFunction.EnumerateFromRange("1", "z"), StringFunction.EnumerateFromRange("a", "7"), StringFunction.EnumerateFromRange("~", "?"), StringFunction.EnumerateFromRange("z", "r"), StringFunction.EnumerateFromRange("a", "Z"), StringFunction.EnumerateFromRange("A", "z"), StringFunction.EnumerateFromRange("1", "@"), StringFunction.EnumerateFromRange("q", "*") }; foreach (List <string> test in testCases) { Assert.AreEqual(null, test); } }
public void GetAdjacentNumbersLeftInclusive() { string[] test = { "1234hjklp;56778", "adfjklfds1k2j3k4", "1k2j3h" }; List <string[]> exResults = new List <string[]> { new string[] { "1", "12", "123", "1234" }, new string[] { }, new string[] { "1" } }; for (int i = 0; i < test.Length; i++) { Assert.IsTrue(exResults[i].SequenceEqual(StringFunction.GetAdjacentNumbersLeftInclusive(test[i]))); } }
/// <summary> /// Three functions: /// <list type="n"> /// <item>Modify Column Headings from run-on camel-case into space-seperated text.</item> /// <item>Inject the original heading text as CSS class attributes into corresponding /// data cells.</item> /// </list> /// </summary> /// <param name="sender">this GridView</param> /// <param name="gvre">A Reference to the new Row. These are categorzied by /// Header, DataRow, and Footer.</param> protected void OnRowCreated(object sender, GridViewRowEventArgs gvre) { if (gvre.Row.RowType == DataControlRowType.Header) { _columnClasses = new string[gvre.Row.Cells.Count]; int index = 0; foreach (TableCell cell in gvre.Row.Cells) { _columnClasses[index] = cell.Text; cell.Text = StringFunction.CamelCaseToDelimitted(cell.Text).Trim(); index++; } } else if (gvre.Row.RowType == DataControlRowType.DataRow) { // Inject the Column's Style (referenced as a CSS class) // into the Data Cell. for (int i = 0; i < gvre.Row.Cells.Count; i++) { TableCell cell = gvre.Row.Cells[i]; cell.CssClass = _columnClasses[i]; } } }
/// <summary> /// Sets the text content of the matched set of elements by calling the specified /// function. /// </summary> /// <param name="textFunction">The function that returns the text content.</param> /// <returns>The current jElement.</returns> public jElement text(StringFunction textFunction) { return null; }
/// <summary> /// Replace each element in the set of matched elements with the content returned from /// the specified function. /// </summary> /// <param name="contetntFunction">The functio returning the HTML to replace with.</param> /// <returns>The current jElement.</returns> public jElement replaceWith(StringFunction contetntFunction) { return null; }
public static Util.Maybe <TResponse> UpdateAgent <TRequest, TResponse>(string brainUid, string agentUid, TRequest input, byte[] bytes, UpdateCallbacks callbacks) { using (new UpdateAgentLock()) using (InGameProfiler.Section("Native.UpdateAgent")) using (var pinnedBytes = Util.Pin(bytes)) { NumUpdateCalls++; bool ok = false; string inputJson = null; string outputJson = null; using (InGameProfiler.Section("ToJson")) { inputJson = JsonUtility.ToJson(input, false); } using (InGameProfiler.Section("UpdateAgentJsonNative")) { UserErrorHandler.Push(callbacks.handleError); UserLogMessageHandler.Push(callbacks.handleLog); userActorStringGetter = callbacks.getActorString; userActorStringSetter = callbacks.setActorString; using (InGameProfiler.Section("setting callbacks")) { // Avoid unnecessary calls to the Set... delegate bind functions, // since those can take ~0.2ms each! Also, any pinning is // unnecessary, since the life time of use is limited to this // function. See: // https://blogs.msdn.microsoft.com/cbrumme/2003/05/06/asynchronous-operations-pinning/ if (lastCallServiceFunction != callbacks.callService) { SetCallServiceFunction(callbacks.callService); lastCallServiceFunction = callbacks.callService; } // BEGIN_GAME_BUILDER_CODE_GEN ACTOR_ACCESSOR_DELEGATE_MAYBE_SETS if (lastBooleanGetterCallback != callbacks.getActorBoolean) // GENERATED { SetActorBooleanGetter(callbacks.getActorBoolean); // GENERATED lastBooleanGetterCallback = callbacks.getActorBoolean; // GENERATED } if (lastBooleanSetterCallback != callbacks.setActorBoolean) // GENERATED { SetActorBooleanSetter(callbacks.setActorBoolean); // GENERATED lastBooleanSetterCallback = callbacks.setActorBoolean; // GENERATED } if (lastVector3GetterCallback != callbacks.getActorVector3) // GENERATED { SetActorVector3Getter(callbacks.getActorVector3); // GENERATED lastVector3GetterCallback = callbacks.getActorVector3; // GENERATED } if (lastVector3SetterCallback != callbacks.setActorVector3) // GENERATED { SetActorVector3Setter(callbacks.setActorVector3); // GENERATED lastVector3SetterCallback = callbacks.setActorVector3; // GENERATED } if (lastQuaternionGetterCallback != callbacks.getActorQuaternion) // GENERATED { SetActorQuaternionGetter(callbacks.getActorQuaternion); // GENERATED lastQuaternionGetterCallback = callbacks.getActorQuaternion; // GENERATED } if (lastQuaternionSetterCallback != callbacks.setActorQuaternion) // GENERATED { SetActorQuaternionSetter(callbacks.setActorQuaternion); // GENERATED lastQuaternionSetterCallback = callbacks.setActorQuaternion; // GENERATED } if (lastFloatGetterCallback != callbacks.getActorFloat) // GENERATED { SetActorFloatGetter(callbacks.getActorFloat); // GENERATED lastFloatGetterCallback = callbacks.getActorFloat; // GENERATED } if (lastFloatSetterCallback != callbacks.setActorFloat) // GENERATED { SetActorFloatSetter(callbacks.setActorFloat); // GENERATED lastFloatSetterCallback = callbacks.setActorFloat; // GENERATED } // END_GAME_BUILDER_CODE_GEN } // Safe callback passing: https://docs.microsoft.com/en-us/dotnet/framework/interop/marshaling-a-delegate-as-a-callback-method StringFunction captureJsonFunction = new StringFunction(json => outputJson = json); ok = UpdateAgentJsonBytes(brainUid, agentUid, inputJson, pinnedBytes.GetPointer(), bytes.Length, captureJsonFunction); UserErrorHandler.Pop(); UserLogMessageHandler.Pop(); } if (!ok) { // TODO consider using the JSON return value for communicating the // exception from JS...and throwing an exception!! Debug.LogError("UpdateAgent failed. inputJson: " + inputJson); return(Util.Maybe <TResponse> .CreateEmpty()); } else { using (InGameProfiler.Section("FromJson")) { #if UNITY_EDITOR if (outputJson.Length > 5 * 1024 * 1024) { Util.LogError($"JSON response from VOOS update is getting dangerously large..exceeding 5MB. Full content: {outputJson}"); Debug.Assert(false, "Editor-only JSON size check. See log for more details."); } #endif TResponse response = JsonUtility.FromJson <TResponse>(outputJson); return(Util.Maybe <TResponse> .CreateWith(response)); } } } }
private static extern void SetDebugLogFunction(StringFunction function);
public static IStringable Build(List <Token> tokens) { // try to build Numerable INumerable inu = NumerableBuilder.Build(tokens); if (!inu.IsNull()) { return(inu as IStringable); } // try to build Timeable ITimeable itim = TimeableBuilder.Build(tokens); if (!itim.IsNull()) { return(itim as IStringable); } // remove first and last bracket if it is there while (tokens[0].GetTokenType().Equals(TokenType.BracketOn) && tokens[tokens.Count - 1].GetTokenType().Equals(TokenType.BracketOff) && !Brackets.ContainsIndependentBracketsPairs(tokens, BracketsType.Normal)) { List <Token> tokensCopy = tokens.Select(t => t.Clone()).ToList(); tokensCopy.RemoveAt(tokens.Count - 1); tokensCopy.RemoveAt(0); tokens = tokensCopy; } // try to build simple one-token Stringable if (tokens.Count == 1) { if (tokens[0].GetTokenType().Equals(TokenType.Variable)) { string str = tokens[0].GetContent(); if (InterVariables.GetInstance().Contains(str, InterVarType.String)) { return(new StringVariableRefer(str)); } else { // try to build reference to date or clock time IStringable istr = BuildTimeVariableRefer(tokens[0]); if (!istr.IsNull()) { return(istr); } } } if (tokens[0].GetTokenType().Equals(TokenType.StringConstant)) { return(new StringConstant(tokens[0].GetContent())); } } //try to build string function if (Functions.IsPossibleFunction(tokens)) { IStringable istr = StringFunction.Build(tokens); if (!istr.IsNull()) { return(istr); } } // try to build string ternary if (TernaryBuilder.IsPossibleTernary(tokens)) { IStringable istr = TernaryBuilder.BuildStringTernary(tokens); if (!istr.IsNull()) { return(istr); } } // try to build reference to n-th element of list of strings if (tokens.Count > 3 && tokens[0].GetTokenType().Equals(TokenType.Variable) && tokens[1].GetTokenType().Equals(TokenType.SquareBracketOn) && tokens[tokens.Count - 1].GetTokenType().Equals(TokenType.SquareBracketOff)) { IStringable istr = BuildListElement(tokens); if (!istr.IsNull()) { return(istr); } } // try to build concatenated string -> text merged by + if (TokenGroups.ContainsTokenOutsideBrackets(tokens, TokenType.Plus) && !TokenGroups.ContainsTokenOutsideBrackets(tokens, TokenType.Comma)) { return(BuildConcatenated(tokens)); } else { return(null); } }
/// <summary> /// Insert content returned from the specified function after each element /// of the matching elements. /// </summary> /// <param name="contentFunction">The function that returns the content to insert.</param> /// <returns>The current jElement</returns> public jElement after(StringFunction contentFunction) { return null; }
/// <summary> /// Adds the CSS class returned by the specified function. /// </summary> /// <param name="cssFunction">The function that returns the CSS class to add.</param> /// <returns>The current jElement.</returns> public jElement addClass(StringFunction cssFunction) { return null; }
/// <summary> /// Prepend content returned from the specified function to the beginning of each element /// of the matching elements. /// </summary> /// <param name="contentFunction">The function that returns the content to prepend.</param> /// <returns>The current jElement</returns> public jElement prepend(StringFunction contentFunction) { return null; }
/// <summary> /// Sets the specified CSS attribute value to the values returned by the /// specified function on the set of matched elements. /// </summary> /// <param name="attributeName">The name of the CSS attribute to set.</param> /// <param name="valueFunction">The function returning attribute values.</param> /// <returns>The current jElement.</returns> public jElement css(string attributeName, StringFunction valueFunction) { return null; }
private static StringFunctionFilter ParseStringFunctionFilter(string oDataFilter, string filterToFind, StringFunction function) { string[] contentParts = oDataFilter.Substring(filterToFind.Length).Split(',', StringSplitOptions.RemoveEmptyEntries); if (contentParts.Length == 2) { string[] constantParts = contentParts[1].Trim().Split('\'', StringSplitOptions.RemoveEmptyEntries); return(new StringFunctionFilter() { Function = function, PropertyName = ToCamelCase(contentParts[0]), Value = constantParts[0], }); } return(null); }
public static bool SetModule(string brainUid, string moduleUid, string javascript, StringFunction handleErrors) { UserErrorHandler.Push(handleErrors); bool rv = SetModule(brainUid, moduleUid, javascript); UserErrorHandler.Pop(); return(rv); }
internal StringFunctionsWalker(StringFunction func, ICriteria criteria) : base(criteria) { this.func = func; }
/** * Handles the case when parsing a string when a token is a function * * @param sf the string function * @param i the token iterator * @param stack the parse tree stack * @exception FormulaException if an error occurs */ private void handleFunction(StringFunction sf,IEnumerator<ParseItem> i,Stack<ParseItem> stack) { ParseItem pi2 = parseCurrent(i); // If the function is unknown, then throw an error if (sf.getFunction(settings) == Function.UNKNOWN) throw new FormulaException(FormulaException.UNRECOGNIZED_FUNCTION); // First check for possible optimized functions and possible // use of the Attribute token if (sf.getFunction(settings) == Function.SUM && arguments == null) { // this is handled by an attribute Attribute a = new Attribute(sf,settings); a.add(pi2); stack.Push(a); return; } if (sf.getFunction(settings) == Function.IF) { // this is handled by an attribute Attribute a = new Attribute(sf,settings); // Add in the if conditions as a var arg function in // the correct order VariableArgFunction vaf = new VariableArgFunction(settings); object [] items = arguments.ToArray(); for (int j = 0; j < items.Length; j++) { ParseItem pi3 = (ParseItem)items[j]; vaf.add(pi3); } a.setIfConditions(vaf); stack.Push(a); return; } int newNumArgs; // Function cannot be optimized. See if it is a variable argument // function or not if (sf.getFunction(settings).getNumArgs() == 0xff) { // If the arg stack has not been initialized, it means // that there was only one argument, which is the // returned parse item if (arguments == null) { int numArgs = pi2 != null ? 1 : 0; VariableArgFunction vaf = new VariableArgFunction(sf.getFunction(settings),numArgs,settings); if (pi2 != null) vaf.add(pi2); stack.Push(vaf); } else { // Add the args to the function in the correct order newNumArgs = arguments.Count; VariableArgFunction vaf = new VariableArgFunction(sf.getFunction(settings),newNumArgs,settings); ParseItem[] args = new ParseItem[newNumArgs]; for (int j = 0; j < newNumArgs; j++) { ParseItem pi3 = (ParseItem)arguments.Pop(); args[newNumArgs - j - 1] = pi3; } for (int j = 0; j < args.Length; j++) vaf.add(args[j]); stack.Push(vaf); arguments.Clear(); arguments = null; } return; } // Function is a standard built in function BuiltInFunction bif = new BuiltInFunction(sf.getFunction(settings),settings); newNumArgs = sf.getFunction(settings).getNumArgs(); if (newNumArgs == 1) { // only one item which is the returned ParseItem bif.add(pi2); } else { if ((arguments == null && newNumArgs != 0) || (arguments != null && newNumArgs != arguments.Count)) { throw new FormulaException(FormulaException.INCORRECT_ARGUMENTS); } // multiple arguments so go to the arguments stack. // Unlike the variable argument function, the args are // stored in reverse order object[] items = arguments.ToArray(); for (int j = 0; j < newNumArgs; j++) { ParseItem pi3 = (ParseItem)items[j]; bif.add(pi3); } } stack.Push(bif); }
/// <summary> /// Toggles the class returned from the function for the set of matched elements. /// </summary> /// <param name="cssFunction">The function returning the class to toggle.</param> /// <returns>The current jElement.</returns> public jElement toggleClass(StringFunction cssFunction) { return null; }
private static extern void SetErrorLogFunction(StringFunction function);
/// <summary> /// Sets the value attribute of the matched set of elements using values returned /// from the specified function. /// </summary> /// <param name="valueFunction">The function returning the values to set.</param> /// <returns>The current jElement.</returns> public jElement val(StringFunction valueFunction) { return null; }
public void TestMyDelete(string init, int pos, int length, string expected) { Assert.AreEqual(expected, StringFunction.MyDelete(init, pos, length)); }
/// <summary> /// Wraps an HTML structure around each of the matched set of elements as /// returned from the specified wrapping function. /// </summary> /// <param name="wrappingFunction">The functio returning the HTML to wrap with.</param> /// <returns>The current jElement.</returns> public jElement wrap(StringFunction wrappingFunction) { return null; }
private Node MakeNode(string line) { var attrs = StringFunction.splitWithFirst(line, "="); return(new Node(attrs[0].Trim(), attrs[1].Trim())); }
/// <summary> /// Sets the specified attributes to the value returned from the specified function. /// </summary> /// <param name="attributeName">The name of the attribute to set.</param> /// <param name="attrFunction">The function returning the attribute values.</param> /// <returns>The current jElement.</returns> public jElement attr(string attributeName, StringFunction attrFunction) { return null; }
private static extern bool UpdateAgentJsonBytes(string brainUid, string agentUid, string json, System.IntPtr bytes_in, int length_in, StringFunction reportJsonResult);
/// <summary> /// Sets the HTML content of the matched set of elements by calling the specified /// function. /// </summary> /// <param name="htmlFunction">The function that returns the HTML content.</param> /// <returns>The current jElement.</returns> public jElement html(StringFunction htmlFunction) { return null; }
static public void GetInfo() { renderer = SystemInfo.graphicsDeviceVersion; renderer = renderer.ToLower(); if (renderer.Length > 8) { s = renderer.Substring(0, 8); if (s == "direct3d" || s == "directx") { renderer = "DirectX" + renderer.Substring(8); } s = s.Substring(0, 6); if (s == "opengl") { renderer = "OpenGL" + renderer.Substring(6); } s = s.Substring(0, 3); if (s == "d3d") { renderer = "DirectX" + renderer.Substring(3); } s = s.Substring(0, 2); if (s == "dx" || s == "dd") { renderer = "DirectX" + renderer.Substring(2); } // check if there's a drivername in the name still (see OpenGL Core) } if (renderer.Contains("[")) { if (renderer.Contains("[level ") == false) { renderer = renderer.Substring(0, renderer.IndexOf('[') - 1); } else { // remove any number before "[level" i = renderer.Length - 6; while (i > 0) { i--; if (renderer.Substring(i, 6) == "[level") { //remove any numbers that come before i while (i > 1) { i--; int.TryParse(renderer.Substring(i, 1), out tester); if (tester != 0 || renderer[i] == '0') { if (renderer[i - 1] == '.') { renderer = renderer.Substring(0, i - 1) + renderer.Substring(i + 1); } else { renderer = renderer.Substring(0, i) + renderer.Substring(i + 1); } } } break; } } // find "[level " in string //count number of '['s i = 0; foreach (char character in renderer) { if (character == '[') { i++; } } if (i == 1) { renderer = renderer.Substring(0, renderer.IndexOf('[') - 1) + renderer.Substring(renderer.IndexOf('[') + 6); // remove ']' if (renderer.Contains("]")) { renderer = renderer.Substring(0, renderer.IndexOf(']')) + renderer.Substring(renderer.IndexOf(']') + 1); } } /*else{ // i > 1 * //find the one that has "level " after it * i = renderer.Length; * while(i > 1){ * i --; * if(renderer.Substring(i, 6) == "[level"){ * renderer = * } * } * }*/ } } renderer = renderer.Replace(" ", string.Empty); // removes any spaces // now insert a space in front of the first number in the string i = 0; while (i < renderer.Length) { int.TryParse(renderer.Substring(i, 1), out tester); if (tester != 0 || renderer[i] == '0') { renderer = renderer.Substring(0, i) + " " + renderer.Substring(i); break; } i++; } while (renderer.Substring(renderer.Length - 1, 1) == " ") { renderer = renderer.Substring(0, renderer.Length - 1); } cpuName = SystemInfo.processorType; // Android Specific CPU name grab #if UNITY_ANDROID && !UNITY_EDITOR string filePath = "/proc/cpuinfo"; string[] content; string processor = null; if (cpuName.Contains("NEON")) { supports_neon = true; } if (File.Exists(filePath)) { content = File.ReadAllLines(filePath); foreach (string line in content) { if (line == "") { continue; } // I want to harvest "Processor" (the first one that comes up) if (line.Length > 9 && processor == null && line.Substring(0, 9) == "Processor") { processor = line.Substring(12); } // and "Hardware" else if (line.Length > 8 && soc == null && line.Substring(0, 8) == "Hardware") { soc = line.Substring(11); break; } // and Neon support else if (supports_neon == false && line.Contains("neon")) { supports_neon = true; } } } if (soc.Substring(0, 2) == "MT") { cpuName = "Mediatek " + soc; } if (cpuName.Substring(0, 4) == "ARMv") { cpuName = processor; } #endif // CPU info (name and speed) //Intel(R) Core(TM) i5(R) CPU M480 @ 2.67Ghz // switcheroo M and 480 FIXED //Intel(R) Core(TM) i7 CPU Q 720 @ 1.60GHz // switcheroo Q and 720 and remove the space between them FIXED //AMD Athlon(tm) 64 X2 Dual Core Processor 4200+ // get rid of "Dual Core" FIXED //Intel(R) Core(TM)2 CPU 6300 @ 1.86GHz // missing "duo" keyword FIXED //AMD A6-3620 APU with Radeon(tm) HD Graphics // get rid of 'APU' and get rid of 'with Radeon(tm) HD Graphics' FIXED //Intel(R) Celeron(TM) M CPU 430 @ 1.73Ghz i = 0; // scan if this PC has a core2 with bad naming convention (has the core2 name, but no 'solo', 'duo' ect suffix) if (cpuName.Contains("Core(TM)2") && (cpuName.Contains("Solo") == false && cpuName.Contains("Duo") == false && cpuName.Contains("Quad") == false && cpuName.Contains("Extreme") == false)) { while (i < cpuName.Length - 1) { print(cpuName.Substring(i, 9)); if (cpuName.Length - i > 8 && cpuName[i] == 'C' && cpuName.Substring(i, 9) == "Core(TM)2") { cpuName = cpuName.Substring(0, i) + "Core2 Duo" + cpuName.Substring(i + 9); break; } i++; } i = 0; } while (i < cpuName.Length - 1) { if (cpuName[i] == '(') { if (cpuName[i + 2] == ')') // removes (r) { cpuName = cpuName.Substring(0, i) + cpuName.Substring(i + 3); } else if (cpuName[i + 3] == ')') // removes (tm) { cpuName = cpuName.Substring(0, i) + cpuName.Substring(i + 4); } } else if (cpuName.Length - i > 2 && (cpuName[i] == 'C' || cpuName[i] == 'c') && (cpuName.Substring(i, 3) == "CPU" || cpuName.Substring(i, 3) == "cpu")) { cpuName = cpuName.Substring(0, i) + cpuName.Substring(i + 4); } else if (cpuName.Length - i > 2 && (cpuName[i] == 'A' || cpuName[i] == 'a') && (cpuName.Substring(i, 3) == "APU" || cpuName.Substring(i, 3) == "apu")) { cpuName = cpuName.Substring(0, i) + cpuName.Substring(i + 4); i--; } else if (cpuName.Length - i > 8 && (cpuName[i] == 'P' || cpuName[i] == 'p') && (cpuName.Substring(i, 9) == "Processor")) { cpuName = cpuName.Substring(0, i) + cpuName.Substring(i + 10); } else if (cpuName.Length - i > 8 && (cpuName[i] == 'A') && (cpuName.Substring(i, 4) == "ARMv")) { cpuName = "Generic ARMv" + cpuName.Substring(i + 4, 1) + " Core"; } else if (cpuName.Length - i > 8 && cpuName[i] == 'D' && cpuName.Substring(i, 9) == "Dual Core") { cpuName = cpuName.Substring(0, i) + cpuName.Substring(i + 10); i--; } else if (cpuName.Length - i > 8 && cpuName[i] == 'Q' && cpuName.Substring(i, 9) == "Quad-Core") { cpuName = cpuName.Substring(0, i) + cpuName.Substring(i + 10); i--; } else if (cpuName.Length - i > 7 && cpuName[i] == 'S' && cpuName.Substring(i, 8) == "Six-Core") { cpuName = cpuName.Substring(0, i) + cpuName.Substring(i + 9); i--; } else if (cpuName.Length - i > 9 && cpuName[i] == 'E' && cpuName.Substring(i, 10) == "Eight-Core") { cpuName = cpuName.Substring(0, i) + cpuName.Substring(i + 11); i--; } else if (cpuName.Length - i > 26 && cpuName[i] == 'w' && cpuName.Substring(i, 27) == "with Radeon(tm) HD Graphics") { cpuName = cpuName.Substring(0, i); break; } else if (cpuName.Contains("FX-9590")) { cpuName = "AMD FX-9590 Black Edition"; cpuSpeed = "4.70GHz"; break; } else if (cpuName.Contains("FX-9370")) { cpuName = "AMD FX-9370 Black Edition"; cpuSpeed = "4.40GHz"; break; } else if (cpuName.Contains("FX-8370E")) { cpuName = "AMD FX-8370E Black Edition"; cpuSpeed = "3.30GHz"; break; } else if (cpuName.Contains("FX-8370 ")) { cpuName = "AMD FX-8370 Black Edition"; cpuSpeed = "4.00GHz"; break; } else if (cpuName.Contains("FX-8350")) { cpuName = "AMD FX-8350 Black Edition"; cpuSpeed = "4.00GHz"; break; } else if (cpuName.Contains("FX-8320E")) { cpuName = "AMD FX-8320E Black Edition"; cpuSpeed = "3.20GHz"; break; } else if (cpuName.Contains("FX-8320 ")) { cpuName = "AMD FX-8320 Black Edition"; cpuSpeed = "3.50GHz"; break; } else if (cpuName.Contains("FX-8150")) { cpuName = "AMD FX-8150 Black Edition"; cpuSpeed = "3.60GHz"; break; } else if (cpuName.Contains("FX-8140")) { cpuName = "AMD FX-8140 Black Edition"; cpuSpeed = "4.10GHz"; break; } else if (cpuName.Contains("FX-8120")) { cpuName = "AMD FX-8120 Black Edition"; cpuSpeed = "3.10GHz"; break; } else if (cpuName.Contains("FX-8100")) { cpuName = "AMD FX-8100 Black Edition"; cpuSpeed = "2.80GHz"; break; } else if (cpuName.Contains("FX-6350")) { cpuName = "AMD FX-6350 Black Edition"; cpuSpeed = "3.90GHz"; break; } else if (cpuName.Contains("FX-6300")) { cpuName = "AMD FX-6300 Black Edition"; cpuSpeed = "3.50GHz"; break; } else if (cpuName.Contains("FX-4350")) { cpuName = "AMD FX-4350 Black Edition"; cpuSpeed = "4.20GHz"; break; } else if (cpuName.Contains("FX-4300")) { cpuName = "AMD FX-4300 Black Edition"; cpuSpeed = "3.80GHz"; break; } else if (cpuName.Contains("FX-4100")) { cpuName = "AMD FX-4100 Black Edition"; cpuSpeed = "3.60Ghz"; break; } else if (cpuName.Contains("X2 5000+")) { cpuName = "AMD Athlon 64 X2 5000+ Black Edition"; cpuSpeed = "2.60GHz"; break; } i++; } if (cpuName.Contains("@")) { // start going string until you hit 'Hz' // then work back until there are no more numbers string[] temp = cpuName.Split('@'); cpuName = temp[0]; if (temp[temp.Length - 1].Contains("hz") || temp[temp.Length - 1].Contains("HZ") || temp[temp.Length - 1].Contains("Hz")) { cpuSpeed = temp[temp.Length - 1].Replace(" ", string.Empty); // removes any spaces } } while (cpuName.Substring(cpuName.Length - 1, 1) == " ") { cpuName = cpuName.Substring(0, cpuName.Length - 1); } // scan for first gen i7 names if (cpuName.Contains("i7 ") || cpuName.Contains("i5 ") || cpuName.Contains("i3 ")) { i = 0; while (i < cpuName.Length) { if (cpuName[i] == 'i' && (cpuName[i + 1] == '7' || cpuName[i + 1] == '5' || cpuName[i + 1] == '3')) { cpuName = cpuName.Substring(0, i + 2) + "-" + cpuName.Substring(i + 3); break; } i++; } } // scan for i7 names with letters ordered BEFORE the type name instead of after it if (cpuName.Contains("i7-") || cpuName.Contains("i5-") || cpuName.Contains("i3-")) { i = 0; while (i < cpuName.Length) { // first fix stray spaces/empty characters if (cpuName[i] == 'i' && cpuName[i + 2] == '-') { if (cpuName[i + 3] == ' ') { //print ("yo"); cpuName = cpuName.Substring(0, i + 3) + cpuName.Substring(i + 4); i--; } if (cpuName[i + 4] == ' ') { cpuName = cpuName.Substring(0, i + 4) + cpuName.Substring(i + 5); } // cool now scan if there's a stray letter, too if (StringFunction.isNumber(cpuName[i + 3]) == false) { // cool, stray letter //print ("stray letter detected"); tester = i; // backup value //keep on looking until we find another space while (i < cpuName.Length) { if (cpuName[i] == ' ') { // first part is name until i-7.. // second part is the type number // final part is the letter cpuName = cpuName.Substring(0, tester + 2) + cpuName.Substring(tester + 4, i - tester) + cpuName[i + 3]; break; } i++; } if (i >= cpuName.Length) // there are no more spaces, so assume the type number until the end of the string { cpuName = cpuName.Substring(0, tester + 3) + cpuName.Substring(tester + 4) + cpuName[tester + 3]; } } break; } i++; } } // GPU name gpuName = SystemInfo.graphicsDeviceName.ToLower(); if (gpuName.Contains("emulated")) // emulated GPU { gpuName = "Software Renderer"; } else { // Removes the ()'s i = 0; while (i < gpuName.Length) { if (gpuName [i] == '(') { tester = i; while (tester < gpuName.Length) { if (gpuName [tester] == ')') { gpuName = gpuName.Substring(0, i) + gpuName.Substring(tester + 1); break; } tester++; } } i++; } while (gpuName.Substring(gpuName.Length - 1, 1) == " ") // remove space at the end { gpuName = gpuName.Substring(0, gpuName.Length - 1); } // convert to title casing gpuName = textInfo.ToTitleCase(gpuName); // TODO: restore HD and GTX and R# (R5, R7, R9 et cetera) if missing } if (gpuName.Substring(gpuName.Length - 3) == " Mp") // catches Mali 400 MP GPU chips { gpuName = gpuName.Substring(0, gpuName.Length - 3) + " MP"; } // grab shader model version shaderModel = SystemInfo.graphicsShaderLevel * 1F / 10F; //D-ram if (SystemInfo.systemMemorySize <= 1024) // if you have less than one GB of DRam show it in MBs { dram = SystemInfo.systemMemorySize + "mb"; } else // if you have more than one gb, show in GBs instead { dram = Mathf.Floor(SystemInfo.systemMemorySize / 102.4f) / 10f + "gb"; } //V-RAM if (SystemInfo.graphicsMemorySize <= 1024) { vram = SystemInfo.graphicsMemorySize + "mb"; } else { vram = Mathf.Floor(SystemInfo.graphicsMemorySize / 10.24f) / 100f + "gb"; } // grab # of logical cores coreCount = Environment.ProcessorCount; if (coreCount == 0) // environment grab failed. Use internal fallback { coreCount = SystemInfo.processorCount; } ; #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN // windows dependant if (cpuSpeed == null) // internal name speed grab failed. Use registery instead. { cpuSpeed = ((int)Registry.GetValue("HKEY_LOCAL_MACHINE\\Hardware\\Description\\System\\CentralProcessor\\0", "~MHz", 0) / 1000f) + " GHz"; } motherBoardModel = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\Hardware\\Description\\System\\BIOS", "BaseBoardProduct", null); // convert to lower case then capitalise the first letter of every word motherBoardModel = motherBoardModel.ToLower(); motherBoardModel = textInfo.ToTitleCase(motherBoardModel); platform = "Windows"; #elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX // osx dependant platform = "OSX"; #elif UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX // linux dependant platform = "Linux"; #elif UNITY_ANDROID platform = "Android"; // this grabs the cpu speed in case we don't already have it // www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt filePath = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"; if (cpuSpeed == null && File.Exists(filePath)) { content = File.ReadAllLines(filePath); int frequency; int.TryParse(content[0], out frequency); if (frequency > 1000) { if (frequency < 1100000) { cpuSpeed = (frequency / 1000f) + " Mhz"; } else { cpuSpeed = (frequency / 1000000f) + " Ghz"; } } } // this gives access to the build information var clazz = AndroidJNI.FindClass("android.os.Build$VERSION"); var fieldID = AndroidJNI.GetStaticFieldID(clazz, "SDK_INT", "I"); android_sdk = AndroidJNI.GetStaticIntField(clazz, fieldID); clazz = AndroidJNI.FindClass("android.os.BatteryManager"); fieldID = AndroidJNI.GetStaticFieldID(clazz, "BATTERY_PROPERTY_CURRENT_AVERAGE", "I"); batteryCurrent = AndroidJNI.GetStaticIntField(clazz, fieldID).ToString(); if (batteryCurrent != "0") { batteryCurrent += " Amp/h"; } else { batteryCurrent = null; } clazz = AndroidJNI.FindClass("android.os.Build"); fieldID = AndroidJNI.GetStaticFieldID(clazz, "BOARD", "Ljava/lang/String;"); board = AndroidJNI.GetStaticStringField(clazz, fieldID); if (board == "unknown") { board = null; } fieldID = AndroidJNI.GetStaticFieldID(clazz, "BRAND", "Ljava/lang/String;"); brand = AndroidJNI.GetStaticStringField(clazz, fieldID); fieldID = AndroidJNI.GetStaticFieldID(clazz, "DEVICE", "Ljava/lang/String;"); device = AndroidJNI.GetStaticStringField(clazz, fieldID); fieldID = AndroidJNI.GetStaticFieldID(clazz, "MANUFACTURER", "Ljava/lang/String;"); manufacturer = AndroidJNI.GetStaticStringField(clazz, fieldID); fieldID = AndroidJNI.GetStaticFieldID(clazz, "MODEL", "Ljava/lang/String;"); model = AndroidJNI.GetStaticStringField(clazz, fieldID); fieldID = AndroidJNI.GetStaticFieldID(clazz, "PRODUCT", "Ljava/lang/String;"); product = AndroidJNI.GetStaticStringField(clazz, fieldID); fieldID = AndroidJNI.GetStaticFieldID(clazz, "CPU_ABI", "Ljava/lang/String;"); abi = AndroidJNI.GetStaticStringField(clazz, fieldID); fieldID = AndroidJNI.GetStaticFieldID(clazz, "SERIAL", "Ljava/lang/String;"); serial = AndroidJNI.GetStaticStringField(clazz, fieldID); #endif }
/// <summary> /// Removes the class returned from the specified function for each of the set of matched elements. /// </summary> /// <param name="cssFunction">The function that returns the CSS class to remove.</param> /// <returns>The current jElement.</returns> public jElement removeClass(StringFunction cssFunction) { return null; }
static public void GetNetworkAdress() { IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); List <NetworkAdapter> adapterList = new List <NetworkAdapter>(); int i = 0; foreach (NetworkInterface adapter in nics) { //if(adapter.GetIPv4Statistics().UnicastPacketsReceived + adapter.GetIPv4Statistics().NonUnicastPacketsReceived == 0) // continue; NetworkAdapter adaptertje = new NetworkAdapter(); PhysicalAddress address = adapter.GetPhysicalAddress(); // name of the adapter adaptertje.adapterName = StringFunction.FilterString(adapter.Description); adaptertje.adapterAltName = adapter.Name; // IPv4 and IPv6 adresses and MTU if (adapter.GetIPProperties().GatewayAddresses.Count > 0) { adaptertje.gateway = adapter.GetIPProperties().GatewayAddresses[0].Address.ToString(); } foreach (UnicastIPAddressInformation ip in adapter.GetIPProperties().UnicastAddresses) { if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { adaptertje.IPv4Adress = ip.Address.ToString(); adaptertje.MTU = (Mathf.Floor(adapter.GetIPProperties().GetIPv4Properties().Mtu / 100f) / 10f) + " KB"; } else if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) { adaptertje.IPv6Adress = ip.Address.ToString(); adaptertje.MTU = (Mathf.Floor(adapter.GetIPProperties().GetIPv6Properties().Mtu / 100f) / 10f) + " KB"; } } // Adapter nominal speed if (adapter.Speed == 1000000000) { adaptertje.nominalSpeed = "Gigabit"; } else if (adapter.Speed > 1000000000) { adaptertje.nominalSpeed = (Mathf.Ceil((float)adapter.Speed / 100000000) / 10f) + " Gigabit"; } else if (adapter.Speed < 1000000) { adaptertje.nominalSpeed = (Mathf.Floor((float)adapter.Speed / 100f) / 10f) + " Kbps"; } else { adaptertje.nominalSpeed = (Mathf.Floor((float)adapter.Speed / 100000f) / 10f) + " Mbps"; } // MAC address byte[] bytes = address.GetAddressBytes(); string mac = null; for (i = 0; i < bytes.Length; i++) { mac = string.Concat(mac + (string.Format("{0}", bytes[i].ToString("X2")))); if (i != bytes.Length - 1) { mac = string.Concat(mac + "-"); } } adaptertje.macAdress = mac; adapterList.Add(adaptertje); } if (netAdapters.Length != adapterList.Count) { netAdapters = new NetworkAdapter[adapterList.Count]; } i = 0; foreach (NetworkAdapter adapter in adapterList) { netAdapters[i] = adapter; i++; } }
/** * Constructor for use when this is called when parsing a string * * @param sf the built in function * @param ws the workbook settings */ public Attribute(StringFunction sf,WorkbookSettings ws) { settings = ws; if (sf.getFunction(settings) == Function.SUM) { options |= SUM_MASK; } else if (sf.getFunction(settings) == Function.IF) { options |= IF_MASK; } }