Beispiel #1
0
        /// <summary>
        /// Parse the raw text of a Perforce form into a P4Form object
        /// </summary>
        /// <param name="formCommand">The form command.</param>
        /// <param name="formContents">Raw contents of the form spec.</param>
        /// <returns>
        /// A P4Form 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 Parse_Form(string formCommand, string formContents)
        {
            // logic stolen from P4Ruby.  Cache the spec defs, and load a form from the cached specdefs.

            // If we don't have a cached Spec def, we need to create a dummy form to get it in the cache
            if (!cachedSpecDefs.ContainsKey(formCommand))
            {
                string bogusSpec = "__p4net_bogus_spec__";
                P4Form outputForm;

                //
                // For specs of the following types we need the bogus spec name
                //
                if (formCommand == "branch" || formCommand == "label" || formCommand == "depot" || formCommand == "group")
                {
                    outputForm = Fetch_Form(formCommand, bogusSpec);
                }
                else
                {
                    outputForm = Fetch_Form(formCommand);
                }
            }

            return(P4Form.LoadFromSpec(formCommand, cachedSpecDefs[formCommand], formContents, m_ClientApi.Encoding));
        }