Ejemplo n.º 1
0
        public Instance(Configuration configuration, string domain, Index index = null)
        {
            // Set instance on configuration
            Configuration = configuration;

            // Init things
            ObjDb = new Db(Configuration.Object.Database.ConnectionString); // Database
            CacheObj = new MemoryCache("instance-obj-" + domain); // Cache
            //CacheQ = new MemoryCache("instance-q-" + domain); // Cache

            if (null == index) {
                // Create new index
                Index = new Index(Configuration.Schema);

                // Build base index
                var retry = new RetryPolicy<DbRetryStrategy>(3, new TimeSpan(0, 0, 1));
                using (var rdr = ObjDb.Query("SELECT [uid],[type],[serial],[properties] FROM [obj] WHERE [oid] NOT IN (SELECT [predecessor] FROM [obj])").ExecuteReaderWithRetry(retry)) {
                    while (rdr.Read()) {
                        Index.Set((string)rdr["uid"], (string)rdr["type"], (long)rdr["serial"], (string)rdr["properties"]);
                    }
                }
            } else {
                Index = index;
            }

            // Init mode
            Mode = Amos.ImplementationMode.Mode.Select(Configuration.Mode, this);
        }
Ejemplo n.º 2
0
        protected void Changed(object sender, FileSystemEventArgs e)
        {
            if (skip) return;

            issues = new List<Issue>();

            var v = Amos.Common.Util.GetContents(e.FullPath);
            current = v;
            issues = Processing.JsonLint(v);
            foreach (var issue in issues) {
                issue.AssemblyName = "?";
                issue.ComponentName = "Config";
                issue.ModuleName = "";
            }
            if (issues.Count == 0) Configuration = Configuration.FromJson(v);

            Handler.Change();
        }