public void Create(DependencyCreateArgs args)
        {
            DBDependencyCreateArgs arg = (DBDependencyCreateArgs)args;

            if (args == null)
            {
                throw new ArgumentException();
            }
            OracleConnection conn = (OracleConnection)arg.DbOp.GetConnection();

            using (OracleCommand cmd = new OracleCommand(arg.Sql, conn))
            {
                instance = new OracleCacheDependency(cmd);
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: lyllylyq/IocCore
        public static IDependencyWrapper TestGetData_CacheDependencyCallback(object target, object[] args)
        {
            CacheDependencyWrapper dependency = new CacheDependencyWrapper();

            try
            {
                if (args.Length == 2)
                {
                    IDependencyWrapper     dbDependency = IocCoreFactory.Get <IDependencyWrapper>("DBDependency");
                    DBDependencyCreateArgs dbArg
                        = new DBDependencyCreateArgs()
                        {
                        Sql = args[0] as string, DbOp = args[1] as IDbOp
                        };
                    dbDependency.Create(dbArg);
                    IDependencyWrapper         dbConnDependency = IocCoreFactory.Get <IDependencyWrapper>("DBConnDependency");
                    DBConnDependencyCreateArgs dbCoonArg
                        = new DBConnDependencyCreateArgs()
                        {
                        DbOp = args[1] as IDbOp
                        };
                    dbConnDependency.Create(dbCoonArg);
                    IDependencyWrapper            aggregateDependency = IocCoreFactory.Get <IDependencyWrapper>("AggregateDependency");
                    AggregateDependencyCreateArgs aggregateArg
                        = new AggregateDependencyCreateArgs()
                        {
                        Wrappers = new IDependencyWrapper[] { dbDependency, dbConnDependency }
                        };
                    aggregateDependency.Create(aggregateArg);
                    return(aggregateDependency);
                }
                else
                {
                    throw new ArgumentException();
                }
            }
            catch (Exception ex)
            {
                //这里处理缓存依赖生成过程中的异常
                throw ex;
                //return null;
            }
        }