/// <summary> /// Binds the events exposed by the source to the handlers in the listener. /// </summary> /// <param name="source">The source of instrumentation events. Must be an instance of <see cref="SymmetricAlgorithmInstrumentationProvider"/>.</param> /// <param name="listener">The listener for instrumentation events. Must be an instance of <see cref="SymmetricAlgorithmInstrumentationListener"/>.</param> public void Bind(object source, object listener) { SymmetricAlgorithmInstrumentationListener castedListener = (SymmetricAlgorithmInstrumentationListener)listener; SymmetricAlgorithmInstrumentationProvider castedProvider = (SymmetricAlgorithmInstrumentationProvider)source; castedProvider.cyptographicOperationFailed += castedListener.CyptographicOperationFailed; castedProvider.symmetricDecryptionPerformed += castedListener.SymmetricDecryptionPerformed; castedProvider.symmetricEncryptionPerformed += castedListener.SymmetricEncryptionPerformed; }
internal SymmetricAlgorithmProvider(Type algorithmType, ProtectedKey key) { if (algorithmType == null) throw new ArgumentNullException("algorithmType"); if (!typeof(SymmetricAlgorithm).IsAssignableFrom(algorithmType)) throw new ArgumentException(Resources.ExceptionCreatingSymmetricAlgorithmInstance, "algorithmType"); this.algorithmType = algorithmType; this.key = key; this.instrumentationProvider = new SymmetricAlgorithmInstrumentationProvider(); }