Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@@ -0,0 +1,51 @@
//------------------------------------------------------------------------------
// <copyright file="AddingNewEventArgs.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ComponentModel {
using System;
using System.ComponentModel;
using System.Security.Permissions;
/// <devdoc>
/// Provides data for an event that signals the adding of a new object
/// to a list, allowing any event handler to supply the new object. If
/// no event handler supplies a new object to use, the list should create
/// one itself.
/// </devdoc>
[HostProtection(SharedState = true)]
public class AddingNewEventArgs : EventArgs
{
private object newObject = null;
/// <devdoc>
/// Initializes a new instance of the <see cref='System.ComponentModel.AddingNewEventArgs'/> class,
/// with no new object defined.
/// </devdoc>
public AddingNewEventArgs() : base() {
}
/// <devdoc>
/// Initializes a new instance of the <see cref='System.ComponentModel.AddingNewEventArgs'/> class,
/// with the specified object defined as the default new object.
/// </devdoc>
public AddingNewEventArgs(object newObject) : base() {
this.newObject = newObject;
}
/// <devdoc>
/// Gets or sets the new object that will be added to the list.
/// </devdoc>
public object NewObject {
get {
return newObject;
}
set {
newObject = value;
}
}
}
}

View File

@@ -0,0 +1,18 @@
//------------------------------------------------------------------------------
// <copyright file="AddingNewEventHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ComponentModel {
using System;
using System.ComponentModel;
using System.Security.Permissions;
/// <devdoc>
/// Represents the method that will handle the AddingNew event on a list,
/// and provide the new object to be added to the list.
/// </devdoc>
[HostProtection(SharedState = true)]
public delegate void AddingNewEventHandler(object sender, AddingNewEventArgs e);
}

View File

@@ -0,0 +1,157 @@
//------------------------------------------------------------------------------
// <copyright file="AmbientValueAttribute.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace System.ComponentModel {
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters;
using System.Security.Permissions;
/// <devdoc>
/// <para>Specifies the ambient value for a property. The ambient value is the value you
/// can set into a property to make it inherit its ambient.</para>
/// </devdoc>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
[AttributeUsage(AttributeTargets.All)]
public sealed class AmbientValueAttribute : Attribute {
private readonly object value;
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class, converting the
/// specified value to the
/// specified type, and using the U.S. English culture as the
/// translation
/// context.</para>
/// </devdoc>
public AmbientValueAttribute(Type type, string value) {
// The try/catch here is because attributes should never throw exceptions. We would fail to
// load an otherwise normal class.
try {
this.value = TypeDescriptor.GetConverter(type).ConvertFromInvariantString(value);
}
catch {
Debug.Fail("Ambient value attribute of type " + type.FullName + " threw converting from the string '" + value + "'.");
}
}
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class using a Unicode
/// character.</para>
/// </devdoc>
public AmbientValueAttribute(char value) {
this.value = value;
}
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class using an 8-bit unsigned
/// integer.</para>
/// </devdoc>
public AmbientValueAttribute(byte value) {
this.value = value;
}
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class using a 16-bit signed
/// integer.</para>
/// </devdoc>
public AmbientValueAttribute(short value) {
this.value = value;
}
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class using a 32-bit signed
/// integer.</para>
/// </devdoc>
public AmbientValueAttribute(int value) {
this.value = value;
}
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class using a 64-bit signed
/// integer.</para>
/// </devdoc>
public AmbientValueAttribute(long value) {
this.value = value;
}
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class using a
/// single-precision floating point
/// number.</para>
/// </devdoc>
public AmbientValueAttribute(float value) {
this.value = value;
}
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class using a
/// double-precision floating point
/// number.</para>
/// </devdoc>
public AmbientValueAttribute(double value) {
this.value = value;
}
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class using a <see cref='System.Boolean'/>
/// value.</para>
/// </devdoc>
public AmbientValueAttribute(bool value) {
this.value = value;
}
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class using a <see cref='System.String'/>.</para>
/// </devdoc>
public AmbientValueAttribute(string value) {
this.value = value;
}
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/>
/// class.</para>
/// </devdoc>
public AmbientValueAttribute(object value) {
this.value = value;
}
/// <devdoc>
/// <para>
/// Gets the ambient value of the property this
/// attribute is
/// bound to.
/// </para>
/// </devdoc>
public object Value {
get {
return value;
}
}
public override bool Equals(object obj) {
if (obj == this) {
return true;
}
AmbientValueAttribute other = obj as AmbientValueAttribute;
if (other != null) {
if (value != null) {
return value.Equals(other.Value);
}
else {
return (other.Value == null);
}
}
return false;
}
public override int GetHashCode() {
return base.GetHashCode();
}
}
}

View File

