示例#1
0
        /// <summary>
        /// Reads the attributes of this parameter and returns true if it was a known attribute.
        /// Otherwise returns the base method output
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            bool b = true;

            if (this.IsAttributeMatch(XmlHelper.ParameterDirection, reader, context) && !string.IsNullOrEmpty(reader.Value))
            {
                this.Direction = XmlHelper.ParseEnum <System.Data.ParameterDirection>(reader.Value);
            }
            else if (this.IsAttributeMatch(XmlHelper.ParameterSize, reader, context) && !string.IsNullOrEmpty(reader.Value))
            {
                this.Size = int.Parse(reader.Value);
            }
            else if (this.IsAttributeMatch(XmlHelper.Name, reader, context))
            {
                this.Name = reader.Value;
            }
            else if (this.IsAttributeMatch(XmlHelper.DbType, reader, context) && !string.IsNullOrEmpty(reader.Value))
            {
                this.DbType = XmlHelper.ParseEnum <System.Data.DbType>(reader.Value);
            }
            else
            {
                b = base.ReadAnAttribute(reader, context);
            }

            return(b);
        }
示例#2
0
        /// <summary>
        /// Reads each inner Xml element and returns true if it was a known xml element
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            bool b;

            if (this.IsElementMatch(XmlHelper.Into, reader, context) && !reader.IsEmptyElement && reader.Read())
            {
                this._into = (DBTable)this.ReadNextInnerClause(XmlHelper.Into, reader, context);
                b          = true;
            }
            else if (this.IsElementMatch(XmlHelper.Fields, reader, context))
            {
                this._fields = (DBSelectSet)context.Factory.Read(XmlHelper.Fields, reader, context);
                b            = true;
            }
            else if (this.IsElementMatch(XmlHelper.Values, reader, context))
            {
                this._values = (DBValueSet)context.Factory.Read(XmlHelper.Values, reader, context);
                b            = true;
            }
            else if (this.IsElementMatch(XmlHelper.Select, reader, context))
            {
                this._innerselect = (DBSelectQuery)context.Factory.Read(XmlHelper.Select, reader, context);
                this._innerselect.IsInnerQuery = true;
                b = true;
            }
            else
            {
                b = base.ReadAnInnerElement(reader, context);
            }

            return(b);
        }
示例#3
0
        /// <summary>
        /// Overrides the default implementation to read the table, assignments and where elements
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            bool b;

            if (this.IsElementMatch(XmlHelper.From, reader, context))
            {
                this.TableSet = (DBTableSet)context.Factory.Read(XmlHelper.From, reader, context);
                b             = true;
            }
            else if (this.IsElementMatch(XmlHelper.Assignments, reader, context))
            {
                this.AssignSet = (DBAssignSet)context.Factory.Read(XmlHelper.Assignments, reader, context);
                b = true;
            }
            else if (this.IsElementMatch(XmlHelper.Where, reader, context))
            {
                this.WhereSet = (DBFilterSet)context.Factory.Read(XmlHelper.Where, reader, context);
                b             = true;
            }
            else
            {
                b = base.ReadAnInnerElement(reader, context);
            }


            return(b);
        }
示例#4
0
 protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (IsAttributeMatch(XmlHelper.UpdateAction, reader, context))
     {
         this.OnUpdateAction = XmlHelper.ParseEnum <DBFKAction>(reader.Value);
         return(true);
     }
     else if (IsAttributeMatch(XmlHelper.DeleteAction, reader, context))
     {
         this.OnDeleteAction = XmlHelper.ParseEnum <DBFKAction>(reader.Value);
         return(true);
     }
     else if (IsAttributeMatch(XmlHelper.ReferenceOwner, reader, context))
     {
         this.ReferenceOwner = reader.Value;
         return(true);
     }
     else if (IsAttributeMatch(XmlHelper.ReferenceTable, reader, context))
     {
         this.ReferenceName = reader.Value;
         return(true);
     }
     else
     {
         return(base.ReadAnAttribute(reader, context));
     }
 }
