Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / WinForms / Managed / System / WinForms / HtmlElementCollection.cs / 1 / HtmlElementCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Security.Permissions;
using System.Security;
using System.Runtime.InteropServices;
using System.Net;
using System.Collections;
namespace System.Windows.Forms {
///
///
/// [To be supplied.]
///
public sealed class HtmlElementCollection : ICollection {
private UnsafeNativeMethods.IHTMLElementCollection htmlElementCollection;
private HtmlElement[] elementsArray;
private HtmlShimManager shimManager;
internal HtmlElementCollection(HtmlShimManager shimManager) {
this.htmlElementCollection = null;
this.elementsArray = null;
this.shimManager = shimManager;
}
internal HtmlElementCollection(HtmlShimManager shimManager, UnsafeNativeMethods.IHTMLElementCollection elements) {
this.htmlElementCollection = elements;
this.elementsArray = null;
this.shimManager = shimManager;
Debug.Assert(this.NativeHtmlElementCollection != null, "The element collection object should implement IHTMLElementCollection");
}
internal HtmlElementCollection(HtmlShimManager shimManager, HtmlElement[] array) {
this.htmlElementCollection = null;
this.elementsArray = array;
this.shimManager = shimManager;
}
private UnsafeNativeMethods.IHTMLElementCollection NativeHtmlElementCollection {
get {
return this.htmlElementCollection;
}
}
///
///
/// [To be supplied.]
///
public HtmlElement this[int index] {
get {
//do some bounds checking here...
if (index < 0 || index >= this.Count) {
throw new ArgumentOutOfRangeException("index", SR.GetString(SR.InvalidBoundArgument, "index", index, 0, this.Count - 1));
}
if (this.NativeHtmlElementCollection != null) {
UnsafeNativeMethods.IHTMLElement htmlElement =
this.NativeHtmlElementCollection.Item((object)index, (object)0) as UnsafeNativeMethods.IHTMLElement;
return (htmlElement != null) ? new HtmlElement(shimManager, htmlElement) : null;
}
else if (elementsArray != null) {
return this.elementsArray[index];
}
else {
return null;
}
}
}
///
///
/// [To be supplied.]
///
public HtmlElement this[string elementId] {
get {
if (this.NativeHtmlElementCollection != null) {
UnsafeNativeMethods.IHTMLElement htmlElement =
this.NativeHtmlElementCollection.Item((object)elementId, (object)0) as UnsafeNativeMethods.IHTMLElement;
return (htmlElement != null) ? new HtmlElement(shimManager, htmlElement) : null;
}
else if (elementsArray != null) {
int count = this.elementsArray.Length;
for (int i = 0; i < count; i++) {
HtmlElement element = this.elementsArray[i];
if (element.Id == elementId) {
return element;
}
}
return null; // not found
}
else {
return null;
}
}
}
///
///
/// [To be supplied.]
///
public HtmlElementCollection GetElementsByName(string name) {
int count = this.Count;
HtmlElement[] temp = new HtmlElement[count]; // count is the maximum # of matches
int tempIndex = 0;
for (int i = 0; i < count; i++) {
HtmlElement element = this[i];
if (element.GetAttribute("name") == name) {
temp[tempIndex] = element;
tempIndex++;
}
}
if (tempIndex == 0) {
return new HtmlElementCollection(shimManager);
}
else {
HtmlElement[] elements = new HtmlElement[tempIndex];
for (int i = 0; i < tempIndex; i++) {
elements[i] = temp[i];
}
return new HtmlElementCollection(shimManager, elements);
}
}
///
///
/// Returns the total number of elements in the collection.
///
public int Count {
get {
if (this.NativeHtmlElementCollection != null) {
return this.NativeHtmlElementCollection.GetLength();
}
else if (elementsArray != null) {
return this.elementsArray.Length;
}
else {
return 0;
}
}
}
///
///
bool ICollection.IsSynchronized {
get {
return false;
}
}
///
///
object ICollection.SyncRoot {
get {
return this;
}
}
///
///
void ICollection.CopyTo(Array dest, int index) {
int count = this.Count;
for (int i = 0; i < count; i++) {
dest.SetValue(this[i], index++);
}
}
///
///
public IEnumerator GetEnumerator() {
HtmlElement[] htmlElements = new HtmlElement[this.Count];
((ICollection)this).CopyTo(htmlElements, 0);
return htmlElements.GetEnumerator();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Security.Permissions;
using System.Security;
using System.Runtime.InteropServices;
using System.Net;
using System.Collections;
namespace System.Windows.Forms {
///
///
/// [To be supplied.]
///
public sealed class HtmlElementCollection : ICollection {
private UnsafeNativeMethods.IHTMLElementCollection htmlElementCollection;
private HtmlElement[] elementsArray;
private HtmlShimManager shimManager;
internal HtmlElementCollection(HtmlShimManager shimManager) {
this.htmlElementCollection = null;
this.elementsArray = null;
this.shimManager = shimManager;
}
internal HtmlElementCollection(HtmlShimManager shimManager, UnsafeNativeMethods.IHTMLElementCollection elements) {
this.htmlElementCollection = elements;
this.elementsArray = null;
this.shimManager = shimManager;
Debug.Assert(this.NativeHtmlElementCollection != null, "The element collection object should implement IHTMLElementCollection");
}
internal HtmlElementCollection(HtmlShimManager shimManager, HtmlElement[] array) {
this.htmlElementCollection = null;
this.elementsArray = array;
this.shimManager = shimManager;
}
private UnsafeNativeMethods.IHTMLElementCollection NativeHtmlElementCollection {
get {
return this.htmlElementCollection;
}
}
///
///
/// [To be supplied.]
///
public HtmlElement this[int index] {
get {
//do some bounds checking here...
if (index < 0 || index >= this.Count) {
throw new ArgumentOutOfRangeException("index", SR.GetString(SR.InvalidBoundArgument, "index", index, 0, this.Count - 1));
}
if (this.NativeHtmlElementCollection != null) {
UnsafeNativeMethods.IHTMLElement htmlElement =
this.NativeHtmlElementCollection.Item((object)index, (object)0) as UnsafeNativeMethods.IHTMLElement;
return (htmlElement != null) ? new HtmlElement(shimManager, htmlElement) : null;
}
else if (elementsArray != null) {
return this.elementsArray[index];
}
else {
return null;
}
}
}
///
///
/// [To be supplied.]
///
public HtmlElement this[string elementId] {
get {
if (this.NativeHtmlElementCollection != null) {
UnsafeNativeMethods.IHTMLElement htmlElement =
this.NativeHtmlElementCollection.Item((object)elementId, (object)0) as UnsafeNativeMethods.IHTMLElement;
return (htmlElement != null) ? new HtmlElement(shimManager, htmlElement) : null;
}
else if (elementsArray != null) {
int count = this.elementsArray.Length;
for (int i = 0; i < count; i++) {
HtmlElement element = this.elementsArray[i];
if (element.Id == elementId) {
return element;
}
}
return null; // not found
}
else {
return null;
}
}
}
///
///
/// [To be supplied.]
///
public HtmlElementCollection GetElementsByName(string name) {
int count = this.Count;
HtmlElement[] temp = new HtmlElement[count]; // count is the maximum # of matches
int tempIndex = 0;
for (int i = 0; i < count; i++) {
HtmlElement element = this[i];
if (element.GetAttribute("name") == name) {
temp[tempIndex] = element;
tempIndex++;
}
}
if (tempIndex == 0) {
return new HtmlElementCollection(shimManager);
}
else {
HtmlElement[] elements = new HtmlElement[tempIndex];
for (int i = 0; i < tempIndex; i++) {
elements[i] = temp[i];
}
return new HtmlElementCollection(shimManager, elements);
}
}
///
///
/// Returns the total number of elements in the collection.
///
public int Count {
get {
if (this.NativeHtmlElementCollection != null) {
return this.NativeHtmlElementCollection.GetLength();
}
else if (elementsArray != null) {
return this.elementsArray.Length;
}
else {
return 0;
}
}
}
///
///
bool ICollection.IsSynchronized {
get {
return false;
}
}
///
///
object ICollection.SyncRoot {
get {
return this;
}
}
///
///
void ICollection.CopyTo(Array dest, int index) {
int count = this.Count;
for (int i = 0; i < count; i++) {
dest.SetValue(this[i], index++);
}
}
///
///
public IEnumerator GetEnumerator() {
HtmlElement[] htmlElements = new HtmlElement[this.Count];
((ICollection)this).CopyTo(htmlElements, 0);
return htmlElements.GetEnumerator();
}
}
}
// 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
- Stream.cs
- EventProviderClassic.cs
- HttpContext.cs
- SafeSecurityHelper.cs
- ManageRequest.cs
- ToolStripGripRenderEventArgs.cs
- EntityDataSourceView.cs
- SspiNegotiationTokenProvider.cs
- ResolveNameEventArgs.cs
- PermissionSet.cs
- FormatException.cs
- FamilyCollection.cs
- InvalidOperationException.cs
- DoubleLink.cs
- Trace.cs
- DiscoveryMessageSequenceGenerator.cs
- PasswordBox.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- CompressStream.cs
- DSASignatureFormatter.cs
- DataGridViewCellStateChangedEventArgs.cs
- CompressedStack.cs
- ListDictionaryInternal.cs
- Enlistment.cs
- HashRepartitionStream.cs
- ToolBar.cs
- TypeDefinition.cs
- DebugManager.cs
- UpDownEvent.cs
- CollectionViewGroupRoot.cs
- WindowsRegion.cs
- RuntimeHelpers.cs
- AspNetPartialTrustHelpers.cs
- ToolStripLocationCancelEventArgs.cs
- SamlEvidence.cs
- DispatcherEventArgs.cs
- indexingfiltermarshaler.cs
- RegexCapture.cs
- BitmapEffectGeneralTransform.cs
- CacheManager.cs
- SiteMapDataSourceView.cs
- InstallerTypeAttribute.cs
- XmlToDatasetMap.cs
- ServiceReference.cs
- ItemsControlAutomationPeer.cs
- SecurityElement.cs
- MinimizableAttributeTypeConverter.cs
- AxisAngleRotation3D.cs
- TreeChangeInfo.cs
- Manipulation.cs
- FieldBuilder.cs
- StateManagedCollection.cs
- Attachment.cs
- ObjectItemCollection.cs
- PeerName.cs
- HttpResponseHeader.cs
- WebScriptMetadataMessageEncoderFactory.cs
- sqlcontext.cs
- SortKey.cs
- ActionItem.cs
- PersistencePipeline.cs
- LabelInfo.cs
- _IPv6Address.cs
- CompModSwitches.cs
- XmlAnyElementAttributes.cs
- DeclarativeCatalogPart.cs
- OletxResourceManager.cs
- RepeaterItemEventArgs.cs
- ObjectDataSourceFilteringEventArgs.cs
- PolyBezierSegment.cs
- ClientSponsor.cs
- PackageStore.cs
- cryptoapiTransform.cs
- EmptyEnumerator.cs
- PropertyGridDesigner.cs
- ReceiveSecurityHeaderEntry.cs
- TextBox.cs
- WebExceptionStatus.cs
- QueueAccessMode.cs
- TreeChangeInfo.cs
- GradientStop.cs
- IgnoreFileBuildProvider.cs
- OleDbTransaction.cs
- OdbcReferenceCollection.cs
- EntityDesignerDataSourceView.cs
- ComplexTypeEmitter.cs
- HMACSHA512.cs
- BmpBitmapEncoder.cs
- SQLMoney.cs
- NameTable.cs
- ContentPropertyAttribute.cs
- DataGridPagingPage.cs
- FileDialog.cs
- XslCompiledTransform.cs
- PagedControl.cs
- HtmlInputImage.cs
- RotateTransform3D.cs
- WebPartZoneCollection.cs
- RootBrowserWindowProxy.cs
- MappingException.cs