/// <summary>
 /// Sets a dynamic property.
 /// </summary>
 /// <typeparam name="T">Type of the value</typeparam>
 /// <param name="instance">The instance object.</param>
 /// <param name="memberKey">The member key.</param>
 /// <param name="attributeKey">The attribute key.</param>
 /// <param name="value">The value.</param>
 /// <exception cref="System.ArgumentNullException">
 /// instance
 /// or
 /// memberKey
 /// or
 /// attributeKey
 /// </exception>
 public static void SetDynamicProperty <T>(this object instance, object memberKey, PropertyKey <T> attributeKey, T value)
 {
     if (instance == null)
     {
         throw new ArgumentNullException(nameof(instance));
     }
     if (memberKey == null)
     {
         throw new ArgumentNullException(nameof(memberKey));
     }
     if (attributeKey == null)
     {
         throw new ArgumentNullException(nameof(attributeKey));
     }
     ShadowObject.GetOrCreate(instance)[new ShadowObjectPropertyKey(memberKey, attributeKey)] = value;
 }
Beispiel #2
0
        public static CollectionItemIdentifiers GetCollectionItemIds(object instance)
        {
            if (instance.GetType().IsValueType)
            {
                throw new ArgumentException(@"The given instance is a value type and cannot have a item ids attached to it.", nameof(instance));
            }

            var    shadow = ShadowObject.GetOrCreate(instance);
            object result;

            if (shadow.TryGetValue(CollectionItemIdKey, out result))
            {
                return((CollectionItemIdentifiers)result);
            }

            var itemIds = new CollectionItemIdentifiers();

            shadow.Add(CollectionItemIdKey, itemIds);
            return(itemIds);
        }
Beispiel #3
0
        public static void SetId(object instance, Guid id)
        {
            var shadow = ShadowObject.GetOrCreate(instance);

            shadow?.SetId(instance, id);
        }
Beispiel #4
0
        public static Guid GetId(object instance)
        {
            var shadow = ShadowObject.GetOrCreate(instance);

            return(shadow.GetId(instance));
        }