@@ -0,0 +1,109 @@
//------------------------------------------------------------------------------
// <copyright file="ArrayConverter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace System.ComponentModel {
using Microsoft.Win32;
using System.Collections;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Serialization.Formatters;
using System.Security.Permissions;
/// <devdoc>
/// <para>Provides a type converter to convert <see cref='System.Array'/>
/// objects to and from various other representations.</para>
/// </devdoc>
[HostProtection(SharedState = true)]
public class ArrayConverter : CollectionConverter
{
/// <devdoc>
/// <para>Converts the given value object to the specified destination type.</para>
/// </devdoc>
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
if (destinationType == null) {
throw new ArgumentNullException("destinationType");
}
if (destinationType == typeof(string)) {
if (value is Array) {
return SR.GetString(SR.ArrayConverterText, value.GetType().Name);
}
}
return base.ConvertTo(context, culture, value, destinationType);
}
/// <devdoc>
/// <para>Gets a collection of properties for the type of array
/// specified by the value
/// parameter.</para>
/// </devdoc>
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) {
PropertyDescriptor[] props = null;
if (value.GetType().IsArray) {
Array valueArray = (Array)value;
int length = valueArray.GetLength(0);
props = new PropertyDescriptor[length];
Type arrayType = value.GetType();
Type elementType = arrayType.GetElementType();
for (int i = 0; i < length; i++) {
props[i] = new ArrayPropertyDescriptor(arrayType, elementType, i);
}
}
return new PropertyDescriptorCollection(props);
}
/// <devdoc>
/// <para>Gets a value indicating whether this object
/// supports properties.</para>
/// </devdoc>
public override bool GetPropertiesSupported(ITypeDescriptorContext context) {
return true;
}
private class ArrayPropertyDescriptor : SimplePropertyDescriptor {
private int index;
public ArrayPropertyDescriptor(Type arrayType, Type elementType, int index) : base(arrayType, "[" + index + "]", elementType, null) {
this.index = index;
}
public override object GetValue(object instance) {
if (instance is Array) {
Array array = (Array)instance;
if (array.GetLength(0) > index) {
return array.GetValue(index);
}
}
return null;
}
public override void SetValue(object instance, object value) {
if (instance is Array) {
Array array = (Array)instance;
if (array.GetLength(0) > index) {
array.SetValue(value, index);
}
OnValueChanged(instance, EventArgs.Empty);
}
}
}
}
}

View File

@@ -0,0 +1,56 @@
//------------------------------------------------------------------------------
// <copyright file="ArraySubsetEnumerator.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ComponentModel {
using System;
using System.Collections;
using System.Diagnostics;
using System.Security.Permissions;
[HostProtection(SharedState = true)]
internal class ArraySubsetEnumerator : IEnumerator
{
private Array array;
private int total;
private int current;
public ArraySubsetEnumerator(Array array, int count) {
Debug.Assert(count == 0 || array != null, "if array is null, count should be 0");
Debug.Assert(array == null || count <= array.Length, "Trying to enumerate more than the array contains");
this.array = array;
this.total = count;
current = -1;
}
public bool MoveNext() {
if (current < total - 1) {
current++;
return true;
}
else {
return false;
}
}
public void Reset() {
current = -1;
}
public object Current {
get {
if (current == -1) {
throw new InvalidOperationException();
}
else {
return array.GetValue(current);
}
}
}
}
}

View File

