public override StringList getNames() { // name of this datamodel to be used in scxml element StringList names = new StringList(); names.add("simple"); return names; }
public override ReturnCode Execute( Interpreter interpreter, IClientData clientData, ArgumentList arguments, ref Result result ) { if ((arguments == null) || (arguments.Count < 2)) { result = Utility.WrongNumberOfArguments( this, 1, arguments, "command"); return ReturnCode.Error; } try { var processor = new CommandLineProcessor(); var o = processor.Pharse(arguments.Select(argument => (string) argument).Skip(1).ToArray()); if (!(o is string) && o is IEnumerable) result = new StringList(o); else { result = o == null ? "" : new Variant(o).ToString(); } } catch (Exception exception) { Log.Error("Script error ", exception); result = "Error on command execution " + exception.Message; } return ReturnCode.Ok; }
private static SharpNL.Dictionary.Dictionary CreateDictionary() { var sampleStream = CreateSample(); var sample = sampleStream.Read(); var entries = new List<string[]>(); while (sample != null) { Span[] names = sample.Names; if (names != null && names.Length > 0) { var toks = sample.Sentence; foreach (Span name in names) { var nameToks = new string[name.Length]; Array.Copy(toks, name.Start, nameToks, 0, name.Length); entries.Add(nameToks); } } sample = sampleStream.Read(); } sampleStream.Dispose(); var dictionary = new SharpNL.Dictionary.Dictionary(true); foreach (var entry in entries) { var dicEntry = new StringList(entry); dictionary.Add(dicEntry); } return dictionary; }
public static EntityMemberMask Create(EntityInfo entity, string propertiesOrGroups) { var invalidNames = new StringList(); var mask = new EntityMemberMask(propertiesOrGroups, entity); var props = propertiesOrGroups.SplitNames(',', ';'); foreach (var name in props) { //first try member if (string.IsNullOrWhiteSpace(name)) continue; var grp = entity.GetPropertyGroup(name); if (grp != null) { foreach (var m in grp.Members) mask.Set(m); continue; } var member = entity.GetMember(name); if (member != null) { mask.Set(member); continue; } //name is invalid invalidNames.Add(name); } if (invalidNames.Count > 0) Util.Throw("Properties/subgroups [{0}] not found in entity {1}.", string.Join(",", invalidNames), entity.EntityType); return mask; }
private void FolderSet(StringList FldList) { for (int i = 0; i < FldList.Count; i++) { this.FolderAddSet(FldList[i]); } }
public override int CreateTempUploadFile(int userID, string uploadAction, string searchInfo, StringList customParamList, string filename, string serverFileName, string md5, long fileSize, string fileID) { int tempUploadFileID; using (SqlQuery query = new SqlQuery()) { query.CommandType = CommandType.StoredProcedure; query.CommandText = "bx_CreateTempUploadFile"; query.CreateParameter<int>("@UserID", userID, SqlDbType.Int); query.CreateParameter<string>("@UploadAction", uploadAction, SqlDbType.VarChar, 100); query.CreateParameter<string>("@SearchInfo", searchInfo, SqlDbType.NVarChar, 100); query.CreateParameter<string>("@CustomParams", customParamList.ToString(), SqlDbType.NVarChar, 3000); query.CreateParameter<string>("@FileName", filename, SqlDbType.NVarChar, 256); query.CreateParameter<string>("@ServerFileName", serverFileName, SqlDbType.VarChar, 100); query.CreateParameter<string>("@MD5", md5, SqlDbType.Char, 32); query.CreateParameter<long>("@FileSize", fileSize, SqlDbType.Int); query.CreateParameter<string>("@FileID", fileID, SqlDbType.VarChar, 50); SqlParameter returnParam = query.CreateParameter<int>("@TempUploadFileID", SqlDbType.Int, ParameterDirection.Output); query.ExecuteNonQuery(); tempUploadFileID = (int)returnParam.Value; } return tempUploadFileID; }
public LineContinuationTerminal(string name, params string[] startSymbols) : base(name, TokenCategory.Outline) { var symbols = startSymbols.Where(s => !IsNullOrWhiteSpace(s)).ToArray(); StartSymbols = new StringList(symbols); if (StartSymbols.Count == 0) StartSymbols.AddRange(_defaultStartSymbols); Priority = Terminal.HighestPriority; }
/// <summary> /// Called when the component should do it's actual work. /// </summary> public override void Compute() { //validate config if (config.Directory == null) { throw new ComponentException("Directory has not been specified."); } if (Directory.Exists(config.Directory) == false) { throw new ComponentException(String.Format("Directory does not exist '{0}'.", config.Directory.Absolute)); } string[] files; if (String.IsNullOrEmpty(config.SearchPattern) == true) { files = Directory.GetFiles(config.Directory, "*", TranslateSearchOption(config.SearchOption)); } else { files = Directory.GetFiles(config.Directory, config.SearchPattern, TranslateSearchOption(config.SearchOption)); } StringList listOfFiles = new StringList(); listOfFiles.AddRange(files); Workspace.Store("files", listOfFiles); Workspace.Store("numberOfFiles", listOfFiles.Count); Logger.Trace(String.Format("Found {0} files in the given directory that match given search pattern.", listOfFiles.Count)); }
/// <summary> /// Runs the processor. /// </summary> /// <param name="args">The arguments.</param> public virtual void Process(PipelineArgs args) { Assert.ArgumentNotNull(args, "args"); User user = args.CustomData["user"] as User; if (user == null) { Log.Error("The user is null", this); return; } GeneralSettings generalSettings = Context.Entity.GetConfiguration<GeneralSettings>(); StringList roles = new StringList(generalSettings.DefaultCustomerRoles); foreach (string role in roles) { if (Roles.RoleExists(role)) { user.Roles.Add(Role.FromName(role)); } else { Log.Warn(string.Format("Role: '{0}' does not exist", role), this); } } }
public void HistoryUserListSet(StringList uc) { if (uc.Count > 0) { this.txbUserCode.Text = uc[uc.Count - 1]; } }
public override IList<string> GetFirsts() { var firsts = new StringList(); foreach (var t in LineTerminators) firsts.Add(t.ToString()); return firsts; }
public string GetValue() { StringTable table = new StringTable(); //table.Add("LimitType", LimitType.ToString()); table.Add("LimitType", ((byte)LimitType).ToString()); foreach (KeyValuePair<Guid, List<Guid>> item in ExcludeRoles) { if (item.Value != null) { StringList roles = new StringList(); foreach (Guid roleID in item.Value) { roles.Add(roleID.ToString()); } table.Add("ExcludeRoles-" + item.Key.ToString("N"), roles.ToString()); } } return table.ToString(); }
private bool _isLineComment; //true if NewLine is one of EndSymbols; if yes, EOF is also considered a valid end symbol #endregion Fields #region Constructors public CommentTerminal(String name, string startSymbol, params string[] endSymbols) : base(name, TokenCategory.Comment) { this.StartSymbol = startSymbol; this.EndSymbols = new StringList(); EndSymbols.AddRange(endSymbols); }
/// <summary> /// Initializes a new instance of the <see cref="ClientExtension"/> class. /// </summary> /// <param name="type">Extension type</param> /// <param name="scope">Extension install scope</param> /// <param name="manifestStream">Manifest stream, can be null</param> /// <param name="marketplaceAssetID">The asset ID for Office Marketplace</param> /// <param name="marketplaceContentMarket">The content market for Office Marketplace</param> /// <param name="isAvailable">Whether extension is available</param> /// <param name="isMandatory">Whether extension is mandatory</param> /// <param name="isEnabledByDefault">Whether extension is enabled by default</param> /// <param name="providedTo">Who the extension is provided for (e.g. "entire org" or "specific users")</param> /// <param name="specificUsers">List of users extension is provided for, can be null</param> /// <param name="appStatus">App status</param> /// <param name="etoken">Etoken</param> public ClientExtension( ExtensionType type, ExtensionInstallScope scope, Stream manifestStream, string marketplaceAssetID, string marketplaceContentMarket, bool isAvailable, bool isMandatory, bool isEnabledByDefault, ClientExtensionProvidedTo providedTo, StringList specificUsers, string appStatus, string etoken) : this() { this.Type = type; this.Scope = scope; this.ManifestStream = manifestStream; this.MarketplaceAssetID = marketplaceAssetID; this.MarketplaceContentMarket = marketplaceContentMarket; this.IsAvailable = isAvailable; this.IsMandatory = isMandatory; this.IsEnabledByDefault = isEnabledByDefault; this.ProvidedTo = providedTo; this.SpecificUsers = specificUsers; this.AppStatus = appStatus; this.Etoken = etoken; }
public override IList<string> GetFirsts() { StringList result = new StringList(); result.AddRange(Prefixes); //we assume that prefix is always optional, so string can start with start-end symbol result.AddRange(_startEndSymbols); return result; }
public CommentTerminal(string name, string startSymbol, params string[] endSymbols) : base(name, TokenCategory.Comment) { StartSymbol = startSymbol; EndSymbols = new StringList(); EndSymbols.AddRange(endSymbols); Priority = TerminalPriority.High; //assign max priority }
public override IList<string> GetFirsts() { StringList result = new StringList(); result.AddRange(base.Prefixes); //we assume that prefix is always optional, so number can always start with plain digit result.AddRange(new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }); return result; }
public static string FormatSqlParameters(ICollection prms, string format = "{0}={1}", string delimiter = ", ", int maxValueLen = 50) { var sValues = new StringList(); foreach (IDbDataParameter prm in prms) sValues.Add(FormatSqlParameter(prm, format, maxValueLen)); var result = string.Join(delimiter, sValues); return result; }
public void TestBasics() { var list = new StringList("a", "b"); Assert.AreEqual(list.Count, 2); Assert.AreEqual(list[0], "a"); Assert.AreEqual(list[1], "b"); }
public void TestDifferentCaseLookupCaseSensitive() { var entry1 = new StringList(new[] {"1a", "1b"}); var entry2 = new StringList(new[] {"1A", "1B"}); var dic = new SharpNL.Dictionary.Dictionary(true) {entry1}; Assert.False(dic.Contains(entry2)); }
public override void Compute() { StringList list = new StringList(); foreach (string theString in DevelopmentKit.IO.Generics.ImportStrings(_config.FileName.Absolute)) { list.Add(theString); } Workspace.Store("ListOfStrings", list); }
public void op_Equals_objectSame() { var obj = new StringList(); // ReSharper disable EqualExpressionComparison Assert.True(obj.Equals(obj)); // ReSharper restore EqualExpressionComparison }
public void op_AsEnumerable_ofString() { const string expected = "example"; var obj = new StringList { expected }; Assert.Equal(expected, obj.AsEnumerable().First()); }
public void StringListSerializationTest() { StringList dataToSerialize = new StringList(); byte[] data = SerializationUtil.SerializeData(dataToSerialize); Assert.IsNotNull(data); Assert.AreNotEqual(0, data.Length); StringList deserializedData = SerializationUtil.DeserializeData<StringList>(data); Assert.IsNotNull(deserializedData); Assert.AreNotSame(dataToSerialize, deserializedData); }
/// <summary> /// Constructor /// </summary> public ApiResponse(SessionAuthUser authUser, ApiRequest request) : base(authUser) { if (request == null) throw new ArgumentNullException("request"); TrackingID = request.TrackingID; Function = request.Function; ErrorMessages = new StringList(); }
/// <summary> /// Constructor /// </summary> public CustomViewEngine(params string[] additionalLocations) { StringList viewLocations = new StringList(); viewLocations.Add("~/Views/{1}/{0}.cshtml"); viewLocations.Add("~/Views/Shared/{0}.cshtml"); viewLocations.AddRange(additionalLocations); this.PartialViewLocationFormats = viewLocations.ToArray(); this.ViewLocationFormats = viewLocations.ToArray(); }
public RuntimeObjectsLoader() { fileList = new StringList(); assemblyList = new ListEx<Assembly>(); referenceList = new StringList(); report = new RuntimeObjectsLoaderReport(); registerMethod = typeof(RuntimeAttribute).GetMethod("Register", BindingFlags.Instance | BindingFlags.NonPublic); Debug.Assert(registerMethod != null, "Register method not found."); }
internal void Run(StringList values) { if (string.IsNullOrEmpty(Command)) { return; } List<Item> items = new List<Item>(); StringList othervalues = new StringList(); foreach (var val in values) { ItemUri uri = ItemUri.Parse(val); if (uri != null) { items.Add(Sitecore.Data.Database.GetItem(uri)); } else { othervalues.Add(val); } } Command command = CommandManager.GetCommand(Command); Debug.Assert(command != null, Command + " not found."); // If our command can hanlde more than one item in the context we run it once if (!SingleItemContext) { CommandContext cc = new CommandContext(items.ToArray()); cc.CustomData = othervalues; command.Execute(cc); } //otherwise we have to generate as many commands as items else { if (items.Count > 0) { foreach (var item in items) { CommandContext cc = new CommandContext(item); command.Execute(cc); } } if (othervalues.Count > 0) { foreach (var othervalue in othervalues) { CommandContext cc = new CommandContext(); cc.CustomData = othervalue; command.Execute(cc); } } } }
public override IList<string> GetFirsts() { StringList result = new StringList(); result.AddRange(base.Prefixes); //we assume that prefix is always optional, so number can always start with plain digit result.AddRange(new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }); // Python float numbers can start with a dot if (IsSet(TermOptions.NumberAllowStartEndDot)) result.Add(DecimalSeparator.ToString()); return result; }
public void StringListConstructorTest() { StringList list = new StringList(true); Assert.IsTrue(list.IsUniqueList, "List Uniqueness Failure"); list = new StringList(false); Assert.IsFalse(list.IsUniqueList, "List Uniqueness Failure"); list = new StringList(); Assert.AreEqual(false, list.IsUniqueList, "List Uniqueness Failure"); }
/////////////////////////////////////////////////////////////////////// #region IExecute Members public override ReturnCode Execute( Interpreter interpreter, IClientData clientData, ArgumentList arguments, ref Result result ) { if (interpreter == null) { result = "invalid interpreter"; return(ReturnCode.Error); } if (arguments == null) { result = "invalid argument list"; return(ReturnCode.Error); } if (arguments.Count < 2) { result = "wrong # args: should be \"hash option ?arg ...?\""; return(ReturnCode.Error); } ReturnCode code; string subCommand = arguments[1]; bool tried = false; code = ScriptOps.TryExecuteSubCommandFromEnsemble( interpreter, this, clientData, arguments, true, false, ref subCommand, ref tried, ref result); if ((code != ReturnCode.Ok) || tried) { return(code); } // // NOTE: These algorithms are known to be supported by the // framework. // // Normal: MD5, RIPEMD160, SHA, SHA1, SHA256, SHA384, SHA512 // // Keyed: MACTripleDES // // HMAC: HMACMD5, HMACRIPEMD160, HMACSHA1, HMACSHA256, // HMACSHA384, HMACSHA512 // switch (subCommand) { case "keyed": { if (arguments.Count >= 4) { OptionDictionary options = new OptionDictionary( new IOption[] { new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-raw", null), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-filename", null), /* COMPAT: Tcllib. */ new Option(null, OptionFlags.MustHaveEncodingValue, Index.Invalid, Index.Invalid, "-encoding", null), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, Option.EndOfOptions, null) }); int argumentIndex = Index.Invalid; code = interpreter.GetOptions( options, arguments, 0, 2, Index.Invalid, false, ref argumentIndex, ref result); if (code == ReturnCode.Ok) { if ((argumentIndex != Index.Invalid) && ((argumentIndex + 2) <= arguments.Count) && ((argumentIndex + 3) >= arguments.Count)) { Variant value = null; bool raw = false; if (options.IsPresent("-raw")) { raw = true; } bool isFileName = false; if (options.IsPresent("-filename", ref value)) { isFileName = true; } Encoding encoding = null; if (options.IsPresent("-encoding", ref value)) { encoding = (Encoding)value.Value; } if (code == ReturnCode.Ok) { try { using (KeyedHashAlgorithm algorithm = KeyedHashAlgorithm.Create( arguments[argumentIndex])) { if (algorithm != null) { algorithm.Initialize(); if ((argumentIndex + 3) == arguments.Count) { byte[] bytes = null; code = StringOps.GetBytes( encoding, arguments[argumentIndex + 2], EncodingType.Binary, ref bytes, ref result); if (code == ReturnCode.Ok) { algorithm.Key = bytes; } } if (code == ReturnCode.Ok) { if (isFileName) { Stream stream = null; try { code = RuntimeOps.NewStream( interpreter, arguments[argumentIndex + 1], FileMode.Open, FileAccess.Read, ref stream, ref result); if (code == ReturnCode.Ok) { if (raw) { result = new ByteList( algorithm.ComputeHash(stream)); } else { result = FormatOps.Hash( algorithm.ComputeHash(stream)); } } } finally { if (stream != null) { stream.Close(); stream = null; } } } else { byte[] bytes = null; code = StringOps.GetBytes( encoding, arguments[argumentIndex + 1], EncodingType.Binary, ref bytes, ref result); if (raw) { result = new ByteList( algorithm.ComputeHash(bytes)); } else { result = FormatOps.Hash( algorithm.ComputeHash(bytes)); } } } } else { result = String.Format( "unsupported keyed hash algorithm \"{0}\"", arguments[argumentIndex]); code = ReturnCode.Error; } } } catch (Exception e) { Engine.SetExceptionErrorCode(interpreter, e); result = e; code = ReturnCode.Error; } } } else { if ((argumentIndex != Index.Invalid) && Option.LooksLikeOption(arguments[argumentIndex])) { result = OptionDictionary.BadOption( options, arguments[argumentIndex]); } else { result = String.Format( "wrong # args: should be \"{0} {1} ?options? algorithm string ?key?\"", this.Name, subCommand); } code = ReturnCode.Error; } } } else { result = String.Format( "wrong # args: should be \"{0} {1} ?options? algorithm string ?key?\"", this.Name, subCommand); code = ReturnCode.Error; } break; } case "list": { if ((arguments.Count == 2) || (arguments.Count == 3)) { string type = null; if (arguments.Count == 3) { type = arguments[2]; } switch (type) { case null: case "all": { StringList list = new StringList(); lock (syncRoot) { if (defaultAlgorithms != null) { list.AddRange(defaultAlgorithms); } } if (keyedHashAlgorithmNames != null) { foreach (string hashAlgorithmName in keyedHashAlgorithmNames) { list.Add(StringList.MakeList("keyed", hashAlgorithmName)); } } if (macHashAlgorithmNames != null) { foreach (string hashAlgorithmName in macHashAlgorithmNames) { list.Add(StringList.MakeList("mac", hashAlgorithmName)); } } if (normalHashAlgorithmNames != null) { foreach (string hashAlgorithmName in normalHashAlgorithmNames) { list.Add(StringList.MakeList("normal", hashAlgorithmName)); } } result = list; break; } case "default": { lock (syncRoot) { result = (defaultAlgorithms != null) ? new StringList(defaultAlgorithms) : null; } break; } case "keyed": { result = (keyedHashAlgorithmNames != null) ? new StringList(keyedHashAlgorithmNames) : null; break; } case "mac": { result = (macHashAlgorithmNames != null) ? new StringList(macHashAlgorithmNames) : null; break; } case "normal": { result = (normalHashAlgorithmNames != null) ? new StringList(normalHashAlgorithmNames) : null; break; } default: { result = "unknown algorithm list, must be: all, default, keyed, mac, or normal"; code = ReturnCode.Error; break; } } } else { result = String.Format( "wrong # args: should be \"{0} {1} ?type?\"", this.Name, subCommand); code = ReturnCode.Error; } break; } case "mac": { if (arguments.Count >= 4) { OptionDictionary options = new OptionDictionary( new IOption[] { new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-raw", null), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-filename", null), /* COMPAT: Tcllib. */ new Option(null, OptionFlags.MustHaveEncodingValue, Index.Invalid, Index.Invalid, "-encoding", null), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, Option.EndOfOptions, null) }); int argumentIndex = Index.Invalid; code = interpreter.GetOptions( options, arguments, 0, 2, Index.Invalid, false, ref argumentIndex, ref result); if (code == ReturnCode.Ok) { if ((argumentIndex != Index.Invalid) && ((argumentIndex + 2) <= arguments.Count) && ((argumentIndex + 3) >= arguments.Count)) { Variant value = null; bool raw = false; if (options.IsPresent("-raw")) { raw = true; } bool isFileName = false; if (options.IsPresent("-filename", ref value)) { isFileName = true; } Encoding encoding = null; if (options.IsPresent("-encoding", ref value)) { encoding = (Encoding)value.Value; } if (code == ReturnCode.Ok) { try { using (HMAC algorithm = HMAC.Create( arguments[argumentIndex])) { if (algorithm != null) { algorithm.Initialize(); if ((argumentIndex + 3) == arguments.Count) { byte[] bytes = null; code = StringOps.GetBytes( encoding, arguments[argumentIndex + 2], EncodingType.Binary, ref bytes, ref result); if (code == ReturnCode.Ok) { algorithm.Key = bytes; } } if (code == ReturnCode.Ok) { if (isFileName) { Stream stream = null; try { code = RuntimeOps.NewStream( interpreter, arguments[argumentIndex + 1], FileMode.Open, FileAccess.Read, ref stream, ref result); if (code == ReturnCode.Ok) { if (raw) { result = new ByteList( algorithm.ComputeHash(stream)); } else { result = FormatOps.Hash( algorithm.ComputeHash(stream)); } } } finally { if (stream != null) { stream.Close(); stream = null; } } } else { byte[] bytes = null; code = StringOps.GetBytes( encoding, arguments[argumentIndex + 1], EncodingType.Binary, ref bytes, ref result); if (raw) { result = new ByteList( algorithm.ComputeHash(bytes)); } else { result = FormatOps.Hash( algorithm.ComputeHash(bytes)); } } } } else { result = String.Format( "unsupported hmac algorithm \"{0}\"", arguments[argumentIndex]); code = ReturnCode.Error; } } } catch (Exception e) { Engine.SetExceptionErrorCode(interpreter, e); result = e; code = ReturnCode.Error; } } } else { if ((argumentIndex != Index.Invalid) && Option.LooksLikeOption(arguments[argumentIndex])) { result = OptionDictionary.BadOption( options, arguments[argumentIndex]); } else { result = String.Format( "wrong # args: should be \"{0} {1} ?options? algorithm string ?key?\"", this.Name, subCommand); } code = ReturnCode.Error; } } } else { result = String.Format( "wrong # args: should be \"{0} {1} ?options? algorithm string ?key?\"", this.Name, subCommand); code = ReturnCode.Error; } break; } case "normal": { if (arguments.Count >= 4) { OptionDictionary options = new OptionDictionary( new IOption[] { new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-raw", null), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-filename", null), /* COMPAT: Tcllib. */ new Option(null, OptionFlags.MustHaveEncodingValue, Index.Invalid, Index.Invalid, "-encoding", null), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, Option.EndOfOptions, null) }); int argumentIndex = Index.Invalid; code = interpreter.GetOptions( options, arguments, 0, 2, Index.Invalid, false, ref argumentIndex, ref result); if (code == ReturnCode.Ok) { if ((argumentIndex != Index.Invalid) && ((argumentIndex + 2) == arguments.Count)) { Variant value = null; bool raw = false; if (options.IsPresent("-raw")) { raw = true; } bool isFileName = false; if (options.IsPresent("-filename", ref value)) { isFileName = true; } Encoding encoding = null; if (options.IsPresent("-encoding", ref value)) { encoding = (Encoding)value.Value; } if (code == ReturnCode.Ok) { try { using (HashAlgorithm algorithm = HashAlgorithm.Create( arguments[argumentIndex])) { if (algorithm != null) { algorithm.Initialize(); if (isFileName) { Stream stream = null; try { code = RuntimeOps.NewStream( interpreter, arguments[argumentIndex + 1], FileMode.Open, FileAccess.Read, ref stream, ref result); if (code == ReturnCode.Ok) { if (raw) { result = new ByteList( algorithm.ComputeHash(stream)); } else { result = FormatOps.Hash( algorithm.ComputeHash(stream)); } } } finally { if (stream != null) { stream.Close(); stream = null; } } } else { byte[] bytes = null; code = StringOps.GetBytes( encoding, arguments[argumentIndex + 1], EncodingType.Binary, ref bytes, ref result); if (code == ReturnCode.Ok) { if (raw) { result = new ByteList( algorithm.ComputeHash(bytes)); } else { result = FormatOps.Hash( algorithm.ComputeHash(bytes)); } } } } else { result = String.Format( "unsupported hash algorithm \"{0}\"", arguments[argumentIndex]); code = ReturnCode.Error; } } } catch (Exception e) { Engine.SetExceptionErrorCode(interpreter, e); result = e; code = ReturnCode.Error; } } } else { if ((argumentIndex != Index.Invalid) && Option.LooksLikeOption(arguments[argumentIndex])) { result = OptionDictionary.BadOption( options, arguments[argumentIndex]); } else { result = String.Format( "wrong # args: should be \"{0} {1} ?options? algorithm string\"", this.Name, subCommand); } code = ReturnCode.Error; } } } else { result = String.Format( "wrong # args: should be \"{0} {1} ?options? algorithm string\"", this.Name, subCommand); code = ReturnCode.Error; } break; } default: { result = ScriptOps.BadSubCommand( interpreter, null, null, subCommand, this, null, null); code = ReturnCode.Error; break; } } return(code); }
public void Delete(Int32 fieldIndex) { StringList.RemoveAt(fieldIndex); }
public void Update(Int32 fieldIndex, String value) { StringList.RemoveAt(fieldIndex); StringList.Insert(fieldIndex, value); }
public void Add(String value) { Length += value.Length; StringList.Add(value); }
public void Append(IEnumerable <IEnumerable <KeyValuePair <string, object> > > xseq, IEnumerable <string> yseq) { var _yseq = new StringList(yseq.ToList()); _trainer.append(new ItemSequence(xseq).Items, _yseq, 0); }
public int importarDiretorioViaXML(Aba aba, string sNomeArquivo, List <Diretorio> listaDirPai, IProgressoLog progressoLog) { string sTexto; int nArquivo, resultado; StringList listaLocal; DiretorioXML diretorioXML; List <Diretorio> listaDiretorio; resultado = 0; diretorioXML = new DiretorioXML(); listaDiretorio = new List <Diretorio>(); listaLocal = new StringList(); listaLocal.LoadFromFile(sNomeArquivo); if (!listaLocal[0].Equals("<diretorio>")) { resultado = -1; } else { nArquivo = 0; foreach (string sTexto1 in listaLocal) { sTexto = sTexto1.Trim(); nArquivo = XMLParaDiretorio(sTexto, nArquivo, diretorioXML); if (nArquivo == -1) { resultado = -1; break; } else if (nArquivo == 13) { nArquivo = 1; diretorioXML.Diretorio.Aba = aba; listaDiretorio.Add(diretorioXML.Diretorio); if (verificaCodDir(aba.Codigo, diretorioXML.Diretorio.Caminho, listaDirPai)) { resultado = -2; break; } diretorioXML.Diretorio = new Diretorio(); } else if (nArquivo == -3) { resultado = nArquivo; } else { nArquivo++; } } } salvarDiretorio(listaDiretorio, progressoLog); listaDiretorio.Clear(); return(resultado); }
/////////////////////////////////////////////////////////////////////// #region IExecute Members public override ReturnCode Execute( Interpreter interpreter, IClientData clientData, ArgumentList arguments, ref Result result ) { ReturnCode code = ReturnCode.Ok; if (interpreter != null) { if (arguments != null) { if (arguments.Count == 4) { StringList list = null; code = Parser.SplitList( interpreter, arguments[1], 0, Length.Invalid, true, ref list, ref result); if (code == ReturnCode.Ok) { int firstIndex = Index.Invalid; code = Value.GetIndex( arguments[2], list.Count, ValueFlags.AnyIndex, interpreter.CultureInfo, ref firstIndex, ref result); if (code == ReturnCode.Ok) { int lastIndex = Index.Invalid; code = Value.GetIndex( arguments[3], list.Count, ValueFlags.AnyIndex, interpreter.CultureInfo, ref lastIndex, ref result); if (code == ReturnCode.Ok) { if (firstIndex < 0) { firstIndex = 0; } if (lastIndex >= list.Count) { lastIndex = list.Count - 1; } if (firstIndex <= lastIndex) { result = StringList.GetRange( list, firstIndex, lastIndex); } else { result = String.Empty; } } } } } else { result = "wrong # args: should be \"lrange list first last\""; code = ReturnCode.Error; } } else { result = "invalid argument list"; code = ReturnCode.Error; } } else { result = "invalid interpreter"; code = ReturnCode.Error; } return(code); }
public override ReturnCode Execute( Interpreter interpreter, IClientData clientData, ArgumentList arguments, ref Result result ) { ReturnCode code = ReturnCode.Ok; if (interpreter != null) { if (arguments != null) { if (arguments.Count >= 3) { StringList list = null; code = Parser.SplitList( interpreter, arguments[1], 0, Length.Invalid, true, ref list, ref result); if (code == ReturnCode.Ok) { int argumentIndex; for (argumentIndex = 2; argumentIndex < arguments.Count; argumentIndex++) { string value; if ((argumentIndex - 2) < list.Count) { value = list[argumentIndex - 2]; } else { value = String.Empty; } code = interpreter.SetVariableValue( VariableFlags.None, arguments[argumentIndex], value, null, ref result); if (code != ReturnCode.Ok) { break; } } if (code == ReturnCode.Ok) { if ((argumentIndex - 2) < list.Count) { result = StringList.GetRange(list, argumentIndex - 2); } else { result = String.Empty; } } } } else { result = "wrong # args: should be \"lassign list varName ?varName ...?\""; code = ReturnCode.Error; } } else { result = "invalid argument list"; code = ReturnCode.Error; } } else { result = "invalid interpreter"; code = ReturnCode.Error; } return(code); }
public CatalogProps(string sign, string title) { Sign = sign; Title = title; Index = null; }
private void PrepareData() { mainIndex = new StringList(); byIndex = new StringList(); dyIndex = new StringList(); bpIndex = new StringList(); dpIndex = new StringList(); deathCauses = new StringList(); occuIndex = new StringList(); reliIndex = new StringList(); sourcesIndex = new StringList(); GDMRecord rec; var iEnum = fTree.GetEnumerator(GDMRecordType.rtIndividual); while (iEnum.MoveNext(out rec)) { GDMIndividualRecord iRec = (GDMIndividualRecord)rec; string text = GKUtils.GetNameString(iRec, true, false); string st; mainIndex.AddObject(text, iRec); int evNum = iRec.Events.Count; for (int k = 0; k < evNum; k++) { GDMCustomEvent evt = iRec.Events[k]; if (evt == null) { continue; } int srcNum2 = evt.SourceCitations.Count; for (int m = 0; m < srcNum2; m++) { GDMSourceRecord src = evt.SourceCitations[m].Value as GDMSourceRecord; if (src == null) { continue; } st = src.ShortTitle; if (string.IsNullOrEmpty(st)) { st = src.Title.Lines.Text; } PrepareSpecIndex(sourcesIndex, st, iRec); } // The analysis places // st = ev.Detail.Place.StringValue; // if (!string.IsNullOrEmpty(st)) PrepareSpecIndex(places, st, iRec); var evtType = evt.GetTagType(); if (evtType == GEDCOMTagType.BIRT) { // Analysis on births PrepareEventYear(byIndex, evt, iRec); st = GKUtils.GetPlaceStr(evt, false); if (!string.IsNullOrEmpty(st)) { PrepareSpecIndex(bpIndex, st, iRec); } } else if (evtType == GEDCOMTagType.DEAT) { // Analysis by causes of death PrepareEventYear(dyIndex, evt, iRec); st = GKUtils.GetPlaceStr(evt, false); if (!string.IsNullOrEmpty(st)) { PrepareSpecIndex(dpIndex, st, iRec); } st = evt.Cause; if (!string.IsNullOrEmpty(st)) { PrepareSpecIndex(deathCauses, st, iRec); } } else if (evtType == GEDCOMTagType.OCCU) { // Analysis by occupation st = evt.StringValue; if (!string.IsNullOrEmpty(st)) { PrepareSpecIndex(occuIndex, st, iRec); } } else if (evtType == GEDCOMTagType.RELI) { // Analysis by religion st = evt.StringValue; if (!string.IsNullOrEmpty(st)) { PrepareSpecIndex(reliIndex, st, iRec); } } } int srcNum = iRec.SourceCitations.Count; for (int k = 0; k < srcNum; k++) { GDMSourceRecord src = iRec.SourceCitations[k].Value as GDMSourceRecord; if (src == null) { continue; } st = src.ShortTitle; if (string.IsNullOrEmpty(st)) { st = src.Title.Lines.Text; } PrepareSpecIndex(sourcesIndex, st, iRec); } } mainIndex.Sort(); BookCatalogs[(int)BookCatalog.Catalog_BirthYears].Index = byIndex; BookCatalogs[(int)BookCatalog.Catalog_DeathYears].Index = dyIndex; BookCatalogs[(int)BookCatalog.Catalog_BirthPlaces].Index = bpIndex; BookCatalogs[(int)BookCatalog.Catalog_DeathPlaces].Index = dpIndex; BookCatalogs[(int)BookCatalog.Catalog_DeathCauses].Index = deathCauses; BookCatalogs[(int)BookCatalog.Catalog_Occupations].Index = occuIndex; BookCatalogs[(int)BookCatalog.Catalog_Religion].Index = reliIndex; BookCatalogs[(int)BookCatalog.Catalog_Sources].Index = sourcesIndex; }
public void SetTips(StringList tips) { fTips.Assign(tips); }
public DayTipsDlgController(IDayTipsDlg view) : base(view) { fTips = new StringList(); }
//////////////////////////////////////////////////////////////////////// #region System.Object Overrides public override string ToString() { return((name != null) ? StringList.MakeList(FormatOps.TypeName(GetType()), name) : base.ToString()); }
public static void AddList(this Menu menu, string name, string param, StringList List) { menu.AddItem(new MenuItem(name, param).SetValue(List)); }
/////////////////////////////////////////////////////////////////////// public override string ToString() { return(StringList.MakeList(this.X, this.Y, this.Z)); }
public Data(StringList history, StringList replaceHistory) { this.history = history; this.replaceHistory = replaceHistory; }
/////////////////////////////////////////////////////////////////////// #region IExecute Members public override ReturnCode Execute( Interpreter interpreter, IClientData clientData, ArgumentList arguments, ref Result result ) { if (interpreter == null) { result = "invalid interpreter"; return(ReturnCode.Error); } if (arguments == null) { result = "invalid argument list"; return(ReturnCode.Error); } if (arguments.Count < 2) { result = String.Format( "wrong # args: should be \"{0} option ?arg ...?\"", this.Name); return(ReturnCode.Error); } string subCommand = arguments[1]; if (!String.Equals( subCommand, this.Name, StringOps.SystemStringComparisonType)) { result = ScriptOps.BadSubCommand( interpreter, null, null, subCommand, this, null, null); return(ReturnCode.Error); } // // NOTE: Evaluate the configured script command, maybe // adding all the local arguments, and return the // results verbatim. // string name = StringList.MakeList(this.Name); ICallFrame frame = interpreter.NewTrackingCallFrame(name, CallFrameFlags.Evaluate | CallFrameFlags.SubCommand); interpreter.PushAutomaticCallFrame(frame); ReturnCode code = interpreter.EvaluateScript( ScriptOps.GetArgumentsForExecute(this, scriptCommand, GetArgumentsForExecute(arguments), 0), 0, ref result); if (code == ReturnCode.Error) { Engine.AddErrorInformation(interpreter, result, String.Format("{0} (\"{1}\" body line {2})", Environment.NewLine, ScriptOps.GetNameForExecute( arguments[0], this), Interpreter.GetErrorLine( interpreter))); } // // NOTE: Pop the original call frame that we pushed above and // any intervening scope call frames that may be leftover // (i.e. they were not explicitly closed). // /* IGNORED */ interpreter.PopScopeCallFramesAndOneMore(); return(code); }
public static string GetItemName(Item item) { if (StringList == null || item.Name != null) { return(item.Name); } ObjectPropertyList opl = new ObjectPropertyList(item); item.GetProperties(opl); if (opl == null) { //if there was a problem with this process, just return null return(null); } //since the object property list is based on a packet object, the property info is packed away in a packet format byte[] data = opl.UnderlyingStream.UnderlyingStream.ToArray(); int index = 15; // First localization number index string basestring = null; //reset the number property uint number = 0; //if there's not enough room for another record, quit if (index + 4 >= data.Length) { return(null); } //read number property from the packet data number = (uint)(data[index++] << 24 | data[index++] << 16 | data[index++] << 8 | data[index++]); //reset the length property ushort length = 0; //if there's not enough room for another record, quit if (index + 2 > data.Length) { return(null); } //read length property from the packet data length = (ushort)(data[index++] << 8 | data[index++]); //determine the location of the end of the string int end = index + length; //truncate if necessary if (end >= data.Length) { end = data.Length - 1; } //read the string into a StringBuilder object StringBuilder s = new StringBuilder(); while (index + 2 <= end + 1) { short next = (short)(data[index++] | data[index++] << 8); if (next == 0) { break; } s.Append(Encoding.Unicode.GetString(BitConverter.GetBytes(next))); } basestring = StringList.GetString((int)number); string args = s.ToString(); if (args == null || args == String.Empty) { return(basestring); } string[] parms = args.Split('\t'); try { if (parms.Length > 1) { for (int i = 0; i < parms.Length; i++) { parms[i] = parms[i].Trim(' '); if (parms[i].IndexOf("#") == 0) { parms[i] = StringList.GetString(Convert.ToInt32(parms[i].Substring(1, parms[i].Length - 1))); } } } else if (parms.Length == 1 && parms[0].IndexOf("#") == 0) { parms[0] = StringList.GetString(Convert.ToInt32(args.Substring(1, parms[0].Length - 1))); } } catch { return(null); } Ultima.StringEntry entry = StringList.GetEntry((int)number); if (entry != null) { return(entry.Format(parms)); } return(basestring); }
public override ReturnCode Execute( Interpreter interpreter, IClientData clientData, ArgumentList arguments, ref Result result ) { ReturnCode code = ReturnCode.Ok; if (interpreter != null) { if (arguments != null) { if (arguments.Count >= 2) { OptionDictionary options = new OptionDictionary( new IOption[] { new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-debug", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-commandline", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-dequote", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-quoteall", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-unicode", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-ignorestderr", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-killonerror", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-keepnewline", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-noexitcode", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-nocapture", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-shell", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-nocarriagereturns", null), // simple switch new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-trimall", null), // simple switch new Option(typeof(ExitCode), OptionFlags.MustHaveEnumValue, Index.Invalid, Index.Invalid, "-success", null), // success exit code new Option(null, OptionFlags.MustHaveValue, Index.Invalid, Index.Invalid, "-domainname", null), new Option(null, OptionFlags.MustHaveValue, Index.Invalid, Index.Invalid, "-username", null), new Option(null, OptionFlags.MustHaveSecureStringValue, Index.Invalid, Index.Invalid, "-password", null), new Option(null, OptionFlags.MustHaveListValue, Index.Invalid, Index.Invalid, "-preprocessarguments", null), // command new Option(null, OptionFlags.MustHaveValue, Index.Invalid, Index.Invalid, "-directory", null), // directory name new Option(null, OptionFlags.MustHaveValue, Index.Invalid, Index.Invalid, "-processid", null), // varName for processId new Option(null, OptionFlags.MustHaveValue, Index.Invalid, Index.Invalid, "-exitcode", null), // varName for exitCode new Option(null, OptionFlags.MustHaveValue, Index.Invalid, Index.Invalid, "-stdin", null), // varName for StdIn input new Option(null, OptionFlags.MustHaveValue, Index.Invalid, Index.Invalid, "-stdout", null), // varName for StdOut output new Option(null, OptionFlags.MustHaveValue, Index.Invalid, Index.Invalid, "-stderr", null), // varName for StdErr output new Option(typeof(EventFlags), OptionFlags.MustHaveEnumValue, Index.Invalid, Index.Invalid, "-eventflags", new Variant(interpreter.EngineEventFlags)), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, Option.EndOfOptions, null) }); int argumentIndex = Index.Invalid; code = interpreter.GetOptions(options, arguments, 0, 1, Index.Invalid, true, ref argumentIndex, ref result); if (code == ReturnCode.Ok) { if (argumentIndex != Index.Invalid) { bool debug = false; if (options.IsPresent("-debug")) { debug = true; } bool commandLine = false; if (options.IsPresent("-commandline")) { commandLine = true; } bool dequote = false; if (options.IsPresent("-dequote")) { dequote = true; } bool quoteAll = false; if (options.IsPresent("-quoteall")) { quoteAll = true; } bool captureExitCode = true; if (options.IsPresent("-noexitcode")) { captureExitCode = false; } bool captureInput = true; bool captureOutput = true; if (options.IsPresent("-nocapture")) { captureInput = false; captureOutput = false; } bool useUnicode = false; if (options.IsPresent("-unicode")) { useUnicode = true; } bool ignoreStdErr = false; if (options.IsPresent("-ignorestderr")) { ignoreStdErr = true; } bool killOnError = false; if (options.IsPresent("-killonerror")) { killOnError = true; } bool keepNewLine = false; if (options.IsPresent("-keepnewline")) { keepNewLine = true; } bool carriageReturns = true; if (options.IsPresent("-nocarriagereturns")) { carriageReturns = false; } bool trimAll = false; if (options.IsPresent("-trimall")) { trimAll = true; } bool useShellExecute = false; if (options.IsPresent("-shell")) { useShellExecute = true; } Variant value = null; ExitCode?successExitCode = null; if (options.IsPresent("-success", ref value)) { successExitCode = (ExitCode)value.Value; } string domainName = null; if (options.IsPresent("-domainname", ref value)) { domainName = value.ToString(); } string userName = null; if (options.IsPresent("-username", ref value)) { userName = value.ToString(); } SecureString password = null; if (options.IsPresent("-password", ref value)) { password = (SecureString)value.Value; } string directory = null; if (options.IsPresent("-directory", ref value)) { directory = value.ToString(); } string processIdVarName = null; if (options.IsPresent("-processid", ref value)) { processIdVarName = value.ToString(); } string exitCodeVarName = null; if (options.IsPresent("-exitcode", ref value)) { exitCodeVarName = value.ToString(); } string stdInVarName = null; if (options.IsPresent("-stdin", ref value)) { stdInVarName = value.ToString(); } string stdOutVarName = null; if (options.IsPresent("-stdout", ref value)) { stdOutVarName = value.ToString(); } string stdErrVarName = null; if (options.IsPresent("-stderr", ref value)) { stdErrVarName = value.ToString(); } EventFlags eventFlags = interpreter.EngineEventFlags; if (options.IsPresent("-eventflags", ref value)) { eventFlags = (EventFlags)value.Value; } StringList list = null; if (options.IsPresent("-preprocessarguments", ref value)) { list = (StringList)value.Value; } int argumentStopIndex = arguments.Count - 1; bool background = false; if (arguments[arguments.Count - 1] == Characters.Ampersand.ToString()) { argumentStopIndex--; background = true; } string execFileName = arguments[argumentIndex]; if (!PathOps.IsRemoteUri(execFileName)) { execFileName = PathOps.GetNativePath(execFileName); } string execArguments = null; if ((argumentIndex + 1) < arguments.Count) { if (commandLine) { execArguments = RuntimeOps.BuildCommandLine( ArgumentList.GetRangeAsStringList(arguments, argumentIndex + 1, argumentStopIndex, dequote), quoteAll); } else { execArguments = ListOps.Concat(arguments, argumentIndex + 1, argumentStopIndex); } } Result input = null; if ((code == ReturnCode.Ok) && !useShellExecute && captureInput && (stdInVarName != null)) { code = interpreter.GetVariableValue(VariableFlags.None, stdInVarName, ref input, ref result); } if (debug) { TraceOps.DebugTrace(String.Format( "Execute: interpreter = {0}, domainName = {1}, userName = {2}, " + "password = {3}, execFileName = {4}, execArguments = {5}, " + "directory = {6}, input = {7}, eventFlags = {8}, debug = {9}, " + "commandLine = {10}, dequote = {11}, quoteAll = {12}, " + "useShellExecute = {13}, captureExitCode = {14}, " + "captureInput = {15}, captureOutput = {16}, useUnicode = {17}, " + "ignoreStdErr = {18}, killOnError = {19}, keepNewLine = {20}, " + "carriageReturns = {21}, trimAll = {22}, background = {23}, " + "successExitCode = {24}, processIdVarName = {25}, exitCodeVarName = {26}, " + "stdInVarName = {27}, stdOutVarName = {28}, stdErrVarName = {29}", FormatOps.InterpreterNoThrow(interpreter), FormatOps.WrapOrNull(domainName), FormatOps.WrapOrNull(userName), FormatOps.WrapOrNull(password), FormatOps.WrapOrNull(execFileName), FormatOps.WrapOrNull(execArguments), FormatOps.WrapOrNull(directory), FormatOps.WrapOrNull(input), FormatOps.WrapOrNull(eventFlags), debug, commandLine, dequote, quoteAll, useShellExecute, captureExitCode, captureInput, captureOutput, useUnicode, ignoreStdErr, killOnError, keepNewLine, carriageReturns, trimAll, background, FormatOps.WrapOrNull(successExitCode), FormatOps.WrapOrNull(processIdVarName), FormatOps.WrapOrNull(exitCodeVarName), FormatOps.WrapOrNull(stdInVarName), FormatOps.WrapOrNull(stdOutVarName), FormatOps.WrapOrNull(stdErrVarName)), typeof(Exec).Name, TracePriority.Command); } int processId = 0; ExitCode exitCode = ResultOps.SuccessExitCode(); Result error = null; if (code == ReturnCode.Ok) { if (list != null) { list.Add(execFileName); list.Add(directory); list.Add(execArguments); code = interpreter.EvaluateScript(list.ToString(), ref result); if (code == ReturnCode.Return) { execArguments = result; code = ReturnCode.Ok; } else if (code == ReturnCode.Continue) { code = ReturnCode.Ok; goto done; } } if (code == ReturnCode.Ok) { code = ProcessOps.ExecuteProcess( interpreter, domainName, userName, password, execFileName, execArguments, directory, input, eventFlags, useShellExecute, captureExitCode, captureOutput, useUnicode, ignoreStdErr, killOnError, keepNewLine, background, !background, ref processId, ref exitCode, ref result, ref error); } } done: if (debug) { TraceOps.DebugTrace(String.Format( "Execute: interpreter = {0}, domainName = {1}, userName = {2}, " + "password = {3}, execFileName = {4}, execArguments = {5}, " + "directory = {6}, input = {7}, eventFlags = {8}, debug = {9}, " + "commandLine = {10}, dequote = {11}, quoteAll = {12}, " + "useShellExecute = {13}, captureExitCode = {14}, " + "captureInput = {15}, captureOutput = {16}, useUnicode = {17}, " + "ignoreStdErr = {18}, killOnError = {19}, keepNewLine = {20}, " + "carriageReturns = {21}, trimAll = {22}, background = {23}, " + "successExitCode = {24}, processIdVarName = {25}, exitCodeVarName = {26}, " + "stdInVarName = {27}, stdOutVarName = {28}, stdErrVarName = {29}, " + "processId = {30}, exitCode = {31}, result = {32}, error = {33}", FormatOps.InterpreterNoThrow(interpreter), FormatOps.WrapOrNull(domainName), FormatOps.WrapOrNull(userName), FormatOps.WrapOrNull(password), FormatOps.WrapOrNull(execFileName), FormatOps.WrapOrNull(execArguments), FormatOps.WrapOrNull(directory), FormatOps.WrapOrNull(input), FormatOps.WrapOrNull(eventFlags), debug, commandLine, dequote, quoteAll, useShellExecute, captureExitCode, captureInput, captureOutput, useUnicode, ignoreStdErr, killOnError, keepNewLine, carriageReturns, trimAll, background, FormatOps.WrapOrNull(successExitCode), FormatOps.WrapOrNull(processIdVarName), FormatOps.WrapOrNull(exitCodeVarName), FormatOps.WrapOrNull(stdInVarName), FormatOps.WrapOrNull(stdOutVarName), FormatOps.WrapOrNull(stdErrVarName), processId, exitCode, FormatOps.WrapOrNull(true, true, result), FormatOps.WrapOrNull(true, true, error)), typeof(Exec).Name, TracePriority.Command); } // // NOTE: Even upon failure, always set the variable to contain // process Id, if applicable. // if (processIdVarName != null) { /* IGNORED */ interpreter.SetVariableValue( /* EXEMPT */ VariableFlags.NoReady, processIdVarName, processId.ToString(), null); } if (code == ReturnCode.Ok) { // // NOTE: Remove all carriage returns from output (leaving // only line feeds as line separators)? // if (!carriageReturns) { if (!String.IsNullOrEmpty(result)) { result = result.Replace( Characters.CarriageReturnString, String.Empty); } if (!String.IsNullOrEmpty(error)) { error = error.Replace( Characters.CarriageReturnString, String.Empty); } } // // NOTE: Remove all surrounding whitespace from the output? // if (trimAll) { if (!String.IsNullOrEmpty(result)) { result = result.Trim(); } if (!String.IsNullOrEmpty(error)) { error = error.Trim(); } } // // NOTE: Now, "result" contains any StdOut output and "error" // contains any StdErr output. // if ((code == ReturnCode.Ok) && !background && captureExitCode && (exitCodeVarName != null)) { code = interpreter.SetVariableValue(VariableFlags.None, exitCodeVarName, exitCode.ToString(), null, ref error); } if ((code == ReturnCode.Ok) && !useShellExecute && !background && captureOutput && (stdOutVarName != null)) { code = interpreter.SetVariableValue(VariableFlags.None, stdOutVarName, result, null, ref error); } if ((code == ReturnCode.Ok) && !useShellExecute && !background && captureOutput && (stdErrVarName != null)) { code = interpreter.SetVariableValue(VariableFlags.None, stdErrVarName, error, null, ref error); } // // NOTE: If they specified a "success" exit code, make sure // that is the same as the exit code we actually got // from the process. // if ((code == ReturnCode.Ok) && !background && captureExitCode && (successExitCode != null) && (exitCode != successExitCode)) { /* IGNORED */ interpreter.SetVariableValue( /* EXEMPT */ Engine.ErrorCodeVariableFlags, TclVars.ErrorCode, StringList.MakeList( "CHILDSTATUS", processId, exitCode), null); Engine.SetErrorCodeSet(interpreter, true); error = "child process exited abnormally"; code = ReturnCode.Error; } if (code != ReturnCode.Ok) { // // NOTE: Transfer error to command result. // result = error; } } else { // // NOTE: Transfer error to command result. // result = error; } } else { result = "wrong # args: should be \"exec ?options? arg ?arg ...?\""; code = ReturnCode.Error; } } } else { result = "wrong # args: should be \"exec ?options? arg ?arg ...?\""; code = ReturnCode.Error; } } else { result = "invalid argument list"; code = ReturnCode.Error; } } else { result = "invalid interpreter"; code = ReturnCode.Error; } return(code); }
public void match1Test() { Assert.IsTrue(StringList.match("hello world 1+1=2", "*world.1*")); }
public MruManager() { _mruList = new StringList(); }
/////////////////////////////////////////////////////////////////////// private static StringList GetAlgorithms() { lock (syncRoot) { MemberInfo memberInfo = GetAlgorithmsMemberInfo(); if (memberInfo == null) { return(null); } if (CommonOps.Runtime.IsMono()) { object value = ((FieldInfo)memberInfo).GetValue(null); if (value is IDictionary <string, Type> ) /* v3.x */ { StringList list = new StringList(); foreach (KeyValuePair <string, Type> pair in ((IDictionary <string, Type>)value)) { if ((pair.Key == null) || (pair.Value == null)) { continue; } string subTypeName = null; if (!IsHashAlgorithm(pair.Value, ref subTypeName)) { continue; } list.Add(StringList.MakeList( subTypeName, pair.Key)); } return(list); } else if (value is Hashtable) /* v2.x */ { StringList list = new StringList(); foreach (DictionaryEntry entry in ((Hashtable)value)) { if (entry.Key == null) { continue; } string subTypeName = null; if (!IsHashAlgorithm( entry.Value as string, ref subTypeName)) { continue; } list.Add(StringList.MakeList( subTypeName, entry.Key.ToString())); } return(list); } } else { object value = ((PropertyInfo)memberInfo).GetValue( null, null); if (value is IDictionary <string, object> ) /* v4.x */ { StringList list = new StringList(); foreach (KeyValuePair <string, object> pair in ((IDictionary <string, object>)value)) { if (pair.Key == null) { continue; } string subTypeName = null; if (!IsHashAlgorithm( pair.Value as Type, ref subTypeName)) { continue; } list.Add(StringList.MakeList( subTypeName, pair.Key)); } return(list); } else if (value is Hashtable) /* v2.x */ { StringList list = new StringList(); foreach (DictionaryEntry entry in ((Hashtable)value)) { if (entry.Key == null) { continue; } string subTypeName = null; if (!IsHashAlgorithm( entry.Value as Type, ref subTypeName)) { continue; } list.Add(StringList.MakeList( subTypeName, entry.Key.ToString())); } return(list); } } return(null); } }
public void Add() { StringList.Add(String.Empty); }
public override ReturnCode Execute( Interpreter interpreter, IClientData clientData, ArgumentList arguments, ref Result result ) { ReturnCode code = ReturnCode.Ok; if (interpreter != null) { if (arguments != null) { if (arguments.Count >= 4) { StringList list = null; // // WARNING: Cannot cache list representation here, the list // is modified below. // code = Parser.SplitList( interpreter, arguments[1], 0, Length.Invalid, false, ref list, ref result); if (code == ReturnCode.Ok) { int firstIndex = Index.Invalid; code = Value.GetIndex( arguments[2], list.Count, ValueFlags.AnyIndex, interpreter.CultureInfo, ref firstIndex, ref result); if (code == ReturnCode.Ok) { int lastIndex = Index.Invalid; code = Value.GetIndex( arguments[3], list.Count, ValueFlags.AnyIndex, interpreter.CultureInfo, ref lastIndex, ref result); if (code == ReturnCode.Ok) { if (firstIndex < 0) { firstIndex = 0; } if ((firstIndex < list.Count) || (list.Count == 0)) { if (list.Count > 0) { if (lastIndex >= list.Count) { lastIndex = list.Count - 1; } int numToDelete; if (firstIndex <= lastIndex) { numToDelete = (lastIndex - firstIndex + 1); } else { numToDelete = 0; } list.RemoveRange(firstIndex, numToDelete); if (arguments.Count >= 5) { list.InsertRange(firstIndex, arguments, 4); } result = list; } else if (ScriptOps.HasFlags(interpreter, InterpreterFlags.ReplaceEmptyListOk, true)) { result = list; } else { result = String.Format( "list doesn't contain element {0}", arguments[2]); code = ReturnCode.Error; } } else { result = String.Format( "list doesn't contain element {0}", arguments[2]); code = ReturnCode.Error; } } } } } else { result = "wrong # args: should be \"lreplace list first last ?value ...?\""; code = ReturnCode.Error; } } else { result = "invalid argument list"; code = ReturnCode.Error; } } else { result = "invalid interpreter"; code = ReturnCode.Error; } return(code); }
public void Delete(String value) { StringList.Remove(value); }
public void exportarDiretorio(TipoExportar tipo, Aba aba, string sNomeArquivo, IProgressoLog progressoLog) { string sTexto = "", sCR, sTAB, sTAB2, sSQL, sCondicaoTotal; Aba abaLocal = new Aba(); StringList listaLocal; List <Diretorio> listaDiretorio; sTAB = "\t"; sTAB2 = "\t\t"; sCR = "\n"; sCondicaoTotal = " where aba=" + aba.Codigo; sSQL = SQL_CONSULTA_ARQUIVO + sCondicaoTotal + " order by 1, 2, 3"; listaDiretorio = carregarDiretorio(sSQL, sCondicaoTotal, progressoLog); listaLocal = new StringList(); switch (tipo) { case TipoExportar.teCSV: { sTexto = "\"Aba\";\"Nome\";\"TamanhoBytes\";\"Tamanho\";" + "\"Tipo\";\"Modificado\";\"Atributos\";\"Caminho\""; } break; case TipoExportar.teHTML: { sTexto = "<!DOCTYPE html>" + sCR; sTexto += "<html>" + sCR; sTexto += "<body>" + sCR; sTexto += "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">" + sCR; sTexto += sTAB + "<tr>" + sCR; sTexto += sTAB2 + "<th>Aba</th>" + sCR; sTexto += sTAB2 + "<th>Nome</th>" + sCR; sTexto += sTAB2 + "<th>Tamanho</th>" + sCR; sTexto += sTAB2 + "<th>Tamanho Formatado</th>" + sCR; sTexto += sTAB2 + "<th>Tipo</th>" + sCR; sTexto += sTAB2 + "<th>Modificado</th>" + sCR; sTexto += sTAB2 + "<th>Atributos</th>" + sCR; sTexto += sTAB2 + "<th>Caminho</th>" + sCR; sTexto += sTAB + "</tr>"; } break; case TipoExportar.teXML: { sTexto = "<diretorio>"; } break; case TipoExportar.teSQL: { abaLocal.Codigo = listaDiretorio[0].Aba.Codigo; abaLocal.Nome = listaDiretorio[0].Aba.Nome; sTexto = AbaBO.Instancia.abaToSQL(abaLocal); } break; } if (sTexto.Length > 0) { listaLocal.Add(sTexto); } foreach (Diretorio diretorio in listaDiretorio) { if (diretorio.Aba.Codigo == aba.Codigo) { if (tipo == TipoExportar.teTXT) { sTexto = diretorioToTXT(diretorio); } else if (tipo == TipoExportar.teCSV) { sTexto = diretorioToCSV(diretorio); } else if (tipo == TipoExportar.teHTML) { sTexto = diretorioToHTML(diretorio); } else if (tipo == TipoExportar.teXML) { sTexto = diretorioToXML(diretorio); } else if (tipo == TipoExportar.teSQL) { sTexto = diretorioToSQL(diretorio, true) + ";"; } listaLocal.Add(sTexto); } } if (tipo == TipoExportar.teHTML) { sTexto += sCR + "</table>" + sCR; sTexto += "</body>" + sCR; sTexto += "</html>" + sCR; } else if (tipo == TipoExportar.teXML) { sTexto = "</diretorio>"; } listaLocal.Add(sTexto); listaLocal.SaveToFile(sNomeArquivo); listaDiretorio.Clear(); listaLocal.Clear(); }
public void LoadPlaces() { try { PlacesCache.Instance.Load(); IProgressController progress = AppHost.Progress; GEDCOMTree tree = fBase.Context.Tree; fView.MapBrowser.InitMap(); fView.PersonsCombo.BeginUpdate(); fView.PlacesTree.BeginUpdate(); progress.ProgressInit(LangMan.LS(LSID.LSID_LoadingLocations), tree.RecordsCount); try { fBaseRoot = fView.PlacesTree.AddNode(null, LangMan.LS(LSID.LSID_RPLocations), null); fPlaces.Clear(); var personValues = new StringList(); int num = tree.RecordsCount; for (int i = 0; i < num; i++) { GEDCOMRecord rec = tree[i]; bool res = rec is GEDCOMIndividualRecord && IsSelected(rec); if (res) { GEDCOMIndividualRecord ind = rec as GEDCOMIndividualRecord; int pCnt = 0; int num2 = ind.Events.Count; for (int j = 0; j < num2; j++) { GEDCOMCustomEvent ev = ind.Events[j]; if (ev.Place.StringValue != "") { AddPlace(ev.Place, ev); pCnt++; } } if (pCnt > 0) { personValues.AddObject(GKUtils.GetNameString(ind, true, false) + " [" + pCnt.ToString() + "]", ind); } } progress.ProgressStep(); } fView.PlacesTree.Expand(fBaseRoot); personValues.Sort(); fView.PersonsCombo.Clear(); fView.PersonsCombo.AddItem(LangMan.LS(LSID.LSID_NotSelected), null); fView.PersonsCombo.AddStrings(personValues); fView.SelectPlacesBtn.Enabled = true; } finally { progress.ProgressDone(); fView.PlacesTree.EndUpdate(); fView.PersonsCombo.EndUpdate(); PlacesCache.Instance.Save(); } } catch (Exception ex) { Logger.LogWrite("MapsViewerWin.PlacesLoad(): " + ex.Message); } }
public void Test_ShowXInfo() { StringList summary = new StringList(); summary.Clear(); GKUtils.ShowFamilyInfo(fContext, null, null); GDMFamilyRecord famRec = fContext.Tree.XRefIndex_Find("F1") as GDMFamilyRecord; GKUtils.ShowFamilyInfo(fContext, famRec, summary); summary.Clear(); GKUtils.ShowGroupInfo(null, null); GDMGroupRecord grpRec = fContext.Tree.XRefIndex_Find("G1") as GDMGroupRecord; GKUtils.ShowGroupInfo(grpRec, summary); summary.Clear(); GKUtils.ShowMultimediaInfo(null, null); GDMMultimediaRecord mmRec = fContext.Tree.XRefIndex_Find("O1") as GDMMultimediaRecord; GKUtils.ShowMultimediaInfo(mmRec, summary); summary.Clear(); GKUtils.ShowNoteInfo(null, null); GDMNoteRecord noteRec = fContext.Tree.XRefIndex_Find("N1") as GDMNoteRecord; GKUtils.ShowNoteInfo(noteRec, summary); summary.Clear(); GKUtils.ShowPersonInfo(fContext, null, null); GDMIndividualRecord indRec = fContext.Tree.XRefIndex_Find("I1") as GDMIndividualRecord; GKUtils.ShowPersonInfo(fContext, indRec, summary); summary.Clear(); GKUtils.ShowSourceInfo(null, null); GDMSourceRecord srcRec = fContext.Tree.XRefIndex_Find("S1") as GDMSourceRecord; GKUtils.ShowSourceInfo(srcRec, summary); summary.Clear(); GKUtils.ShowRepositoryInfo(null, null); GDMRepositoryRecord repRec = fContext.Tree.XRefIndex_Find("R1") as GDMRepositoryRecord; GKUtils.ShowRepositoryInfo(repRec, summary); summary.Clear(); GKUtils.ShowResearchInfo(null, null); GDMResearchRecord resRec = fContext.Tree.XRefIndex_Find("RS1") as GDMResearchRecord; GKUtils.ShowResearchInfo(resRec, summary); summary.Clear(); GKUtils.ShowTaskInfo(null, null); GDMTaskRecord taskRec = fContext.Tree.XRefIndex_Find("TK1") as GDMTaskRecord; GKUtils.ShowTaskInfo(taskRec, summary); summary.Clear(); GKUtils.ShowCommunicationInfo(null, null); GDMCommunicationRecord commRec = fContext.Tree.XRefIndex_Find("CM1") as GDMCommunicationRecord; GKUtils.ShowCommunicationInfo(commRec, summary); summary.Clear(); GKUtils.ShowLocationInfo(null, null); GDMLocationRecord locRec = fContext.Tree.XRefIndex_Find("L1") as GDMLocationRecord; GKUtils.ShowLocationInfo(locRec, summary); }
public override ReturnCode Execute( Interpreter interpreter, IClientData clientData, ArgumentList arguments, ref Result result ) { ReturnCode code; if (interpreter != null) { if (arguments != null) { if (arguments.Count >= 2) { OptionDictionary options = new OptionDictionary( new IOption[] { new Option(null, OptionFlags.MustHaveObjectValue, Index.Invalid, Index.Invalid, "-clientdata", null), new Option(null, OptionFlags.MustHaveObjectValue, Index.Invalid, Index.Invalid, "-data", null), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-nocase", null), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-keeplibrary", null), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, "-nocomplain", null), new Option(null, OptionFlags.MustHaveMatchModeValue, Index.Invalid, Index.Invalid, "-match", new Variant(StringOps.DefaultUnloadMatchMode)), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, Option.EndOfOptions, null) }); int argumentIndex = Index.Invalid; code = interpreter.GetOptions(options, arguments, 0, 1, Index.Invalid, false, ref argumentIndex, ref result); if (code == ReturnCode.Ok) { // // NOTE: There should be a minimum of one and a maximum // of three arguments after the final option. // if ((argumentIndex != Index.Invalid) && ((argumentIndex + 3) >= arguments.Count)) { string path = ((argumentIndex + 2) < arguments.Count) ? (string)arguments[argumentIndex + 2] : String.Empty; Interpreter slaveInterpreter = null; code = interpreter.GetNestedSlaveInterpreter( path, LookupFlags.Interpreter, false, ref slaveInterpreter, ref result); if (code == ReturnCode.Ok) { Variant value = null; IClientData localClientData = clientData; if (options.IsPresent("-clientdata", ref value)) { IObject @object = (IObject)value.Value; if ((@object.Value == null) || (@object.Value is IClientData)) { localClientData = (IClientData)@object.Value; } else { result = "option value has invalid clientData"; code = ReturnCode.Error; } } if (code == ReturnCode.Ok) { if (options.IsPresent("-data", ref value)) { IObject @object = (IObject)value.Value; localClientData = _Public.ClientData.WrapOrReplace( localClientData, @object.Value); } MatchMode mode = StringOps.DefaultUnloadMatchMode; if (options.IsPresent("-match", ref value)) { mode = (MatchMode)value.Value; } bool noCase = false; if (options.IsPresent("-nocase")) { noCase = true; } if (slaveInterpreter.HasPlugins(ref result)) { string fileName = PathOps.ResolveFullPath( interpreter, arguments[argumentIndex]); if (!String.IsNullOrEmpty(fileName)) { string typeName = null; if ((argumentIndex + 1) < arguments.Count) { typeName = arguments[argumentIndex + 1]; } // // NOTE: Grab the plugin flags to match from the target // interpreter and add the Demand flag to them. // PluginFlags pluginFlags = slaveInterpreter.PluginFlags | PluginFlags.Demand; // // FIXME: PRI 4: Threading. // bool unload = false; StringList list = slaveInterpreter.CopyPluginKeys(); foreach (string name in list) { IPluginData pluginData = slaveInterpreter.GetPluginData(name); // // NOTE: Check that this plugin represents a loaded // assembly. // if (pluginData != null) { if ((pluginData.FileName != null) && PathOps.IsSameFile(interpreter, pluginData.FileName, fileName)) { if (String.IsNullOrEmpty(typeName) || StringOps.Match(interpreter, mode, pluginData.TypeName, typeName, noCase) || StringOps.Match(interpreter, mode, pluginData.Name, typeName, noCase)) { code = slaveInterpreter.UnloadPlugin( name, localClientData, pluginFlags, ref result); if (code == ReturnCode.Ok) { unload = true; } // // NOTE: Stop as soon as we match and // attempt to unload a plugin, // whether or not we actually // unloaded it. We always halt // on errors and since we only // support unloading a single // plugin at a time (even if // there are multiple plugins // contained in a particular // assembly file), we know it // is safe to stop now. // break; } } } } if ((code == ReturnCode.Ok) && !unload) { if (typeName != null) { result = String.Format( "type \"{0}\" and file \"{1}\" have never been loaded", typeName, fileName); } else { result = String.Format( "file \"{0}\" has never been loaded", fileName); } code = ReturnCode.Error; } } else { result = "invalid file name"; code = ReturnCode.Error; } } else { code = ReturnCode.Error; } } } } else { if ((argumentIndex != Index.Invalid) && Option.LooksLikeOption(arguments[argumentIndex])) { result = OptionDictionary.BadOption(options, arguments[argumentIndex]); } else { result = "wrong # args: should be \"unload ?options? fileName ?packageName? ?interp?\""; } code = ReturnCode.Error; } } } else { result = "wrong # args: should be \"unload ?options? fileName ?packageName? ?interp?\""; code = ReturnCode.Error; } } else { result = "invalid argument list"; code = ReturnCode.Error; } } else { result = "invalid interpreter"; code = ReturnCode.Error; } return(code); }
/// <summary> /// /// </summary> public ManagerConfig() : base() { this.plugins = new StringList(); }