private static void InitializeWithCommonValue(XElement element, Tree tree, ActionNode actionNode, string defaultIconName, string defaultLabelName = null, ActionLocation defaultActionLocation = null, List<PermissionType> defaultPermissionTypes = null) { XAttribute labelAttribute = element.Attribute("Label"); XAttribute toolTipAttribute = element.Attribute("ToolTip"); XAttribute iconAttribute = element.Attribute("Icon"); if ((defaultLabelName == null) && (labelAttribute == null)) tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "Label"); actionNode.XPath = element.GetXPath(); actionNode.Id = tree.BuildProcessContext.ActionIdCounter++; actionNode.Label = labelAttribute.GetValueOrDefault(defaultLabelName); actionNode.ToolTip = toolTipAttribute.GetValueOrDefault(actionNode.Label); actionNode.Icon = FactoryHelper.GetIcon(iconAttribute.GetValueOrDefault(defaultIconName)); actionNode.Location = GetActionLocation(element, tree, defaultActionLocation); if (defaultPermissionTypes != null) { actionNode.PermissionTypes = defaultPermissionTypes; } else { actionNode.PermissionTypes = GetPermissionTypes(element, tree); } }
public static ActionLocation GetActionLocation(XElement element, Tree tree, ActionLocation defaultActionLocation = null) { XAttribute locationAttribute = element.Attribute("Location"); if (locationAttribute == null) return ActionLocation.OtherPrimaryActionLocation; switch (locationAttribute.Value) { case "Add": return ActionLocation.AddPrimaryActionLocation; case "Edit": return ActionLocation.EditPrimaryActionLocation; case "Delete": return ActionLocation.DeletePrimaryActionLocation; case "Other": return ActionLocation.OtherPrimaryActionLocation; default: if (defaultActionLocation != null) return defaultActionLocation; tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.WrongLocationValue", locationAttribute.Value); return ActionLocation.OtherPrimaryActionLocation; } }
private static string CalculateActionCategoryGroupId(ActionLocation actionLocation) { // trying to aqvoid overflow - might be lamo way return "Key" + Math.Abs(Math.Abs(actionLocation.ActionGroup.Priority.GetHashCode()) - Math.Abs(actionLocation.ActionGroup.Name.GetHashCode())).ToString(); }