@@ -0,0 +1,70 @@
//------------------------------------------------------------------------------
// <copyright file="AsyncCompletedEventArgs.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ComponentModel
{
using System.Diagnostics.CodeAnalysis;
using System.Security.Permissions;
using System.Reflection;
[HostProtection(SharedState = true)]
public class AsyncCompletedEventArgs : System.EventArgs
{
private readonly Exception error;
private readonly bool cancelled;
private readonly object userState;
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public AsyncCompletedEventArgs()
{
// This method was public in .NET CF, but didn't do anything. The fact that it was public was to
// work around a tooling issue on their side.
}
public AsyncCompletedEventArgs(Exception error, bool cancelled, object userState)
{
this.error = error;
this.cancelled = cancelled;
this.userState = userState;
}
[ SRDescription(SR.Async_AsyncEventArgs_Cancelled) ]
public bool Cancelled
{
get { return cancelled; }
}
[ SRDescription(SR.Async_AsyncEventArgs_Error) ]
public Exception Error
{
get { return error; }
}
[ SRDescription(SR.Async_AsyncEventArgs_UserState) ]
public object UserState
{
get { return userState; }
}
// Call from every result 'getter'. Will throw if there's an error or operation was cancelled
//
[SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")]
protected void RaiseExceptionIfNecessary()
{
if (Error != null)
{
throw new TargetInvocationException(SR.GetString(SR.Async_ExceptionOccurred), Error);
}
else if (Cancelled)
{
throw new InvalidOperationException(SR.GetString(SR.Async_OperationCancelled));
}
}
}
}

View File

@@ -0,0 +1,13 @@
//------------------------------------------------------------------------------
// <copyright file="AsyncCompletedEventHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ComponentModel
{
using System.Security.Permissions;
[HostProtection(SharedState = true)]
public delegate void AsyncCompletedEventHandler(object sender, AsyncCompletedEventArgs e);
}

View File

@@ -0,0 +1,114 @@
//------------------------------------------------------------------------------
// <copyright file="AsyncOperation.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ComponentModel
{
using System.Security.Permissions;
using System.Threading;
[HostProtection(SharedState = true)]
public sealed class AsyncOperation
{
private SynchronizationContext syncContext;
private object userSuppliedState;
private bool alreadyCompleted;
/// <summary>
/// Constructor. Protected to avoid unwitting usage - AsyncOperation objects
/// are typically created by AsyncOperationManager calling CreateOperation.
/// </summary>
private AsyncOperation(object userSuppliedState, SynchronizationContext syncContext)
{
this.userSuppliedState = userSuppliedState;
this.syncContext = syncContext;
this.alreadyCompleted = false;
this.syncContext.OperationStarted();
}
/// <summary>
/// Destructor. Guarantees that [....] context will always get notified of completion.
/// </summary>
~AsyncOperation()
{
if (!alreadyCompleted && syncContext != null)
{
syncContext.OperationCompleted();
}
}
public object UserSuppliedState
{
get { return userSuppliedState; }
}
/// <include file='doc\AsyncOperation.uex' path='docs/doc[@for="AsyncOperation.SynchronizationContext"]/*' />
public SynchronizationContext SynchronizationContext
{
get
{
return syncContext;
}
}
public void Post(SendOrPostCallback d, object arg)
{
VerifyNotCompleted();
VerifyDelegateNotNull(d);
syncContext.Post(d, arg);
}
public void PostOperationCompleted(SendOrPostCallback d, object arg)
{
Post(d, arg);
OperationCompletedCore();
}
public void OperationCompleted()
{
VerifyNotCompleted();
OperationCompletedCore();
}
private void OperationCompletedCore()
{
try
{
syncContext.OperationCompleted();
}
finally
{
alreadyCompleted = true;
GC.SuppressFinalize(this);
}
}
private void VerifyNotCompleted()
{
if (alreadyCompleted)
{
throw new InvalidOperationException(SR.GetString(SR.Async_OperationAlreadyCompleted));
}
}
private void VerifyDelegateNotNull(SendOrPostCallback d)
{
if (d == null)
{
throw new ArgumentNullException(SR.GetString(SR.Async_NullDelegate), "d");
}
}
/// <summary>
/// Only for use by AsyncOperationManager to create new AsyncOperation objects
/// </summary>
internal static AsyncOperation CreateOperation(object userSuppliedState, SynchronizationContext syncContext)
{
AsyncOperation newOp = new AsyncOperation(userSuppliedState, syncContext);
return newOp;
}
}
}

View File

@@ -0,0 +1,49 @@
//------------------------------------------------------------------------------
// <copyright file="AsyncOperationManager.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ComponentModel
{
using System.Collections;
using System.Threading;
using System.Diagnostics;
using System.Security.Permissions;
[HostProtection(SharedState = true)]
public static class AsyncOperationManager {
public static AsyncOperation CreateOperation(object userSuppliedState) {
return AsyncOperation.CreateOperation(userSuppliedState, SynchronizationContext);
}
/// <include file='doc\AsyncOperationManager.uex' path='docs/doc[@for="AsyncOperationManager.SynchronizationContext"]/*' />
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static SynchronizationContext SynchronizationContext {
get {
if (SynchronizationContext.Current == null) {
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
}
return SynchronizationContext.Current;
}
#if SILVERLIGHT
// a thread should set this to null when it is done, else the context will never be disposed/GC'd
[SecurityCritical]
[FriendAccessAllowed]
internal set {
SynchronizationContext.SetSynchronizationContext(value);
}
#else
// a thread should set this to null when it is done, else the context will never be disposed/GC'd
[PermissionSetAttribute(SecurityAction.LinkDemand, Name="FullTrust")]
set {
SynchronizationContext.SetSynchronizationContext(value);
}
#endif
}
}
}

View File

@@ -0,0 +1,441 @@
//------------------------------------------------------------------------------
// <copyright file="AttributeCollection.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
/*
This class has the HostProtectionAttribute. The purpose of this attribute is to enforce host-specific programming model guidelines, not security behavior.
Suppress FxCop message - BUT REVISIT IF ADDING NEW SECURITY ATTRIBUTES.
*/
[assembly: SuppressMessage("Microsoft.Security", "CA2112:SecuredTypesShouldNotExposeFields", Scope="type", Target="System.ComponentModel.AttributeCollection")]
[assembly: SuppressMessage("Microsoft.Security", "CA2112:SecuredTypesShouldNotExposeFields", Scope="type", Target="System.ComponentModel.AttributeCollection")]
[assembly: SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Scope="member", Target="System.ComponentModel.AttributeCollection.CopyTo(System.Array,System.Int32):System.Void")]
[assembly: SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Scope="member", Target="System.ComponentModel.AttributeCollection.System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator")]
[assembly: SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Scope="member", Target="System.ComponentModel.AttributeCollection.System.Collections.ICollection.get_IsSynchronized():System.Boolean")]
[assembly: SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Scope="member", Target="System.ComponentModel.AttributeCollection.System.Collections.ICollection.get_Count():System.Int32")]
[assembly: SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Scope="member", Target="System.ComponentModel.AttributeCollection.System.Collections.ICollection.get_SyncRoot():System.Object")]
[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope="member", Target="System.ComponentModel.AttributeCollection.Contains(System.Attribute):System.Boolean")]
[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope="member", Target="System.ComponentModel.AttributeCollection.CopyTo(System.Array,System.Int32):System.Void")]
[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope="member", Target="System.ComponentModel.AttributeCollection..ctor(System.Attribute[])")]
[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope="member", Target="System.ComponentModel.AttributeCollection.GetEnumerator():System.Collections.IEnumerator")]
[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope="member", Target="System.ComponentModel.AttributeCollection.get_Item(System.Type):System.Attribute")]
[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope="member", Target="System.ComponentModel.AttributeCollection.get_Item(System.Int32):System.Attribute")]
[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope="member", Target="System.ComponentModel.AttributeCollection.get_Count():System.Int32")]
namespace System.ComponentModel
{
using System.Reflection;
using System.Diagnostics;
using System.Collections;
/// <devdoc>
/// Represents a collection of attributes.
/// </devdoc>
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
[System.Security.Permissions.HostProtection(Synchronization=true)]
public class AttributeCollection : ICollection
{
/// <devdoc>
/// An empty AttributeCollection that can used instead of creating a new one.
/// </devdoc>
public static readonly AttributeCollection Empty = new AttributeCollection((Attribute[])null);
private static Hashtable _defaultAttributes;
private Attribute[] _attributes;
private static object internalSyncObject = new object();
private struct AttributeEntry
{
public Type type;
public int index;
}
private const int FOUND_TYPES_LIMIT = 5;
private AttributeEntry[] _foundAttributeTypes;
private int _index = 0;
/// <devdoc>
/// Creates a new AttributeCollection.
/// </devdoc>
public AttributeCollection(params Attribute[] attributes)
{
if (attributes == null)
{
attributes = new Attribute[0];
}
_attributes = attributes;
for (int idx = 0; idx < attributes.Length; idx++)
{
if (attributes[idx] == null)
{
throw new ArgumentNullException("attributes");
}
}
}
protected AttributeCollection()
{
}
/// <devdoc>
/// Creates a new AttributeCollection from an existing AttributeCollection
/// </devdoc>
public static AttributeCollection FromExisting(AttributeCollection existing, params Attribute[] newAttributes)
{
// VSWhidbey #75418
// This method should be a constructor, but making it one introduces a breaking change.
//
if (existing == null)
{
throw new ArgumentNullException("existing");
}
if (newAttributes == null)
{
newAttributes = new Attribute[0];
}
Attribute[] newArray = new Attribute[existing.Count + newAttributes.Length];
int actualCount = existing.Count;
existing.CopyTo(newArray, 0);
for (int idx = 0; idx < newAttributes.Length; idx++)
{
if (newAttributes[idx] == null)
{
throw new ArgumentNullException("newAttributes");
}
// We must see if this attribute is already in the existing
// array. If it is, we replace it.
bool match = false;
for (int existingIdx = 0; existingIdx < existing.Count; existingIdx++)
{
if (newArray[existingIdx].TypeId.Equals(newAttributes[idx].TypeId))
{
match = true;
newArray[existingIdx] = newAttributes[idx];
break;
}
}
if (!match)
{
newArray[actualCount++] = newAttributes[idx];
}
}
// Now, if we collapsed some attributes, create a new array.
//
Attribute[] attributes = null;
if (actualCount < newArray.Length)
{
attributes = new Attribute[actualCount];
Array.Copy(newArray, 0, attributes, 0, actualCount);
}
else
{
attributes = newArray;
}
return new AttributeCollection(attributes);
}
/// <devdoc>
/// Gets the attributes collection.
/// </devdoc>
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays",
Justification = "Matches constructor input type")]
protected virtual Attribute[] Attributes
{
get
{
return _attributes;
}
}
/// <devdoc>
/// Gets the number of attributes.
/// </devdoc>
public int Count
{
get
{
return Attributes.Length;
}
}
/// <devdoc>
/// Gets the attribute with the specified index number.
/// </devdoc>
public virtual Attribute this[int index]
{
get
{
return Attributes[index];
}
}
/// <devdoc>
/// Gets the attribute with the specified type.
/// </devdoc>
public virtual Attribute this[Type attributeType]
{
get
{
lock (internalSyncObject) {
// 2 passes here for perf. Really! first pass, we just
// check equality, and if we don't find it, then we
// do the IsAssignableFrom dance. Turns out that's
// a relatively expensive call and we try to avoid it
// since we rarely encounter derived attribute types
// and this list is usually short.
//
if (_foundAttributeTypes == null)
{
_foundAttributeTypes = new AttributeEntry[FOUND_TYPES_LIMIT];
}
int ind = 0;
for (; ind < FOUND_TYPES_LIMIT; ind++)
{
if (_foundAttributeTypes[ind].type == attributeType)
{
int index = _foundAttributeTypes[ind].index;
if (index != -1)
{
return Attributes[index];
}
else{
return GetDefaultAttribute(attributeType);
}
}
if (_foundAttributeTypes[ind].type == null)
break;
}
ind = _index++;
if (_index >= FOUND_TYPES_LIMIT)
{
_index = 0;
}
_foundAttributeTypes[ind].type = attributeType;
int count = Attributes.Length;
for (int i = 0; i < count; i++)
{
Attribute attribute = Attributes[i];
Type aType = attribute.GetType();
if (aType == attributeType)
{
_foundAttributeTypes[ind].index = i;
return attribute;
}
}
// now check the hierarchies.
for (int i = 0; i < count; i++)
{
Attribute attribute = Attributes[i];
Type aType = attribute.GetType();
if (attributeType.IsAssignableFrom(aType))
{
_foundAttributeTypes[ind].index = i;
return attribute;
}
}
_foundAttributeTypes[ind].index = -1;
return GetDefaultAttribute(attributeType);
}
}
}
/// <devdoc>
/// Determines if this collection of attributes has the specified attribute.
/// </devdoc>
public bool Contains(Attribute attribute)
{
Attribute attr = this[attribute.GetType()];
if (attr != null && attr.Equals(attribute))
{
return true;
}
return false;
}
/// <devdoc>
/// Determines if this attribute collection contains the all
/// the specified attributes in the attribute array.
/// </devdoc>
public bool Contains(Attribute[] attributes)
{
if (attributes == null)
{
return true;
}
for (int i = 0; i < attributes.Length; i++)
{
if (!Contains(attributes[i]))
{
return false;
}
}
return true;
}
/// <devdoc>
/// Returns the default value for an attribute. This uses the following hurestic:
/// 1. It looks for a public static field named "Default".
/// </devdoc>
protected Attribute GetDefaultAttribute(Type attributeType)
{
lock (internalSyncObject)
{
if (_defaultAttributes == null)
{
_defaultAttributes = new Hashtable();
}
// If we have already encountered this, use what's in the
// table.
if (_defaultAttributes.ContainsKey(attributeType))
{
return(Attribute)_defaultAttributes[attributeType];
}
Attribute attr = null;
// Nope, not in the table, so do the legwork to discover the default value.
Type reflect = TypeDescriptor.GetReflectionType(attributeType);
System.Reflection.FieldInfo field = reflect.GetField("Default", BindingFlags.Public | BindingFlags.Static | BindingFlags.GetField);
if (field != null && field.IsStatic)
{
attr = (Attribute)field.GetValue(null);
}
else
{
ConstructorInfo ci = reflect.UnderlyingSystemType.GetConstructor(new Type[0]);
if (ci != null)
{
attr = (Attribute)ci.Invoke(new object[0]);
// If we successfully created, verify that it is the
// default. Attributes don't have to abide by this rule.
if (!attr.IsDefaultAttribute())
{
attr = null;
}
}
}
_defaultAttributes[attributeType] = attr;
return attr;
}
}
/// <devdoc>
/// Gets an enumerator for this collection.
/// </devdoc>
public IEnumerator GetEnumerator()
{
return Attributes.GetEnumerator();
}
/// <devdoc>
/// Determines if a specified attribute is the same as an attribute
/// in the collection.
/// </devdoc>
public bool Matches(Attribute attribute)
{
for (int i = 0; i < Attributes.Length; i++)
{
if (Attributes[i].Match(attribute))
{
return true;
}
}
return false;
}
/// <devdoc>
/// Determines if the attributes in the specified array are
/// the same as the attributes in the collection.
/// </devdoc>
public bool Matches(Attribute[] attributes)
{
for (int i = 0; i < attributes.Length; i++)
{
if (!Matches(attributes[i]))
{
return false;
}
}
return true;
}
/// <internalonly/>
int ICollection.Count
{
get
{
return Count;
}
}
/// <internalonly/>
bool ICollection.IsSynchronized
{
get
{
return false;
}
}
/// <internalonly/>
object ICollection.SyncRoot
{
get
{
return null;
}
}
/// <devdoc>
/// Copies this collection to an array.
/// </devdoc>
public void CopyTo(Array array, int index)
{
Array.Copy(Attributes, 0, array, index, Attributes.Length);
}
/// <internalonly/>
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}

