/// <summary />
        public static RepositorySchema Subtract(this RepositorySchema schema1, RepositorySchema schema2)
        {
            try
            {
                //Create new schema init to parent
                var retval = new RepositorySchema();
                retval.LoadXml(schema1.ToXml());

                //Load extension schema, check for errors
                foreach (var f in schema2.FieldList)
                {
                    if (retval.FieldList.Any(x => x.Name.Match(f.Name)))
                    {
                        retval.FieldList.RemoveAll(x => x.Name.Match(f.Name));
                    }
                }

                return(retval);
            }
            catch (Exception ex)
            {
                LoggerCQ.LogError(ex);
                throw;
            }
        }
        /// <summary />
        public static RepositorySchema Merge(this RepositorySchema parentSchema, RepositorySchema schema)
        {
            try
            {
                //Create new schema init to extension
                var retval = new RepositorySchema();
                retval.LoadXml(schema.ToXml());

                //Load extension schema, check for errors
                var index = 0;
                foreach (var f in parentSchema.FieldList)
                {
                    if (retval.FieldList.Any(x => x.Name.Match(f.Name)))
                    {
                        throw new Exception("Field is already defined in the parent object");
                    }
                    else
                    {
                        retval.FieldList.Insert(index++, f);
                    }
                }
                return(retval);
            }
            catch (Exception ex)
            {
                LoggerCQ.LogError(ex);
                throw;
            }
        }
        /// <summary />
        public static RepositorySchema CreateFromXml(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }

            var retval = new RepositorySchema();

            retval.LoadXml(xml);
            return(retval);
        }
 /// <summary />
 public RepositorySchema Clone()
 {
     try
     {
         var retval = new RepositorySchema();
         retval.LoadXml(this.ToXml());
         retval.InternalID  = this.InternalID;
         retval.ChangeStamp = this.ChangeStamp;
         return(retval);
     }
     catch (Exception ex)
     {
         LoggerCQ.LogError(ex);
         throw;
     }
 }