Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / UI / ChtmlTextWriter.cs / 1 / ChtmlTextWriter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- // ChtmlTextWriter.cs // namespace System.Web.UI { using System; using System.Collections; using System.Collections.Specialized; using System.IO; using System.Text; using System.Web.UI.WebControls; using System.Web.Util; using System.Globalization; using System.Security.Permissions; ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class ChtmlTextWriter : Html32TextWriter { private Hashtable _recognizedAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); private Hashtable _suppressedAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); private Hashtable _globalSuppressedAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); public ChtmlTextWriter(TextWriter writer) : this(writer, DefaultTabString) { } public ChtmlTextWriter(TextWriter writer, string tabString) : base(writer, tabString) { _globalSuppressedAttributes["onclick"] = true; _globalSuppressedAttributes["ondblclick"] = true; _globalSuppressedAttributes["onmousedown"] = true; _globalSuppressedAttributes["onmouseup"] = true; _globalSuppressedAttributes["onmouseover"] = true; _globalSuppressedAttributes["onmousemove"] = true; _globalSuppressedAttributes["onmouseout"] = true; _globalSuppressedAttributes["onkeypress"] = true; _globalSuppressedAttributes["onkeydown"] = true; _globalSuppressedAttributes["onkeyup"] = true; // Supress certain element attribute pairs that can happen when Html32TextWriter performs the div table // substitution. RemoveRecognizedAttributeInternal("div", "accesskey"); // VSWhidbey 270254 RemoveRecognizedAttributeInternal("div", "cellspacing"); RemoveRecognizedAttributeInternal("div", "cellpadding"); RemoveRecognizedAttributeInternal("div", "gridlines"); RemoveRecognizedAttributeInternal("div", "rules"); RemoveRecognizedAttributeInternal("span", "cellspacing"); RemoveRecognizedAttributeInternal("span", "cellpadding"); RemoveRecognizedAttributeInternal("span", "gridlines"); RemoveRecognizedAttributeInternal("span", "rules"); } ///[To be supplied.] ////// public virtual void AddRecognizedAttribute(string elementName, string attributeName) { Hashtable eltAttributes = (Hashtable) _recognizedAttributes[elementName]; if (eltAttributes == null) { eltAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); _recognizedAttributes[elementName] = eltAttributes; } eltAttributes.Add(attributeName, true); } ///[To be supplied.] ////// Override to filter out unnecessary attributes /// protected override bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key) { Hashtable elementRecognizedAttributes = (Hashtable)_recognizedAttributes[TagName]; if (elementRecognizedAttributes != null && elementRecognizedAttributes[name] != null) { return true; } if (_globalSuppressedAttributes[name] != null) { return false; } Hashtable elementSuppressedAttributes = (Hashtable)_suppressedAttributes[TagName]; if (elementSuppressedAttributes != null && elementSuppressedAttributes[name] != null) { return false; } return true; } protected override bool OnStyleAttributeRender(string name,string value, HtmlTextWriterStyle key) { if (key == HtmlTextWriterStyle.TextDecoration) { if (StringUtil.EqualsIgnoreCase("line-through", value)) { return false; } } return base.OnStyleAttributeRender(name, value, key); } protected override bool OnTagRender(string name, HtmlTextWriterTag key) { return base.OnTagRender(name, key) && key != HtmlTextWriterTag.Span; } ////// public virtual void RemoveRecognizedAttribute(string elementName, string attributeName) { RemoveRecognizedAttributeInternal(elementName, attributeName); } private void RemoveRecognizedAttributeInternal(string elementName, string attributeName) { // Since recognized attributes have precedence, we need to do two operations: add this attribute // to the suppressed list, and remove it from the recognized list. Hashtable eltAttributes = (Hashtable) _suppressedAttributes[elementName]; if (eltAttributes == null) { eltAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); _suppressedAttributes[elementName] = eltAttributes; } eltAttributes.Add(attributeName, true); eltAttributes = (Hashtable)_recognizedAttributes[elementName]; if (eltAttributes == null) { eltAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); _recognizedAttributes[elementName] = eltAttributes; } // Note: Hashtable::Remove silently continues if the key does not exist. eltAttributes.Remove(attributeName); } public override void WriteBreak() { Write("[To be supplied.] ///
"); } public override void WriteEncodedText(String text) { if (null == text || text.Length == 0) { return; } int length = text.Length; int start = -1; for(int pos = 0; pos < length; pos++) { int ch = text[pos]; if(ch > 160 && ch < 256) { if(start != -1) { base.WriteEncodedText(text.Substring(start, pos - start)); start = -1; } base.Write(text[pos]); } else { if(start == -1) { start = pos; } } } if(start != -1) { if(start == 0) { base.WriteEncodedText(text); } else { base.WriteEncodedText(text.Substring(start, length - start)); } } } protected Hashtable RecognizedAttributes { get { return _recognizedAttributes; } } protected Hashtable SuppressedAttributes { get { return _suppressedAttributes; } } protected Hashtable GlobalSuppressedAttributes { get { return _globalSuppressedAttributes; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- // ChtmlTextWriter.cs // namespace System.Web.UI { using System; using System.Collections; using System.Collections.Specialized; using System.IO; using System.Text; using System.Web.UI.WebControls; using System.Web.Util; using System.Globalization; using System.Security.Permissions; ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class ChtmlTextWriter : Html32TextWriter { private Hashtable _recognizedAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); private Hashtable _suppressedAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); private Hashtable _globalSuppressedAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); public ChtmlTextWriter(TextWriter writer) : this(writer, DefaultTabString) { } public ChtmlTextWriter(TextWriter writer, string tabString) : base(writer, tabString) { _globalSuppressedAttributes["onclick"] = true; _globalSuppressedAttributes["ondblclick"] = true; _globalSuppressedAttributes["onmousedown"] = true; _globalSuppressedAttributes["onmouseup"] = true; _globalSuppressedAttributes["onmouseover"] = true; _globalSuppressedAttributes["onmousemove"] = true; _globalSuppressedAttributes["onmouseout"] = true; _globalSuppressedAttributes["onkeypress"] = true; _globalSuppressedAttributes["onkeydown"] = true; _globalSuppressedAttributes["onkeyup"] = true; // Supress certain element attribute pairs that can happen when Html32TextWriter performs the div table // substitution. RemoveRecognizedAttributeInternal("div", "accesskey"); // VSWhidbey 270254 RemoveRecognizedAttributeInternal("div", "cellspacing"); RemoveRecognizedAttributeInternal("div", "cellpadding"); RemoveRecognizedAttributeInternal("div", "gridlines"); RemoveRecognizedAttributeInternal("div", "rules"); RemoveRecognizedAttributeInternal("span", "cellspacing"); RemoveRecognizedAttributeInternal("span", "cellpadding"); RemoveRecognizedAttributeInternal("span", "gridlines"); RemoveRecognizedAttributeInternal("span", "rules"); } ///[To be supplied.] ////// public virtual void AddRecognizedAttribute(string elementName, string attributeName) { Hashtable eltAttributes = (Hashtable) _recognizedAttributes[elementName]; if (eltAttributes == null) { eltAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); _recognizedAttributes[elementName] = eltAttributes; } eltAttributes.Add(attributeName, true); } ///[To be supplied.] ////// Override to filter out unnecessary attributes /// protected override bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key) { Hashtable elementRecognizedAttributes = (Hashtable)_recognizedAttributes[TagName]; if (elementRecognizedAttributes != null && elementRecognizedAttributes[name] != null) { return true; } if (_globalSuppressedAttributes[name] != null) { return false; } Hashtable elementSuppressedAttributes = (Hashtable)_suppressedAttributes[TagName]; if (elementSuppressedAttributes != null && elementSuppressedAttributes[name] != null) { return false; } return true; } protected override bool OnStyleAttributeRender(string name,string value, HtmlTextWriterStyle key) { if (key == HtmlTextWriterStyle.TextDecoration) { if (StringUtil.EqualsIgnoreCase("line-through", value)) { return false; } } return base.OnStyleAttributeRender(name, value, key); } protected override bool OnTagRender(string name, HtmlTextWriterTag key) { return base.OnTagRender(name, key) && key != HtmlTextWriterTag.Span; } ////// public virtual void RemoveRecognizedAttribute(string elementName, string attributeName) { RemoveRecognizedAttributeInternal(elementName, attributeName); } private void RemoveRecognizedAttributeInternal(string elementName, string attributeName) { // Since recognized attributes have precedence, we need to do two operations: add this attribute // to the suppressed list, and remove it from the recognized list. Hashtable eltAttributes = (Hashtable) _suppressedAttributes[elementName]; if (eltAttributes == null) { eltAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); _suppressedAttributes[elementName] = eltAttributes; } eltAttributes.Add(attributeName, true); eltAttributes = (Hashtable)_recognizedAttributes[elementName]; if (eltAttributes == null) { eltAttributes = new Hashtable(StringComparer.CurrentCultureIgnoreCase); _recognizedAttributes[elementName] = eltAttributes; } // Note: Hashtable::Remove silently continues if the key does not exist. eltAttributes.Remove(attributeName); } public override void WriteBreak() { Write("[To be supplied.] ///
"); } public override void WriteEncodedText(String text) { if (null == text || text.Length == 0) { return; } int length = text.Length; int start = -1; for(int pos = 0; pos < length; pos++) { int ch = text[pos]; if(ch > 160 && ch < 256) { if(start != -1) { base.WriteEncodedText(text.Substring(start, pos - start)); start = -1; } base.Write(text[pos]); } else { if(start == -1) { start = pos; } } } if(start != -1) { if(start == 0) { base.WriteEncodedText(text); } else { base.WriteEncodedText(text.Substring(start, length - start)); } } } protected Hashtable RecognizedAttributes { get { return _recognizedAttributes; } } protected Hashtable SuppressedAttributes { get { return _suppressedAttributes; } } protected Hashtable GlobalSuppressedAttributes { get { return _globalSuppressedAttributes; } } } } // 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
- SwitchElementsCollection.cs
- ByteFacetDescriptionElement.cs
- EqualityArray.cs
- CodeSnippetExpression.cs
- ErrorWebPart.cs
- ColorTransformHelper.cs
- RoutedEvent.cs
- HostExecutionContextManager.cs
- ContentFileHelper.cs
- ResolveNameEventArgs.cs
- CatalogZone.cs
- XPathNavigator.cs
- AliasExpr.cs
- CacheSection.cs
- ImmutableCommunicationTimeouts.cs
- SystemResources.cs
- StringAnimationBase.cs
- ChtmlTextWriter.cs
- LocalizationParserHooks.cs
- RSAOAEPKeyExchangeDeformatter.cs
- WebEventTraceProvider.cs
- MetadataArtifactLoaderResource.cs
- MorphHelper.cs
- AccessViolationException.cs
- ItemsPresenter.cs
- ProcessingInstructionAction.cs
- ListView.cs
- RijndaelManaged.cs
- HttpRequestWrapper.cs
- SimpleBitVector32.cs
- TextTreeFixupNode.cs
- HtmlToClrEventProxy.cs
- Update.cs
- SchemaMerger.cs
- FormViewDeletedEventArgs.cs
- DbConnectionStringBuilder.cs
- HtmlSelect.cs
- SessionEndingEventArgs.cs
- SspiNegotiationTokenAuthenticatorState.cs
- RuleSet.cs
- GridItem.cs
- ThicknessConverter.cs
- ThreadSafeList.cs
- MaterialGroup.cs
- URIFormatException.cs
- PersistenceMetadataNamespace.cs
- AnnotationResource.cs
- Int32KeyFrameCollection.cs
- InstanceLockException.cs
- EntitySqlQueryCacheEntry.cs
- Validator.cs
- SmiEventSink.cs
- RichTextBoxConstants.cs
- XsdCachingReader.cs
- TextBoxBase.cs
- DataFormats.cs
- WmlCalendarAdapter.cs
- QilInvokeLateBound.cs
- DataSourceXmlSubItemAttribute.cs
- EndpointDiscoveryMetadata11.cs
- LambdaCompiler.cs
- ComponentDispatcherThread.cs
- BrowsableAttribute.cs
- WebServiceClientProxyGenerator.cs
- basemetadatamappingvisitor.cs
- TraceXPathNavigator.cs
- ProfileSettings.cs
- IdentityReference.cs
- XPathSelectionIterator.cs
- ContractHandle.cs
- ThemeConfigurationDialog.cs
- WeakRefEnumerator.cs
- Message.cs
- WebBrowserNavigatedEventHandler.cs
- Module.cs
- DataControlFieldHeaderCell.cs
- CodeFieldReferenceExpression.cs
- CheckPair.cs
- ProgressiveCrcCalculatingStream.cs
- ModelPerspective.cs
- ThreadLocal.cs
- TimeManager.cs
- ActiveXHelper.cs
- FormView.cs
- WebPartDisplayModeEventArgs.cs
- GridViewColumnHeader.cs
- AsyncStreamReader.cs
- SchemaNotation.cs
- ConsoleTraceListener.cs
- InstancePersistenceCommand.cs
- PopupRootAutomationPeer.cs
- ContentElementAutomationPeer.cs
- UserControlAutomationPeer.cs
- CrossSiteScriptingValidation.cs
- DockEditor.cs
- IconEditor.cs
- MimeMultiPart.cs
- Compiler.cs
- StringSource.cs
- FigureParaClient.cs