// =============================================================================== // SqlCommand // ========== protected void InitializeSqlCommand(IMethodInvocation invocation) { Type targetType = GetComponentDef(invocation).ComponentType; IDaoMetaData dmd = _daoMetaDataFactory.GetDaoMetaData(targetType); if (typeof(OutsideSqlDao).IsAssignableFrom(targetType)) { return; // Do nothing! } else { Object[] arguments = invocation.Arguments; if (arguments != null && arguments.Length > 0 && arguments[0] is String) { String methodName = (String)arguments[0]; try { dmd.GetSqlCommand(methodName); } catch (MethodNotFoundRuntimeException ignored) { // Do nothing! if (IsLogEnabled()) { Log("Not Found the method: " + methodName + " msg=" + ignored.Message); } } return; } else { String msg = "The method should have one string argument as method name: " + invocation; throw new SystemException(msg); } } }
protected ISqlCommand FindSqlCommand(IMethodInvocation invocation) { ISqlCommand cmd; Type targetType = GetComponentDef(invocation).ComponentType; IDaoMetaData dmd = _daoMetaDataFactory.GetDaoMetaData(targetType); if (typeof(OutsideSqlDao).IsAssignableFrom(targetType)) { cmd = dmd.GetSqlCommand(GenerateSpecifiedOutsideSqlUniqueKey(invocation)); } else { cmd = dmd.GetSqlCommand(invocation.Method.Name); } return(cmd); }
// =============================================================================== // Implementation // ============== public IDaoMetaData GetDaoMetaData(Type daoType) { lock (this) { string key = daoType.FullName; IDaoMetaData dmd = (IDaoMetaData)_daoMetaDataCache[key]; if (dmd != null) { return(dmd); } if (_log.IsDebugEnabled) { _log.Debug("...Creating daoMetaData for '" + daoType.Name + "'."); } dmd = CreateDaoMetaData(daoType); _daoMetaDataCache[key] = dmd; return(dmd); } }