本文整理汇总了C#中IPropertyBag类的典型用法代码示例。如果您正苦于以下问题:C# IPropertyBag类的具体用法?C# IPropertyBag怎么用?C# IPropertyBag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPropertyBag类属于命名空间,在下文中一共展示了IPropertyBag类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Run
public override object Run(object obj, string[] parameters, IPropertyBag bag, IMarkupBase markup)
{
if (parameters == null || (parameters.Length < 2 || parameters.Length > 3))
throw new ImpressionInterpretException("Filter " + Keyword + " expects 2 or 3 parameters.", markup);
// text field to bind to
// selected value
// text field to bind to
// value field to bind to
// selected value
if (obj == null)
return null;
if (obj.GetType().GetInterface("IEnumerable") != null) {
IReflector reflector = new Reflector();
bool textOnly = parameters.Length == 2;
string textField = parameters[0];
string selectedField = textOnly ? parameters[1] : parameters[2];
StringBuilder optionBuilder = new StringBuilder();
IEnumerator en = ((IEnumerable) obj).GetEnumerator();
// " for quotes
// ' for apostrophes
// lookup the selected value
object selectedObject = bag == null ? null : reflector.Eval(bag, selectedField);
string selectedValue = selectedObject != null ? selectedObject.ToString() : null;
if (textOnly) {
while (en.MoveNext()) {
object current = en.Current;
object textObject = reflector.Eval(current, textField);
string textString = textObject != null ? textObject.ToString() : null;
string selected = (textString == selectedValue) ? " selected=\"true\"" : "";
optionBuilder.AppendFormat("<option{1}>{0}</option>", textString, selected);
}
} else {
string valueField = parameters[1];
while(en.MoveNext()) {
object current = en.Current;
object textObject = reflector.Eval(current, textField);
string textString = textObject != null ? textObject.ToString() : null;
object valueObject = reflector.Eval(current, valueField);
string valueString = valueObject != null ? valueObject.ToString() : null;
string selected = (valueString == selectedValue) ? " selected=\"true\"" : "";
optionBuilder.AppendFormat("<option value=\"{0}\"{2}>{1}</option>", valueString, textString, selected);
}
}
return optionBuilder.ToString();
}
return null;
}
开发者ID:codesoda,项目名称:Impression,代码行数:60,代码来源:HtmlOptionsFilter.cs
示例2: Get
/// <summary>
/// Gets the dataset.
/// </summary>
/// <param name="context">The request context.</param>
/// <param name="attributes">The attributes of this tag.</param>
/// <returns>Returns the result.</returns>
protected override Dataset Get(IMansionContext context, IPropertyBag attributes)
{
// create the dataset
var dataset = new Dataset();
// loop over all the CMS plugin types
foreach (var plugin in typeService.Load(context, "CmsPlugin").GetInheritingTypes(context).Select(type =>
{
// get the plugin descriptor
CmsPluginDescriptor descriptor;
if (!type.TryGetDescriptor(out descriptor))
throw new InvalidOperationException(string.Format("Type '{0}' does not contain a CMS-plugin", type.Name));
// return the model
return new
{
Type = type,
Descriptor = descriptor
};
}).OrderBy(plugin => plugin.Descriptor.GetOrder(context)))
{
// create the plugin row
var row = new PropertyBag
{
{"type", plugin.Type.Name}
};
// add the row to the dataset
dataset.AddRow(row);
}
return dataset;
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:39,代码来源:GetPluginDatasetTag.cs
示例3: IsVisible
public bool IsVisible(IPropertyBag properties)
{
if (base.CompareFromContext(properties, "UserMode", "1") != 0) // Runtime
return true;
else // DesignTime
return properties.GetPropertyValue<bool>("EnableCheckbox");
}
开发者ID:genexuslabs,项目名称:gxui,代码行数:7,代码来源:UncheckedNodesResolver.cs
示例4: DoCreateNode
/// <summary>
/// Creates a new node in this repository.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="parent">The parent node.</param>
/// <param name="newProperties">The properties of the node which to create.</param>
/// <returns>Returns the created nodes.</returns>
protected override Node DoCreateNode(IMansionContext context, Node parent, IPropertyBag newProperties)
{
// build the query
int nodeId;
using (var connection = CreateConnection())
using (var transaction = connection.BeginTransaction())
using (var command = context.Nucleus.CreateInstance<InsertNodeCommand>())
{
// init the command
command.Prepare(context, connection, transaction, parent.Pointer, newProperties);
// execute the command
try
{
// execute the query
nodeId = command.Execute();
// woohoo it worked!
transaction.Commit();
}
catch (Exception)
{
// something terrible happened, revert everything
transaction.Rollback();
throw;
}
}
// retrieve the created node
return RetrieveSingleNode(context, new Query().Add(new IsPropertyEqualSpecification("id", nodeId)));
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:38,代码来源:SqlServerRepository.cs
示例5: DoToUpdateStatement
/// <summary>
///
/// </summary>
/// <param name="context"></param>
/// <param name="queryBuilder"></param>
/// <param name="record"> </param>
/// <param name="modifiedProperties"></param>
protected override void DoToUpdateStatement(IMansionContext context, ModificationQueryBuilder queryBuilder, Record record, IPropertyBag modifiedProperties)
{
// check if the property is not modified
int newOrder;
if (!modifiedProperties.TryGet(context, PropertyName, out newOrder))
return;
// check if the record contains a pointer
NodePointer pointer;
if (!record.TryGet(context, "pointer", out pointer))
throw new InvalidOperationException("Could not update this record because it did not contain a pointer");
// don't update order for root nodes
if (pointer.Depth == 1)
return;
// do not allow values smaller than 1
if (newOrder < 1)
throw new InvalidOperationException("Can not set orders smaller than 1");
// assemble parameter
var newOrderParameterName = queryBuilder.AddParameter("newOrder", newOrder, DbType.Int32);
var oldOrderParameterName = queryBuilder.AddParameter("oldOrder", record.Get<int>(context, PropertyName), DbType.Int32);
var parentIdParameterName = queryBuilder.AddParameter("parentId", pointer.Parent.Id, DbType.Int32);
// update the orders before updating the order of the current node
queryBuilder.PrependQuery(string.Format("UPDATE [Nodes] SET [order] = [order] + 1 WHERE (parentId = {0}) AND ([order] < {1} AND [order] >= {2})", parentIdParameterName, oldOrderParameterName, newOrderParameterName));
queryBuilder.PrependQuery(string.Format("UPDATE [Nodes] SET [order] = [order] - 1 WHERE (parentId = {0}) AND ([order] > {1} AND [order] <= {2})", parentIdParameterName, oldOrderParameterName, newOrderParameterName));
// update the column
queryBuilder.AddColumnValue(PropertyName, newOrderParameterName);
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:39,代码来源:OrderColumn.cs
示例6: Initialize
/// <summary>
/// Initializes the given <paramref name="column"/>.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="column">The <see cref="PropertyColumn"/> which to initialze.</param>
/// <param name="properties">The properties.</param>
/// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception>
protected static void Initialize(IMansionContext context, PropertyColumn column, IPropertyBag properties)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (column == null)
throw new ArgumentNullException("column");
if (properties == null)
throw new ArgumentNullException("properties");
// get the allow null flag
column.AllowNullValue = properties.Get(context, "allowNullValue", false);
// check if there is an expression
string expressionString;
if (properties.TryGet(context, "expression", out expressionString))
{
var expressionService = context.Nucleus.ResolveSingle<IExpressionScriptService>();
column.HasExpression = true;
column.Expression = expressionService.Parse(context, new LiteralResource(expressionString));
}
// get the default value
string defaultValue;
if (properties.TryGet(context, "defaultValue", out defaultValue))
{
var expressionService = context.Nucleus.ResolveSingle<IExpressionScriptService>();
var defaultValueExpression = expressionService.Parse(context, new LiteralResource(defaultValue));
column.DefaultValue = defaultValueExpression.Execute<object>(context);
column.HasDefaultValue = true;
}
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:39,代码来源:PropertyColumn.cs
示例7: Write
/// <summary>
/// Writes <paramref name="values"/> to the output.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="values">The <see cref="IPropertyBag"/> containing the values which to write.</param>
public void Write(IMansionContext context, IPropertyBag values)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (values == null)
throw new ArgumentNullException("values");
CheckDisposed();
// write out the values
for (var index = 0; index < format.ColumnProperties.Length; index++)
{
// write out the current value when there is one
string value;
if (values.TryGet(context, format.ColumnProperties[index], out value))
{
outputPipe.Writer.Write(format.TextQualifier);
outputPipe.Writer.Write(value);
outputPipe.Writer.Write(format.TextQualifier);
}
// write out the column or row delimitor
outputPipe.Writer.Write(index == (format.ColumnProperties.Length - 1) ? format.RowDelimitor : format.ColumnDelimitor);
}
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:30,代码来源:CsvOutputPipe.cs
示例8: Populate
/// <summary>
/// Populates the fullText property.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="modifiedProperties">The modified <see cref="IPropertyBag"/>.</param>
/// <param name="originalProperties">The original <see cref="IPropertyBag"/>.</param>
/// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception>
public void Populate(IMansionContext context, IPropertyBag modifiedProperties, IPropertyBag originalProperties)
{
//validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (modifiedProperties == null)
throw new ArgumentNullException("modifiedProperties");
if (originalProperties == null)
throw new ArgumentNullException("originalProperties");
// get all the properties over which to loop
var properties = Properties.Get<string>(context, "properties").Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Select(property => property.Trim());
// assemble the content
var buffer = new StringBuilder();
foreach (var property in properties)
{
// get the content for the given property
String content;
if (!modifiedProperties.TryGet(context, property, out content))
{
if (!originalProperties.TryGet(context, property, out content))
continue;
}
// strip the HTML
content = content.StripHtml();
// add it to the buffer
buffer.AppendLine(content);
}
// if there is full-text content, add it to the full-text property, otherwise set it to null
modifiedProperties.Set("fullText", buffer.Length > 0 ? buffer.ToString() : null);
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:42,代码来源:FullTextDescriptor.cs
示例9: Section
/// <summary>
/// Constructs an section.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="properties">The descriptor of this section.</param>
/// <param name="expression">The expressio of this section.</param>
public Section(IMansionContext context, IPropertyBag properties, IExpressionScript expression)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (properties == null)
throw new ArgumentNullException("properties");
if (expression == null)
throw new ArgumentNullException("expression");
// set values
Properties = properties;
Expression = expression;
Id = Guid.NewGuid().ToString();
Name = Properties.Get<string>(context, "name");
ShouldBeRenderedOnce = !Properties.Get(context, "repeatable", true);
TargetField = Properties.Get(context, "field", Name);
// check if there is a requires property
string requiresExpressionString;
if (Properties.TryGet(context, "requires", out requiresExpressionString))
{
// assemble the expression
var expressionService = context.Nucleus.ResolveSingle<IExpressionScriptService>();
var requiresExpression = expressionService.Parse(context, new LiteralResource(requiresExpressionString));
// execute the expression
areRequirementsSatisfied = requiresExpression.Execute<bool>;
}
else
areRequirementsSatisfied = mansionContext => true;
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:38,代码来源:Section.cs
示例10: Run
public object Run(object obj, string[] parameters, IPropertyBag bag, IMarkupBase markup)
{
if (parameters != null && parameters.Length > 1)
throw new ImpressionInterpretException("Filter " + Keyword + " does not accept parameters.");
if (obj == null)
{
obj = 0.0;
}
double val = 0;
string valString = obj.ToString();
if (Double.TryParse(valString, out val))
{
int pointIndex = valString.IndexOf('.');
if (pointIndex >= 0)
{
string subs = valString.Substring(pointIndex + 1, valString.Length - (pointIndex + 1));
if (subs.Length > 2)
{
obj = subs.Substring(0, 2);
} else
{
obj = subs.PadRight(2, '0');
}
} else
{
obj = "00";
}
}
return obj;
}
开发者ID:codesoda,项目名称:Impression,代码行数:33,代码来源:MoneyFilter.cs
示例11: ReviveUser
/// <summary>
/// Tries to revive the user based on the revival properties.
/// </summary>
/// <param name="context">The security context.</param>
/// <param name="revivalProperties">The revival properties.</param>
/// <returns>Returns the revived <see cref="UserState"/> or null.</returns>
public override UserState ReviveUser(IMansionContext context, IPropertyBag revivalProperties)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (revivalProperties == null)
throw new ArgumentNullException("revivalProperties");
// get the id of the from the revival properties
Guid id;
if (!revivalProperties.TryGet(context, "id", out id))
return null;
// retrieve the user by guid
var userNode = context.Repository.RetrieveSingleNode(context, new PropertyBag {
{"baseType", "User"},
{"guid", id},
{"status", "any"},
{"bypassAuthorization", true},
{"cache", false},
{StorageOnlyQueryComponent.PropertyKey, true}
});
if (userNode == null)
return null;
// create and return the user state
return CreateUserState(context, userNode);
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:34,代码来源:RepositoryAuthenticationProvider.cs
示例12: DoProcess
/// <summary>
/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="parameters">The parameters which to process.</param>
/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
{
// check for search
string where;
if (parameters.TryGetAndRemove(context, "sqlWhere", out where) && !string.IsNullOrEmpty(where))
query.Add(new SqlWhereSpecification(where));
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:13,代码来源:SqlWhereQueryArgumentProcessor.cs
示例13: DoProcess
/// <summary>
/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="parameters">The parameters which to process.</param>
/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
{
// check for the cache flag
object tmp;
if (parameters.TryGetAndRemove(context, StorageOnlyQueryComponent.PropertyKey, out tmp))
query.Add(new StorageOnlyQueryComponent());
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:13,代码来源:StorageOnlyArgumentProcessor.cs
示例14: RecordSet
/// <summary>
/// Creates a filled nodeset.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="properties"></param>
/// <param name="records"></param>
public RecordSet(IMansionContext context, IPropertyBag properties, IEnumerable<Record> records) : base(properties)
{
// validate arguments
if (records == null)
throw new ArgumentNullException("records");
if (properties == null)
throw new ArgumentNullException("properties");
// set values
foreach (var node in records)
RowCollection.Add(node);
Set("count", RowCollection.Count);
// check for paging
var totalRowCount = properties.Get(context, "totalCount", -1);
var pageNumber = properties.Get(context, "pageNumber", -1);
var rowsPerPage = properties.Get(context, "pageSize", -1);
if (totalRowCount != -1 && pageNumber != -1 && rowsPerPage != -1)
SetPaging(totalRowCount, pageNumber, rowsPerPage);
// check for sort
string sortString;
if (properties.TryGet(context, "sort", out sortString))
{
foreach (var sort in Collections.Sort.Parse(sortString))
AddSort(sort);
}
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:34,代码来源:RecordSet.cs
示例15: DoAfterUpdate
/// <summary>
/// This method is called just after a node is updated by the repository.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="record"> </param>
/// <param name="properties">The properties which were set to the updated <paramref name="record"/>.</param>
protected override void DoAfterUpdate(IMansionContext context, Record record, IPropertyBag properties)
{
// get the propagate property names
var propagatePropertyNames = properties.Names.Where(x => x.StartsWith(PropagatePrefix, StringComparison.OrdinalIgnoreCase));
// get the property names who's value is true
var propagatedNowProperties = propagatePropertyNames.Where(x => properties.Get(context, x, false));
// loop over all the updated properties and propagated properties
foreach (var propagatePropertyName in propagatedNowProperties)
{
// get the name of the property being propagated
var propagatedPropertyName = propagatePropertyName.Substring(PropagatePrefix.Length);
// get the propagated property value
var propagatedPropertyValue = properties.Get<object>(context, propagatedPropertyName);
// retrieve all the children nodes and update them all
foreach (var childNode in context.Repository.RetrieveNodeset(context, new PropertyBag
{
{"parentSource", record},
{"depth", "any"}
}).Nodes)
{
context.Repository.UpdateNode(context, childNode, new PropertyBag
{
{propagatedPropertyName, propagatedPropertyValue}
});
}
}
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:37,代码来源:PropagateListener.cs
示例16: DoMap
/// <summary>
/// Maps the given <paramref name="dbRecord"/> to <paramref name="properties"/>.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="dbRecord">The <see cref="DbRecord"/> which to map.</param>
/// <param name="properties">The <see cref="IPropertyBag"/> in which to store the mapped result.</param>
protected override void DoMap(IMansionContext context, DbRecord dbRecord, IPropertyBag properties)
{
// field indices
var idIndex = dbRecord.GetOrdinal("id");
var parentPointerIndex = dbRecord.GetOrdinal("parentPointer");
var nameIndex = dbRecord.GetOrdinal("name");
var parentPathIndex = dbRecord.GetOrdinal("parentPath");
var typeIndex = dbRecord.GetOrdinal("type");
var parentStructureIndex = dbRecord.GetOrdinal("parentStructure");
// assemble the node pointer
var pointer = (dbRecord.IsDBNull(parentPointerIndex) ? string.Empty : dbRecord.GetString(parentPointerIndex) + NodePointer.PointerSeparator) + dbRecord.GetInt32(idIndex);
var structure = (dbRecord.IsDBNull(parentStructureIndex) ? string.Empty : dbRecord.GetString(parentStructureIndex) + NodePointer.StructureSeparator) + dbRecord.GetString(typeIndex);
var path = (dbRecord.IsDBNull(parentPathIndex) ? string.Empty : dbRecord.GetString(parentPathIndex) + NodePointer.PathSeparator) + dbRecord.GetString(nameIndex);
var nodePointer = NodePointer.Parse(pointer, structure, path);
// set the pointer
properties.Set("pointer", nodePointer);
properties.Set("path", nodePointer.PathString);
properties.Set("structure", nodePointer.StructureString);
properties.Set("depth", nodePointer.Depth);
properties.Set("name", nodePointer.Name);
properties.Set("type", nodePointer.Type);
if (nodePointer.HasParent)
{
properties.Set("parentPointer", nodePointer.Parent);
properties.Set("parentId", nodePointer.Parent.Id);
}
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:35,代码来源:NodePointerRecordMapper.cs
示例17: DoProcess
/// <summary>
/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="parameters">The parameters which to process.</param>
/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
{
var counter = 0;
// check for id, guid or pointer
int id;
if (parameters.TryGetAndRemove(context, "id", out id))
{
query.Add(new IsPropertyEqualSpecification("id", id));
counter++;
}
string guids;
if (parameters.TryGetAndRemove(context, "guid", out guids) && !string.IsNullOrEmpty(guids))
{
// split the value
var values = guids.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray();
query.Add(new IsPropertyInSpecification("guid", values));
counter++;
}
NodePointer pointer;
if (parameters.TryGetAndRemove(context, "pointer", out pointer))
{
query.Add(new IsPropertyEqualSpecification("id", pointer.Id));
counter++;
}
// check for ambigous parameters
if (counter > 1)
throw new InvalidOperationException("Detected an ambigious id parmeters. Remove either id, guid or pointer.");
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:36,代码来源:IdArgumentProcessor.cs
示例18: if
int IVsPersistSolutionProps.WriteSolutionProps(IVsHierarchy pHierarchy, string pszKey, IPropertyBag pPropBag)
{
if (pHierarchy != null)
return VSConstants.S_OK; // Not send by our code!
else if(pPropBag == null)
return VSConstants.E_POINTER;
// This method is called from the VS implementation after a request from SaveSolutionProps
ISccSettingsStore translate = GetService<ISccSettingsStore>();
IVisualGitSccService scc = GetService<IVisualGitSccService>();
using (IPropertyMap map = translate.GetMap(pPropBag))
{
switch (pszKey)
{
case GitPropertyCategory:
map.SetRawValue(ManagedPropertyName, true.ToString());
// BH: Don't localize this text! Changing it will change all solutions marked as managed by VisualGit
map.SetRawValue(ManagerPropertyName, "VisualGit - Git Support for Visual Studio");
scc.WriteSolutionProperties(map);
break;
case VisualGitId.SccStructureName:
translate.WriteSolutionProperties(map);
break;
}
}
return VSConstants.S_OK;
}
开发者ID:pvginkel,项目名称:VisualGit,代码行数:31,代码来源:VisualGitPackage.SolutionProperties.cs
示例19: Run
public override object Run(object obj, string[] parameters, IPropertyBag bag, IMarkupBase markup)
{
string dateFormat = null;
if (parameters != null && parameters.Length > 1)
throw new ImpressionInterpretException("Formatter " + Keyword + " does not accept more than one parameter.");
if (parameters == null || parameters.Length == 0)
dateFormat = ImpressionEngine.DateFormat;
else
dateFormat = IsLiteral(parameters[0])
? GetLiteral(parameters[0])
: bag[parameters[0]].ToString();
if (obj != null) {
if (obj is DateTime) {
obj = ((DateTime)obj).ToString(dateFormat);
}
else {
DateTime val;
if (DateTime.TryParse(obj.ToString(), out val)) {
obj = val.ToString(dateFormat);
}
}
}
return obj;
}
开发者ID:codesoda,项目名称:Impression,代码行数:27,代码来源:DateFilter.cs
示例20: DoBeforeUpdate
/// <summary>
/// This method is called just before a node is updated by the repository.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="node">The node which will be modified.</param>
/// <param name="modifiedProperties">The updated properties of the node.</param>
protected override void DoBeforeUpdate(IMansionContext context, Node node, IPropertyBag modifiedProperties)
{
// if the name has not changed we are not interested
string newName;
if (!modifiedProperties.TryGet(context, "name", out newName))
return;
// if the name has not changed after normalization we are not interested
newName = TagUtilities.Normalize(newName);
if (node.Pointer.Name.Equals(newName))
{
modifiedProperties.Remove("name");
return;
}
modifiedProperties.Set("name", newName);
// if the tag is renamed to another already existing tag, move all content to that existing tag and delete this one
Node existingTag;
var tagIndexNode = TagUtilities.RetrieveTagIndexNode(context);
if (TagUtilities.TryRetrieveTagNode(context, tagIndexNode, newName, out existingTag))
{
// TODO: move all content to the existing tag
// TODO: delete this tag
}
}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:32,代码来源:TagListener.cs
注:本文中的IPropertyBag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论