本文整理汇总了C#中IPropertyBag.TrySet方法的典型用法代码示例。如果您正苦于以下问题:C# IPropertyBag.TrySet方法的具体用法?C# IPropertyBag.TrySet怎么用?C# IPropertyBag.TrySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPropertyBag
的用法示例。
在下文中一共展示了IPropertyBag.TrySet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoBeforeCreate
/// <summary>
/// This method is called just before a node is created by the repository.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="properties">The new properties of the node.</param>
protected override void DoBeforeCreate(IMansionContext context, IPropertyBag properties)
{
// check if the layout is set
string layout;
if (properties.TryGet(context, "layout", out layout))
return;
// set the layout
properties.TrySet("layout", layout);
}
示例2: DoBeforeCreate
/// <summary>
/// This method is called just before a node is created by the repository.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="parent">The parent node to which the new child will be added.</param>
/// <param name="newProperties">The new properties of the node.</param>
protected override void DoBeforeCreate(IMansionContext context, Node parent, IPropertyBag newProperties)
{
// check if the layout is set
string layout;
if (newProperties.TryGet(context, "layout", out layout))
return;
if (!parent.TryGet(context, "layout", out layout))
layout = "OneColumnLayout";
// set the layout
newProperties.TrySet("layout", layout);
}
示例3: Prepare
/// <summary>
/// Prepares an insert query.
/// </summary>
/// <param name="context"></param>
/// <param name="connection">The connection.</param>
/// <param name="transaction">The transaction.</param>
/// <param name="node"></param>
/// <param name="modifiedProperties"></param>
/// <returns></returns>
public void Prepare(IMansionContext context, SqlConnection connection, SqlTransaction transaction, Node node, IPropertyBag modifiedProperties)
{
// validate arguments
if (connection == null)
throw new ArgumentNullException("connection");
if (transaction == null)
throw new ArgumentNullException("transaction");
if (node == null)
throw new ArgumentNullException("node");
if (modifiedProperties == null)
throw new ArgumentNullException("modifiedProperties");
// set the modified date
modifiedProperties.TrySet("modified", DateTime.Now);
// retrieve the type
var type = typeService.Load(context, node.Pointer.Type);
// retrieve the schema
var schema = Resolver.Resolve(context, type);
// set the full text property
SqlServerUtilities.PopulateFullTextColumn(context, type, modifiedProperties, node);
// create the commandse
command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.Transaction = transaction;
// prepare the query
var queryBuilder = new ModificationQueryBuilder(command);
// loop through all the tables in the schema and let them prepare for update
foreach (var table in schema.Tables)
table.ToUpdateStatement(context, queryBuilder, node, modifiedProperties);
// finish the insert statement
command.CommandText = queryBuilder.ToStatement();
}