View File

@@ -0,0 +1,91 @@
//------------------------------------------------------------------------------
// <copyright file="AttributeProviderAttribute.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ComponentModel
{
using System;
using System.Security.Permissions;
/// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute"]/*' />
/// <devdoc>
/// </devdoc>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
[AttributeUsage(AttributeTargets.Property)]
public class AttributeProviderAttribute : Attribute
{
private string _typeName;
private string _propertyName;
/// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute.AttributeProviderAttribute"]/*' />
/// <devdoc>
/// Creates a new AttributeProviderAttribute object.
/// </devdoc>
public AttributeProviderAttribute(string typeName)
{
if (typeName == null)
{
throw new ArgumentNullException("typeName");
}
_typeName = typeName;
}
/// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute.AttributeProviderAttribute"]/*' />
/// <devdoc>
/// Creates a new AttributeProviderAttribute object.
/// </devdoc>
public AttributeProviderAttribute(string typeName, string propertyName) {
if (typeName == null) {
throw new ArgumentNullException("typeName");
}
if (propertyName == null) {
throw new ArgumentNullException("propertyName");
}
_typeName = typeName;
_propertyName = propertyName;
}
/// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute.AttributeProviderAttribute1"]/*' />
/// <devdoc>
/// Creates a new AttributeProviderAttribute object.
/// </devdoc>
public AttributeProviderAttribute(Type type)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
_typeName = type.AssemblyQualifiedName;
}
/// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute.TypeName"]/*' />
/// <devdoc>
/// The TypeName property returns the assembly qualified type name
/// passed into the constructor.
/// </devdoc>
public string TypeName
{
get
{
return _typeName;
}
}
/// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute.TypeName"]/*' />
/// <devdoc>
/// The TypeName property returns the property name that will be used to query attributes from.
/// </devdoc>
public string PropertyName {
get {
return _propertyName;
}
}
}
}

