Beispiel #1
0
        /// <summary>
        /// Formats the P4Form as a formated Perforce spec.
        /// </summary>
        /// <returns>String of the formated form spec.</returns>
        public string FormatSpec()
        {
            string ret = null;

            using (p4dn.Error err = new p4dn.Error(_encoding))
            {
                ret = _spec.Format(base.AllFieldDictionary, err);
                if (err.Test())
                {
                    throw new Exceptions.FormParseException(_formCommand, err.Fmt());
                }
            }
            return(ret);
        }
Beispiel #2
0
        /// <summary>
        /// Parses a Perforce form without making a server connection.
        /// </summary>
        /// <param name="formCommand">The command that would otherwise be used to fetch the form.</param>
        /// <param name="specDef">The Perforce 'specdef' for the form.</param>
        /// <param name="formContents">The raw formated form text.</param>
        /// <param name="encoding">Server encoding (either ANSI or UFT-8).</param>
        /// <returns>A Perforce form object.</returns>
        /// <remarks>
        /// LoadFromSpec can be used to parse a form without making a call to the server.
        /// LoadFromSpec can be useful in form triggers.
        /// It does require you to know the SpecDef to call, which can change when upgrading or changing
        /// the server configuration.
        /// </remarks>
        public static P4Form LoadFromSpec(string formCommand, string specDef, string formContents, System.Text.Encoding encoding)
        {
            p4dn.Spec spec = new p4dn.Spec(specDef, encoding);
            Hashtable ht   = null;

            using (p4dn.Error err = new p4dn.Error(encoding))
            {
                ht = spec.Parse(formContents, err);
                if (err.Test())
                {
                    throw new Exceptions.FormParseException(formCommand, err.Fmt());
                }
            }
            return(new P4Form(formCommand, specDef, ht, encoding));
        }
Beispiel #3
0
        /// <summary>
        /// Parses a Perforce form without making a server connection.
        /// </summary>
        /// <param name="formCommand">The command that would otherwise be used to fetch the form.</param>
        /// <param name="specDef">The Perforce 'specdef' for the form.</param>
        /// <param name="formContents">The raw formated form text.</param>
        /// <param name="encoding">Server encoding (either ANSI or UFT-8).</param>
        /// <returns>A Perforce form object.</returns>
        /// <remarks>
        /// LoadFromSpec can be used to parse a form without making a call to the server.  
        /// LoadFromSpec can be useful in form triggers.
        /// It does require you to know the SpecDef to call, which can change when upgrading or changing
        /// the server configuration.
        /// </remarks>
        public static P4Form LoadFromSpec(string formCommand, string specDef, string formContents, System.Text.Encoding encoding)
        {

            p4dn.Spec spec = new p4dn.Spec(specDef, encoding);
            Dictionary<string, string> ht = null;
            using (p4dn.Error err = new p4dn.Error(encoding))
            {
                ht = spec.Parse(formContents, err);
                if (err.Test())
                {
                    throw new Exceptions.FormParseException(formCommand, err.Fmt());
                }
            }
            return new P4Form(formCommand, specDef, ht, encoding);

        }
Beispiel #4
0
 /// <summary>
 /// Formats the P4Form as a formated Perforce spec.
 /// </summary>
 /// <returns>String of the formated form spec.</returns>
 public string FormatSpec()
 {
     string ret = null;
     using (p4dn.Error err = new p4dn.Error(_encoding))
     {
         ret = _spec.Format(base.AllFieldDictionary, err);
         if (err.Test())
         {
             throw new Exceptions.FormParseException(_formCommand, err.Fmt());
         }
     }
     return ret;
 }