protected override void WriteKeyIdentifierCore(XmlWriter writer, SecurityKeyIdentifier keyIdentifier) { bool flag = false; XmlDictionaryWriter writer2 = XmlDictionaryWriter.CreateDictionaryWriter(writer); for (int i = 0; i < this.keyIdentifierEntries.Count; i++) { KeyIdentifierEntry entry = this.keyIdentifierEntries[i]; if (entry.SupportsCore(keyIdentifier)) { try { entry.WriteKeyIdentifierCore(writer2, keyIdentifier); } catch (Exception exception) { if (!this.ShouldWrapException(exception)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("ErrorSerializingKeyIdentifier"), exception)); } flag = true; break; } } if (!flag) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("StandardsManagerCannotWriteObject", new object[] { keyIdentifier.GetType() }))); } writer2.Flush(); }
protected override bool CanWriteKeyIdentifierCore(SecurityKeyIdentifier keyIdentifier) { for (int i = 0; i < _keyIdentifierEntries.Count; ++i) { KeyIdentifierEntry keyIdentifierEntry = _keyIdentifierEntries[i]; if (keyIdentifierEntry.SupportsCore(keyIdentifier)) { return(true); } } return(false); }
protected override void WriteKeyIdentifierCore(XmlWriter writer, SecurityKeyIdentifier keyIdentifier) { bool wroteKeyIdentifier = false; XmlDictionaryWriter localWriter = XmlDictionaryWriter.CreateDictionaryWriter(writer); for (int i = 0; i < _keyIdentifierEntries.Count; ++i) { KeyIdentifierEntry keyIdentifierEntry = _keyIdentifierEntries[i]; if (keyIdentifierEntry.SupportsCore(keyIdentifier)) { try { keyIdentifierEntry.WriteKeyIdentifierCore(localWriter, keyIdentifier); } #pragma warning disable 56500 // covered by FxCOP catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (!ShouldWrapException(e)) { throw; } throw /*System.ServiceModel.*/ DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(string.Format(SR_IdentityModel.ErrorSerializingKeyIdentifier), e)); } wroteKeyIdentifier = true; break; } } if (!wroteKeyIdentifier) { //TODO: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.StandardsManagerCannotWriteObject, keyIdentifier.GetType()))); throw new XmlException(SRServiceModel.StandardsManagerCannotWriteObject); } localWriter.Flush(); }
protected override void WriteKeyIdentifierCore(XmlWriter writer, SecurityKeyIdentifier keyIdentifier) { bool wroteKeyIdentifier = false; XmlDictionaryWriter localWriter = XmlDictionaryWriter.CreateDictionaryWriter(writer); for (int i = 0; i < _keyIdentifierEntries.Count; ++i) { KeyIdentifierEntry keyIdentifierEntry = _keyIdentifierEntries[i]; if (keyIdentifierEntry.SupportsCore(keyIdentifier)) { try { keyIdentifierEntry.WriteKeyIdentifierCore(localWriter, keyIdentifier); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (!ShouldWrapException(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format("ErrorSerializingKeyIdentifier"), e)); } wroteKeyIdentifier = true; break; } } if (!wroteKeyIdentifier) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.StandardsManagerCannotWriteObject, keyIdentifier.GetType()))); } localWriter.Flush(); }