Exemplo n.º 1
0
 /// <summary>
 /// Create a new value definition, by providing a value, which is represented as a string literal, plus a <paramref name="type"/> argument to
 /// specify how SharePoint should parse the value string literal.
 /// <para>Some complex types, such as <see cref="ValueTypes.Choice"/> may not be supported by SharePoint.</para>
 /// </summary>
 /// <example>
 /// <c>var textVal = FromLiteralStringValue("this is some text", ValueTypes.Text);
 /// var intVal = FromLiteralStringValue("12", ValueTypes.Integer);</c>
 /// </example>
 /// <param name="value"></param>
 /// <param name="type">See <see cref="ValueTypes"/> enumeration for a list of possible values.</param>
 /// <returns></returns>
 public static ValueDefinition FromLiteralStringValue(string value, ValueTypes type = ValueTypes.Text)
 {
     if (value.IsEmpty())
     {
         throw new ArgumentNullException(nameof(value));
     }
     return(new ValueDefinition {
         Untyped = XElement.Parse($"<Value Type=\"{type.StringValue()}\">{value}</Value>")
     });
 }