示例#5
0
        /// <summary>
        /// Parses the XML data and generates the list of DBClauses from this.
        /// </summary>
        /// <param name="endElement"></param>
        /// <param name="reader"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public bool ReadXml(string endElement, System.Xml.XmlReader reader, XmlReaderContext context)
        {
            bool isEmpty = reader.IsEmptyElement && XmlHelper.IsElementMatch(endElement, reader, context);

            do
            {
                if (reader.NodeType == System.Xml.XmlNodeType.Element)
                {
                    DBClause c = context.Factory.Read(reader.LocalName, reader, context);
                    if (c != null)
                    {
                        this.Add(c);
                    }

                    if (isEmpty)
                    {
                        return(true);
                    }
                }

                if (reader.NodeType == System.Xml.XmlNodeType.EndElement && XmlHelper.IsElementMatch(endElement, reader, context))
                {
                    break;
                }
            }while (reader.Read());

            return(true);
        }
示例#6
0
        /// <summary>
        /// Reads any known iner elements
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            if (reader.NodeType == System.Xml.XmlNodeType.Text && reader.Value == XmlHelper.NullString)
            {
                this.Value = DBNull.Value;
            }
            else
            {
                if (reader.IsEmptyElement == false)
                {
                    string end = reader.LocalName;

                    do
                    {
                        if (reader.NodeType == System.Xml.XmlNodeType.EndElement && this.IsElementMatch(end, reader, context))
                        {
                            break;
                        }
                        else if (reader.NodeType == System.Xml.XmlNodeType.Element && this.IsElementMatch(XmlHelper.ParameterValue, reader, context))
                        {
                            this.Value = XmlHelper.ReadNativeValue(reader, context);
                        }
                    }while (reader.Read());
                }
            }
            return(base.ReadAnInnerElement(reader, context));
        }
示例#7
0
        //
        // Xml read methods
        //

        #region public bool ReadXml(System.Xml.XmlReader reader, XmlReaderContext context)

        /// <summary>
        /// Reads the element the reader is positioned at - initially reading the attributes then any inner elements
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public bool ReadXml(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            string name    = reader.LocalName;
            bool   isEmpty = reader.IsEmptyElement;

            if (reader.HasAttributes)
            {
                this.ReadAllAttributes(reader, context);
            }
            if (!isEmpty)
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element ||
                        reader.NodeType == XmlNodeType.Entity ||
                        reader.NodeType == XmlNodeType.CDATA ||
                        reader.NodeType == XmlNodeType.ProcessingInstruction ||
                        reader.NodeType == XmlNodeType.Text)
                    {
                        this.ReadAnInnerElement(reader, context);
                    }
                    if (reader.NodeType == XmlNodeType.EndElement && XmlHelper.IsElementMatch(name, reader, context))
                    {
                        break;
                    }
                }
            }
            return(true);
        }
示例#8
0
        protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            bool b;

            if (this.IsAttributeMatch(XmlHelper.Owner, reader, context))
            {
                this.TableOwner = reader.Value;
                b = true;
            }
            else if (this.IsAttributeMatch(XmlHelper.Name, reader, context))
            {
                this.TableName = reader.Value;
                b = true;
            }
            else if (this.IsAttributeMatch(XmlHelper.Temp, reader, context))
            {
                bool temp;
                if (bool.TryParse(reader.Value, out temp))
                {
                    this.Temporary = temp;
                }
                b = true;
            }
            else
            {
                b = base.ReadAnAttribute(reader, context);
            }

            return(b);
        }
示例#9
0
        protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            bool b = false;

            if (this.IsElementMatch(XmlHelper.Compare, reader, context) &&
                !reader.IsEmptyElement && reader.Read())
            {
                this.CompareTo = this.ReadNextInnerClause(XmlHelper.Compare, reader, context);
                b = (this.CompareTo != null);
            }
            else if (this.IsElementMatch(XmlHelper.MinValue, reader, context) &&
                     !reader.IsEmptyElement && reader.Read())
            {
                this.MinValue = this.ReadNextInnerClause(XmlHelper.MinValue, reader, context);
                b             = (this.MinValue != null);
            }
            else if (this.IsElementMatch(XmlHelper.MaxValue, reader, context) &&
                     !reader.IsEmptyElement && reader.Read())
            {
                this.MaxValue = this.ReadNextInnerClause(XmlHelper.MaxValue, reader, context);
                b             = (this.MaxValue != null);
            }
            else
            {
                b = base.ReadAnInnerElement(reader, context);
            }

            return(b);
        }
示例#10
0
        public bool ReadXml(string endElement, XmlReader reader, XmlReaderContext context)
        {
            bool isEmpty = reader.IsEmptyElement && XmlHelper.IsElementMatch(endElement, reader, context);

            do
            {
                if (reader.NodeType == System.Xml.XmlNodeType.Element)
                {
                    DBParam p = DBParam.Param();
                    this.Add(p);

                    if (isEmpty)
                    {
                        return(true);
                    }
                }

                if (reader.NodeType == System.Xml.XmlNodeType.EndElement && XmlHelper.IsElementMatch(endElement, reader, context))
                {
                    break;
                }
            }while (reader.Read());

            return(true);
        }
