Datei: NDODLL/Mapping/Attributes/FieldAttribute.cs
Last Commit (c39bd40)
1 | -- File didn't exist -- |
New Commit (dff5303)
1 | // |
2 | // Copyright (c) 2002-2016 Mirko Matytschak |
3 | // (www.netdataobjects.de) |
4 | // |
5 | // Author: Mirko Matytschak |
6 | // |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
11 | // conditions: |
12 | |
13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
14 | // of the Software. |
15 | // |
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. |
21 | |
22 | using System; |
23 | using System.ComponentModel; |
24 | |
25 | namespace NDO.Mapping.Attributes |
26 | { |
27 | ····/// <summary> |
28 | ····/// This attribute is used to place hints for the mapping information of fields in the source code |
29 | ····/// </summary> |
30 | ····/// <remarks>Note: This attribute is used like the <see cref="ColumnAttribute">ColumnAttribute</see>. The properties defined with FieldAttribute apply only to fields.</remarks> |
31 | ····[AttributeUsage( AttributeTargets.Field )] |
32 | ····public class FieldAttribute : Attribute |
33 | ····{ |
34 | ········private bool? encrypted; |
35 | |
36 | ········/// <summary> |
37 | ········/// True if the values should be stored encrypted. |
38 | ········/// </summary> |
39 | ········/// <remarks>This property affects the parent <see cref="Field">Field</see> of a column.</remarks> |
40 | ········[Description( "True if the values should be stored encrypted." )] |
41 | ········public bool Encrypted |
42 | ········{ |
43 | ············get => this.encrypted.HasValue ? this.encrypted.Value : false; |
44 | ············set => this.encrypted = value; |
45 | ········} |
46 | |
47 | ········/// <summary> |
48 | ········/// Initializes a given column to the values defined in this ColumnAttribute. |
49 | ········/// </summary> |
50 | ········/// <param name="field">The field to be initialized.</param> |
51 | ········public void SetFieldValues( Field field ) |
52 | ········{ |
53 | ············if (this.encrypted.HasValue) |
54 | ················field.Encrypted = this.encrypted.Value; |
55 | ········} |
56 | |
57 | ········/// <summary> |
58 | ········/// Initializes a given column to the values defined in this ColumnAttribute. |
59 | ········/// </summary> |
60 | ········/// <param name="field">The field to be initialized.</param> |
61 | ········public void RemapField( Field field ) |
62 | ········{ |
63 | ············if (this.encrypted.HasValue && !field.Encrypted) |
64 | ················field.Encrypted = this.encrypted.Value; |
65 | ········} |
66 | ····} |
67 | } |
68 |