Esempio n. 1
0
        internal static Script Add(
            ObjectTextDumper objectTextDumper,
            Type objectType,
            ClassDumpData classDumpData,
            DumpScript _dumpScript)
        {
            if (objectTextDumper == null)
            {
                throw new ArgumentNullException(nameof(objectTextDumper));
            }
            if (objectType == null)
            {
                throw new ArgumentNullException(nameof(objectType));
            }
            if (_dumpScript == null)
            {
                throw new ArgumentNullException(nameof(_dumpScript));
            }

            var lookup = new ScriptLookup(objectType, classDumpData, objectTextDumper);
            var script = _dumpScript.GetScriptAction();

            _sync.EnterWriteLock();

            _cache[lookup] = script;
            _buildingNow.Remove(lookup);

            _sync.ExitWriteLock();

            return(script);
        }
Esempio n. 2
0
        internal static bool TryFind(
            ObjectTextDumper objectTextDumper,
            object obj,
            ClassDumpData classDumpData,
            out Script script)
        {
            if (objectTextDumper == null)
            {
                throw new ArgumentNullException(nameof(objectTextDumper));
            }
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            script = null;

            var lookup = new ScriptLookup(obj.GetType(), classDumpData, objectTextDumper);

            _sync.EnterReadLock();

            var found = _cache.TryGetValue(lookup, out script);

            if (!found)
            {
                found = _buildingNow.Contains(lookup);
            }

            _sync.ExitReadLock();
            return(found);
        }
        public IHttpActionResult GetScriptQuestionLookup(decimal id)
        {
            ScriptLookup scriptLookup = db.ScriptLookups.Find(id);

            if (scriptLookup == null)
            {
                return(NotFound());
            }

            return(Ok(scriptLookup));
        }