View File

@@ -0,0 +1,267 @@
//------------------------------------------------------------------------------
// <copyright file="BackgroundWorker.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ComponentModel
{
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
using System.Security.Permissions;
using System.Threading;
[
SRDescription(SR.BackgroundWorker_Desc),
DefaultEvent("DoWork"),
HostProtection(SharedState = true)
]
public class BackgroundWorker : Component
{
// Private statics
private static readonly object doWorkKey = new object();
private static readonly object runWorkerCompletedKey = new object();
private static readonly object progressChangedKey = new object();
// Private instance members
private bool canCancelWorker = false;
private bool workerReportsProgress = false;
private bool cancellationPending = false;
private bool isRunning = false;
private AsyncOperation asyncOperation = null;
private readonly WorkerThreadStartDelegate threadStart;
private readonly SendOrPostCallback operationCompleted;
private readonly SendOrPostCallback progressReporter;
public BackgroundWorker()
{
threadStart = new WorkerThreadStartDelegate(WorkerThreadStart);
operationCompleted = new SendOrPostCallback(AsyncOperationCompleted);
progressReporter = new SendOrPostCallback(ProgressReporter);
}
private void AsyncOperationCompleted(object arg)
{
isRunning = false;
cancellationPending = false;
OnRunWorkerCompleted((RunWorkerCompletedEventArgs)arg);
}
[
Browsable(false),
SRDescription(SR.BackgroundWorker_CancellationPending)
]
public bool CancellationPending
{
get { return cancellationPending; }
}
public void CancelAsync()
{
if (!WorkerSupportsCancellation)
{
throw new InvalidOperationException(SR.GetString(SR.BackgroundWorker_WorkerDoesntSupportCancellation));
}
cancellationPending = true;
}
[
SRCategory(SR.PropertyCategoryAsynchronous),
SRDescription(SR.BackgroundWorker_DoWork)
]
public event DoWorkEventHandler DoWork
{
add
{
this.Events.AddHandler(doWorkKey, value);
}
remove
{
this.Events.RemoveHandler(doWorkKey, value);
}
}
/// <include file='doc\BackgroundWorker.uex' path='docs/doc[@for="BackgroundWorker.IsBusy"]/*' />
[
Browsable(false),
SRDescription(SR.BackgroundWorker_IsBusy)
]
public bool IsBusy
{
get
{
return isRunning;
}
}
/// <include file='doc\BackgroundWorker.uex' path='docs/doc[@for="BackgroundWorker.OnDoWork"]/*' />
protected virtual void OnDoWork(DoWorkEventArgs e)
{
DoWorkEventHandler handler = (DoWorkEventHandler)(Events[doWorkKey]);
if (handler != null)
{
handler(this, e);
}
}
/// <include file='doc\BackgroundWorker.uex' path='docs/doc[@for="BackgroundWorker.OnRunWorkerCompleted"]/*' />
protected virtual void OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
{
RunWorkerCompletedEventHandler handler = (RunWorkerCompletedEventHandler)(Events[runWorkerCompletedKey]);
if (handler != null)
{
handler(this, e);
}
}
protected virtual void OnProgressChanged(ProgressChangedEventArgs e)
{
ProgressChangedEventHandler handler = (ProgressChangedEventHandler)(Events[progressChangedKey]);
if (handler != null)
{
handler(this, e);
}
}
[
SRCategory(SR.PropertyCategoryAsynchronous),
SRDescription(SR.BackgroundWorker_ProgressChanged)
]
public event ProgressChangedEventHandler ProgressChanged
{
add
{
this.Events.AddHandler(progressChangedKey, value);
}
remove
{
this.Events.RemoveHandler(progressChangedKey, value);
}
}
// Gets invoked through the AsyncOperation on the proper thread.
private void ProgressReporter(object arg)
{
OnProgressChanged((ProgressChangedEventArgs)arg);
}
// Cause progress update to be posted through current AsyncOperation.
public void ReportProgress(int percentProgress)
{
ReportProgress(percentProgress, null);
}
// Cause progress update to be posted through current AsyncOperation.
public void ReportProgress(int percentProgress, object userState)
{
if (!WorkerReportsProgress)
{
throw new InvalidOperationException(SR.GetString(SR.BackgroundWorker_WorkerDoesntReportProgress));
}
ProgressChangedEventArgs args = new ProgressChangedEventArgs(percentProgress, userState);
if (asyncOperation != null)
{
asyncOperation.Post(progressReporter, args);
}
else
{
progressReporter(args);
}
}
public void RunWorkerAsync()
{
RunWorkerAsync(null);
}
public void RunWorkerAsync(object argument)
{
if (isRunning)
{
throw new InvalidOperationException(SR.GetString(SR.BackgroundWorker_WorkerAlreadyRunning));
}
isRunning = true;
cancellationPending = false;
asyncOperation = AsyncOperationManager.CreateOperation(null);
threadStart.BeginInvoke(argument,
null,
null);
}
[
SRCategory(SR.PropertyCategoryAsynchronous),
SRDescription(SR.BackgroundWorker_RunWorkerCompleted)
]
public event RunWorkerCompletedEventHandler RunWorkerCompleted
{
add
{
this.Events.AddHandler(runWorkerCompletedKey, value);
}
remove
{
this.Events.RemoveHandler(runWorkerCompletedKey, value);
}
}
[ SRCategory(SR.PropertyCategoryAsynchronous),
SRDescription(SR.BackgroundWorker_WorkerReportsProgress),
DefaultValue(false)
]
public bool WorkerReportsProgress
{
get { return workerReportsProgress; }
set { workerReportsProgress = value; }
}
[
SRCategory(SR.PropertyCategoryAsynchronous),
SRDescription(SR.BackgroundWorker_WorkerSupportsCancellation),
DefaultValue(false)
]
public bool WorkerSupportsCancellation
{
get { return canCancelWorker; }
set { canCancelWorker = value; }
}
private delegate void WorkerThreadStartDelegate(object argument);
private void WorkerThreadStart(object argument)
{
object workerResult = null;
Exception error = null;
bool cancelled = false;
try
{
DoWorkEventArgs doWorkArgs = new DoWorkEventArgs(argument);
OnDoWork(doWorkArgs);
if (doWorkArgs.Cancel)
{
cancelled = true;
}
else
{
workerResult = doWorkArgs.Result;
}
}
catch (Exception exception)
{
error = exception;
}
RunWorkerCompletedEventArgs e =
new RunWorkerCompletedEventArgs(workerResult, error, cancelled);
asyncOperation.PostOperationCompleted(operationCompleted, e);
}
}
}