示例#11
0
        protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            bool b;

            if (this.IsAttributeMatch(XmlHelper.Owner, reader, context))
            {
                this.Owner = reader.Value;
                b          = true;
            }
            else if (this.IsAttributeMatch(XmlHelper.Name, reader, context))
            {
                this.Name = reader.Value;
                b         = true;
            }
            else if (this.IsAttributeMatch(XmlHelper.Alias, reader, context))
            {
                this.Alias = reader.Value;
                b          = true;
            }
            else
            {
                b = base.ReadAnAttribute(reader, context);
            }

            return(b);
        }
示例#12
0
 protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (this.IsElementMatch(XmlHelper.ColumnList, reader, context))
     {
         this.ColumnOrders.ReadXml(XmlHelper.ColumnList, reader, context);
         return(true);
     }
     return(base.ReadAnInnerElement(reader, context));
 }
示例#13
0
 protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (this.IsAttributeMatch(XmlHelper.Name, reader, context))
     {
         this.SequenceName = reader.Value;
         return(true);
     }
     else if (this.IsAttributeMatch(XmlHelper.Owner, reader, context))
     {
         this.Owner = reader.Value;
         return(true);
     }
     else if (this.IsAttributeMatch(XmlHelper.SequenceMin, reader, context))
     {
         this.MinValue = int.Parse(reader.Value);
         return(true);
     }
     else if (this.IsAttributeMatch(XmlHelper.SequenceMax, reader, context))
     {
         this.MaxValue = int.Parse(reader.Value);
         return(true);
     }
     else if (this.IsAttributeMatch(XmlHelper.SequenceStart, reader, context))
     {
         this.StartWithValue = int.Parse(reader.Value);
         return(true);
     }
     else if (this.IsAttributeMatch(XmlHelper.SequenceIncrement, reader, context))
     {
         this.IncrementValue = int.Parse(reader.Value);
         return(true);
     }
     else if (this.IsAttributeMatch(XmlHelper.SequenceNoCache, reader, context))
     {
         this.CacheSize = NO_CACHE_VALUE;
         return(true);
     }
     else if (this.IsAttributeMatch(XmlHelper.SequenceCache, reader, context))
     {
         this.CacheSize = int.Parse(reader.Value);
         return(true);
     }
     else if (this.IsAttributeMatch(XmlHelper.SequenceCycling, reader, context))
     {
         this.Cycling = XmlHelper.ParseEnum <DBSequenceCycling>(reader.Value);
         return(true);
     }
     else if (this.IsAttributeMatch(XmlHelper.SequenceOrdering, reader, context))
     {
         this.Order = XmlHelper.ParseEnum <DBSequenceOrdering>(reader.Value);
         return(true);
     }
     else
     {
         return(base.ReadAnAttribute(reader, context));
     }
 }
示例#14
0
 protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (IsElementMatch(XmlHelper.ColumnList, reader, context))
     {
         this.PKColumns = new DBColumnList();
         this.PKColumns.ReadReferenceXml(reader, context);
         return(true);
     }
     return(base.ReadAnInnerElement(reader, context));
 }
示例#15
0
 protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (IsAttributeMatch(XmlHelper.HintOption, reader, context))
     {
         object val = XmlHelper.ParseEnum <DBTableHint>(reader.Value);
         this.Option = (DBTableHint)val;
         return(true);
     }
     return(base.ReadAnAttribute(reader, context));
 }
示例#16
0
 protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (this.IsAttributeMatch(XmlHelper.Name, reader, context))
     {
         this.DBName = reader.Value;
         return(true);
     }
     else
     {
         return(base.ReadAnAttribute(reader, context));
     }
 }
示例#17
0
 protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (this.IsAttributeMatch(XmlHelper.CheckExists, reader, context))
     {
         this.CheckExists = XmlHelper.ParseEnum <DBExistState>(reader.Value);
         return(true);
     }
     else
     {
         return(base.ReadAnAttribute(reader, context));
     }
 }
