Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / ManagedLibraries / Security / System / Security / Cryptography / Xml / DataObject.cs / 1305376 / DataObject.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// [....]
//
//
// DataObject.cs
//
// 21 [....] 2000
//
namespace System.Security.Cryptography.Xml
{
using System;
using System.IO;
using System.Xml;
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class DataObject {
private string m_id;
private string m_mimeType;
private string m_encoding;
private CanonicalXmlNodeList m_elData;
private XmlElement m_cachedXml;
//
// public constructors
//
public DataObject () {
m_cachedXml = null;
m_elData = new CanonicalXmlNodeList();
}
public DataObject (string id, string mimeType, string encoding, XmlElement data) {
if (data == null)
throw new ArgumentNullException("data");
m_id = id;
m_mimeType = mimeType;
m_encoding = encoding;
m_elData = new CanonicalXmlNodeList();
m_elData.Add(data);
m_cachedXml = null;
}
//
// public properties
//
public string Id {
get { return m_id; }
set {
m_id = value;
m_cachedXml = null;
}
}
public string MimeType {
get { return m_mimeType; }
set {
m_mimeType = value;
m_cachedXml = null;
}
}
public string Encoding {
get { return m_encoding; }
set {
m_encoding = value;
m_cachedXml = null;
}
}
public XmlNodeList Data {
get { return m_elData; }
set {
if (value == null)
throw new ArgumentNullException("value");
// Reset the node list
m_elData = new CanonicalXmlNodeList();
foreach (XmlNode node in value) {
m_elData.Add(node);
}
m_cachedXml = null;
}
}
private bool CacheValid {
get {
return(m_cachedXml != null);
}
}
//
// public methods
//
public XmlElement GetXml() {
if (CacheValid) return(m_cachedXml);
XmlDocument document = new XmlDocument();
document.PreserveWhitespace = true;
return GetXml(document);
}
internal XmlElement GetXml (XmlDocument document) {
XmlElement objectElement = document.CreateElement("Object", SignedXml.XmlDsigNamespaceUrl);
if (!String.IsNullOrEmpty(m_id))
objectElement.SetAttribute("Id", m_id);
if (!String.IsNullOrEmpty(m_mimeType))
objectElement.SetAttribute("MimeType", m_mimeType);
if (!String.IsNullOrEmpty(m_encoding))
objectElement.SetAttribute("Encoding", m_encoding);
if (m_elData != null) {
foreach (XmlNode node in m_elData) {
objectElement.AppendChild(document.ImportNode(node, true));
}
}
return objectElement;
}
public void LoadXml (XmlElement value) {
if (value == null)
throw new ArgumentNullException("value");
m_id = Utils.GetAttribute(value, "Id", SignedXml.XmlDsigNamespaceUrl);
m_mimeType = Utils.GetAttribute(value, "MimeType", SignedXml.XmlDsigNamespaceUrl);
m_encoding = Utils.GetAttribute(value, "Encoding", SignedXml.XmlDsigNamespaceUrl);
foreach (XmlNode node in value.ChildNodes) {
m_elData.Add(node);
}
// Save away the cached value
m_cachedXml = value;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// [....]
//
//
// DataObject.cs
//
// 21 [....] 2000
//
namespace System.Security.Cryptography.Xml
{
using System;
using System.IO;
using System.Xml;
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public class DataObject {
private string m_id;
private string m_mimeType;
private string m_encoding;
private CanonicalXmlNodeList m_elData;
private XmlElement m_cachedXml;
//
// public constructors
//
public DataObject () {
m_cachedXml = null;
m_elData = new CanonicalXmlNodeList();
}
public DataObject (string id, string mimeType, string encoding, XmlElement data) {
if (data == null)
throw new ArgumentNullException("data");
m_id = id;
m_mimeType = mimeType;
m_encoding = encoding;
m_elData = new CanonicalXmlNodeList();
m_elData.Add(data);
m_cachedXml = null;
}
//
// public properties
//
public string Id {
get { return m_id; }
set {
m_id = value;
m_cachedXml = null;
}
}
public string MimeType {
get { return m_mimeType; }
set {
m_mimeType = value;
m_cachedXml = null;
}
}
public string Encoding {
get { return m_encoding; }
set {
m_encoding = value;
m_cachedXml = null;
}
}
public XmlNodeList Data {
get { return m_elData; }
set {
if (value == null)
throw new ArgumentNullException("value");
// Reset the node list
m_elData = new CanonicalXmlNodeList();
foreach (XmlNode node in value) {
m_elData.Add(node);
}
m_cachedXml = null;
}
}
private bool CacheValid {
get {
return(m_cachedXml != null);
}
}
//
// public methods
//
public XmlElement GetXml() {
if (CacheValid) return(m_cachedXml);
XmlDocument document = new XmlDocument();
document.PreserveWhitespace = true;
return GetXml(document);
}
internal XmlElement GetXml (XmlDocument document) {
XmlElement objectElement = document.CreateElement("Object", SignedXml.XmlDsigNamespaceUrl);
if (!String.IsNullOrEmpty(m_id))
objectElement.SetAttribute("Id", m_id);
if (!String.IsNullOrEmpty(m_mimeType))
objectElement.SetAttribute("MimeType", m_mimeType);
if (!String.IsNullOrEmpty(m_encoding))
objectElement.SetAttribute("Encoding", m_encoding);
if (m_elData != null) {
foreach (XmlNode node in m_elData) {
objectElement.AppendChild(document.ImportNode(node, true));
}
}
return objectElement;
}
public void LoadXml (XmlElement value) {
if (value == null)
throw new ArgumentNullException("value");
m_id = Utils.GetAttribute(value, "Id", SignedXml.XmlDsigNamespaceUrl);
m_mimeType = Utils.GetAttribute(value, "MimeType", SignedXml.XmlDsigNamespaceUrl);
m_encoding = Utils.GetAttribute(value, "Encoding", SignedXml.XmlDsigNamespaceUrl);
foreach (XmlNode node in value.ChildNodes) {
m_elData.Add(node);
}
// Save away the cached value
m_cachedXml = value;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UIPermission.cs
- JoinElimination.cs
- XmlSchemaSimpleContentRestriction.cs
- PrinterUnitConvert.cs
- UInt32Converter.cs
- FileInfo.cs
- initElementDictionary.cs
- SelectionChangedEventArgs.cs
- DataControlFieldHeaderCell.cs
- NamespaceQuery.cs
- HttpUnhandledOperationInvoker.cs
- CharacterString.cs
- SortQueryOperator.cs
- CodeIdentifier.cs
- PatternMatcher.cs
- ScrollBar.cs
- CfgRule.cs
- DataServiceQueryProvider.cs
- PageSetupDialog.cs
- DataObjectSettingDataEventArgs.cs
- ToolStripLabel.cs
- ModelPerspective.cs
- ChangePasswordAutoFormat.cs
- GB18030Encoding.cs
- DataGrid.cs
- DesignerTransactionCloseEvent.cs
- Utilities.cs
- WindowVisualStateTracker.cs
- ExcludeFromCodeCoverageAttribute.cs
- ThemeableAttribute.cs
- CodeMemberProperty.cs
- XamlBuildTaskServices.cs
- RMEnrollmentPage3.cs
- WinFormsSpinner.cs
- PluralizationService.cs
- ListItemCollection.cs
- ResourceExpressionBuilder.cs
- _SSPIWrapper.cs
- HTTPRemotingHandler.cs
- NetStream.cs
- ResourceDictionary.cs
- EnumMemberAttribute.cs
- XmlSchemaParticle.cs
- WebPartRestoreVerb.cs
- PointAnimation.cs
- Speller.cs
- ELinqQueryState.cs
- _AutoWebProxyScriptWrapper.cs
- LinkTarget.cs
- ThreadExceptionEvent.cs
- AtomPub10ServiceDocumentFormatter.cs
- ProcessModelSection.cs
- ToolStripPanelRow.cs
- ColorAnimation.cs
- BufferedStream.cs
- ForEachAction.cs
- BulletChrome.cs
- FilterableAttribute.cs
- SqlError.cs
- validationstate.cs
- Figure.cs
- Storyboard.cs
- ItemDragEvent.cs
- SqlDataSourceConnectionPanel.cs
- WindowPattern.cs
- ContainerControlDesigner.cs
- TreeNode.cs
- Decoder.cs
- MemberDomainMap.cs
- DataGridViewRowStateChangedEventArgs.cs
- DesignerUtility.cs
- AttachedProperty.cs
- HtmlTableCellCollection.cs
- CodeArrayCreateExpression.cs
- PrintControllerWithStatusDialog.cs
- RemotingConfiguration.cs
- prompt.cs
- TraceFilter.cs
- IPAddressCollection.cs
- HttpCapabilitiesSectionHandler.cs
- Enumerable.cs
- WebPartHeaderCloseVerb.cs
- util.cs
- ValueProviderWrapper.cs
- HtmlInputFile.cs
- XmlSchemaComplexContent.cs
- translator.cs
- Module.cs
- WebPartEditorApplyVerb.cs
- BindingOperations.cs
- XmlNodeReader.cs
- CodeVariableReferenceExpression.cs
- ControlCollection.cs
- DebugInfoExpression.cs
- LinkButton.cs
- Tag.cs
- BinaryUtilClasses.cs
- ResourceManagerWrapper.cs
- TemplateDefinition.cs
- Button.cs