Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Compiler / TypeSystem / PropertyInfo.cs / 1305376 / PropertyInfo.cs
#pragma warning disable 1634, 1691 namespace System.Workflow.ComponentModel.Compiler { using System; using System.CodeDom; using System.Collections; using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System.Globalization; using System.Reflection; #region DesignTimePropertyInfo internal sealed class DesignTimePropertyInfo: PropertyInfo { #region Members and Constructors private Attribute[] attributes = null; private CodeMemberProperty property = null; private DesignTimeType declaringType = null; private MethodInfo getMethod = null; private MethodInfo setMethod = null; internal DesignTimePropertyInfo(DesignTimeType declaringType, CodeMemberProperty property) { this.property = property; this.declaringType = declaringType; } #endregion internal CodeMemberProperty CodeMemberProperty { get { return this.property; } } #region Property Info overrides public override Type PropertyType { get { return declaringType.ResolveType(DesignTimeType.GetTypeNameFromCodeTypeReference(this.property.Type, declaringType)); } } public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { throw new NotImplementedException(TypeSystemSR.GetString("Error_RuntimeNotSupported")); } public override MethodInfo[] GetAccessors(bool nonPublic) { ArrayList accessorList = new ArrayList(); if (Helper.IncludeAccessor(this.GetGetMethod(nonPublic), nonPublic)) accessorList.Add(this.getMethod); if (Helper.IncludeAccessor(this.GetSetMethod(nonPublic), nonPublic)) accessorList.Add(this.setMethod); return accessorList.ToArray(typeof(MethodInfo)) as MethodInfo[]; } public override MethodInfo GetGetMethod(bool nonPublic) { if (this.CanRead && this.getMethod == null) { String accessor = "get_" + this.Name; this.getMethod = new PropertyMethodInfo(true, accessor, this); } // now check to see if getMethod is public if (nonPublic || ((this.getMethod != null) && ((this.getMethod.Attributes & MethodAttributes.Public) == MethodAttributes.Public))) return this.getMethod; return null; } public override MethodInfo GetSetMethod(bool nonPublic) { if (this.CanWrite && this.setMethod == null) { String accessor = "set_" + this.Name; this.setMethod = new PropertyMethodInfo(false, accessor, this); } // now check to see if getMethod is public if (nonPublic || ((this.setMethod != null) && ((this.setMethod.Attributes & MethodAttributes.Public) == MethodAttributes.Public))) return this.setMethod; return null; } public override ParameterInfo[] GetIndexParameters() { int numParams = 0; ParameterInfo[] methParams = null; // First try to get the Get method. MethodInfo methodInfo = this.GetGetMethod(true); if (methodInfo != null) { // There is a Get method so use it. methParams = methodInfo.GetParameters(); numParams = methParams.Length; } else { // If there is no Get method then use the Set method. methodInfo = GetSetMethod(true); if (methodInfo != null) { methParams = methodInfo.GetParameters(); // Exclude value parameter numParams = methParams.Length - 1; } } // Now copy over the parameter info's and change their // owning member info to the current property info. ParameterInfo[] propParams = new ParameterInfo[numParams]; for (int i = 0; i < numParams; i++) propParams[i] = methParams[i]; return propParams; // } public override PropertyAttributes Attributes { get { return PropertyAttributes.None; } } public override bool CanRead { get { return this.property.HasGet; } } public override bool CanWrite { get { return this.property.HasSet; } } public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { throw new NotImplementedException(TypeSystemSR.GetString("Error_RuntimeNotSupported")); } public override string Name { get { return Helper.EnsureTypeName(this.property.Name); } } public override Type DeclaringType { get { return this.declaringType; } } public override Type ReflectedType { get { return this.declaringType; } } #endregion #region MemberInfo Overrides public override object[] GetCustomAttributes(bool inherit) { return GetCustomAttributes(typeof(object), inherit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException("attributeType"); if (this.attributes == null) this.attributes = Helper.LoadCustomAttributes(this.property.CustomAttributes, this.DeclaringType as DesignTimeType); return Helper.GetCustomAttributes(attributeType, inherit, this.attributes, this); } public override bool IsDefined(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException("attributeType"); if (this.attributes == null) this.attributes = Helper.LoadCustomAttributes(this.property.CustomAttributes, this.DeclaringType as DesignTimeType); if (Helper.IsDefined(attributeType, inherit, attributes, this)) return true; return false; } #endregion #region PropertyInfo MethodInfo classes private sealed class PropertyMethodInfo: MethodInfo { private string name = String.Empty; private DesignTimePropertyInfo property = null; private ParameterInfo[] parameters = null; private bool isGetter = false; internal PropertyMethodInfo(bool isGetter, string name, DesignTimePropertyInfo property) { this.isGetter = isGetter; this.name = name; this.property = property; } public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotImplementedException(TypeSystemSR.GetString("Error_RuntimeNotSupported")); } internal bool IsGetter { get { return this.isGetter; } } #region MemberInfo Overrides public override string Name { get { return Helper.EnsureTypeName(this.name); } } public override Type DeclaringType { get { return this.property.declaringType; } } public override Type ReflectedType { get { return this.property.declaringType; } } public override object[] GetCustomAttributes(bool inherit) { return GetCustomAttributes(typeof(object), inherit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return new Object[0]; } public override bool IsDefined(Type attributeType, bool inherit) { return false; } #endregion #region Method Info overrides public override ParameterInfo ReturnParameter { get { #pragma warning suppress 56503 throw new NotImplementedException(); } } public override Type ReturnType { get { if(this.isGetter) return ((DesignTimeType)this.DeclaringType).ResolveType(DesignTimeType.GetTypeNameFromCodeTypeReference(this.property.CodeMemberProperty.Type, ((DesignTimeType)this.DeclaringType))); return typeof(void); } } public override ICustomAttributeProvider ReturnTypeCustomAttributes { get { #pragma warning suppress 56503 throw new NotImplementedException(); } } public override MethodInfo GetBaseDefinition() { throw new NotImplementedException(); } #endregion #region MethodBase Overrides public override ParameterInfo[] GetParameters() { if (this.parameters == null) { // Get the parameters CodeParameterDeclarationExpressionCollection parameters = this.property.CodeMemberProperty.Parameters; ParameterInfo[] paramArray = new ParameterInfo[this.IsGetter ? parameters.Count : parameters.Count + 1]; for (int index = 0; index < parameters.Count; index++) { paramArray[index] = new DesignTimeParameterInfo(parameters[index], index, this.property); } if (!this.IsGetter) { CodeParameterDeclarationExpression valueParameter = new CodeParameterDeclarationExpression(this.property.CodeMemberProperty.Type.BaseType, "value"); valueParameter.Direction = FieldDirection.In; paramArray[parameters.Count] = new DesignTimeParameterInfo(valueParameter, 0, this.property); } this.parameters = paramArray; } return this.parameters; // } public override MethodImplAttributes GetMethodImplementationFlags() { return MethodImplAttributes.IL; } public override RuntimeMethodHandle MethodHandle { get { // not interested in Runtime information #pragma warning suppress 56503 throw new NotImplementedException(TypeSystemSR.GetString("Error_RuntimeNotSupported")); } } public override MethodAttributes Attributes { get { return (Helper.ConvertToMethodAttributes(this.property.CodeMemberProperty.Attributes) | MethodAttributes.SpecialName); } } #endregion } #endregion } #endregion } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. #pragma warning disable 1634, 1691 namespace System.Workflow.ComponentModel.Compiler { using System; using System.CodeDom; using System.Collections; using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System.Globalization; using System.Reflection; #region DesignTimePropertyInfo internal sealed class DesignTimePropertyInfo: PropertyInfo { #region Members and Constructors private Attribute[] attributes = null; private CodeMemberProperty property = null; private DesignTimeType declaringType = null; private MethodInfo getMethod = null; private MethodInfo setMethod = null; internal DesignTimePropertyInfo(DesignTimeType declaringType, CodeMemberProperty property) { this.property = property; this.declaringType = declaringType; } #endregion internal CodeMemberProperty CodeMemberProperty { get { return this.property; } } #region Property Info overrides public override Type PropertyType { get { return declaringType.ResolveType(DesignTimeType.GetTypeNameFromCodeTypeReference(this.property.Type, declaringType)); } } public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { throw new NotImplementedException(TypeSystemSR.GetString("Error_RuntimeNotSupported")); } public override MethodInfo[] GetAccessors(bool nonPublic) { ArrayList accessorList = new ArrayList(); if (Helper.IncludeAccessor(this.GetGetMethod(nonPublic), nonPublic)) accessorList.Add(this.getMethod); if (Helper.IncludeAccessor(this.GetSetMethod(nonPublic), nonPublic)) accessorList.Add(this.setMethod); return accessorList.ToArray(typeof(MethodInfo)) as MethodInfo[]; } public override MethodInfo GetGetMethod(bool nonPublic) { if (this.CanRead && this.getMethod == null) { String accessor = "get_" + this.Name; this.getMethod = new PropertyMethodInfo(true, accessor, this); } // now check to see if getMethod is public if (nonPublic || ((this.getMethod != null) && ((this.getMethod.Attributes & MethodAttributes.Public) == MethodAttributes.Public))) return this.getMethod; return null; } public override MethodInfo GetSetMethod(bool nonPublic) { if (this.CanWrite && this.setMethod == null) { String accessor = "set_" + this.Name; this.setMethod = new PropertyMethodInfo(false, accessor, this); } // now check to see if getMethod is public if (nonPublic || ((this.setMethod != null) && ((this.setMethod.Attributes & MethodAttributes.Public) == MethodAttributes.Public))) return this.setMethod; return null; } public override ParameterInfo[] GetIndexParameters() { int numParams = 0; ParameterInfo[] methParams = null; // First try to get the Get method. MethodInfo methodInfo = this.GetGetMethod(true); if (methodInfo != null) { // There is a Get method so use it. methParams = methodInfo.GetParameters(); numParams = methParams.Length; } else { // If there is no Get method then use the Set method. methodInfo = GetSetMethod(true); if (methodInfo != null) { methParams = methodInfo.GetParameters(); // Exclude value parameter numParams = methParams.Length - 1; } } // Now copy over the parameter info's and change their // owning member info to the current property info. ParameterInfo[] propParams = new ParameterInfo[numParams]; for (int i = 0; i < numParams; i++) propParams[i] = methParams[i]; return propParams; // } public override PropertyAttributes Attributes { get { return PropertyAttributes.None; } } public override bool CanRead { get { return this.property.HasGet; } } public override bool CanWrite { get { return this.property.HasSet; } } public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { throw new NotImplementedException(TypeSystemSR.GetString("Error_RuntimeNotSupported")); } public override string Name { get { return Helper.EnsureTypeName(this.property.Name); } } public override Type DeclaringType { get { return this.declaringType; } } public override Type ReflectedType { get { return this.declaringType; } } #endregion #region MemberInfo Overrides public override object[] GetCustomAttributes(bool inherit) { return GetCustomAttributes(typeof(object), inherit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException("attributeType"); if (this.attributes == null) this.attributes = Helper.LoadCustomAttributes(this.property.CustomAttributes, this.DeclaringType as DesignTimeType); return Helper.GetCustomAttributes(attributeType, inherit, this.attributes, this); } public override bool IsDefined(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException("attributeType"); if (this.attributes == null) this.attributes = Helper.LoadCustomAttributes(this.property.CustomAttributes, this.DeclaringType as DesignTimeType); if (Helper.IsDefined(attributeType, inherit, attributes, this)) return true; return false; } #endregion #region PropertyInfo MethodInfo classes private sealed class PropertyMethodInfo: MethodInfo { private string name = String.Empty; private DesignTimePropertyInfo property = null; private ParameterInfo[] parameters = null; private bool isGetter = false; internal PropertyMethodInfo(bool isGetter, string name, DesignTimePropertyInfo property) { this.isGetter = isGetter; this.name = name; this.property = property; } public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotImplementedException(TypeSystemSR.GetString("Error_RuntimeNotSupported")); } internal bool IsGetter { get { return this.isGetter; } } #region MemberInfo Overrides public override string Name { get { return Helper.EnsureTypeName(this.name); } } public override Type DeclaringType { get { return this.property.declaringType; } } public override Type ReflectedType { get { return this.property.declaringType; } } public override object[] GetCustomAttributes(bool inherit) { return GetCustomAttributes(typeof(object), inherit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return new Object[0]; } public override bool IsDefined(Type attributeType, bool inherit) { return false; } #endregion #region Method Info overrides public override ParameterInfo ReturnParameter { get { #pragma warning suppress 56503 throw new NotImplementedException(); } } public override Type ReturnType { get { if(this.isGetter) return ((DesignTimeType)this.DeclaringType).ResolveType(DesignTimeType.GetTypeNameFromCodeTypeReference(this.property.CodeMemberProperty.Type, ((DesignTimeType)this.DeclaringType))); return typeof(void); } } public override ICustomAttributeProvider ReturnTypeCustomAttributes { get { #pragma warning suppress 56503 throw new NotImplementedException(); } } public override MethodInfo GetBaseDefinition() { throw new NotImplementedException(); } #endregion #region MethodBase Overrides public override ParameterInfo[] GetParameters() { if (this.parameters == null) { // Get the parameters CodeParameterDeclarationExpressionCollection parameters = this.property.CodeMemberProperty.Parameters; ParameterInfo[] paramArray = new ParameterInfo[this.IsGetter ? parameters.Count : parameters.Count + 1]; for (int index = 0; index < parameters.Count; index++) { paramArray[index] = new DesignTimeParameterInfo(parameters[index], index, this.property); } if (!this.IsGetter) { CodeParameterDeclarationExpression valueParameter = new CodeParameterDeclarationExpression(this.property.CodeMemberProperty.Type.BaseType, "value"); valueParameter.Direction = FieldDirection.In; paramArray[parameters.Count] = new DesignTimeParameterInfo(valueParameter, 0, this.property); } this.parameters = paramArray; } return this.parameters; // } public override MethodImplAttributes GetMethodImplementationFlags() { return MethodImplAttributes.IL; } public override RuntimeMethodHandle MethodHandle { get { // not interested in Runtime information #pragma warning suppress 56503 throw new NotImplementedException(TypeSystemSR.GetString("Error_RuntimeNotSupported")); } } public override MethodAttributes Attributes { get { return (Helper.ConvertToMethodAttributes(this.property.CodeMemberProperty.Attributes) | MethodAttributes.SpecialName); } } #endregion } #endregion } #endregion } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FixedSOMSemanticBox.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- ConfigurationProperty.cs
- IdnElement.cs
- WindowsButton.cs
- Tile.cs
- ScriptResourceMapping.cs
- xmlsaver.cs
- SiteMapDataSource.cs
- Stroke2.cs
- AspProxy.cs
- ContextMarshalException.cs
- MappingItemCollection.cs
- BitmapSizeOptions.cs
- StoragePropertyMapping.cs
- TagNameToTypeMapper.cs
- NativeCppClassAttribute.cs
- ExpressionBindings.cs
- MetadataCache.cs
- HtmlImageAdapter.cs
- MachineKeyConverter.cs
- CfgParser.cs
- PropertyIdentifier.cs
- LifetimeServices.cs
- ToolstripProfessionalRenderer.cs
- SubqueryTrackingVisitor.cs
- AcceleratedTokenAuthenticator.cs
- SQLStringStorage.cs
- WasEndpointConfigContainer.cs
- WebPartActionVerb.cs
- ZipIOCentralDirectoryFileHeader.cs
- EnumerableRowCollection.cs
- WindowManager.cs
- SqlUserDefinedTypeAttribute.cs
- KeysConverter.cs
- TableItemPattern.cs
- CompilerGeneratedAttribute.cs
- PrintDialogException.cs
- AuthStoreRoleProvider.cs
- TemplateControl.cs
- ClientFactory.cs
- ResponseBodyWriter.cs
- BamlTreeUpdater.cs
- ColorTransformHelper.cs
- UserControlParser.cs
- TableRowGroup.cs
- DataRecordInfo.cs
- DesignerMetadata.cs
- RefreshPropertiesAttribute.cs
- TextSelectionHelper.cs
- TypeDescriptionProvider.cs
- ToolStrip.cs
- XXXOnTypeBuilderInstantiation.cs
- SqlPersistenceProviderFactory.cs
- TextServicesManager.cs
- RuleSettingsCollection.cs
- InfoCardXmlSerializer.cs
- XmlILStorageConverter.cs
- ControlBuilder.cs
- ShapingWorkspace.cs
- XmlSchemas.cs
- EntityParameterCollection.cs
- JsonUriDataContract.cs
- WebDescriptionAttribute.cs
- validationstate.cs
- FixedPageAutomationPeer.cs
- CommentEmitter.cs
- WindowsIPAddress.cs
- DesignTimeData.cs
- RegexCharClass.cs
- LicenseManager.cs
- PersonalizablePropertyEntry.cs
- Lease.cs
- SqlMultiplexer.cs
- ListViewCancelEventArgs.cs
- MouseDevice.cs
- BamlBinaryReader.cs
- ManagementPath.cs
- XmlSchemaGroup.cs
- VisualBasicValue.cs
- OdbcStatementHandle.cs
- EventEntry.cs
- SkipStoryboardToFill.cs
- HwndProxyElementProvider.cs
- ProxyHelper.cs
- XmlIterators.cs
- GeneratedCodeAttribute.cs
- MethodBuilder.cs
- XmlElementCollection.cs
- XmlEventCache.cs
- TextServicesProperty.cs
- InputDevice.cs
- sqlinternaltransaction.cs
- FieldNameLookup.cs
- AttributeUsageAttribute.cs
- SqlDataSourceCommandEventArgs.cs
- MarshalDirectiveException.cs
- LineProperties.cs
- StrokeNodeData.cs
- NameValueSectionHandler.cs