/// <summary> /// Creates a new Resource Operation exception /// </summary> /// <param name="resource"></param> /// <param name="operations"></param> /// <param name="rule"></param> /// <param name="bk"></param> public ResourceOperationException(string resource, string operations, ConflictRule rule, BookKeeper bk) : base(String.Format("The operation sequence {1} on the resource \"{0}\" violates the {2}", resource, operations, rule.ToString())) { _resource = resource; _operations = operations; _rule = rule; _bookkeeper = bk; }
private void procAssembly(Assembly asm) { foreach (Object ca in asm.GetCustomAttributes(typeof(ConflictRuleAttribute), true)) { ConflictRuleAttribute cae = (ConflictRuleAttribute)ca; string resname; if ("*".Equals(cae.Resource)) { resname = "*"; } else { short ord; ResourceType rt = BookKeeper.getResourceType(cae.Resource, out ord); if (rt == ResourceType.Custom) { resname = cae.Resource.ToLower(); } else if (rt == ResourceType.ArgumentEntry && ord > -1) { resname = BookKeeper.resourceTypeAsString(rt) + ord; } else { resname = BookKeeper.resourceTypeAsString(rt); } } bool add = true; foreach (ConflictRule cr in rules) { if (cr.Constraint == cae.Constraint && cr.Resource.Equals(resname) && cr.Pattern.Equals(cae.Pattern)) { add = false; break; } } if (add) { try { ConflictRule cr = new ConflictRule(cae.Pattern, resname, cae.Constraint, cae.Message); rules.Add(cr); } catch (Exception e) { #if DEBUG Console.Error.WriteLine("<ResourceValidator> Unable to create conflict rule with pattern {0} for resource {1}", cae.Pattern, resname); Console.Error.WriteLine("<ResourceValidator> " + e.Message); Console.Error.WriteLine("<ResourceValidator> " + e.StackTrace); #endif } } } }