-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ConventionalAnnotation to store ConfigurationSource in instead of…
… InternalMetadataBuilder Part of #3476
- Loading branch information
1 parent
57dbddb
commit 00c71db
Showing
26 changed files
with
244 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/EntityFramework.Core/Metadata/Internal/ConventionalAnnotatable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using JetBrains.Annotations; | ||
using Microsoft.Data.Entity.Infrastructure; | ||
|
||
namespace Microsoft.Data.Entity.Metadata.Internal | ||
{ | ||
public class ConventionalAnnotatable : Annotatable | ||
{ | ||
public new virtual IEnumerable<ConventionalAnnotation> GetAnnotations() => base.GetAnnotations().Cast<ConventionalAnnotation>(); | ||
|
||
public virtual ConventionalAnnotation AddAnnotation( | ||
[NotNull] string name, [NotNull] object value, ConfigurationSource configurationSource) | ||
=> (ConventionalAnnotation)base.AddAnnotation(name, CreateAnnotation(name, value, configurationSource)); | ||
|
||
public new virtual ConventionalAnnotation AddAnnotation([NotNull] string name, [NotNull] object value) | ||
=> (ConventionalAnnotation)base.AddAnnotation(name, value); | ||
|
||
public new virtual ConventionalAnnotation GetOrAddAnnotation([NotNull] string name, [NotNull] object value) | ||
=> (ConventionalAnnotation)base.GetOrAddAnnotation(name, value); | ||
|
||
public new virtual ConventionalAnnotation FindAnnotation([NotNull] string name) | ||
=> (ConventionalAnnotation)base.FindAnnotation(name); | ||
|
||
public new virtual ConventionalAnnotation RemoveAnnotation([NotNull] string name) | ||
=> (ConventionalAnnotation)base.RemoveAnnotation(name); | ||
|
||
private ConventionalAnnotation CreateAnnotation( | ||
string name, object value, ConfigurationSource configurationSource) | ||
=> new ConventionalAnnotation(name, value, configurationSource); | ||
|
||
protected override Annotation CreateAnnotation(string name, object value) | ||
=> CreateAnnotation(name, value, ConfigurationSource.Explicit); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/EntityFramework.Core/Metadata/Internal/ConventionalAnnotation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using JetBrains.Annotations; | ||
using Microsoft.Data.Entity.Infrastructure; | ||
|
||
namespace Microsoft.Data.Entity.Metadata.Internal | ||
{ | ||
public class ConventionalAnnotation : Annotation | ||
{ | ||
private ConfigurationSource _configurationSource; | ||
|
||
public ConventionalAnnotation([NotNull] string name, [NotNull] object value, ConfigurationSource configurationSource) | ||
: base(name, value) | ||
{ | ||
_configurationSource = configurationSource; | ||
} | ||
|
||
public ConfigurationSource GetConfigurationSource() => _configurationSource; | ||
|
||
public ConfigurationSource UpdateConfigurationSource(ConfigurationSource configurationSource) | ||
=> _configurationSource = _configurationSource.Max(configurationSource); | ||
} | ||
} |
Oops, something went wrong.