/// <summary>
 /// Initializes a new instance of this class.
 /// Used internally to initialize the structure on materialization.
 /// </summary>
 /// <param name="owner">The owner of this instance.</param>
 /// <param name="field">The owner field that describes this instance.</param>
 protected Structure(Persistent owner, FieldInfo field)
     : base(owner.Session)
 {
     try {
         typeInfo = GetTypeInfo();
         Owner    = owner;
         Field    = field;
         if (owner == null || field == null)
         {
             tuple = typeInfo.TuplePrototype.Clone();
         }
         else
         {
             tuple = field.ExtractValue(
                 new ReferencedTuple(() => Owner.Tuple));
         }
         SystemBeforeInitialize(true);
         InitializeOnMaterialize();
     }
     catch (Exception error) {
         InitializationErrorOnMaterialize(error);
         throw;
     }
 }
Example #2
0
 internal static void ExecuteOnValidate(Persistent target)
 {
     target.OnValidate();
 }
 private static Key GetOwnerKey(Persistent owner)
 {
     return(owner is IFieldValueAdapter asFieldValueAdapter
 ? GetOwnerKey(asFieldValueAdapter.Owner)
 : ((Entity)owner).Key);
 }