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


C# ItemType.HasFlag方法代码示例

本文整理汇总了C#中ItemType.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# ItemType.HasFlag方法的具体用法?C# ItemType.HasFlag怎么用?C# ItemType.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ItemType的用法示例。


在下文中一共展示了ItemType.HasFlag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

 public static ExportOptions Create(OperationState state, ItemType types, bool exportDeletions, int maxNumberOfItemsToExport)
 {
     return new ExportOptions
     {
         ExportAttachments = types.HasFlag(ItemType.Attachments),
         ExportDocuments = types.HasFlag(ItemType.Documents),
         ExportDeletions = exportDeletions,
         StartEtags = state,
         MaxNumberOfDocumentsToExport = maxNumberOfItemsToExport - state.NumberOfExportedDocuments,
         MaxNumberOfAttachmentsToExport = maxNumberOfItemsToExport - state.NumberOfExportedAttachments
     };
 }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:12,代码来源:ExportOptions.cs

示例2: ExportIdentities

		private static async Task ExportIdentities(DocumentStore exportStore, DocumentStore importStore, ItemType operateOnTypes)
		{
			int start = 0;
			const int pageSize = 1024;
			long totalIdentitiesCount;
			var identities = new List<KeyValuePair<string, long>>();

			ShowProgress("Exporting Identities");

			do
			{
				var url = exportStore.Url.ForDatabase(exportStore.DefaultDatabase) + "/debug/identities?start=" + start + "&pageSize=" + pageSize;
				using (var request = exportStore.JsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(null, url, "GET", exportStore.DatabaseCommands.PrimaryCredentials, exportStore.Conventions)))
				{
					var identitiesInfo = (RavenJObject)await request.ReadResponseJsonAsync();
					totalIdentitiesCount = identitiesInfo.Value<long>("TotalCount");

					foreach (var identity in identitiesInfo.Value<RavenJArray>("Identities"))
					{
						identities.Add(new KeyValuePair<string, long>(identity.Value<string>("Key"), identity.Value<long>("Value")));
					}

					start += pageSize;
				}
			} while (identities.Count < totalIdentitiesCount);

			ShowProgress("Exported {0} following identities: {1}", identities.Count, string.Join(", ", identities.Select(x => x.Key)));

			var filteredIdentities = identities.Where(x =>
			{
				if ("Raven/Etag".Equals(x.Key, StringComparison.InvariantCultureIgnoreCase))
					return true;

				if ("IndexId".Equals(x.Key, StringComparison.InvariantCultureIgnoreCase) && operateOnTypes.HasFlag(ItemType.Indexes))
					return true;

				if (operateOnTypes.HasFlag(ItemType.Documents))
					return true;

				return false;
			}).ToList();

			ShowProgress("After filtering {0} identities need to be imported: {1}", filteredIdentities.Count, string.Join(", ", filteredIdentities.Select(x => x.Key)));

			foreach (var identityInfo in filteredIdentities)
			{
				importStore.DatabaseCommands.SeedIdentityFor(identityInfo.Key, identityInfo.Value);

				ShowProgress("Identity '{0}' imported with value {1}", identityInfo.Key, identityInfo.Value);
			}

			ShowProgress("Done with importing indentities");
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:53,代码来源:SmugglerDatabaseBetweenOperation.cs

示例3: ExportIdentities

        private static async Task ExportIdentities(DocumentStore exportStore, DocumentStore importStore, ItemType operateOnTypes, SmugglerDatabaseOptions databaseOptions)
        {
            int start = 0;
            const int pageSize = 1024;
            long totalIdentitiesCount = 0;
            var identities = new List<KeyValuePair<string, long>>();
            var retries = RetriesCount;

            ShowProgress("Exporting Identities");

            do
            {
                var url = exportStore.Url.ForDatabase(exportStore.DefaultDatabase) + "/debug/identities?start=" + start + "&pageSize=" + pageSize;
                using (var request = exportStore.JsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(null, url, "GET", exportStore.DatabaseCommands.PrimaryCredentials, exportStore.Conventions)))
                {
                    RavenJObject identitiesInfo;

                    try
                    {
                        identitiesInfo = (RavenJObject)await request.ReadResponseJsonAsync();
                    }
                    catch (Exception e)
                    {
                        if (retries-- == 0 && databaseOptions.IgnoreErrorsAndContinue)
                        {
                            ShowProgress("Failed to fetch identities too much times. Cancelling identities export. Message: {0}", e.Message);
                            return;
                        }

                        if (databaseOptions.IgnoreErrorsAndContinue == false)
                            throw;

                        ShowProgress("Failed to fetch identities. {0} retries remaining. Message: {1}", retries, e.Message);
                        continue;
                    }

                    totalIdentitiesCount = identitiesInfo.Value<long>("TotalCount");

                    // ReSharper disable once LoopCanBeConvertedToQuery --> the code is more readable when NOT converted to linq
                    foreach (var identity in identitiesInfo.Value<RavenJArray>("Identities"))
                    {
                        identities.Add(new KeyValuePair<string, long>(identity.Value<string>("Key"), identity.Value<long>("Value")));
                    }

                    start += pageSize;
                }
            } while (identities.Count < totalIdentitiesCount);

            ShowProgress("Exported {0} following identities: {1}", identities.Count, string.Join(", ", identities.Select(x => x.Key)));

            var filteredIdentities = identities.Where(x =>
            {
                if ("Raven/Etag".Equals(x.Key, StringComparison.OrdinalIgnoreCase))
                    return false;

                if ("IndexId".Equals(x.Key, StringComparison.OrdinalIgnoreCase))
                    return false;

                if (Constants.RavenSubscriptionsPrefix.Equals(x.Key, StringComparison.OrdinalIgnoreCase))
                    return false;

                if (operateOnTypes.HasFlag(ItemType.Documents))
                    return true;

                return false;
            }).ToList();

            ShowProgress("After filtering {0} identities need to be imported: {1}", filteredIdentities.Count, string.Join(", ", filteredIdentities.Select(x => x.Key)));

            foreach (var identityInfo in filteredIdentities)
            {
                try
                {
                    importStore.DatabaseCommands.SeedIdentityFor(identityInfo.Key, identityInfo.Value);
                }
                catch (Exception e)
                {
                    ShowProgress("Failed seeding identity for {0}. Message: {1}", identityInfo.Key, e.Message);
                    continue;
                }

                ShowProgress("Identity '{0}' imported with value {1}", identityInfo.Key, identityInfo.Value);
            }

            ShowProgress("Done with importing indentities");
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:86,代码来源:SmugglerDatabaseBetweenOperation.cs

示例4: FilterIdentity

		public bool FilterIdentity(string indentityName, ItemType operateOnTypes)
		{
			if ("Raven/Etag".Equals(indentityName, StringComparison.InvariantCultureIgnoreCase))
				return true;

			if ("IndexId".Equals(indentityName, StringComparison.InvariantCultureIgnoreCase) && operateOnTypes.HasFlag(ItemType.Indexes))
				return true;

			if (operateOnTypes.HasFlag(ItemType.Documents))
				return true;

			return false;
		}
开发者ID:kijanawoodard,项目名称:ravendb,代码行数:13,代码来源:SmugglerApiBase.cs


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