コード例 #1
0
        /// <summary>
        /// Fetch a form object from Perforce.
        /// </summary>
        /// <param name="FormCommand">The form command.</param>
        /// <param name="Args">The args.</param>
        /// <returns>
        /// A Form object.  The fields of the form can be read or updated.  If you update a filed, you can save it with Save_Form.
        /// </returns>
        /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
        public P4Form Fetch_Form(string FormCommand, params string[] Args)
        {
            if (FormCommand == null)
            {
                throw new ArgumentNullException();
            }
            if (Args == null)
            {
                throw new ArgumentNullException();
            }

            string[] AllArgs = new string[Args.Length + 1];
            AllArgs[0] = "-o";

            for (int i = 0; i < Args.Length; i++)
            {
                if (Args[i] == null)
                {
                    throw new ArgumentNullException();
                }
                if (Args[i] == "-o")
                {
                    throw new InvalidFormArgument();
                }
                AllArgs[i + 1] = Args[i];
            }

            EstablishConnection(true);

            P4FormRecordSet     r  = new P4FormRecordSet(FormCommand, m_ClientApi.Encoding);
            P4RecordsetCallback cb = new P4RecordsetCallback(r);

            //RunIt(FormCommand, AllArgs, r.ResultClientUser);
            RunCallback(cb, FormCommand, AllArgs);

            // The Fetch_Form command must always throw an error
            // because there will be no form to return if there's a
            // problem
            if (r.HasErrors())
            {
                throw new FormFetchException(FormCommand, r.ErrorMessage);
            }

            // save the spec def, in case Parse_Form is called in the future
            cachedSpecDefs[FormCommand] = r.Form.SpecDef;

            return(r.Form);
        }
コード例 #2
0
ファイル: P4Connection.cs プロジェクト: orecht/P4.net
        /// <summary>
        /// Fetch a form object from Perforce.
        /// </summary>
        /// <param name="FormCommand">The form command.</param>
        /// <param name="Args">The args.</param>
        /// <returns>
        /// A Form object.  The fields of the form can be read or updated.  If you update a filed, you can save it with Save_Form.
        /// </returns>
        /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
        public P4Form Fetch_Form(string FormCommand, params string[] Args)
        {
            if (FormCommand == null) throw new ArgumentNullException();
            if (Args == null) throw new ArgumentNullException();

            string[] AllArgs = new string[Args.Length + 1];
            AllArgs[0] = "-o";

            for (int i = 0; i < Args.Length ; i++)
            {
                if (Args[i] == null)
                {
                    throw new ArgumentNullException();
                }
                if (Args[i] == "-o")
                {
                    throw new InvalidFormArgument();
                }
                AllArgs[i+1] = Args[i];
            }

            EstablishConnection(true);

            P4FormRecordSet r = new P4FormRecordSet(FormCommand, m_ClientApi.Encoding);
            P4RecordsetCallback cb = new P4RecordsetCallback(r);

            //RunIt(FormCommand, AllArgs, r.ResultClientUser);
            RunCallback(cb, FormCommand, AllArgs);

            // The Fetch_Form command must always throw an error
            // because there will be no form to return if there's a 
            // problem
            if (r.HasErrors())
            {
                throw new FormFetchException(FormCommand, r.ErrorMessage);
            }

            // save the spec def, in case Parse_Form is called in the future
            cachedSpecDefs[FormCommand] = r.Form.SpecDef;

            return r.Form;
        }