private IRule ParseAssemblyElement(XElement element, ParserContext context) { var filenameAttribute = element.Attributes().FirstOrDefault(a => a.Name.LocalName.ToLower() == "filename"); if (filenameAttribute == null) { return(null); } var filename = filenameAttribute.Value; var assembly = Assembly.Load(filename); foreach (var classElement in element.Elements()) { var nameAttribute = classElement.Attributes().FirstOrDefault(a => a.Name.LocalName.ToLower() == "name"); var typeAttribute = classElement.Attributes().FirstOrDefault(a => a.Name.LocalName.ToLower() == "type"); var classNameAttribute = classElement.Attributes().FirstOrDefault(a => a.Name.LocalName.ToLower() == "classname"); if (nameAttribute == null || typeAttribute == null || classNameAttribute == null) { continue; } var type = assembly.GetType(classNameAttribute.Value, false, true); if (type == null) { type = BuildManager.GetType(classNameAttribute.Value, false); } if (type == null) { throw new Exception("Unable to load type " + classNameAttribute.Value + " from " + assembly.FullName); } switch (typeAttribute.Value.ToLower()) { case "operation": if (!typeof(IOperation).IsAssignableFrom(type)) { throw new Exception("Type " + type.FullName + " from " + filename + " does not implement IOperation"); } _customTypeRegistrar.RegisterOperation(type, nameAttribute.Value); break; case "action": if (!typeof(IAction).IsAssignableFrom(type)) { throw new Exception("Type " + type.FullName + " from " + filename + " does not implement IAction"); } _customTypeRegistrar.RegisterAction(type, nameAttribute.Value); break; case "condition": if (!typeof(ICondition).IsAssignableFrom(type)) { throw new Exception("Type " + type.FullName + " from " + filename + " does not implement ICondition"); } _customTypeRegistrar.RegisterCondition(type, nameAttribute.Value); break; } } return(null); }