View File

@@ -0,0 +1,34 @@
//------------------------------------------------------------------------------
// <copyright file="BaseComponentEditor.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace System.ComponentModel {
using System;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para> Provides the base class for a custom component
/// editor.</para>
/// </devdoc>
[HostProtection(SharedState = true)]
public abstract class ComponentEditor
{
/// <devdoc>
/// <para>Gets a value indicating whether the component was modified.</para>
/// </devdoc>
public bool EditComponent(object component) {
return EditComponent(null, component);
}
/// <devdoc>
/// <para>Gets a value indicating whether the component was modified.</para>
/// </devdoc>
public abstract bool EditComponent(ITypeDescriptorContext context, object component);
}
}

View File

@@ -0,0 +1,142 @@
//------------------------------------------------------------------------------
// <copyright file="BindableAttribute.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace System.ComponentModel {
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para>Specifies whether a property is appropriate to bind data
/// to.</para>
/// </devdoc>
[AttributeUsage(AttributeTargets.All)]
public sealed class BindableAttribute : Attribute {
/// <devdoc>
/// <para>
/// Specifies that a property is appropriate to bind data to. This
/// <see langword='static '/>field is read-only.
/// </para>
/// </devdoc>
public static readonly BindableAttribute Yes = new BindableAttribute(true);
/// <devdoc>
/// <para>
/// Specifies that a property is not appropriate to bind
/// data to. This <see langword='static '/>field is read-only.
/// </para>
/// </devdoc>
public static readonly BindableAttribute No = new BindableAttribute(false);
/// <devdoc>
/// <para>
/// Specifies the default value for the <see cref='System.ComponentModel.BindableAttribute'/>,
/// which is <see cref='System.ComponentModel.BindableAttribute.No'/>. This <see langword='static '/>field is
/// read-only.
/// </para>
/// </devdoc>
public static readonly BindableAttribute Default = No;
private bool bindable = false;
private bool isDefault = false;
private BindingDirection direction;
/// <devdoc>
/// <para>
/// Initializes a new instance of the <see cref='System.ComponentModel.BindableAttribute'/> class.
/// </para>
/// </devdoc>
public BindableAttribute(bool bindable) : this(bindable, BindingDirection.OneWay) {
}
/// <devdoc>
/// <para>
/// Initializes a new instance of the <see cref='System.ComponentModel.BindableAttribute'/> class.
/// </para>
/// </devdoc>
public BindableAttribute(bool bindable, BindingDirection direction) {
this.bindable = bindable;
this.direction = direction;
}
/// <devdoc>
/// <para>
/// Initializes a new instance of the <see cref='System.ComponentModel.BindableAttribute'/> class.
/// </para>
/// </devdoc>
public BindableAttribute(BindableSupport flags) : this(flags, BindingDirection.OneWay) {
}
/// <devdoc>
/// <para>
/// Initializes a new instance of the <see cref='System.ComponentModel.BindableAttribute'/> class.
/// </para>
/// </devdoc>
public BindableAttribute(BindableSupport flags, BindingDirection direction) {
this.bindable = (flags != BindableSupport.No);
this.isDefault = (flags == BindableSupport.Default);
this.direction = direction;
}
/// <devdoc>
/// <para>
/// Gets a value indicating
/// whether a property is appropriate to bind data to.
/// </para>
/// </devdoc>
public bool Bindable {
get {
return bindable;
}
}
/// <devdoc>
/// <para>
/// Gets a value indicating
/// the direction(s) this property be bound to data.
/// </para>
/// </devdoc>
public BindingDirection Direction {
get {
return direction;
}
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
public override bool Equals(object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj is BindableAttribute) {
return (((BindableAttribute)obj).Bindable == bindable);
}
return false;
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public override int GetHashCode() {
return bindable.GetHashCode();
}
#if !SILVERLIGHT
/// <devdoc>
/// </devdoc>
/// <internalonly/>
public override bool IsDefaultAttribute() {
return (this.Equals(Default) || isDefault);
}
#endif
}
}

