Beispiel #1
0
        /// <summary>
        ///     Specifies a global site property and other options.
        /// </summary>
        /// <param name="propertyName">the name of the property to be retrieved</param>
        /// <param name="defaultValue">the default value to use if the property is not found</param>
        /// <param name="autoHyperlinkType">specifies how to handle hyperlinks <see cref="CAML.AutoHyperlinkType" /></param>
        /// <param name="autoNewLine">
        ///     TRUE to insert &lt;BR&gt; tags into the text stream and to replace multiple spaces with a
        ///     nonbreaking space.
        /// </param>
        /// <param name="expandXML">
        ///     TRUE to re-pass the rendered content through the CAML interpreter, which allows CAML to render
        ///     CAML.
        /// </param>
        /// <param name="htmlEncode">
        ///     TRUE to convert embedded characters so that they are displayed as text in the browser.  In
        ///     other words, characters that could be confused with HTML tags are converted to entities.
        /// </param>
        /// <param name="stripWhiteSpace">
        ///     TRUE to remove white space from the beginning and end of the value returned by the
        ///     element.
        /// </param>
        /// <param name="urlEncodingType">specifies how to handle URL encoding <see cref="CAML.UrlEncodingType" /></param>
        /// <returns></returns>
        public static string ProjectProperty(
            string propertyName,
            string defaultValue,
            AutoHyperlinkType autoHyperlinkType,
            bool autoNewLine,
            bool expandXML,
            bool htmlEncode,
            bool stripWhiteSpace,
            UrlEncodingType urlEncodingType)
        {
            var attributes = new[]
            {
                new XAttribute(Resources.Resources.Select, propertyName),
                new XAttribute(Resources.Resources.Default, defaultValue),
                new XAttribute(
                    autoHyperlinkType == AutoHyperlinkType.Plain
                        ? Resources.Resources.AutoHyperLinkNoEncoding
                        : Resources.Resources.AutoHyperLink,
                    BoolToString(autoHyperlinkType == AutoHyperlinkType.None)
                    ),
                new XAttribute(Resources.Resources.AutoNewLine, BoolToString(autoNewLine)),
                new XAttribute(Resources.Resources.HTMLEncode, BoolToString(htmlEncode)),
                new XAttribute(Resources.Resources.StripWS, BoolToString(stripWhiteSpace)),
                new XAttribute(
                    urlEncodingType == UrlEncodingType.EncodeAsUrl
                        ? Resources.Resources.URLEncodeAsURL
                        : Resources.Resources.URLEncode,
                    BoolToString(urlEncodingType != UrlEncodingType.None)
                    )
            };

            return(Base.Tag(Resources.Resources.ProjectProperty, attributes).ToStringBySettings());
        }
Beispiel #2
0
        /// <summary>
        /// Returns a string of query parameters with a specified separator and encoding parameters.
        /// </summary>
        /// <param name="separator">The separator of query parameters.</param>
        /// <param name="encodingType">The type of the encoder.</param>
        /// <param name="parametersType">The types of parameters to be used.</param>
        public string ToStringParameters(string separator, UrlEncodingType encodingType, HttpParameterType parametersType)
        {
            string result = "";

            foreach (var itm in this)
            {
                // ignore files and request body
                if (itm.GetType() == typeof(HttpFile) || itm.GetType() == typeof(HttpRequestBody))
                {
                    continue;
                }
                // ignore common parameters, if specified in the rule
                // note: !parametersType.HasFlag(HttpParameterType.Unformed) is not supported in the .net framework 3.5
                if (itm.GetType() != typeof(HttpUrlParameter) && (parametersType & HttpParameterType.Unformed) != HttpParameterType.Unformed)
                {
                    continue;
                }
                if (result.Length > 0)
                {
                    result += "&";
                }
                result += String.Format("{0}={1}", itm.Name, itm.Value.ToEncodedString(encodingType));
            }
            return(result);
        }
Beispiel #3
0
 /// <summary>
 /// Returns an encoded string of the value.
 /// </summary>
 public string ToEncodedString(UrlEncodingType encodingType)
 {
     if (this.Value == null)
     {
         return(null);
     }
     return(OAuthUtility.UrlEncode(this.ToString(), encodingType));
 }
Beispiel #4
0
 /// <summary>
 /// Returns an encoded string of the value.
 /// </summary>
 public string ToEncodedString(UrlEncodingType encodingType)
 {
     if (this.Value == null)
     {
         return(null);
     }
     if (encodingType == UrlEncodingType.Default)
     {
         return(HttpUtility.UrlEncode(this.ToString()));
     }
     else if (encodingType == UrlEncodingType.PercentEncoding)
     {
         return(OAuthUtility.UrlEncode(this.ToString()));
     }
     else
     {
         return(this.ToString());
     }
 }
Beispiel #5
0
 /// <summary>
 /// Encodes a <b>URL</b> string using the specified encoding object.
 /// </summary>
 /// <param name="value">The text to encode.</param>
 /// <param name="codePage">The <see cref="System.Text.Encoding"/> object that specifies the encoding scheme. </param>
 /// <param name="encodingType">The type of the encoder.</param>
 public static string UrlEncode(string value, UrlEncodingType encodingType, Encoding codePage)
 {
     if (String.IsNullOrEmpty(value))
     {
         return(String.Empty);
     }
     if (encodingType == UrlEncodingType.PercentEncoding)
     {
         return(OAuthUtility.PercentEncode(value, codePage));
     }
     else if (encodingType == UrlEncodingType.Default)
     {
         return(HttpUtility.UrlEncode(value, codePage));
     }
     else
     {
         return(value);
     }
 }
