Пример #1
0
        /// <summary>
        /// Looks in this instances commands for a matching command -
        /// either the first command if name is not set, or the command with the matching name.
        /// </summary>
        /// <param name="cmdName"></param>
        /// <param name="found"></param>
        /// <returns></returns>
        private bool GetCommandToExecute(string cmdName, out XPathProviderCommandBase found)
        {
            if (string.IsNullOrEmpty(cmdName))
            {
                if (this.HasCommands)
                {
                    found = this.Commands[0];
                }
                else
                {
                    found = null;
                }

                return(found != null);
            }
            else
            {
                if (this.HasCommands)
                {
                    found = this.Commands[cmdName];
                }
                else
                {
                    found = null;
                }

                if (null == found)
                {
                    throw new NullReferenceException(string.Format(Errors.CommandWithNameCannotBeFound, cmdName, this.ID));
                }

                return(true);
            }
        }
Пример #2
0
        /// <summary>
        /// Fills the data into the dataset from the releated command, and then adds the relation constraint to the data set.
        /// </summary>
        /// <param name="rel"></param>
        /// <param name="ds"></param>
        /// <param name="source"></param>
        /// <param name="context"></param>
        protected virtual void FillRelatedData(DataRelation rel, DataSet ds, XPathDataSourceBase source, PDFDataContext context)
        {
            string cmd = rel.ChildCommand;
            XPathProviderCommandBase provider = source.Commands[cmd];

            if (null == provider)
            {
                throw new NullReferenceException(string.Format(Errors.CommandWithNameCannotBeFound, cmd, source.ID));
            }
            if (!(provider is IPDFDataSetProviderCommand))
            {
                throw new InvalidCastException(string.Format(Errors.CommandForRelatedDataMustMatchType, typeof(SqlProviderCommand), typeof(SqlProviderCommand)));
            }

            IPDFDataSetProviderCommand dsProvider = (IPDFDataSetProviderCommand)provider;

            dsProvider.FillData(ds, source, this, context);

            rel.AddRelation(this, dsProvider, ds, context);
        }