示例#18
0
 protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (this.IsElementMatch(XmlHelper.Assign, reader, context))
     {
         this.Assignment = context.Factory.Read(XmlHelper.Assign, reader, context) as DBAssign;
         return(this.Assignment != null);
     }
     else
     {
         return(base.ReadAnInnerElement(reader, context));
     }
 }
示例#19
0
        //
        // Xml match methods
        //

        #region public static bool IsAttributeMatch(string attrName, XmlReader reader, XmlReaderContext context)

        public static bool IsAttributeMatch(string attrName, XmlReader reader, XmlReaderContext context)
        {
            if (context.QualifiedAttribute)
            {
                bool pre  = string.Equals(reader.Prefix, context.Prefix, StringComparison.Ordinal);
                bool attr = string.Equals(reader.LocalName, attrName, StringComparison.Ordinal);
                return(attr && pre);
            }
            else
            {
                return(string.Equals(reader.LocalName, attrName));
            }
        }
示例#20
0
 /// <summary>
 /// Reads the element attribute(s)
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (IsAttributeMatch(XmlHelper.HintOption, reader, context))
     {
         object parsed = XmlHelper.ParseEnum <DBQueryOption>(reader.Value);
         this.Option = (DBQueryOption)parsed;
         return(true);
     }
     else
     {
         return(base.ReadAnAttribute(reader, context));
     }
 }
示例#21
0
 protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (this.IsElementMatch("to-return", reader, context))
     {
         DBClause ret = this.ReadNextInnerClause("to-return", reader, context);
         this.ToReturn = ret;
         return(true);
     }
     else
     {
         return(base.ReadAnInnerElement(reader, context));
     }
 }
示例#22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            Operator op;

            if (reader.LocalName == XmlHelper.Operator)
            {
                object value = XmlHelper.ParseEnum <Operator>(reader.LocalName);
                op             = (Operator)value;
                this.Operation = op;
            }

            return(base.ReadAnAttribute(reader, context));
        }
示例#23
0
        protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            DBClause c = context.Factory.Read(reader.Name, reader, context);

            if (c is DBQuery)
            {
                this.InnerQuery = (DBQuery)c;
                return(true);
            }
            else
            {
                throw new InvalidCastException(Errors.CanOnlyUseQueriesInInnerSelects);
            }
        }
示例#24
0
        //
        // XML Serialization
        //

        protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            if (this.IsElementMatch(XmlHelper.TableHint, reader, context))
            {
                DBTableHintOption inner = DBTableHintOption.Empty();
                inner.ReadXml(reader, context);
                this.Hints.Add(inner);
                return(true);
            }
            else
            {
                return(base.ReadAnInnerElement(reader, context));
            }
        }
示例#25
0
 /// <summary>
 /// Reads any inner elements
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (IsElementMatch(XmlHelper.HintParameter, reader, context))
     {
         reader.Read();
         DBClause clause = this.ReadNextInnerClause(XmlHelper.HintParameter, reader, context);
         this.Clause = clause;
         return(true);
     }
     else
     {
         return(base.ReadAnInnerElement(reader, context));
     }
 }
示例#26
0
        protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            DBClause c = this.ReadNextInnerClause(reader.Name, reader, context);

            if (c is DBStatement)
            {
                this.Select = c as DBStatement;
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#27
0
文件: DBJoin.cs 项目: jschmer/dynasql
 protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
 {
     if (IsAttributeMatch(XmlHelper.JoinType, reader, context))
     {
         string   value = reader.Value;
         JoinType result;
         if (string.IsNullOrEmpty(value) == false && XmlHelper.TryParseEnum <JoinType>(value, out result))
         {
             this.JoinType = result;
             return(true);
         }
     }
     return(base.ReadAnAttribute(reader, context));
 }
示例#28
0
        protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            DBClause c = context.Factory.Read(reader.LocalName, reader, context);

            if (c != null)
            {
                this.Groupings.Add(c);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#29
0
        protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            DBClause filter = context.Factory.Read(reader.LocalName, reader, context);

            if (filter == null)
            {
                return(false);
            }
            else
            {
                this.Filters = filter;
                return(true);
            }
        }
示例#30
0
        protected override bool ReadAnAttribute(System.Xml.XmlReader reader, XmlReaderContext context)
        {
            bool b = true;

            if (this.IsAttributeMatch(XmlHelper.Operator, reader, context))
            {
                this.CompareOperator = XmlHelper.ParseEnum <Compare>(reader.Value);
            }
            else
            {
                b = base.ReadAnAttribute(reader, context);
            }

            return(b);
        }