private static void FetchRetentionPolicyTagDataFromService(StoreRetentionPolicyTagHelper srpth)
		{
			StoreRetentionPolicyTagHelper.InitializeServiceBinding(srpth);
			if (srpth.serviceBinding != null)
			{
				GetUserConfigurationType getUserConfiguration = new GetUserConfigurationType
				{
					UserConfigurationName = new UserConfigurationNameType
					{
						Name = "MRM",
						Item = new DistinguishedFolderIdType
						{
							Id = DistinguishedFolderIdNameType.inbox
						}
					},
					UserConfigurationProperties = (UserConfigurationPropertyType.Dictionary | UserConfigurationPropertyType.XmlData | UserConfigurationPropertyType.BinaryData)
				};
				StoreRetentionPolicyTagHelper.CallEwsWithRetries(() => srpth.serviceBinding.GetUserConfiguration(getUserConfiguration), delegate(ResponseMessageType responseMessage, int messageIndex)
				{
					GetUserConfigurationResponseMessageType getUserConfigurationResponseMessageType = responseMessage as GetUserConfigurationResponseMessageType;
					if (getUserConfigurationResponseMessageType.ResponseClass == ResponseClassType.Success && getUserConfigurationResponseMessageType.UserConfiguration != null)
					{
						if (getUserConfigurationResponseMessageType.UserConfiguration.XmlData != null)
						{
							ExTraceGlobals.ELCTracer.TraceDebug(0L, "Acquired MRM user configuration.");
							srpth.TagData = MrmFaiFormatter.Deserialize(getUserConfigurationResponseMessageType.UserConfiguration.XmlData, srpth.exchangePrincipal, out srpth.deletedTags, out srpth.retentionHoldData, true, out srpth.defaultArchiveTagData, out srpth.fullCrawlRequired);
							srpth.configItemExists = true;
						}
						else
						{
							ExTraceGlobals.ELCTracer.TraceDebug(0L, "MRM user configuration is null");
							srpth.TagData = new Dictionary<Guid, StoreTagData>();
							srpth.configItemExists = false;
						}
						return true;
					}
					if (getUserConfigurationResponseMessageType.ResponseClass == ResponseClassType.Error && getUserConfigurationResponseMessageType.ResponseCode == ResponseCodeType.ErrorItemNotFound)
					{
						ExTraceGlobals.ELCTracer.TraceDebug(0L, "MRM user configuration not found");
						srpth.TagData = new Dictionary<Guid, StoreTagData>();
						srpth.configItemExists = false;
						return true;
					}
					ExTraceGlobals.ELCTracer.TraceDebug(0L, "Getting MRM user configuration failed");
					return false;
				}, srpth);
				return;
			}
			throw new ElcUserConfigurationException(Strings.ElcUserConfigurationServiceBindingNotAvailable);
		}
		private void SaveToService()
		{
			StoreRetentionPolicyTagHelper.InitializePrincipal(this);
			StoreRetentionPolicyTagHelper.InitializeServiceBinding(this);
			if (this.serviceBinding == null)
			{
				throw new ElcUserConfigurationException(Strings.ElcUserConfigurationServiceBindingNotAvailable);
			}
			if (this.configItemExists)
			{
				StoreRetentionPolicyTagHelper.UpdateUserConfiguration(this);
				return;
			}
			StoreRetentionPolicyTagHelper.CreateUserConfiguration(this);
		}
		private static void CallEwsWithRetries(Func<BaseResponseMessageType> delegateEwsCall, Func<ResponseMessageType, int, bool> responseMessageProcessor, StoreRetentionPolicyTagHelper srpth)
		{
			ExDateTime t = ExDateTime.UtcNow.Add(StoreRetentionPolicyTagHelper.TotalExecutionTimeWindow);
			Exception ex = null;
			int num = -1;
			bool flag;
			do
			{
				ex = null;
				flag = false;
				try
				{
					BaseResponseMessageType baseResponseMessageType = delegateEwsCall();
					num++;
					int i = 0;
					while (i < baseResponseMessageType.ResponseMessages.Items.Length)
					{
						ResponseMessageType responseMessageType = baseResponseMessageType.ResponseMessages.Items[i];
						if (responseMessageProcessor != null && responseMessageProcessor(responseMessageType, i))
						{
							ExTraceGlobals.ELCTracer.TraceDebug(0L, "Successfully executed EWS call");
							break;
						}
						if (responseMessageType.ResponseClass == ResponseClassType.Error)
						{
							if (responseMessageType.ResponseCode == ResponseCodeType.ErrorCrossSiteRequest)
							{
								ExTraceGlobals.ELCTracer.TraceDebug(0L, "Crosssite request error , recreate exchange binding and reset the url caches");
								flag = true;
								StoreRetentionPolicyTagHelper.InitializePrincipal(srpth);
								StoreRetentionPolicyTagHelper.InitializeServiceBinding(srpth);
								break;
							}
							if (!StoreRetentionPolicyTagHelper.TransientServiceErrors.Contains(responseMessageType.ResponseCode))
							{
								ExTraceGlobals.ELCTracer.TraceError(0L, string.Format("Permanent error encountered:  {0}, {1}, {2}", responseMessageType.ResponseClass.ToString(), responseMessageType.ResponseCode.ToString(), responseMessageType.MessageText.ToString()));
								throw new ElcUserConfigurationException(Strings.FailedToGetElcUserConfigurationFromService(responseMessageType.ResponseClass.ToString(), responseMessageType.ResponseCode.ToString(), responseMessageType.MessageText.ToString()));
							}
							flag = true;
							ex = new ElcUserConfigurationException(Strings.FailedToGetElcUserConfigurationFromService(responseMessageType.ResponseClass.ToString(), responseMessageType.ResponseCode.ToString(), responseMessageType.MessageText.ToString()));
							ExTraceGlobals.ELCTracer.TraceDebug(0L, "Transient error encountered, will attempt to retry, Exception: " + ex);
							break;
						}
						else
						{
							i++;
						}
					}
				}
				catch (CommunicationException ex2)
				{
					ex = ex2;
					ExTraceGlobals.ELCTracer.TraceDebug(0L, "Transient error encountered, will attempt to retry, Exception: " + ex);
					flag = true;
				}
				catch (WebException ex3)
				{
					ex = ex3;
					ExTraceGlobals.ELCTracer.TraceDebug(0L, "Transient error encountered, will attempt to retry, Exception: " + ex);
					flag = true;
				}
				catch (TimeoutException ex4)
				{
					ex = ex4;
					flag = false;
				}
				catch (SoapException ex5)
				{
					ex = ex5;
					flag = false;
				}
				catch (IOException ex6)
				{
					ex = ex6;
					flag = false;
				}
				catch (InvalidOperationException ex7)
				{
					ex = ex7;
					flag = false;
				}
				catch (LocalizedException ex8)
				{
					ex = ex8;
					flag = false;
				}
			}
			while (flag && t > ExDateTime.UtcNow);
			if (ex != null)
			{
				ExTraceGlobals.ELCTracer.TraceError(0L, string.Format("Failed to access elc user configuration.  Total attempts made {0}, Exception: {1} ", num, ex));
				throw new ElcUserConfigurationException(Strings.ErrorElcUserConfigurationServiceCall, ex);
			}
		}