Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Design / system / Data / EntityModel / Emitters / PropertyEmitterBase.cs / 1305376 / PropertyEmitterBase.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.CodeDom;
using System.Data.Metadata.Edm;
using System.Data.Services.Design;
using System.Diagnostics;
namespace System.Data.EntityModel.Emitters
{
internal abstract class PropertyEmitterBase : MetadataItemEmitter
{
private bool _declaringTypeUsesStandardBaseType;
protected PropertyEmitterBase(ClientApiGenerator generator, MetadataItem item, bool declaringTypeUsesStandardBaseType)
: base(generator, item)
{
Debug.Assert(item != null, "item is null");
_declaringTypeUsesStandardBaseType = declaringTypeUsesStandardBaseType;
}
///
/// This is where the derived classes supply their emit logic.
///
/// The CodeDom representation of the type that the property is being added to.
protected abstract void EmitProperty(CodeTypeDeclaration typeDecl);
///
/// Validation logic specific to property emitters
///
protected override void Validate()
{
VerifyGetterAndSetterAccessibilityCompatability();
Generator.VerifyLanguageCaseSensitiveCompatibilityForProperty(Item as EdmMember);
}
///
/// The compiler ensures accessibility on a Setter/Getter is more restrictive than on the Property.
/// However accessibility modifiers are not well ordered. Internal and Protected don't go well together
/// because neither is more restrictive than others.
///
private void VerifyGetterAndSetterAccessibilityCompatability()
{
if (PropertyEmitter.GetGetterAccessibility(Item) == MemberAttributes.Assembly
&& PropertyEmitter.GetSetterAccessibility(Item) == MemberAttributes.Family)
{
Generator.AddError(Strings.GeneratedPropertyAccessibilityConflict(Item.Name, "Internal", "Protected"),
ModelBuilderErrorCode.GeneratedPropertyAccessibilityConflict,
EdmSchemaErrorSeverity.Error);
}
else if (PropertyEmitter.GetGetterAccessibility(Item) == MemberAttributes.Family
&& PropertyEmitter.GetSetterAccessibility(Item) == MemberAttributes.Assembly)
{
Generator.AddError(Strings.GeneratedPropertyAccessibilityConflict(Item.Name, "Protected", "Internal"),
ModelBuilderErrorCode.GeneratedPropertyAccessibilityConflict,
EdmSchemaErrorSeverity.Error);
}
}
///
/// Main method for Emitting property code.
///
/// The CodeDom representation of the type that the property is being added to.
public void Emit(CodeTypeDeclaration typeDecl)
{
Validate();
EmitProperty(typeDecl);
}
protected bool AncestorClassDefinesName(string name)
{
if (_declaringTypeUsesStandardBaseType && Utils.DoesTypeReserveMemberName(Item.DeclaringType, name, Generator.LanguageAppropriateStringComparer))
{
return true;
}
StructuralType baseType = Item.DeclaringType.BaseType as StructuralType;
if (baseType != null && baseType.Members.Contains(name))
{
return true;
}
return false;
}
public new EdmMember Item
{
get
{
return base.Item as EdmMember;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.CodeDom;
using System.Data.Metadata.Edm;
using System.Data.Services.Design;
using System.Diagnostics;
namespace System.Data.EntityModel.Emitters
{
internal abstract class PropertyEmitterBase : MetadataItemEmitter
{
private bool _declaringTypeUsesStandardBaseType;
protected PropertyEmitterBase(ClientApiGenerator generator, MetadataItem item, bool declaringTypeUsesStandardBaseType)
: base(generator, item)
{
Debug.Assert(item != null, "item is null");
_declaringTypeUsesStandardBaseType = declaringTypeUsesStandardBaseType;
}
///
/// This is where the derived classes supply their emit logic.
///
/// The CodeDom representation of the type that the property is being added to.
protected abstract void EmitProperty(CodeTypeDeclaration typeDecl);
///
/// Validation logic specific to property emitters
///
protected override void Validate()
{
VerifyGetterAndSetterAccessibilityCompatability();
Generator.VerifyLanguageCaseSensitiveCompatibilityForProperty(Item as EdmMember);
}
///
/// The compiler ensures accessibility on a Setter/Getter is more restrictive than on the Property.
/// However accessibility modifiers are not well ordered. Internal and Protected don't go well together
/// because neither is more restrictive than others.
///
private void VerifyGetterAndSetterAccessibilityCompatability()
{
if (PropertyEmitter.GetGetterAccessibility(Item) == MemberAttributes.Assembly
&& PropertyEmitter.GetSetterAccessibility(Item) == MemberAttributes.Family)
{
Generator.AddError(Strings.GeneratedPropertyAccessibilityConflict(Item.Name, "Internal", "Protected"),
ModelBuilderErrorCode.GeneratedPropertyAccessibilityConflict,
EdmSchemaErrorSeverity.Error);
}
else if (PropertyEmitter.GetGetterAccessibility(Item) == MemberAttributes.Family
&& PropertyEmitter.GetSetterAccessibility(Item) == MemberAttributes.Assembly)
{
Generator.AddError(Strings.GeneratedPropertyAccessibilityConflict(Item.Name, "Protected", "Internal"),
ModelBuilderErrorCode.GeneratedPropertyAccessibilityConflict,
EdmSchemaErrorSeverity.Error);
}
}
///
/// Main method for Emitting property code.
///
/// The CodeDom representation of the type that the property is being added to.
public void Emit(CodeTypeDeclaration typeDecl)
{
Validate();
EmitProperty(typeDecl);
}
protected bool AncestorClassDefinesName(string name)
{
if (_declaringTypeUsesStandardBaseType && Utils.DoesTypeReserveMemberName(Item.DeclaringType, name, Generator.LanguageAppropriateStringComparer))
{
return true;
}
StructuralType baseType = Item.DeclaringType.BaseType as StructuralType;
if (baseType != null && baseType.Members.Contains(name))
{
return true;
}
return false;
}
public new EdmMember Item
{
get
{
return base.Item as EdmMember;
}
}
}
}
// 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
- XmlIterators.cs
- ProtocolsConfigurationHandler.cs
- DodSequenceMerge.cs
- SQLCharsStorage.cs
- ipaddressinformationcollection.cs
- StateValidator.cs
- SqlRowUpdatingEvent.cs
- AnimationStorage.cs
- CodeIdentifiers.cs
- ConfigsHelper.cs
- WebServiceMethodData.cs
- PropertyToken.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- XmlLanguageConverter.cs
- CodeComment.cs
- DecimalConstantAttribute.cs
- IdleTimeoutMonitor.cs
- XomlCompilerParameters.cs
- HiddenField.cs
- AdRotator.cs
- MappingException.cs
- ProfessionalColorTable.cs
- ChannelBinding.cs
- PerfCounterSection.cs
- SqlCacheDependencyDatabaseCollection.cs
- TextParaClient.cs
- CompilerCollection.cs
- DetailsViewPageEventArgs.cs
- AtomContentProperty.cs
- SqlEnums.cs
- SSmlParser.cs
- Publisher.cs
- AuthStoreRoleProvider.cs
- XsdDataContractExporter.cs
- FamilyTypefaceCollection.cs
- SizeFConverter.cs
- DateTimeOffset.cs
- Parameter.cs
- DriveInfo.cs
- MSAAWinEventWrap.cs
- GeometryGroup.cs
- SmiRecordBuffer.cs
- Registry.cs
- Directory.cs
- ConnectionPoint.cs
- ErrorHandler.cs
- GroupItem.cs
- UnsafeNativeMethods.cs
- SpellerInterop.cs
- InternalUserCancelledException.cs
- CodeLinePragma.cs
- AuthenticationConfig.cs
- ApplicationGesture.cs
- CodeGotoStatement.cs
- OperatorExpressions.cs
- ObjectReaderCompiler.cs
- WasHttpHandlersInstallComponent.cs
- ViewRendering.cs
- SplitterPanel.cs
- SrgsGrammarCompiler.cs
- ContentPresenter.cs
- CodeArrayCreateExpression.cs
- MiniModule.cs
- OletxTransactionFormatter.cs
- PropertySet.cs
- DigestTraceRecordHelper.cs
- ImageMetadata.cs
- DynamicVirtualDiscoSearcher.cs
- SiteMapDataSource.cs
- RegisteredHiddenField.cs
- SystemInfo.cs
- Matrix3DStack.cs
- Effect.cs
- SmiTypedGetterSetter.cs
- ViewgenContext.cs
- RemoveStoryboard.cs
- Command.cs
- PatternMatcher.cs
- MULTI_QI.cs
- UnionQueryOperator.cs
- RemoteDebugger.cs
- GridViewPageEventArgs.cs
- ReferencedCollectionType.cs
- ConditionalWeakTable.cs
- DurableServiceAttribute.cs
- AssemblyNameProxy.cs
- WinEventQueueItem.cs
- HashSetEqualityComparer.cs
- SmiContext.cs
- Random.cs
- AssemblyContextControlItem.cs
- Int32Animation.cs
- PeerTransportElement.cs
- OletxResourceManager.cs
- FrameworkReadOnlyPropertyMetadata.cs
- ButtonDesigner.cs
- ConfigurationSectionGroup.cs
- ApplicationCommands.cs
- WpfKnownMember.cs
- OleDbPermission.cs