-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncodedEntity.cs
More file actions
108 lines (91 loc) · 3.67 KB
/
Copy pathEncodedEntity.cs
File metadata and controls
108 lines (91 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System;
using System.Collections.Generic;
using Rock.Data;
namespace EntityCoding
{
/// <summary>
/// Describes an Entity object in a portable manner that can be used
/// to re-create the entity on another Rock installation.
/// </summary>
public class EncodedEntity
{
#region Properties
/// <summary>
/// The entity class name that we are describing.
/// </summary>
public string EntityType { get; set; }
/// <summary>
/// The guid to use to check if this entity already exists.
/// </summary>
public Guid Guid { get; set; }
/// <summary>
/// Specifies if this entity should be given a new Guid during import.
/// </summary>
public bool GenerateNewGuid { get; set; }
/// <summary>
/// The values that describe the entities properties.
/// </summary>
public Dictionary<string, object> Properties { get; private set; }
/// <summary>
/// Any processor transform data that is needed to re-create the entity.
/// </summary>
public Dictionary<string, object> Transforms { get; private set; }
/// <summary>
/// List of references that will be used to re-create inter-entity references.
/// </summary>
public List<Reference> References { get; private set; }
#endregion
#region Instance Methods
/// <summary>
/// Create a new instance of an encoded entity.
/// </summary>
public EncodedEntity()
{
Properties = new Dictionary<string, object>();
Transforms = new Dictionary<string, object>();
References = new List<Reference>();
}
/// <summary>
/// Replace a "by id" property that references another entity with a reference
/// object that contains the information we will need to re-create that property
/// at import time.
/// </summary>
/// <param name="originalProperty">The original property name that we are replacing.</param>
/// <param name="entity">The entity that is being referenced.</param>
public void MakePropertyIntoReference( string originalProperty, IEntity entity )
{
Properties.Remove( originalProperty );
if ( entity != null )
{
Reference reference = new Reference( entity, originalProperty );
References.Add( reference );
Properties.Remove( originalProperty );
}
}
/// <summary>
/// Get the transform data value for the given processor.
/// </summary>
/// <param name="name">The full class name of the processor.</param>
/// <returns>An object containing the data for the processor, or null if none was found.</returns>
public object GetTransformData( string name )
{
if ( Transforms.ContainsKey( name ) )
{
return Transforms[name];
}
return null;
}
/// <summary>
/// Add a new transform object to this encoded entity. These are used by EntityProcessor
/// implementations to facilitate in exporting and imported complex entities that need
/// a little extra customization done to them.
/// </summary>
/// <param name="name">The name of the transform, this is the full class name of the processor.</param>
/// <param name="value">The black box value for the transform.</param>
public void AddTransformData( string name, object value )
{
Transforms.Add( name, value );
}
#endregion
}
}