/// <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;
            }
        }
Beispiel #3
0
        /// <summary />
        public virtual bool FromUrl(string url)
        {
            try
            {
                var svalues = url.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                if (svalues.Length < 3)
                {
                    return(false);
                }

                Datastore.Common.ComparisonConstants enumValue;
                if (!Enum.TryParse <Datastore.Common.ComparisonConstants>(svalues[1], true, out enumValue))
                {
                    return(false);
                }

                if (svalues.Length == 5 &&
                    enumValue != ComparisonConstants.ContainsAll &&
                    enumValue != ComparisonConstants.ContainsAny &&
                    enumValue != ComparisonConstants.ContainsNone)
                {
                    if (string.IsNullOrEmpty(svalues[0]))
                    {
                        return(false);
                    }
                    if (!(this is GeoCodeFieldFilter))
                    {
                        return(false);
                    }

                    this.Name     = svalues[0];
                    this.Comparer = enumValue;
                    ((GeoCodeFieldFilter)this).Latitude  = svalues[2].ToDouble();
                    ((GeoCodeFieldFilter)this).Longitude = svalues[3].ToDouble();
                    ((GeoCodeFieldFilter)this).Radius    = svalues[4].ToInt();
                }
                else if (svalues.Length >= 3)
                {
                    if (string.IsNullOrEmpty(svalues[0]))
                    {
                        return(false);
                    }

                    this.Name     = svalues[0];
                    this.Comparer = enumValue;
                    ((IFieldFilter)this).Value = svalues[2];
                }
                return(true);
            }
            catch (Exception ex)
            {
                LoggerCQ.LogError(ex);
                throw;
            }
        }
 /// <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;
     }
 }