Here are the examples of the csharp api class string.Format(System.IFormatProvider, string, params object[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
200 Examples
3
1. Example
View licensepublic string ToStringFull() { return string.Format("Room: '{0}' {1},{2} {4}/{3} players.\ncustomProps: {5}", this.nameField, this.visibleField ? "visible" : "hidden", this.openField ? "open" : "closed", this.maxPlayersField, this.PlayerCount, this.customPropertiesField.ToStringFull()); }
2
2. Example
View licenseprivate void UpdateDebugText() { if ( debugText ) { debugText.text = string.Format( "Linear: {0}\nAngle: {1}\n", linearMapping.value, outAngle ); } }
1
3. Example
View licensepublic new string ToStringFull() { return string.Format("Room: '{0}' {1},{2} {4}/{3} players.\ncustomProps: {5}", this.nameField, this.visibleField ? "visible" : "hidden", this.openField ? "open" : "closed", this.maxPlayersField, this.PlayerCount, this.CustomProperties.ToStringFull()); }
0
4. Example
View licenseprivate IEnumerable<FeedUri> GetInterfaces(FeedUri feedUri, ref Stability suggestedStabilityPolicy) { var feed = FeedManager.GetFresh(feedUri); var interfaces = feed.FeedFor.Select(reference => reference.Target).WhereNotNull().ToList(); if (interfaces.Count == 0) throw new OptionException(string.Format(Resources.MissingFeedFor, feedUri), null); if (feed.Elements.Count == 1) { if (feed.Elements[0] is Implementation singletonImplementation) suggestedStabilityPolicy = singletonImplementation.Stability; } return interfaces; }
0
5. Example
View licensepublic override SubCommand GetCommand(string commandName) { #region Sanity checks if (commandName == null) throw new ArgumentNullException(nameof(commandName)); #endregion switch (commandName) { case Search.Name: return new Search(Handler); case Refresh.Name: return new Refresh(Handler); case Add.Name: return new Add(Handler); case Remove.Name: return new Remove(Handler); case Reset.Name: return new Reset(Handler); case List.Name: return new List(Handler); default: throw new OptionException(string.Format(Resources.UnknownCommand, commandName), commandName); } }
0
6. Example
View licenseprotected override ExitCode ShowOutput() { Handler.OutputLow( title: Resources.ExportComplete, message: string.Format(Resources.AllComponentsExported, Selections.Name ?? "app", _outputPath)); return ExitCode.OK; }
0
7. Example
View licenseprivate void DetectReplacement(ref FeedTarget target) { if (target.Feed.ReplacedBy == null || target.Feed.ReplacedBy.Target == null) return; if (Handler.Ask( string.Format(Resources.FeedReplacedAsk, target.Feed.Name, target.Uri, target.Feed.ReplacedBy.Target), defaultAnswer: false, alternateMessage: string.Format(Resources.FeedReplaced, target.Uri, target.Feed.ReplacedBy.Target))) { target = new FeedTarget( target.Feed.ReplacedBy.Target, FeedManager.GetFresh(target.Feed.ReplacedBy.Target)); } }
0
8. Example
View licensepublic override SubCommand GetCommand(string commandName) { #region Sanity checks if (commandName == null) throw new ArgumentNullException(nameof(commandName)); #endregion switch (commandName) { case Deploy.Name: return new Deploy(Handler); case Remove.Name: return new Remove(Handler); case RemoveHelper.Name: return new RemoveHelper(Handler); default: throw new OptionException(string.Format(Resources.UnknownCommand, commandName), commandName); } }
0
9. Example
View licensepublic override SubCommand GetCommand(string commandName) { #region Sanity check/n ..... /n //View Source file for more details /n }
0
10. Example
View licensepublic override ExitCode Execute() { var manifestDigest = new ManifestDigest(AdditionalArgs[0]); string path = Store.GetPath(manifestDigest); if (path == null) throw new ImplementationNotFoundException(manifestDigest); Handler.Output(string.Format(Resources.LocalPathOf, AdditionalArgs[0]), path); return ExitCode.OK; }
0
11. Example
View licenseprivate void buttonRemoveImplDir_Click(object sender, EventArgs e) { var toRemove = listBoxImplDirs.SelectedItems.Cast<string>().ToList(); if (Msg.YesNo(this, string.Format(Resources.RemoveSelectedEntries, toRemove.Count), MsgSeverity.Warn)) { foreach (var store in toRemove) listBoxImplDirs.Items.Remove(store); } }
0
12. Example
View licenseprivate void buttonRemoveCatalogSource_Click(object sender, EventArgs e) { if (Msg.YesNo(this, string.Format(Resources.RemoveSelectedEntries, listBoxCatalogSources.SelectedItems.Count), MsgSeverity.Warn)) { foreach (var item in listBoxCatalogSources.SelectedItems.Cast<object>().ToList()) listBoxCatalogSources.Items.Remove(item); } }
0
13. Example
View licensevoid UpdateIPD() { strIPD = System.String.Format("IPD (mm): {0:F4}", OVRManager.profile.ipd * 1000.0f); }
0
14. Example
View licensevoid UpdateFOV() { OVRDisplay.EyeRenderDesc eyeDesc = OVRManager.display.GetEyeRenderDesc(VR.VRNode.LeftEye); strFOV = System.String.Format("FOV (deg): {0:F3}", eyeDesc.fov.y); }
0
15. Example
View licensepublic override string ToString() { return string.Format(CultureInfo.CurrentCulture, "{{Left={0},Top={1},Right={2},Bottom={3}}}", Left, Top, Right, Bottom); }
0
16. Example
View licensepublic override void Compute() { string error; //do validation if (CoestDatasetImporterHelper.ValidatePath(m_config.FilePath, "Answer Set File", out error)) { var answerMatrix = CoestDatasetImporterHelper.ImportAnswerSet(m_config.FilePath, Logger, m_config.TrimElementValues); Workspace.Store("answerMatrix", answerMatrix); Logger.Trace(String.Format("Answer matrix imported from {0}.", m_config.FilePath)); } else { throw new ArgumentException(error); } }
0
17. Example
View licensepublic override void Compute() { TLArtifactsCollection sourceArtifacts = (TLArtifactsCollection)Workspace.Load("sourceArtifacts"); TLArtifactsCollection targetArtifacts = (TLArtifactsCollection)Workspace.Load("targetArtifacts"); if (sourceArtifacts == null) throw new ArgumentException("Source artifacts cannot be null."); if (targetArtifacts == null) throw new ArgumentException("Target artifacts cannot be null."); string error; //do validation if (CoestDatasetImporterHelper.ValidatePath(m_config.FilePath, "Answer Set File", out error)) { var answerMatrix = CoestDatasetImporterHelper.ImportAnswerSet(m_config.FilePath, sourceArtifacts, targetArtifacts, Logger, m_config.TrimElementValues); Workspace.Store("answerMatrix", answerMatrix); Logger.Trace(String.Format("Answer matrix imported from {0}.", m_config.FilePath)); } else { throw new ArgumentException(error); } }
0
18. Example
View licensepublic override void Compute() { string error; //do validation if (CoestDatasetImporterHelper.ValidatePath(m_config.FilePath, "Artifacts File", out error)) { CoestDatasetImporterHelper.Logger = this.Logger; var artifacts = CoestDatasetImporterHelper.ImportArtifacts(m_config.FilePath, m_config.TrimElementValues); Workspace.Store("listOfArtifacts", artifacts); Logger.Info(String.Format("Collection of artifacts with id '{0}' imported from {1}.", artifacts.CollectionId, m_config.FilePath)); } else { throw new ComponentException(error); } }
0
19. Example
View licensepublic override void Compute() { TLDatasetsList listOfDatasets = (TLDatasetsList)Workspace.Load("listOfDatasets"); if (listOfDatasets == null) { throw new ComponentException("Received null listOfDatasets"); } if (listOfDatasets.Count == 0) { throw new ComponentException("Received empty listOfDatasets"); } int index = (int)Workspace.Load("indexOfDataset"); if (index < 0) { throw new ComponentException("Received negative indexOfDataset"); } if (index > listOfDatasets.Count) { throw new ComponentException("Received indexOfDataset is higher that number of datasets in the received list."); } TLDataset dataset = listOfDatasets[index]; Workspace.Store("sourceArtifacts", dataset.SourceArtifacts); Workspace.Store("targetArtifacts", dataset.TargetArtifacts); Workspace.Store("answerSet", dataset.AnswerSet); Workspace.Store("datasetName", dataset.Name); Logger.Info(String.Format("Loaded dataset '{0}' source artifacts collection (id:{1}), and target artifacts collection (id:{2})", dataset.Name, dataset.SourceArtifacts.CollectionId, dataset.TargetArtifacts.CollectionId)); }
0
20. Example
View licensepublic override void Compute() { TLArtifactsCollection artifactsCollection = (TLArtifactsCollection)Workspace.Load("artifactsCollection"); ArtifactsCollectionExporterUtilities.Export(artifactsCollection, Config.Path, Config.CollectionId, Config.CollectionName, Config.CollectionVersion, Config.CollectionDescription); Logger.Info(String.Format("Artifacts Collection has been saved into xml file '{0}'", Config.Path.Absolute)); }
0
21. Example
View licensepublic override string ToString() { return string.Format("{0}: {1}-->{2}", type, this.Source, this.Target); }
0
22. Example
View licenseprivate void RunProgressDialog(IntPtr owner, object argument) { if( _backgroundW/n ..... /n //View Source file for more details /n }
0
23. Example
View licenseprivate void RunProgressDialog(IntPtr owner, object argument) { if( _backgroundW/n ..... /n //View Source file for more details /n }
0
24. Example
View license[SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow", MessageId = "newValue+1", Justification = "Impractical to add as many Series as it would take to overflow.")] protected virtual void OnGlobalSeriesIndexPropertyChanged(int? oldValue, int? newValue) { if (!CustomTitleInUse && (null == GetBindingExpression(TitleProperty))) { Title = newValue.HasValue ? string.Format(CultureInfo.CurrentCulture, Properties.Resources.Series_OnGlobalSeriesIndexPropertyChanged_UntitledSeriesFormatString, newValue.Value + 1) : null; // Setting Title will set CustomTitleInUse; reset it now CustomTitleInUse = false; } }
0
25. Example
View licensepublic override string ToString() { if (!this.HasData) { return Properties.Resources.Range_ToString_NoData; } else { return string.Format(CultureInfo.CurrentCulture, Properties.Resources.Range_ToString_Data, this.Minimum, this.Maximum); } }
0
26. Example
View licenseprotected virtual void OnIsReadOnlyChanged(bool oldValue, bool newValue) { if (!_settingIsReadOnly) { _settingIsReadOnly = true; this.IsReadOnly = oldValue; throw new InvalidOperationException(string.Format(CultureInfo.CurrentUICulture, Properties.Resources.InvalidAttemptToChangeReadOnlyProperty, "IsReadOnly")); } else { _interactionHelper.OnIsReadOnlyChanged(newValue); } }
0
27. Example
View licensepublic void ProcessComponentScanResults(ComponentScanResults results) { foreach /n ..... /n //View Source file for more details /n }
0
28. Example
View licenseprivate void ExecuteDownloadContestPackage(object param) { //the parameters are /n ..... /n //View Source file for more details /n }
0
29. Example
View licenseprivate string RenderView(IMailTemplate template, string type) { var path = string.Format("{0}_{1}.cshtml", template.ViewFile, type); string view = null; try { view = _viewRenderer.Render(path, template); } catch (Exception ex) { throw new TemplateRenderException(path, template, ex); } return view; }
0
30. Example
View licenseprivate void EnforceUniquenessResult(bool isUnique, AddCustomEntityCommand command, CustomEntityDefinitionSummary definition) { if (!isUnique) { string message; string prop; if (definition.AutoGenerateUrlSlug) { // If the slug is autogenerated then we should show the error with the title message = string.Format("The {1} '{0}' must be unique (symbols and spaces are ignored in the uniqueness check)", command.Title, definition.Terms.GetOrDefault(CustomizableCustomEntityTermKeys.Title, "title").ToLower()); prop = "Title"; } else { message = string.Format("The {1} '{0}' must be unique", command.UrlSlug, definition.Terms.GetOrDefault(CustomizableCustomEntityTermKeys.UrlSlug, "url slug").ToLower()); prop = "UrlSlug"; } throw new UniqueConstraintViolationException(message, prop, command.UrlSlug); } }
0
31. Example
View licenseprivate async Task ValidateIsUnique(UpdateCustomEntityUrlCommand command, CustomEntityDefinitionSummary definition) { if (!definition.ForceUrlSlugUniqueness) return; var query = new IsCustomEntityPathUniqueQuery(); query.CustomEntityDefinitionCode = definition.CustomEntityDefinitionCode; query.CustomEntityId = command.CustomEntityId; query.LocaleId = command.LocaleId; query.UrlSlug = command.UrlSlug; var isUnique = await _queryExecutor.ExecuteAsync(query); if (!isUnique) { var message = string.Format("A {0} already exists with the {2} '{1}'", definition.Name, command.UrlSlug, definition.Terms.GetOrDefault(CustomizableCustomEntityTermKeys.UrlSlug, "url slug").ToLower()); throw new UniqueConstraintViolationException(message, "UrlSlug", command.UrlSlug); } }
0
32. Example
View licensepublic async Task ExecuteAsync(DeleteUnstructuredDataDependenciesCommand command, IExecutionContext executionContext) { string entityName; var entityDefinition = _entityDefinitionRepository.GetByCode(command.RootEntityDefinitionCode); EntityNotFoundException.ThrowIfNull(entityDefinition, command.RootEntityDefinitionCode); entityName = entityDefinition.Name; var query = new GetEntityDependencySummaryByRelatedEntityQuery(command.RootEntityDefinitionCode, command.RootEntityId); var dependencies = await _queryExecutor.ExecuteAsync(query); var requiredDependency = dependencies.FirstOrDefault(d => !d.CanDelete); if (requiredDependency != null) { throw new ValidationException( string.Format("Cannot delete this {0} because {1} '{2}' has a dependency on it.", entityName, requiredDependency.Entity.EntityDefinitionName.ToLower(), requiredDependency.Entity.RootEntityTitle)); } await _entityFrameworkSqlExecutor .ExecuteCommandAsync("Cofoundry.UnstructuredDataDependency_Delete", new SqlParameter("EntityDefinitionCode", command.RootEntityDefinitionCode), new SqlParameter("EntityId", command.RootEntityId) ); }
0
33. Example
View licenseprivate void ValidateIsUnique(AddPageCommand command, bool isUnique) { if (!isUnique) { var message = string.Format("A page already exists with the path '{0}' in that directory", command.UrlPath); throw new UniqueConstraintViolationException(message, "UrlPath", command.UrlPath); } }
0
34. Example
View licenseprivate async Task ValidateIsUnique(AddWebDirectoryCommand command) { var query = new IsWebDirectoryPathUniqueQuery(); query.ParentWebDirectoryId = command.ParentWebDirectoryId; query.UrlPath = command.UrlPath; var isUnique = await _queryExecutor.ExecuteAsync(query); if (!isUnique) { var message = string.Format("A web directory already exists in that parent directory with the path '{0}'", command.UrlPath); throw new UniqueConstraintViolationException(message, "UrlPath", command.UrlPath); } }
0
35. Example
View licenseprivate async Task ValidateIsUnique(UpdateWebDirectoryCommand command) { var query = new IsWebDirectoryPathUniqueQuery(); query.ParentWebDirectoryId = command.ParentWebDirectoryId; query.UrlPath = command.UrlPath; query.WebDirectoryId = command.WebDirectoryId; var isUnique = await _queryExecutor.ExecuteAsync(query); if (!isUnique) { var message = string.Format("A web directory already exists in that parent directory with the path '{0}'", command.UrlPath); throw new UniqueConstraintViolationException(message, "UrlPath", command.UrlPath); } }
0
36. Example
View licensepublic async Task CheckBlockReorganization(SyncConnection connection) { while (true) { var block = this.storage.BlockGetBlockCount(1).FirstOrDefault(); if (block == null) { break; } var client = CryptoClientFactory.Create(connection.ServerDomain, connection.RpcAccessPort, connection.User, connection.Password, connection.Secure); var currentHash = await client.GetblockHashAsync(block.BlockIndex); if (currentHash == block.BlockHash) { break; } this.tracer.Trace("SyncOperations", string.Format("Deleting block {0}", block.BlockIndex)); this.storage.DeleteBlock(block.BlockHash); } }
0
37. Example
View licensepublic async Task CheckBlockReorganization(SyncConnection connection) { while (true) { var block = this.storage.BlockGetBlockCount(1).FirstOrDefault(); if (block == null) { break; } var client = CryptoClientFactory.Create(connection.ServerDomain, connection.RpcAccessPort, connection.User, connection.Password, connection.Secure); var currentHash = await client.GetblockHashAsync(block.BlockIndex); if (currentHash == block.BlockHash) { break; } this.tracer.Trace("SyncOperations", string.Format("Deleting block {0}", block.BlockIndex)); this.storage.DeleteBlock(block.BlockHash); } }
0
38. Example
View licensepublic static string FormatInvariant(this string value, params object[] arguments) { return string.Format(CultureInfo.InvariantCulture, value, arguments); }
0
39. Example
View licensepublic static string FormatLocal(this string value, params object[] arguments) { return string.Format(CultureInfo.CurrentCulture, value, arguments); }
0
40. Example
View licensepublic override string ToString() { return string.Format( CultureInfo.CurrentCulture, "MinSupportedDateTime = {0:d}, MaxSupportedDateTime = {1:d}", MinSupportedDateTime, MaxSupportedDateTime ); }
0
41. Example
View licenseprivate void EnsureLegalLengths() { if ( MaximumLength < 0 ) { throw new InvalidOperationException( DataAnnotationsResources.StringLengthAttribute_InvalidMaxLength ); } if ( MaximumLength < MinimumLength ) { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, DataAnnotationsResources.RangeAttribute_MinGreaterThanMax, new object[] { MaximumLength, MinimumLength } ) ); } }
0
42. Example
View licensepublic virtual string FormatErrorMessage( string name ) { return string.Format( CultureInfo.CurrentCulture, ErrorMessageString, new object[] { name } ); }
0
43. Example
View licensevoid OnHeartRateUpdated (object sender, HeartBeatEventArgs e) { heartRateUnitLabel.Hidden = false; heartRateLabel.Hidden = false; heartRateLabel.Text = e.CurrentHeartBeat.Rate.ToString(); var monitor = (HeartRateMonitor)sender; if (monitor.Location == HeartRateMonitorLocation.Unknown) { statusLabel.Text = "Connected"; } else { statusLabel.Text = String.Format ("Connected on {0}", monitor.Location); } deviceNameLabel.Hidden = false; deviceNameLabel.Text = monitor.Name; }
0
44. Example
View licensepublic static string FormatWith(this string format, params object[] args) { return string.Format(CultureInfo.InvariantCulture, format ?? string.Empty, args); }
0
45. Example
View licensepublic void Register( TestAgent agent ) { AgentRecord r = agentData[agent.Id]; if ( r == null ) throw new ArgumentException( string.Format("Agent {0} is not in the agency database", agent.Id), "agentId"); r.Agent = agent; }
0
46. Example
View licensepublic void ReleaseAgent( TestAgent agent ) { AgentRecord r = agentData[agent.Id]; if ( r == null ) log.Error( string.Format( "Unable to release agent {0} - not in database", agent.Id ) ); else { r.Status = AgentStatus.Ready; log.Debug( "Releasing agent " + agent.Id.ToString() ); } }
0
47. Example
View licenseprotected void SelectedItemChanged(object sender, EventArgs e) { ErrorItem item; IFormatterCatalog formatter; item = _stacktraceView.SelectedItem; if (item == null) { _codeView.Text = null; return; } formatter = _codeView.Formatter; _codeView.Language = formatter.LanguageFromExtension(item.FileExtension); try { _codeView.Text = item.ReadFile(); } catch (Exception ex) { _codeView.Text = String.Format( "Cannot open file: '{0}'\r\nError: '{1}'\r\n", item.Path, ex.Message); } _codeView.CurrentLine = item.LineNumber - 1; return; }
0
48. Example
View licensepublic override string ToString() { return string.Format("<{0}-{1}>", this.runtime, this.frameworkVersion); }
0
49. Example
View licensepublic void Register( TestAgent agent ) { AgentRecord r = agentData[agent.Id]; if ( r == null ) throw new ArgumentException( string.Format("Agent {0} is not in the agency database", agent.Id), "agentId"); r.Agent = agent; }
0
50. Example
View licensepublic void ReleaseAgent( TestAgent agent ) { AgentRecord r = agentData[agent.Id]; if ( r == null ) log.Error( string.Format( "Unable to release agent {0} - not in database", agent.Id ) ); else { r.Status = AgentStatus.Ready; log.Debug( "Releasing agent " + agent.Id.ToString() ); } }