Esempio n. 1
0
        private void AddAuditing(Mappings mappings)
        {
            var auditObjects = new List<IAuxiliaryDatabaseObject>();
              foreach (var table in mappings.IterateTables.ToArray())
              {
            var auditTable = new AuditTable(
              table, _namingStrategy, _columnSource);
            mappings.AddAuxiliaryDatabaseObject(auditTable);

            var insertTrigger = new AuditTrigger(table,
              auditTable, _namingStrategy, TriggerActions.INSERT);
            mappings.AddAuxiliaryDatabaseObject(insertTrigger);

            var updateTrigger = new AuditTrigger(table,
              auditTable, _namingStrategy, TriggerActions.UPDATE);
            mappings.AddAuxiliaryDatabaseObject(updateTrigger);

            var deleteTrigger = new AuditTrigger(table,
              auditTable, _namingStrategy, TriggerActions.DELETE);
            mappings.AddAuxiliaryDatabaseObject(deleteTrigger);
              }
        }
Esempio n. 2
0
		private static void BindAuxiliaryDatabaseObject(XmlNode auxDbObjectNode, Mappings mappings)
		{
			IAuxiliaryDatabaseObject auxDbObject;
			XmlNode definitionNode = auxDbObjectNode.SelectSingleNode(HbmConstants.nsDefinition, nsmgr);
			if (definitionNode != null)
			{
				string className = XmlHelper.GetAttributeValue(definitionNode, "class");
				try
				{
					auxDbObject = (IAuxiliaryDatabaseObject) Activator.CreateInstance(ReflectHelper.ClassForName(className));
					Hashtable parameters = new Hashtable();
					foreach (XmlNode childNode in definitionNode.ChildNodes)
					{
						parameters.Add(childNode.Attributes["name"].Value, childNode.InnerText.Trim());
					}
					auxDbObject.SetParameterValues(parameters);
				}
				catch (TypeLoadException e)
				{
					throw new MappingException(
						"could not locate custom database object class [" +
						className + "]", e
						);
				}
				catch (Exception t)
				{
					throw new MappingException(
						"could not instantiate custom database object class [" +
						className + "]", t
						);
				}
			}
			else
			{
				auxDbObject = new SimpleAuxiliaryDatabaseObject(
					XmlHelper.ElementTextTrim(auxDbObjectNode, HbmConstants.nsCreate, nsmgr),
					XmlHelper.ElementTextTrim(auxDbObjectNode, HbmConstants.nsDrop, nsmgr)
					);
			}

			foreach (XmlNode dialectScoping in auxDbObjectNode.SelectNodes(HbmConstants.nsDialectScope, nsmgr))
			{
				auxDbObject.AddDialectScope(XmlHelper.GetAttributeValue(dialectScoping, "name"));
			}

			mappings.AddAuxiliaryDatabaseObject(auxDbObject);
		}