Transform.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // Transform.cs - Transform implementation for XML Signature
  3. //
  4. // Author:
  5. // Sebastien Pouliot <[email protected]>
  6. //
  7. // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
  8. // (C) 2004 Novell (http://www.novell.com)
  9. //
  10. using System.Runtime.InteropServices;
  11. using System.Xml;
  12. namespace System.Security.Cryptography.Xml {
  13. public abstract class Transform {
  14. private string algo;
  15. public Transform () {}
  16. public string Algorithm {
  17. get { return algo; }
  18. set { algo = value; }
  19. }
  20. public abstract Type[] InputTypes {
  21. get;
  22. }
  23. public abstract Type[] OutputTypes {
  24. get;
  25. }
  26. protected abstract XmlNodeList GetInnerXml ();
  27. public abstract object GetOutput ();
  28. public abstract object GetOutput (Type type);
  29. public XmlElement GetXml ()
  30. {
  31. XmlDocument document = new XmlDocument ();
  32. XmlElement xel = document.CreateElement (XmlSignature.ElementNames.Transform, XmlSignature.NamespaceURI);
  33. xel.SetAttribute (XmlSignature.AttributeNames.Algorithm, algo);
  34. XmlNodeList xnl = this.GetInnerXml ();
  35. if (xnl != null) {
  36. foreach (XmlNode xn in xnl) {
  37. XmlNode importedNode = document.ImportNode (xn, true);
  38. xel.AppendChild (importedNode);
  39. }
  40. }
  41. return xel;
  42. }
  43. public abstract void LoadInnerXml (XmlNodeList nodeList);
  44. public abstract void LoadInput (object obj);
  45. #if ! NET_1_0
  46. private XmlResolver xmlResolver;
  47. [ComVisible(false)]
  48. public XmlResolver Resolver {
  49. set { xmlResolver = value; }
  50. }
  51. internal XmlResolver GetResolver ()
  52. {
  53. return xmlResolver;
  54. }
  55. #endif
  56. }
  57. }