Exemplo n.º 1
0
        public static long GetTypeId(CompositeKeyAuditRepoData instance, out object dynamicInstance, out Type dynamicType)
        {
            dynamicInstance = instance.ToDictionary();
            Type type = instance.GetType();

            dynamicType = type;
            return(GetTypeId(type));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the id on the specified instance then returns journal entries for all of the properties.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        public static IEnumerable <JournalEntry> FromInstance(CompositeKeyAuditRepoData instance, Journal journal = null)
        {
            Args.ThrowIfNull(instance, "instance");
            Type type   = instance.GetType();
            long typeId = TypeMap.GetTypeId(type);

            instance.Id = instance.GetULongKeyHash();
            foreach (PropertyInfo prop in GetProperties(type))
            {
                yield return(new JournalEntry {
                    Journal = journal, TypeId = typeId, InstanceId = instance.Id, PropertyId = TypeMap.GetPropertyId(prop, out string i), Value = prop.GetValue(instance)?.ToString()
                });