You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@ -0,0 +1,33 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="AdditionalEntityFunctions.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
namespace System.Data.Objects
|
||||
{
|
||||
public static partial class EntityFunctions
|
||||
{
|
||||
/// <summary>
|
||||
/// An ELINQ operator that ensures the input string is treated as a unicode string.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static string AsUnicode(string value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An ELINQ operator that treats the input string as a non-unicode string.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static string AsNonUnicode(string value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,172 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="ComplexObject.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the interface that represent the minimum interface required
|
||||
/// to be an entity in ADO.NET.
|
||||
/// </summary>
|
||||
[DataContract(IsReference = true)]
|
||||
[Serializable]
|
||||
public abstract class ComplexObject : StructuralObject
|
||||
{
|
||||
// The following fields are serialized. Adding or removing a serialized field is considered
|
||||
// a breaking change. This includes changing the field type or field name of existing
|
||||
// serialized fields. If you need to make this kind of change, it may be possible, but it
|
||||
// will require some custom serialization/deserialization code.
|
||||
private StructuralObject _parent; // Object that contains this ComplexObject (can be Entity or ComplexObject)
|
||||
private string _parentPropertyName; // Property name for this type on the containing object
|
||||
|
||||
/// <summary>
|
||||
/// Associate the ComplexType with an Entity or another ComplexObject
|
||||
/// Parent may be an Entity or ComplexObject
|
||||
/// </summary>
|
||||
/// <param name="parent">Object to be added to.</param>
|
||||
/// <param name="parentPropertyName">The property on the parent that reference the complex type.</param>
|
||||
internal void AttachToParent(
|
||||
StructuralObject parent,
|
||||
string parentPropertyName)
|
||||
{
|
||||
Debug.Assert(null != parent, "Attempt to attach to a null parent");
|
||||
Debug.Assert(null != parentPropertyName, "Must provide parentPropertyName in order to attach");
|
||||
|
||||
if (_parent != null)
|
||||
{
|
||||
throw EntityUtil.ComplexObjectAlreadyAttachedToParent();
|
||||
}
|
||||
|
||||
Debug.Assert(_parentPropertyName == null);
|
||||
|
||||
_parent = parent;
|
||||
_parentPropertyName = parentPropertyName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes this instance from the parent it was attached to.
|
||||
/// Parent may be an Entity or ComplexObject
|
||||
/// </summary>
|
||||
internal void DetachFromParent()
|
||||
{
|
||||
// We will null out _parent and _parentPropertyName anyway, so if they are already null
|
||||
// it is an unexpected condition, but should not cause a failure in released code
|
||||
Debug.Assert(_parent != null, "Attempt to detach from a null _parent");
|
||||
Debug.Assert(_parentPropertyName != null, "Null _parentPropertyName on a non-null _parent");
|
||||
|
||||
_parent = null;
|
||||
_parentPropertyName = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reports that a change is about to occur to one of the properties of this instance
|
||||
/// to the containing object and then continues default change
|
||||
/// reporting behavior.
|
||||
/// </summary>
|
||||
protected sealed override void ReportPropertyChanging(
|
||||
string property)
|
||||
{
|
||||
EntityUtil.CheckStringArgument(property, "property");
|
||||
|
||||
base.ReportPropertyChanging(property);
|
||||
|
||||
// Since we are a ComplexObject, all changes (scalar or complex) are considered complex property changes
|
||||
ReportComplexPropertyChanging(null, this, property);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reports a change to one of the properties of this instance
|
||||
/// to the containing object and then continues default change
|
||||
/// reporting behavior.
|
||||
/// </summary>
|
||||
protected sealed override void ReportPropertyChanged(
|
||||
string property)
|
||||
{
|
||||
EntityUtil.CheckStringArgument(property, "property");
|
||||
|
||||
// Since we are a ComplexObject, all changes (scalar or complex) are considered complex property changes
|
||||
ReportComplexPropertyChanged(null, this, property);
|
||||
|
||||
base.ReportPropertyChanged(property);
|
||||
}
|
||||
|
||||
|
||||
internal sealed override bool IsChangeTracked
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parent == null ? false : _parent.IsChangeTracked;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is used to report all changes on this ComplexObject to its parent entity or ComplexObject
|
||||
/// </summary>
|
||||
/// <param name="entityMemberName">
|
||||
/// Should be null in this method override.
|
||||
/// This is only relevant in Entity's implementation of this method, so it is unused here
|
||||
/// Instead of passing the most-derived property name up the hierarchy, we will always pass the current _parentPropertyName
|
||||
/// Once this gets up to the Entity, it will actually use the value that was passed in
|
||||
/// </param>
|
||||
/// <param name="complexObject">
|
||||
/// The instance of the object on which the property is changing.
|
||||
/// </param>
|
||||
/// <param name="complexMemberName">
|
||||
/// The name of the changing property on complexObject.
|
||||
/// </param>
|
||||
internal sealed override void ReportComplexPropertyChanging(
|
||||
string entityMemberName, ComplexObject complexObject, string complexMemberName)
|
||||
{
|
||||
// entityMemberName is unused here because we just keep passing the current parent name up the hierarchy
|
||||
// This value is only used in the EntityObject override of this method
|
||||
|
||||
Debug.Assert(complexObject != null, "invalid complexObject");
|
||||
Debug.Assert(!String.IsNullOrEmpty(complexMemberName), "invalid complexMemberName");
|
||||
|
||||
if (null != _parent)
|
||||
{
|
||||
_parent.ReportComplexPropertyChanging(_parentPropertyName, complexObject, complexMemberName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is used to report all changes on this ComplexObject to its parent entity or ComplexObject
|
||||
/// </summary>
|
||||
/// <param name="entityMemberName">
|
||||
/// Should be null in this method override.
|
||||
/// This is only relevant in Entity's implementation of this method, so it is unused here
|
||||
/// Instead of passing the most-derived property name up the hierarchy, we will always pass the current _parentPropertyName
|
||||
/// Once this gets up to the Entity, it will actually use the value that was passed in.
|
||||
/// </param>
|
||||
/// <param name="complexObject">
|
||||
/// The instance of the object on which the property is changing.
|
||||
/// </param>
|
||||
/// <param name="complexMemberName">
|
||||
/// The name of the changing property on complexObject.
|
||||
/// </param>
|
||||
internal sealed override void ReportComplexPropertyChanged(
|
||||
string entityMemberName, ComplexObject complexObject, string complexMemberName)
|
||||
{
|
||||
// entityMemberName is unused here because we just keep passing the current parent name up the hierarchy
|
||||
// This value is only used in the EntityObject override of this method
|
||||
|
||||
Debug.Assert(complexObject != null, "invalid complexObject");
|
||||
Debug.Assert(!String.IsNullOrEmpty(complexMemberName), "invalid complexMemberName");
|
||||
|
||||
if (null != _parent)
|
||||
{
|
||||
_parent.ReportComplexPropertyChanged(_parentPropertyName, complexObject, complexMemberName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmComplexPropertyAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for complex properties
|
||||
/// Implied default AttributeUsage properties Inherited=True, AllowMultiple=False,
|
||||
/// The metadata system expects this and will only look at the first of each of these attributes, even if there are more.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public sealed class EdmComplexPropertyAttribute : EdmPropertyAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute for complex properties
|
||||
/// </summary>
|
||||
public EdmComplexPropertyAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmComplexTypeAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// attribute for complex types
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
[System.AttributeUsage(AttributeTargets.Class)]
|
||||
public sealed class EdmComplexTypeAttribute: EdmTypeAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// attribute for complex types
|
||||
/// </summary>
|
||||
public EdmComplexTypeAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EntityTypeAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
using System;
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute identifying the Edm base class
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||||
public sealed class EdmEntityTypeAttribute : EdmTypeAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute identifying the Edm base class
|
||||
/// </summary>
|
||||
public EdmEntityTypeAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmEnumTypeAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute indicating an enum type.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
[System.AttributeUsage(AttributeTargets.Enum)]
|
||||
public sealed class EdmEnumTypeAttribute : EdmTypeAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of EdmEnumTypeAttribute class.
|
||||
/// </summary>
|
||||
public EdmEnumTypeAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="FunctionAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the given method is a proxy for an EDM function.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
public sealed class EdmFunctionAttribute : Attribute
|
||||
{
|
||||
private readonly string _namespaceName;
|
||||
private readonly string _functionName;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new EdmFunctionAttribute instance.
|
||||
/// </summary>
|
||||
/// <param name="namespaceName">The namespace name of the EDM function represented by the attributed method</param>
|
||||
/// <param name="functionName">The function name of the EDM function represented by the attributed method</param>
|
||||
public EdmFunctionAttribute(string namespaceName, string functionName)
|
||||
{
|
||||
_namespaceName = namespaceName;
|
||||
_functionName = functionName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The namespace name of the EDM function represented by the attributed method
|
||||
/// </summary>
|
||||
public string NamespaceName { get { return _namespaceName; } }
|
||||
|
||||
/// <summary>
|
||||
/// The function name of the EDM function represented by the attributed method
|
||||
/// </summary>
|
||||
public string FunctionName { get { return _functionName; } }
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmPropertyAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
using System;
|
||||
|
||||
#pragma warning disable 3015 // no accessible constructors which use only CLS-compliant types
|
||||
|
||||
/// <summary>
|
||||
/// Base attribute for properties mapped to store elements.
|
||||
/// Implied default AttributeUsage properties Inherited=True, AllowMultiple=False,
|
||||
/// The metadata system expects this and will only look at the first of each of these attributes, even if there are more.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public abstract class EdmPropertyAttribute: System.Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Only allow derived attributes from this assembly
|
||||
/// </summary>
|
||||
internal EdmPropertyAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmRelationshipNavigationPropertyAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
using System;
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute identifying the Ends defined for a RelationshipSet
|
||||
/// Implied default AttributeUsage properties Inherited=True, AllowMultiple=False,
|
||||
/// The metadata system expects this and will only look at the first of each of these attributes, even if there are more.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public sealed class EdmRelationshipNavigationPropertyAttribute : EdmPropertyAttribute
|
||||
{
|
||||
private string _relationshipNamespaceName;
|
||||
private string _relationshipName;
|
||||
private string _targetRoleName;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute identifying the Ends defined for a RelationshipSet
|
||||
/// </summary>
|
||||
public EdmRelationshipNavigationPropertyAttribute(string relationshipNamespaceName, string relationshipName, string targetRoleName)
|
||||
{
|
||||
_relationshipNamespaceName = relationshipNamespaceName;
|
||||
_relationshipName = relationshipName;
|
||||
_targetRoleName = targetRoleName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the namespace name of the relationship
|
||||
/// </summary>
|
||||
public string RelationshipNamespaceName
|
||||
{
|
||||
get { return _relationshipNamespaceName; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the relationship name
|
||||
/// </summary>
|
||||
public string RelationshipName
|
||||
{
|
||||
get { return _relationshipName; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the target role name
|
||||
/// </summary>
|
||||
public string TargetRoleName
|
||||
{
|
||||
get { return _targetRoleName; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmRelationshipRoleAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
using System.Data.Metadata.Edm; //for RelationshipMultiplicity
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
|
||||
public sealed class EdmRelationshipAttribute : System.Attribute
|
||||
{
|
||||
private readonly string _relationshipNamespaceName;
|
||||
private readonly string _relationshipName;
|
||||
private readonly string _role1Name;
|
||||
private readonly string _role2Name;
|
||||
private readonly RelationshipMultiplicity _role1Multiplicity;
|
||||
private readonly RelationshipMultiplicity _role2Multiplicity;
|
||||
private readonly Type _role1Type;
|
||||
private readonly Type _role2Type;
|
||||
private readonly bool _isForeignKey;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute containing the details for a relationship
|
||||
/// This should match the C-Space relationship information, but having it available in this
|
||||
/// attribute allows us access to this information even in O-Space when there is no context.
|
||||
/// There can be multiple attributes of this type in an assembly.
|
||||
/// </summary>
|
||||
public EdmRelationshipAttribute(string relationshipNamespaceName,
|
||||
string relationshipName,
|
||||
string role1Name,
|
||||
RelationshipMultiplicity role1Multiplicity,
|
||||
Type role1Type,
|
||||
string role2Name,
|
||||
RelationshipMultiplicity role2Multiplicity,
|
||||
Type role2Type)
|
||||
{
|
||||
_relationshipNamespaceName = relationshipNamespaceName;
|
||||
_relationshipName = relationshipName;
|
||||
|
||||
_role1Name = role1Name;
|
||||
_role1Multiplicity = role1Multiplicity;
|
||||
_role1Type = role1Type;
|
||||
|
||||
_role2Name = role2Name;
|
||||
_role2Multiplicity = role2Multiplicity;
|
||||
_role2Type = role2Type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute containing the details for a relationship
|
||||
/// This should match the C-Space relationship information, but having it available in this
|
||||
/// attribute allows us access to this information even in O-Space when there is no context.
|
||||
/// There can be multiple attributes of this type in an assembly.
|
||||
/// </summary>
|
||||
public EdmRelationshipAttribute(string relationshipNamespaceName,
|
||||
string relationshipName,
|
||||
string role1Name,
|
||||
RelationshipMultiplicity role1Multiplicity,
|
||||
Type role1Type,
|
||||
string role2Name,
|
||||
RelationshipMultiplicity role2Multiplicity,
|
||||
Type role2Type,
|
||||
bool isForeignKey)
|
||||
{
|
||||
_relationshipNamespaceName = relationshipNamespaceName;
|
||||
_relationshipName = relationshipName;
|
||||
|
||||
_role1Name = role1Name;
|
||||
_role1Multiplicity = role1Multiplicity;
|
||||
_role1Type = role1Type;
|
||||
|
||||
_role2Name = role2Name;
|
||||
_role2Multiplicity = role2Multiplicity;
|
||||
_role2Type = role2Type;
|
||||
|
||||
_isForeignKey = isForeignKey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the namespace that the relationship is in
|
||||
/// </summary>
|
||||
public string RelationshipNamespaceName
|
||||
{
|
||||
get { return _relationshipNamespaceName; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of a relationship
|
||||
/// </summary>
|
||||
public string RelationshipName
|
||||
{
|
||||
get { return _relationshipName; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the role
|
||||
/// </summary>
|
||||
public string Role1Name
|
||||
{
|
||||
get { return _role1Name; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The multiplicity of the the RoleName in RelationshipName
|
||||
/// </summary>
|
||||
public RelationshipMultiplicity Role1Multiplicity
|
||||
{
|
||||
get { return _role1Multiplicity; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The CLR type for the role associated with this relationship
|
||||
/// </summary>
|
||||
public Type Role1Type
|
||||
{
|
||||
get { return _role1Type; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The name of the role
|
||||
/// </summary>
|
||||
public string Role2Name
|
||||
{
|
||||
get { return _role2Name; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The multiplicity of the the RoleName in RelationshipName
|
||||
/// </summary>
|
||||
public RelationshipMultiplicity Role2Multiplicity
|
||||
{
|
||||
get { return _role2Multiplicity; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The CLR type for the role associated with this relationship
|
||||
/// </summary>
|
||||
public Type Role2Type
|
||||
{
|
||||
get { return _role2Type; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this is a common-value (or FK-based) relationship.
|
||||
/// </summary>
|
||||
public bool IsForeignKey
|
||||
{
|
||||
get { return _isForeignKey; }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmScalarPropertyAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for scalar properties in an IEntity.
|
||||
/// Implied default AttributeUsage properties Inherited=True, AllowMultiple=False,
|
||||
/// The metadata system expects this and will only look at the first of each of these attributes, even if there are more.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public sealed class EdmScalarPropertyAttribute : EdmPropertyAttribute
|
||||
{
|
||||
// Private variables corresponding to their properties.
|
||||
private bool _isNullable = true;
|
||||
private bool _entityKeyProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for scalar properties.
|
||||
/// EdmScalarPropertyAttribute(EntityKeyProperty=[true|false], IsNullable=[true|false])
|
||||
/// IsNullable and EntityKeyProperty cannot both be true.
|
||||
/// </summary>
|
||||
public EdmScalarPropertyAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The property is allowed to have a value of NULL.
|
||||
/// </summary>
|
||||
public bool IsNullable
|
||||
{
|
||||
get { return _isNullable; }
|
||||
set { _isNullable = value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The property is a key.
|
||||
/// </summary>
|
||||
public bool EntityKeyProperty
|
||||
{
|
||||
get { return _entityKeyProperty; }
|
||||
set { _entityKeyProperty = value; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmSchemaAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute for static types
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class EdmSchemaAttribute : System.Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for EdmSchemaAttribute
|
||||
/// </summary>
|
||||
public EdmSchemaAttribute()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Setting this parameter to a unique value for each model file in a Visual Basic
|
||||
/// assembly will prevent the following error:
|
||||
/// "'System.Data.Objects.DataClasses.EdmSchemaAttribute' cannot be specified more than once in this project, even with identical parameter values."
|
||||
/// </summary>
|
||||
public EdmSchemaAttribute(string assemblyGuid)
|
||||
{
|
||||
if (null == assemblyGuid)
|
||||
{
|
||||
throw new System.ArgumentNullException("assemblyGuid");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmTypeAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
#pragma warning disable 3015 // no accessible constructors which use only CLS-compliant types
|
||||
|
||||
/// <summary>
|
||||
/// Base attribute for schematized types
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
public abstract class EdmTypeAttribute: System.Attribute
|
||||
{
|
||||
private string _typeName;
|
||||
private string _namespaceName;
|
||||
|
||||
/// <summary>
|
||||
/// Only allow derived attributes from this assembly
|
||||
/// </summary>
|
||||
internal EdmTypeAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the type that this type maps to in the CSpace
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return _typeName;
|
||||
}
|
||||
set
|
||||
{
|
||||
_typeName = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the namespace of the type that this type maps to in the CSpace
|
||||
/// </summary>
|
||||
public string NamespaceName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _namespaceName;
|
||||
}
|
||||
set
|
||||
{
|
||||
_namespaceName = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,275 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="EntityObject.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the class is the basis for all perscribed EntityObject classes.
|
||||
/// </summary>
|
||||
[DataContract(IsReference=true)]
|
||||
[Serializable]
|
||||
public abstract class EntityObject : StructuralObject, IEntityWithKey, IEntityWithChangeTracker, IEntityWithRelationships
|
||||
{
|
||||
#region Privates
|
||||
|
||||
// The following 2 fields are serialized. Adding or removing a serialized field is considered
|
||||
// a breaking change. This includes changing the field type or field name of existing
|
||||
// serialized fields. If you need to make this kind of change, it may be possible, but it
|
||||
// will require some custom serialization/deserialization code.
|
||||
private RelationshipManager _relationships;
|
||||
private EntityKey _entityKey;
|
||||
|
||||
[NonSerialized]
|
||||
private IEntityChangeTracker _entityChangeTracker = s_detachedEntityChangeTracker;
|
||||
[NonSerialized]
|
||||
private static readonly DetachedEntityChangeTracker s_detachedEntityChangeTracker = new DetachedEntityChangeTracker();
|
||||
|
||||
/// <summary>
|
||||
/// Helper class used when we are not currently attached to a change tracker.
|
||||
/// Simplifies the code so we don't always have to check for null before using the change tracker
|
||||
/// </summary>
|
||||
private class DetachedEntityChangeTracker : IEntityChangeTracker
|
||||
{
|
||||
void IEntityChangeTracker.EntityMemberChanging(string entityMemberName) { }
|
||||
void IEntityChangeTracker.EntityMemberChanged(string entityMemberName) { }
|
||||
void IEntityChangeTracker.EntityComplexMemberChanging(string entityMemberName, object complexObject, string complexMemberName) { }
|
||||
void IEntityChangeTracker.EntityComplexMemberChanged(string entityMemberName, object complexObject, string complexMemberName) { }
|
||||
EntityState IEntityChangeTracker.EntityState
|
||||
{
|
||||
get
|
||||
{
|
||||
return EntityState.Detached;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEntityChangeTracker EntityChangeTracker
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_entityChangeTracker == null)
|
||||
{
|
||||
_entityChangeTracker = s_detachedEntityChangeTracker;
|
||||
}
|
||||
return _entityChangeTracker;
|
||||
}
|
||||
set
|
||||
{
|
||||
_entityChangeTracker = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Publics
|
||||
/// <summary>
|
||||
/// The storage state of this EntityObject
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// This property returns a value from the EntityState enum.
|
||||
/// </value>
|
||||
[System.ComponentModel.Browsable(false)]
|
||||
[System.Xml.Serialization.XmlIgnore]
|
||||
public EntityState EntityState
|
||||
{
|
||||
get
|
||||
{
|
||||
Debug.Assert(EntityChangeTracker != null,
|
||||
"EntityChangeTracker should never return null -- if detached should be set to s_detachedEntityChangeTracker");
|
||||
Debug.Assert(EntityChangeTracker != s_detachedEntityChangeTracker ? EntityChangeTracker.EntityState != EntityState.Detached : true,
|
||||
"Should never get a detached state from an attached change tracker.");
|
||||
|
||||
return EntityChangeTracker.EntityState;
|
||||
}
|
||||
}
|
||||
|
||||
#region IEntityWithKey
|
||||
|
||||
/// <summary>
|
||||
/// Returns the EntityKey for this EntityObject.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DataMember]
|
||||
public EntityKey EntityKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return _entityKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
// Report the change to the change tracker
|
||||
// If we are not attached to a change tracker, we can do anything we want to the key
|
||||
// If we are attached, the change tracker should make sure the new value is valid for the current state
|
||||
Debug.Assert(EntityChangeTracker != null, "_entityChangeTracker should never be null -- if detached it should return s_detachedEntityChangeTracker");
|
||||
EntityChangeTracker.EntityMemberChanging(StructuralObject.EntityKeyPropertyName);
|
||||
_entityKey = value;
|
||||
EntityChangeTracker.EntityMemberChanged(StructuralObject.EntityKeyPropertyName);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region IEntityWithChangeTracker
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Used by the ObjectStateManager to attach or detach this EntityObject to the cache.
|
||||
/// </summary>
|
||||
/// <param name="changeTracker">
|
||||
/// Reference to the ObjectStateEntry that contains this entity
|
||||
/// </param>
|
||||
void IEntityWithChangeTracker.SetChangeTracker(IEntityChangeTracker changeTracker)
|
||||
{
|
||||
// Fail if the change tracker is already set for this EntityObject and it's being set to something different
|
||||
// If the original change tracker is associated with a disposed ObjectStateManager, then allow
|
||||
// the entity to be attached
|
||||
if (changeTracker != null && EntityChangeTracker != s_detachedEntityChangeTracker && !Object.ReferenceEquals(changeTracker, EntityChangeTracker))
|
||||
{
|
||||
EntityEntry entry = EntityChangeTracker as EntityEntry;
|
||||
if (entry == null || !entry.ObjectStateManager.IsDisposed)
|
||||
{
|
||||
throw EntityUtil.EntityCantHaveMultipleChangeTrackers();
|
||||
}
|
||||
}
|
||||
|
||||
EntityChangeTracker = changeTracker;
|
||||
}
|
||||
|
||||
#endregion IEntityWithChangeTracker
|
||||
#region IEntityWithRelationships
|
||||
|
||||
/// <summary>
|
||||
/// Returns the container for the lazily created relationship
|
||||
/// navigation property objects, collections and refs.
|
||||
/// </summary>
|
||||
RelationshipManager IEntityWithRelationships.RelationshipManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_relationships == null)
|
||||
{
|
||||
_relationships = RelationshipManager.Create(this);
|
||||
}
|
||||
|
||||
return _relationships;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
#region Protected Change Tracking Methods
|
||||
|
||||
/// <summary>
|
||||
/// This method is called whenever a change is going to be made to an EntityObject
|
||||
/// property.
|
||||
/// </summary>
|
||||
/// <param name="property">
|
||||
/// The name of the changing property.
|
||||
/// </param>
|
||||
/// <exception cref="System.ArgumentNullException">
|
||||
/// When parameter member is null (Nothing in Visual Basic).
|
||||
/// </exception>
|
||||
protected sealed override void ReportPropertyChanging(
|
||||
string property)
|
||||
{
|
||||
EntityUtil.CheckStringArgument(property, "property");
|
||||
|
||||
Debug.Assert(EntityChangeTracker != null, "_entityChangeTracker should never be null -- if detached it should return s_detachedEntityChangeTracker");
|
||||
|
||||
base.ReportPropertyChanging(property);
|
||||
|
||||
EntityChangeTracker.EntityMemberChanging(property);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called whenever a change is made to an EntityObject
|
||||
/// property.
|
||||
/// </summary>
|
||||
/// <param name="property">
|
||||
/// The name of the changed property.
|
||||
/// </param>
|
||||
/// <exception cref="System.ArgumentNullException">
|
||||
/// When parameter member is null (Nothing in Visual Basic).
|
||||
/// </exception>
|
||||
protected sealed override void ReportPropertyChanged(
|
||||
string property)
|
||||
{
|
||||
EntityUtil.CheckStringArgument(property, "property");
|
||||
|
||||
Debug.Assert(EntityChangeTracker != null, "EntityChangeTracker should never return null -- if detached it should be return s_detachedEntityChangeTracker");
|
||||
EntityChangeTracker.EntityMemberChanged(property);
|
||||
|
||||
base.ReportPropertyChanged(property);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Internal ComplexObject Change Tracking Methods and Properties
|
||||
|
||||
internal sealed override bool IsChangeTracked
|
||||
{
|
||||
get
|
||||
{
|
||||
return EntityState != EntityState.Detached;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called by a ComplexObject contained in this Entity
|
||||
/// whenever a change is about to be made to a property of the
|
||||
/// ComplexObject so that the change can be forwarded to the change tracker.
|
||||
/// </summary>
|
||||
/// <param name="entityMemberName">
|
||||
/// The name of the top-level entity property that contains the ComplexObject that is calling this method.
|
||||
/// </param>
|
||||
/// <param name="complexObject">
|
||||
/// The instance of the ComplexObject on which the property is changing.
|
||||
/// </param>
|
||||
/// <param name="complexMemberName">
|
||||
/// The name of the changing property on complexObject.
|
||||
/// </param>
|
||||
internal sealed override void ReportComplexPropertyChanging(
|
||||
string entityMemberName, ComplexObject complexObject, string complexMemberName)
|
||||
{
|
||||
Debug.Assert(complexObject != null, "invalid complexObject");
|
||||
Debug.Assert(!String.IsNullOrEmpty(complexMemberName), "invalid complexMemberName");
|
||||
|
||||
EntityChangeTracker.EntityComplexMemberChanging(entityMemberName, complexObject, complexMemberName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called by a ComplexObject contained in this Entity
|
||||
/// whenever a change has been made to a property of the
|
||||
/// ComplexObject so that the change can be forwarded to the change tracker.
|
||||
/// </summary>
|
||||
/// <param name="entityMemberName">
|
||||
/// The name of the top-level entity property that contains the ComplexObject that is calling this method.
|
||||
/// </param>
|
||||
/// <param name="complexObject">
|
||||
/// The instance of the ComplexObject on which the property is changing.
|
||||
/// </param>
|
||||
/// <param name="complexMemberName">
|
||||
/// The name of the changing property on complexObject.
|
||||
/// </param>
|
||||
internal sealed override void ReportComplexPropertyChanged(
|
||||
string entityMemberName, ComplexObject complexObject, string complexMemberName)
|
||||
{
|
||||
Debug.Assert(complexObject != null, "invalid complexObject");
|
||||
Debug.Assert(!String.IsNullOrEmpty(complexMemberName), "invalid complexMemberName");
|
||||
|
||||
EntityChangeTracker.EntityComplexMemberChanged(entityMemberName, complexObject, complexMemberName);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,55 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="IEntityChangeTracker.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner sparra
|
||||
// @backupOwner barryfr
|
||||
//---------------------------------------------------------------------
|
||||
using System.Data.Objects;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface is implemented by a change tracker and is used by data classes to report changes
|
||||
/// </summary>
|
||||
public interface IEntityChangeTracker
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to report that a scalar entity property is about to change
|
||||
/// </summary>
|
||||
/// <param name="entityMemberName">The name of the entity property that is changing</param>
|
||||
void EntityMemberChanging(string entityMemberName);
|
||||
|
||||
/// <summary>
|
||||
/// Used to report that a scalar entity property has been changed
|
||||
/// </summary>
|
||||
/// <param name="entityMemberName">The name of the entity property that has changed</param>
|
||||
void EntityMemberChanged(string entityMemberName);
|
||||
|
||||
/// <summary>
|
||||
/// Used to report that a complex property is about to change
|
||||
/// </summary>
|
||||
/// <param name="entityMemberName">The name of the top-level entity property that is changing</param>
|
||||
/// <param name="complexObject">The complex object that contains the property that is changing</param>
|
||||
/// <param name="complexObjectMemberName">The name of the property that is changing on complexObject</param>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "object")]
|
||||
void EntityComplexMemberChanging(string entityMemberName, object complexObject, string complexObjectMemberName);
|
||||
|
||||
/// <summary>
|
||||
/// Used to report that a complex property has been changed
|
||||
/// </summary>
|
||||
/// <param name="entityMemberName">The name of the top-level entity property that has changed</param>
|
||||
/// <param name="complexObject">The complex object that contains the property that changed</param>
|
||||
/// <param name="complexObjectMemberName">The name of the property that changed on complexObject</param>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "object")]
|
||||
void EntityComplexMemberChanged(string entityMemberName, object complexObject, string complexObjectMemberName);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the EntityState from the change tracker, or EntityState.Detached if this
|
||||
/// entity is not being managed by a change tracker
|
||||
/// </summary>
|
||||
EntityState EntityState { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="IEntityWithChangeTracker.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner barryfr
|
||||
// @backupOwner sparra
|
||||
//---------------------------------------------------------------------
|
||||
using System.Data.Objects;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.Data.Objects.DataClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// Minimum interface that a data class must implement in order to be managed by a change tracker.
|
||||
/// </summary>
|
||||
public interface IEntityWithChangeTracker
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the change tracker to provide an interface that the data class will use to report changes.
|
||||
/// </summary>
|
||||
/// <param name="changeTracker">Reference to the change tracker that is managing this entity</param>
|
||||
void SetChangeTracker(IEntityChangeTracker changeTracker);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user