Beispiel #1
0
        private Type getTargetType(WorkContext work, string typeName)
        {
            const string PORTAL_PREFIX = @"!#PORTAL\";

            if (typeName.IsNullOrWhiteSpace())
            {
                return(null);
            }
            Type   result = null;
            string key;

            if (work.Portal == null)
            {
                key = typeName;
            }
            else
            {
                key = PORTAL_PREFIX + work.Portal.Name + typeName;
            }


            //1 Lookup in cache
            if (m_Lookup.TryGetValue(key, out result))
            {
                return(result);
            }

            //2 Lookup in locations
            result = lookupTargetInLocations(work, typeName);
            if (result != null)
            {
                var lookup = new TypeLookup(m_Lookup); //thread safe copy

                lookup[key] = result;                  //other thread may have added already
                m_Lookup    = lookup;                  //atomic
                return(result);
            }

            return(null); //404 error - type not found
        }
Beispiel #2
0
        private Type getTargetType(string typeName)
        {
            if (typeName.IsNullOrWhiteSpace())
            {
                return(null);
            }
            Type   result = null;
            string key    = typeName;


            //1 Lookup in cache
            if (m_Lookup.TryGetValue(key, out result))
            {
                return(result);
            }

            //2 Lookup in locations
            result = lookupTargetInLocations(key);
            if (result != null)
            {
                var lookup = new TypeLookup(m_Lookup);//thread safe copy

                //dbl check as other thread may have added to m_Lookup where this istance is cloned from
                Type existing;
                if (lookup.TryGetValue(key, out existing))
                {
                    return(existing);
                }

                lookup.Add(key, result);
                m_Lookup = lookup;//atomic
                return(result);
            }

            return(null); //404 error - type not found
        }
Beispiel #3
0
 public TypeLookup(TypeLookup clone) : base(clone, StringComparer.Ordinal)
 {
 }
Beispiel #4
0
 public TypeLookup(TypeLookup clone) : base(clone)
 {
 }