Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / Providers / ResourceAssociationSet.cs / 1305376 / ResourceAssociationSet.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Describes an association between two resource sets. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Providers { using System.Diagnostics; using System.Collections.Generic; ////// Class to describe an association between two resource sets. /// [DebuggerDisplay("ResourceAssociationSet: ({End1.ResourceSet.Name}, {End1.ResourceType.Name}, {End1.ResourceProperty.Name}) <-> ({End2.ResourceSet.Name}, {End2.ResourceType.Name}, {End2.ResourceProperty.Name})")] public sealed class ResourceAssociationSet { #region Private Fields ////// Name of the association set. /// private readonly string name; ////// End1 of the association set. /// private readonly ResourceAssociationSetEnd end1; ////// End2 of the association set. /// private readonly ResourceAssociationSetEnd end2; #endregion Private Fields #region Constructor ////// Constructs a resource association set instance. /// /// Name of the association set. /// end1 of the association set. /// end2 of the association set. public ResourceAssociationSet(string name, ResourceAssociationSetEnd end1, ResourceAssociationSetEnd end2) { WebUtil.CheckStringArgumentNull(name, "name"); WebUtil.CheckArgumentNull(end1, "end1"); WebUtil.CheckArgumentNull(end2, "end2"); if (end1.ResourceProperty == null && end2.ResourceProperty == null) { throw new ArgumentException(Strings.ResourceAssociationSet_ResourcePropertyCannotBeBothNull); } if (end1.ResourceType == end2.ResourceType && end1.ResourceProperty == end2.ResourceProperty) { throw new ArgumentException(Strings.ResourceAssociationSet_SelfReferencingAssociationCannotBeBiDirectional); } this.name = name; this.end1 = end1; this.end2 = end2; } #endregion Constructor #region Properties ////// Name of the association set. /// public string Name { [DebuggerStepThrough] get { return this.name; } } ////// Source end of the association set. /// public ResourceAssociationSetEnd End1 { [DebuggerStepThrough] get { return this.end1; } } ////// Target end of the association set. /// public ResourceAssociationSetEnd End2 { [DebuggerStepThrough] get { return this.end2; } } ////// Resource association type for the set. /// internal ResourceAssociationType ResourceAssociationType { get; set; } #endregion Properties #region Methods ////// Retrieve the end for the given resource set, type and property. /// /// resource set for the end /// resource type for the end /// resource property for the end ///Resource association set end for the given parameters internal ResourceAssociationSetEnd GetResourceAssociationSetEnd(ResourceSetWrapper resourceSet, ResourceType resourceType, ResourceProperty resourceProperty) { Debug.Assert(resourceSet != null, "resourceSet != null"); Debug.Assert(resourceType != null, "resourceType != null"); foreach (ResourceAssociationSetEnd end in new[] { this.end1, this.end2 }) { if (end.ResourceSet.Name == resourceSet.Name && end.ResourceType.IsAssignableFrom(resourceType)) { if ((end.ResourceProperty == null && resourceProperty == null) || (end.ResourceProperty != null && resourceProperty != null && end.ResourceProperty.Name == resourceProperty.Name)) { return end; } } } return null; } ////// Retrieve the related end for the given resource set, type and property. /// /// resource set for the source end /// resource type for the source end /// resource property for the source end ///Related resource association set end for the given parameters internal ResourceAssociationSetEnd GetRelatedResourceAssociationSetEnd(ResourceSetWrapper resourceSet, ResourceType resourceType, ResourceProperty resourceProperty) { Debug.Assert(resourceSet != null, "resourceSet != null"); Debug.Assert(resourceType != null, "resourceType != null"); ResourceAssociationSetEnd thisEnd = this.GetResourceAssociationSetEnd(resourceSet, resourceType, resourceProperty); if (thisEnd != null) { return thisEnd == this.End1 ? this.End2 : this.End1; } return null; } #endregion Methods } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Describes an association between two resource sets. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Providers { using System.Diagnostics; using System.Collections.Generic; ////// Class to describe an association between two resource sets. /// [DebuggerDisplay("ResourceAssociationSet: ({End1.ResourceSet.Name}, {End1.ResourceType.Name}, {End1.ResourceProperty.Name}) <-> ({End2.ResourceSet.Name}, {End2.ResourceType.Name}, {End2.ResourceProperty.Name})")] public sealed class ResourceAssociationSet { #region Private Fields ////// Name of the association set. /// private readonly string name; ////// End1 of the association set. /// private readonly ResourceAssociationSetEnd end1; ////// End2 of the association set. /// private readonly ResourceAssociationSetEnd end2; #endregion Private Fields #region Constructor ////// Constructs a resource association set instance. /// /// Name of the association set. /// end1 of the association set. /// end2 of the association set. public ResourceAssociationSet(string name, ResourceAssociationSetEnd end1, ResourceAssociationSetEnd end2) { WebUtil.CheckStringArgumentNull(name, "name"); WebUtil.CheckArgumentNull(end1, "end1"); WebUtil.CheckArgumentNull(end2, "end2"); if (end1.ResourceProperty == null && end2.ResourceProperty == null) { throw new ArgumentException(Strings.ResourceAssociationSet_ResourcePropertyCannotBeBothNull); } if (end1.ResourceType == end2.ResourceType && end1.ResourceProperty == end2.ResourceProperty) { throw new ArgumentException(Strings.ResourceAssociationSet_SelfReferencingAssociationCannotBeBiDirectional); } this.name = name; this.end1 = end1; this.end2 = end2; } #endregion Constructor #region Properties ////// Name of the association set. /// public string Name { [DebuggerStepThrough] get { return this.name; } } ////// Source end of the association set. /// public ResourceAssociationSetEnd End1 { [DebuggerStepThrough] get { return this.end1; } } ////// Target end of the association set. /// public ResourceAssociationSetEnd End2 { [DebuggerStepThrough] get { return this.end2; } } ////// Resource association type for the set. /// internal ResourceAssociationType ResourceAssociationType { get; set; } #endregion Properties #region Methods ////// Retrieve the end for the given resource set, type and property. /// /// resource set for the end /// resource type for the end /// resource property for the end ///Resource association set end for the given parameters internal ResourceAssociationSetEnd GetResourceAssociationSetEnd(ResourceSetWrapper resourceSet, ResourceType resourceType, ResourceProperty resourceProperty) { Debug.Assert(resourceSet != null, "resourceSet != null"); Debug.Assert(resourceType != null, "resourceType != null"); foreach (ResourceAssociationSetEnd end in new[] { this.end1, this.end2 }) { if (end.ResourceSet.Name == resourceSet.Name && end.ResourceType.IsAssignableFrom(resourceType)) { if ((end.ResourceProperty == null && resourceProperty == null) || (end.ResourceProperty != null && resourceProperty != null && end.ResourceProperty.Name == resourceProperty.Name)) { return end; } } } return null; } ////// Retrieve the related end for the given resource set, type and property. /// /// resource set for the source end /// resource type for the source end /// resource property for the source end ///Related resource association set end for the given parameters internal ResourceAssociationSetEnd GetRelatedResourceAssociationSetEnd(ResourceSetWrapper resourceSet, ResourceType resourceType, ResourceProperty resourceProperty) { Debug.Assert(resourceSet != null, "resourceSet != null"); Debug.Assert(resourceType != null, "resourceType != null"); ResourceAssociationSetEnd thisEnd = this.GetResourceAssociationSetEnd(resourceSet, resourceType, resourceProperty); if (thisEnd != null) { return thisEnd == this.End1 ? this.End2 : this.End1; } return null; } #endregion Methods } } // 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
- InfocardClientCredentials.cs
- SQLChars.cs
- StreamGeometry.cs
- SettingsPropertyValueCollection.cs
- ZipIOLocalFileBlock.cs
- ViewPort3D.cs
- IsolatedStorageSecurityState.cs
- DataKeyArray.cs
- DependencyPropertyKey.cs
- HyperlinkAutomationPeer.cs
- UidPropertyAttribute.cs
- X509CertificateRecipientClientCredential.cs
- TrackingMemoryStreamFactory.cs
- ProcessManager.cs
- WsdlBuildProvider.cs
- uribuilder.cs
- ModuleBuilderData.cs
- XMLDiffLoader.cs
- mactripleDES.cs
- Sql8ConformanceChecker.cs
- TreeViewTemplateSelector.cs
- OptimalBreakSession.cs
- SqlDataSourceQueryEditorForm.cs
- DiscoveryDocumentSerializer.cs
- RefreshEventArgs.cs
- SqlUDTStorage.cs
- TableAutomationPeer.cs
- XPathItem.cs
- SqlDataSourceView.cs
- TransactionFlowBindingElement.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- CompositeActivityDesigner.cs
- DataGridTableStyleMappingNameEditor.cs
- ModelFunctionTypeElement.cs
- SerialErrors.cs
- XPathSingletonIterator.cs
- Filter.cs
- DeleteWorkflowOwnerCommand.cs
- SymLanguageType.cs
- AuthenticationManager.cs
- AncestorChangedEventArgs.cs
- SafeNativeMethods.cs
- DurationConverter.cs
- AnimationTimeline.cs
- ImageCollectionCodeDomSerializer.cs
- EntityConnectionStringBuilder.cs
- RelatedEnd.cs
- Filter.cs
- ImplicitInputBrush.cs
- ChannelServices.cs
- ResourcePart.cs
- QuaternionAnimationBase.cs
- CheckBoxStandardAdapter.cs
- HtmlGenericControl.cs
- AccessorTable.cs
- WeakReadOnlyCollection.cs
- BaseDataList.cs
- CollectionViewProxy.cs
- IsolatedStoragePermission.cs
- VariantWrapper.cs
- HashAlgorithm.cs
- UIElementCollection.cs
- DesignerVerbCollection.cs
- TagPrefixCollection.cs
- StateMachineWorkflowDesigner.cs
- AttachmentCollection.cs
- CacheDependency.cs
- NativeMethods.cs
- GeneralTransform3DGroup.cs
- InfoCardArgumentException.cs
- dsa.cs
- Parser.cs
- DataSourceCache.cs
- CapabilitiesRule.cs
- EncryptedKeyIdentifierClause.cs
- GridItemPatternIdentifiers.cs
- XmlSerializerImportOptions.cs
- CancellationTokenSource.cs
- TypeInfo.cs
- TextAutomationPeer.cs
- Events.cs
- DataRecordInfo.cs
- OfTypeExpression.cs
- ModuleElement.cs
- ResourceAssociationSetEnd.cs
- GeometryModel3D.cs
- CommandPlan.cs
- OleDbInfoMessageEvent.cs
- SoapReflectionImporter.cs
- GuidelineSet.cs
- WebPartsPersonalizationAuthorization.cs
- CheckBox.cs
- EmbossBitmapEffect.cs
- loginstatus.cs
- Point4DValueSerializer.cs
- MoveSizeWinEventHandler.cs
- ObjectDataSourceEventArgs.cs
- SimpleTableProvider.cs
- DataGridViewTopRowAccessibleObject.cs
- TemplatePartAttribute.cs