本文整理汇总了C#中Collection.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.ToArray方法的具体用法?C# Collection.ToArray怎么用?C# Collection.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToArray
public string[] ToArray(bool obfuscate = false)
{
var parameters = new Collection<string>
{
Cli,
"--key",
obfuscate ? string.Format("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX{0}", Key.Substring(Key.Length - 4)) : Key,
"--entity",
File,
"--time",
Time.ToString(),
"--plugin",
Plugin
};
if (IsWrite)
parameters.Add("--write");
// ReSharper disable once InvertIf
if (!string.IsNullOrEmpty(Project))
{
parameters.Add("--project");
parameters.Add(Project);
}
if (HasExtraHeartbeats)
parameters.Add("--extra-heartbeats");
return parameters.ToArray();
}
示例2: ToArray
public string[] ToArray(bool obfuscate = false)
{
var parameters = new Collection<string>
{
Cli,
"--key",
obfuscate ? string.Format("********-****-****-****-********{0}", Key.Substring(Key.Length - 4)) : Key,
"--file",
File,
"--plugin",
Plugin
};
if (IsWrite)
parameters.Add("--write");
// ReSharper disable once InvertIf
if (!string.IsNullOrEmpty(Project))
{
parameters.Add("--project");
parameters.Add(Project);
}
return parameters.ToArray();
}
示例3: ToArray
public string[] ToArray(bool obfuscate = false)
{
var key = WakaTimeConfigFile.ApiKey;
var parameters = new Collection<string>
{
WakaTimeCli.GetCliPath(),
"--key",
obfuscate ? string.Format("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX{0}", key.Substring(key.Length - 4)) : key,
"--file",
File,
"--plugin",
Plugin
};
if (IsWrite)
parameters.Add("--write");
// ReSharper disable once InvertIf
if (!string.IsNullOrEmpty(Project))
{
parameters.Add("--project");
parameters.Add(Project);
}
return parameters.ToArray();
}
示例4: DownloadAllFilesSynchronously
public static List<SalesforceFileProxy> DownloadAllFilesSynchronously(PackageEntity package, SalesforceContext ctx, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (!ctx.IsLoggedIn)
throw new InvalidOperationException("Service should be logged into Salesforce");
List<SalesforceFileProxy> listFileProxies = new List<SalesforceFileProxy>();
RetrieveRequest[] retrieveRequestArray = ConvertPackageToRequests(package);
List<AsyncResult> listResults = new List<AsyncResult>();
foreach (var retrieveRequest in retrieveRequestArray)
{
RetrieveRequest request = retrieveRequest;
cancellationToken.ThrowIfCancellationRequested();
AsyncResult asyncResult = ctx.SessionExpirationWrapper(() => ctx.MetadataServiceAdapter.Retrieve(request));
listResults.Add(asyncResult);
}
cancellationToken.ThrowIfCancellationRequested();
ICollection<Task<RetrieveResult>> collection = new Collection<Task<RetrieveResult>>();
foreach (var asyncResult in listResults)
{
cancellationToken.ThrowIfCancellationRequested();
Task<RetrieveResult> task = Task<RetrieveResult>.Factory.StartNew(() => ctx.PollingResult.PollForResultWrapper(3, 180, 3, () =>
ctx.CheckRetrieveResult(asyncResult.id), res => res != null, cancellationToken), cancellationToken);
collection.Add(task);
}
ctx.WaitAllTaskskWithHandlingAggregateException(collection.ToArray(), cancellationToken);
foreach (Task<RetrieveResult> task in collection)
{
cancellationToken.ThrowIfCancellationRequested();
RetrieveResult result = task.Result;
string fileName = String.Format("{0}\\{1}.zip", ctx.OutputLocation, Guid.NewGuid().ToString());
bool rawZip = Boolean.Parse(ConfigurationManager.AppSettings["salesforcemigrations:dumprawzip"]);
if(rawZip)
{
var rawZipFile = new SalesforceFileProxy
{
FullName = result.id,
FileName = String.Format("unpackaged/zips/{0}.zip", result.id),
Type = "zip",
BinaryBody = result.zipFile
};
listFileProxies.Add(rawZipFile);
}
List<SalesforceFileProxy> files = UnzipPackageFilesHelper.UnzipPackageFilesRecursive(result.zipFile);
UpdateFileProperties(files, result.fileProperties);
listFileProxies.AddRange(files);
}
return listFileProxies;
}
开发者ID:DavidMGardner,项目名称:Salesforce.Migrations.Assistant,代码行数:59,代码来源:SalesforceRepositoryHelpers.cs
示例5: Write
public bool Write(Collection.IVector<byte> buffer)
{
bool result;
byte[] data = buffer.ToArray();
if (result = (data.NotEmpty() && this.backend.NotNull()))
this.backend.Send(data, data.Length);
return result;
}
示例6: GetRolesExcludingOwner
public static IEnumerable<object> GetRolesExcludingOwner()
{
var roles = new Collection<object>
{
UserRole.Writer,
UserRole.Publisher
};
return roles.ToArray();
}
示例7: GetConfigurationDetails
public KeyValuePair<string, string>[] GetConfigurationDetails()
{
var configs = new Collection<KeyValuePair<string, string>>();
foreach (var entry in _includeEntries)
{
configs.Add(new KeyValuePair<string, string>(entry.Domain, entry.Pattern));
}
return configs.ToArray();
}
示例8: GetColorCollectionFromPalleteFile
public Color[] GetColorCollectionFromPalleteFile(byte[] paletteBytes)
{
var colorCollection = new Collection<Color>();
for (int i = 0; i < paletteBytes.Length - 2; i += 3)
{
colorCollection.Add(Color.FromArgb(255, paletteBytes[i], paletteBytes[i + 1], paletteBytes[i + 2]));
}
return colorCollection.ToArray();
}
示例9: ToString
public static string ToString(string scheme, Collection<string> parameters)
{
if (string.IsNullOrEmpty(scheme) && (parameters == null || parameters.Count == 0))
{
return "";
}
if (parameters == null || parameters.Count == 0)
{
return scheme;
}
return scheme + " " + string.Join(", ", parameters.ToArray());
}
示例10: GetConfigurationDetails
public KeyValuePair<string, string>[] GetConfigurationDetails()
{
var configs = new Collection<KeyValuePair<string, string>>();
foreach (var entry in _preset)
{
string basePath = entry.DatabaseName + ":" + entry.Path;
string excludes = GetExcludeDescription(entry);
configs.Add(new KeyValuePair<string, string>(entry.Name, basePath + excludes));
}
return configs.ToArray();
}
示例11: SendAsync
public async Task SendAsync(IEnumerable<MailMessage> messages, Func<MailMessage, Task> continuationAction)
{
var tasks = new Collection<Task>();
foreach (var message in messages)
{
var message1 = message;
Task task = Task.FromResult(true);
if (continuationAction != null)
task = task.ContinueWith(t => continuationAction(message1));
tasks.Add(task);
}
await Task.WhenAll(tasks.ToArray()).ConfigureAwait(false);
}
示例12: Search
public Person[] Search(int name)
{
Collection<Person> results = new Collection<Person>();
foreach (Person p in Book)
{
if (p.GetID == name)
{
results.Add(p);
}
}
return results.ToArray();
}
示例13: ToDateRange
public static DateTime[] ToDateRange(DateTime startDate, DateTime endDate)
{
lock (m_syncRoot) {
Collection<DateTime> collection = new Collection<DateTime>();
DateTime date = startDate;
while (date <= endDate) {
collection.Add(date);
date = date.AddDays(1);
}
return collection.ToArray();
}
}
示例14: Search
public Person[] Search(string query)
{
Collection<Person> results = new Collection<Person>();
foreach (Person p in List)
{
if (p.FirstName == query || p.LastName == query)
{
results.Add(p);
}
}
return results.ToArray();
}
示例15: SendAsync
public async Task SendAsync(IEnumerable<MailMessage> messages, Func<MailMessage, Task> continuationAction)
{
var tasks = new Collection<Task>();
foreach (var message in messages)
{
var message1 = message;
var smtpClient = new SmtpClient();
Task task = smtpClient.SendMailAsync(message1)
.ContinueWith(task1 => smtpClient.Dispose());
if (continuationAction != null)
task = task.ContinueWith(t => continuationAction(message1));
tasks.Add(task);
}
await Task.WhenAll(tasks.ToArray()).ConfigureAwait(false);
}