View File

@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <copyright file="BindableSupport.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace System.ComponentModel {
using System.Diagnostics;
using System;
/// <devdoc>
/// <para>Specifies which values to say if property or event value can be bound to a data
/// element or another property or event's value.</para>
/// </devdoc>
public enum BindableSupport {
/// <devdoc>
/// <para>
/// The property or event is bindable.
/// </para>
/// </devdoc>
No = 0x00,
/// <devdoc>
/// <para>
/// The property or event is not bindable.
/// </para>
/// </devdoc>
Yes = 0x01,
/// <devdoc>
/// <para>
/// The property or event is the default.
/// </para>
/// </devdoc>
Default = 0x02,
}
}

View File

@@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// <copyright file="BindingDirection.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.ComponentModel {
/// <devdoc>
/// <para>Specifies whether the template can be bound one-way or two-way.</para>
/// </devdoc>
public enum BindingDirection {
/// <devdoc>
/// <para>The template can only accept property values. Used with a generic ITemplate.</para>
/// </devdoc>
OneWay = 0,
/// <devdoc>
/// <para>The template can accept and expose property values. Used with an IBindableTemplate.</para>
/// </devdoc>
TwoWay = 1
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,86 @@
//------------------------------------------------------------------------------
// <copyright file="BooleanConverter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace System.ComponentModel {
using Microsoft.Win32;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Serialization.Formatters;
using System.Security.Permissions;
/// <devdoc>
/// <para>Provides a type converter to convert
/// Boolean objects to and from various other representations.</para>
/// </devdoc>
[HostProtection(SharedState = true)]
public class BooleanConverter : TypeConverter {
private static volatile StandardValuesCollection values;
/// <devdoc>
/// <para>Gets a value indicating whether this converter can
/// convert an object in the given source type to a Boolean object using the
/// specified context.</para>
/// </devdoc>
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
if (sourceType == typeof(string)) {
return true;
}
return base.CanConvertFrom(context, sourceType);
}
/// <devdoc>
/// <para>Converts the given value
/// object to a Boolean object.</para>
/// </devdoc>
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
if (value is string) {
string text = ((string)value).Trim();
try {
return Boolean.Parse(text);
}
catch (FormatException e) {
throw new FormatException(SR.GetString(SR.ConvertInvalidPrimitive, (string)value, "Boolean"), e);
}
}
return base.ConvertFrom(context, culture, value);
}
/// <devdoc>
/// <para>Gets a collection of standard values
/// for the Boolean data type.</para>
/// </devdoc>
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) {
if (values == null) {
values = new StandardValuesCollection(new object[] {true, false});
}
return values;
}
/// <devdoc>
/// <para>Gets a value indicating whether the list of standard values returned from
/// <see cref='System.ComponentModel.BooleanConverter.GetStandardValues'/> is an exclusive list. </para>
/// </devdoc>
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) {
return true;
}
/// <devdoc>
/// <para>Gets a value indicating whether this object supports a standard set of values
/// that can be picked from a list.</para>
/// </devdoc>
public override bool GetStandardValuesSupported(ITypeDescriptorContext context) {
return true;
}
}
}

