public ArrayImpl StrSplit(string inputString, string stringDelimiter, bool includeEmpty = true) { ArrayImpl arrResult = new ArrayImpl(); string[] arrParsed; if (!string.IsNullOrEmpty(inputString)) { if (!string.IsNullOrEmpty(stringDelimiter)) { arrParsed = inputString.Split(new string[] { stringDelimiter }, includeEmpty ? StringSplitOptions.None : StringSplitOptions.RemoveEmptyEntries); } else { arrParsed = new string[] { inputString }; } } else { arrParsed = new string[] { string.Empty }; } arrResult = new ArrayImpl(arrParsed.Select(x => ValueFactory.Create(x))); return(arrResult); }
public ArrayImpl SplitBinaryData(BinaryDataContext data, int size) { // Сделано на int т.к. BinaryContext.Size имеет тип int; ArrayImpl array = new ArrayImpl(); int readedBytes = 0; while (readedBytes < data.Buffer.Length) { int bytesToRead = size; if (bytesToRead > data.Buffer.Length - readedBytes) { bytesToRead = data.Buffer.Length - readedBytes; } byte[] buffer = new byte[bytesToRead]; Buffer.BlockCopy(data.Buffer, readedBytes, buffer, 0, bytesToRead); readedBytes += bytesToRead; array.Add(new BinaryDataContext(buffer)); } return(array); }
private static IValue[] GetArgsToPass(ArrayImpl arguments, MethodInfo methInfo) { var argsToPass = arguments == null ? new IValue[0] : arguments.ToArray(); if (methInfo.ArgCount < argsToPass.Length) { throw RuntimeException.TooManyArgumentsPassed(); } if (methInfo.ArgCount > argsToPass.Length) { throw RuntimeException.TooLittleArgumentsPassed(); } for (int i = 0; i < argsToPass.Length; i++) { if (!methInfo.Params[i].IsByValue) { argsToPass[i] = Variable.Create(argsToPass[i]); } } return(argsToPass); }
public string StrConcat(ArrayImpl input, string delimiter = null) { var strings = input.Select(x => x.AsString()); return(String.Join(delimiter, strings)); }
public static IRuntimeContextInstance Constructor(IValue source) { ArrayImpl RawSource = source.GetRawValue() as ArrayImpl; return(new FixedArrayImpl(RawSource)); }