Beispiel #6
0
 /// <summary>
 /// Specifies a global site property and other options.
 /// </summary>
 /// <param name="propertyName">the name of the property to be retrieved</param>
 /// <param name="defaultValue">the default value to use if the property is not found</param>
 /// <param name="autoHyperlinkType">specifies how to handle hyperlinks <see cref="Q.AutoHyperlinkType"/></param>
 /// <param name="autoNewLine">TRUE to insert &lt;BR&gt; tags into the text stream and to replace multiple spaces with a nonbreaking space.</param>
 /// <param name="expandXML">TRUE to re-pass the rendered content through the CAML interpreter, which allows CAML to render CAML.</param>
 /// <param name="htmlEncode">TRUE to convert embedded characters so that they are displayed as text in the browser.  In other words, characters that could be confused with HTML tags are converted to entities.</param>
 /// <param name="stripWhiteSpace">TRUE to remove white space from the beginning and end of the value returned by the element.</param>
 /// <param name="urlEncodingType">specifies how to handle URL encoding <see cref="Q.UrlEncodingType"/></param>
 /// <returns></returns>
 public static string ProjectProperty(string propertyName, string defaultValue, AutoHyperlinkType autoHyperlinkType, bool autoNewLine, bool expandXML, bool htmlEncode, bool stripWhiteSpace, UrlEncodingType urlEncodingType)
 {
     return Tag(CamlConst.ProjectProperty, null,
         new [] { 
             CamlConst.Select, propertyName, 
             CamlConst.Default, defaultValue,
             autoHyperlinkType==AutoHyperlinkType.Plain ? CamlConst.AutoHyperLinkNoEncoding : CamlConst.AutoHyperLink, 
                 autoHyperlinkType==AutoHyperlinkType.None ? "FALSE" : "TRUE",
             CamlConst.AutoNewLine, autoNewLine ? "TRUE" : "FALSE",
             CamlConst.HTMLEncode, htmlEncode ? "TRUE" : "FALSE",
             CamlConst.StripWS, stripWhiteSpace ? "TRUE" : "FALSE",
             urlEncodingType==UrlEncodingType.EncodeAsUrl ? CamlConst.URLEncodeAsURL : CamlConst.URLEncode,
                 urlEncodingType==UrlEncodingType.None ? "FALSE" : "TRUE"
         });
 }
 /// <summary>
 /// Returns an encoded string of the value.
 /// </summary>
 public string ToEncodedString(UrlEncodingType encodingType)
 {
   if (this.Value == null) { return null; }
   if (encodingType == UrlEncodingType.Default)
   {
     return HttpUtility.UrlEncode(this.ToString());
   }
   else if (encodingType == UrlEncodingType.PercentEncoding)
   {
     return OAuthUtility.UrlEncode(this.ToString());
   }
   else
   {
     return this.ToString();
   }
 }
Beispiel #8
0
 /// <summary>
 /// Returns a string of query parameters with a specified encoding parameters.
 /// </summary>
 public string ToStringParameters(UrlEncodingType encodingType, HttpParameterType parametersType)
 {
     return(this.ToStringParameters("&", encodingType, parametersType));
 }
Beispiel #9
0
 /// <summary>
 /// Returns a string of query parameters with a specified encoding parameters.
 /// </summary>
 public string ToStringParameters(UrlEncodingType encodingType)
 {
     return(this.ToStringParameters("&", encodingType, HttpParameterType.Unformed | HttpParameterType.Url));
 }
Beispiel #10
0
 /// <summary>
 /// Returns a string of query parameters with a specified encoding parameters.
 /// </summary>
 public string ToStringParameters(string separator, UrlEncodingType encodingType)
 {
     return(this.ToStringParameters(separator, encodingType, HttpParameterType.Unformed | HttpParameterType.Url));
 }
Beispiel #11
0
 /// <summary>
 /// Returns an encoded string of the value.
 /// </summary>
 /// <param name="encodingType">The type of the encoder.</param>
 public string ToEncodedString(UrlEncodingType encodingType)
 {
     return(this.ToEncodedString(UrlEncodingType.Default, Encoding.UTF8));
 }
 /// <summary>
 /// Encodes a <b>URL</b> string using the specified encoding object.
 /// </summary>
 /// <param name="value">The text to encode.</param>
 /// <param name="codePage">The <see cref="System.Text.Encoding"/> object that specifies the encoding scheme. </param>
 /// <param name="encodingType">The type of the encoder.</param>
 public static string UrlEncode(string value, UrlEncodingType encodingType, Encoding codePage)
 {
   if (String.IsNullOrEmpty(value)) { return String.Empty; }
   if (encodingType == UrlEncodingType.PercentEncoding)
   {
     return OAuthUtility.PercentEncode(value, codePage);
   }
   else if (encodingType == UrlEncodingType.Default)
   {
     return HttpUtility.UrlEncode(value, codePage);
   }
   else
   {
     return value;
   }
 }
 /// <summary>
 /// Encodes a <b>URL</b> string using the specified encoding object.
 /// </summary>
 /// <param name="value">The text to encode.</param>
 /// <param name="encodingType">The type of the encoder.</param>
 public static string UrlEncode(string value, UrlEncodingType encodingType)
 {
   return OAuthUtility.UrlEncode(value, encodingType, Encoding.UTF8);
 }
Beispiel #14
0
 /// <summary>
 /// Encodes a <b>URL</b> string using the specified encoding object.
 /// </summary>
 /// <param name="value">The text to encode.</param>
 /// <param name="encodingType">The type of the encoder.</param>
 public static string UrlEncode(string value, UrlEncodingType encodingType)
 {
     return(OAuthUtility.UrlEncode(value, encodingType, Encoding.UTF8));
 }