当前位置: 首页>>代码示例>>C#>>正文


C# Collection.ToArray方法代码示例

本文整理汇总了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();
        }
开发者ID:crushjz,项目名称:visualstudio-wakatime,代码行数:30,代码来源:PythonCliParameters.cs

示例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();
        }
开发者ID:vishnupasuleti,项目名称:visualstudio-wakatime,代码行数:25,代码来源:PythonCliParameters.cs

示例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();
        }
开发者ID:ermshiperete,项目名称:wakatime-sharp,代码行数:26,代码来源:PythonCliParameters.cs

示例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;
		}
开发者ID:imintsystems,项目名称:Kean,代码行数:8,代码来源:Sender.cs

示例6: GetRolesExcludingOwner

 public static IEnumerable<object> GetRolesExcludingOwner()
 {
     var roles = new Collection<object>
         {
             UserRole.Writer,
             UserRole.Publisher
         };
     return roles.ToArray();
 }
开发者ID:pvivera,项目名称:FluentSecurity,代码行数:9,代码来源:StaticHelper.cs

示例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();
        }
开发者ID:Eldblom,项目名称:Unicorn,代码行数:10,代码来源:ConfigurationRolePredicate.cs

示例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();
        }
开发者ID:klym1,项目名称:Gpak-tools,代码行数:11,代码来源:RawParser.cs

示例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());
 }
开发者ID:pusp,项目名称:o2platform,代码行数:12,代码来源:AuthenticationHelper.cs

示例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();
        }
开发者ID:bllue78,项目名称:Unicorn,代码行数:13,代码来源:SerializationPresetPredicate.cs

示例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);
 }
开发者ID:webflo-dev,项目名称:StarterApp,代码行数:13,代码来源:EmptyMailer.cs

示例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();
        }
开发者ID:Rabidgeek,项目名称:CIS23,代码行数:13,代码来源:AddressBook.cs

示例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();
            }
        }
开发者ID:gangelo,项目名称:BillingUtils,代码行数:14,代码来源:Dates.cs

示例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();
        }
开发者ID:vtsvang,项目名称:cis-23,代码行数:14,代码来源:AddressBook.cs

示例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);
        }
开发者ID:webflo-dev,项目名称:StarterApp,代码行数:16,代码来源:SmtpMailer.cs


注:本文中的Collection.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。