System.Runtime.Serialization.Formatters.Binary.NameCache.SetCachedValue C# (CSharp) Method

SetCachedValue() private method

private SetCachedValue ( object value ) : void
value object
return void
        internal void SetCachedValue(object value) => s_ht[_name] = value;
    }

Usage Example

示例#1
0
        internal Type FastBindToType(string assemblyName, string typeName)
        {
            Type type = null;

            TypeNAssembly entry = (TypeNAssembly)_typeCache.GetCachedValue(typeName);

            if (entry == null || entry.AssemblyName != assemblyName)
            {
                Assembly assm = null;
                try
                {
                    assm = Assembly.Load(new AssemblyName(assemblyName));
                }
                catch { }

                if (assm == null)
                {
                    return(null);
                }

                if (_isSimpleAssembly)
                {
                    GetSimplyNamedTypeFromAssembly(assm, typeName, ref type);
                }
                else
                {
                    type = FormatterServices.GetTypeFromAssembly(assm, typeName);
                }

                if (type == null)
                {
                    return(null);
                }

                // before adding it to cache, let us do the security check
                CheckTypeForwardedTo(assm, type.Assembly, type);

                entry              = new TypeNAssembly();
                entry.Type         = type;
                entry.AssemblyName = assemblyName;
                _typeCache.SetCachedValue(entry);
            }
            return(entry.Type);
        }