public DBVersionInformation(DBVersionAttribute attribute, IDBVersionBody versionBody, DBHistoryAttribute historyAtrriute)
 {
     if (attribute == null)
         throw new ArgumentNullException();
     this.m_attribute = attribute;
     this.m_versionBody = versionBody;
     this.m_historyAtrribute = historyAtrriute;
 }
Example #2
0
 public DBVersionInformation(DBVersionAttribute attribute, IDBVersionBody versionBody, DBHistoryAttribute historyAtrriute)
 {
     if (attribute == null)
     {
         throw new ArgumentNullException();
     }
     this.m_attribute        = attribute;
     this.m_versionBody      = versionBody;
     this.m_historyAtrribute = historyAtrriute;
 }
        /// <summary>
        /// IMPORTANT: if both classes with DBHistory attribute is in the same file then they have the same
        /// assembly. It means, you need to call this function only once, otherwise you'll get an exception,
        /// that you're trying to add method with the same DBVerstionAttribute.Version, which already exists
        /// </summary>
        /// <param name="type"></param>

        public DBVersionRepository AddVersions(Type type)
        {
            m_log.Debug(string.Format("Importing methods from type {0}", type.FullName));
            DBHistoryAttribute dbHistoryAtr = Minder.Engine.AttributeParser.GetAttribute <DBHistoryAttribute>(type);

            if (dbHistoryAtr == null)
            {
                m_log.Debug(string.Format("Type {0} doesn't have DBHistoryAttribute", type.FullName));
                return(this);
            }
            foreach (MethodInfo method in type.GetMethods())
            {
                DBVersionAttribute dbVersionAtr = Minder.Engine.AttributeParser.GetAttribute <DBVersionAttribute>(method);
                if (dbVersionAtr == null)
                {
                    continue;
                }
                m_log.Debug(string.Format("Adding method {0} with {2} {1}", method.Name, dbVersionAtr.Version, dbHistoryAtr.GetType().Name));
                AddVersions(new DBVersionInformation(dbVersionAtr, new DBVersionBodyMethodInfo(method), dbHistoryAtr));
            }
            return(this);
        }