View File

@@ -0,0 +1,93 @@
//------------------------------------------------------------------------------
// <copyright file="BrowsableAttribute.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace System.ComponentModel {
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para>Specifies whether a property or event should be displayed in
/// a property browsing window.</para>
/// </devdoc>
[AttributeUsage(AttributeTargets.All)]
public sealed class BrowsableAttribute : Attribute {
/// <devdoc>
/// <para>
/// Specifies that a property or event can be modified at
/// design time. This <see langword='static '/>
/// field is read-only.
/// </para>
/// </devdoc>
public static readonly BrowsableAttribute Yes = new BrowsableAttribute(true);
/// <devdoc>
/// <para>
/// Specifies that a property or event cannot be modified at
/// design time. This <see langword='static '/>field is read-only.
/// </para>
/// </devdoc>
public static readonly BrowsableAttribute No = new BrowsableAttribute(false);
/// <devdoc>
/// <para>Specifies the default value for the <see cref='System.ComponentModel.BrowsableAttribute'/>,
/// which is <see cref='System.ComponentModel.BrowsableAttribute.Yes'/>. This <see langword='static '/>field is read-only.</para>
/// </devdoc>
public static readonly BrowsableAttribute Default = Yes;
private bool browsable = true;
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.BrowsableAttribute'/> class.</para>
/// </devdoc>
public BrowsableAttribute(bool browsable) {
this.browsable = browsable;
}
/// <devdoc>
/// <para>
/// Gets a value indicating whether an object is browsable.
/// </para>
/// </devdoc>
public bool Browsable {
get {
return browsable;
}
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
public override bool Equals(object obj) {
if (obj == this) {
return true;
}
BrowsableAttribute other = obj as BrowsableAttribute;
return (other != null) && other.Browsable == browsable;
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public override int GetHashCode() {
return browsable.GetHashCode();
}
#if !SILVERLIGHT
/// <internalonly/>
/// <devdoc>
/// </devdoc>
public override bool IsDefaultAttribute() {
return (this.Equals(Default));
}
#endif
}
}

View File

@@ -0,0 +1,66 @@
//------------------------------------------------------------------------------
// <copyright file="ByteConverter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace System.ComponentModel {
using Microsoft.Win32;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Serialization.Formatters;
using System.Security.Permissions;
/// <devdoc>
/// <para>Provides a
/// type converter to convert 8-bit unsigned
/// integer objects to and from various other representations.</para>
/// </devdoc>
[HostProtection(SharedState = true)]
public class ByteConverter : BaseNumberConverter {
/// <devdoc>
/// The Type this converter is targeting (e.g. Int16, UInt32, etc.)
/// </devdoc>
internal override Type TargetType {
get {
return typeof(Byte);
}
}
/// <devdoc>
/// Convert the given value to a string using the given radix
/// </devdoc>
internal override object FromString(string value, int radix) {
return Convert.ToByte(value, radix);
}
/// <devdoc>
/// Convert the given value to a string using the given formatInfo
/// </devdoc>
internal override object FromString(string value, NumberFormatInfo formatInfo) {
return Byte.Parse(value, NumberStyles.Integer, formatInfo);
}
/// <devdoc>
/// Convert the given value to a string using the given CultureInfo
/// </devdoc>
internal override object FromString(string value, CultureInfo culture){
return Byte.Parse(value, culture);
}
/// <devdoc>
/// Convert the given value from a string using the given formatInfo
/// </devdoc>
internal override string ToString(object value, NumberFormatInfo formatInfo) {
return ((Byte)value).ToString("G", formatInfo);
}
}
}

Some files were not shown because too many files have changed in this diff Show More