Beispiel #1
0
 internal void ClearReflectionCache()
 {
     _tyname         = new SafeDictionary <Type, string>();
     _typecache      = new SafeDictionary <string, Type>();
     _constrcache    = new SafeDictionary <Type, CreateObject>();
     _getterscache   = new SafeDictionary <Type, Getters[]>();
     _propertycache  = new SafeDictionary <string, Dictionary <string, myPropInfo> >();
     _genericTypes   = new SafeDictionary <Type, Type[]>();
     _genericTypeDef = new SafeDictionary <Type, Type>();
 }
Beispiel #2
0
        private static bool TryGetOpCode(short code, out OpCode opCode)
        {
            if (_opCodes != null)
            {
                return(_opCodes.TryGetValue(code, out opCode));
            }
            var dict = new SafeDictionary <short, OpCode>();

            foreach (var fi in typeof(OpCodes).GetFields(BindingFlags.Public | BindingFlags.Static))
            {
                if (!typeof(OpCode).IsAssignableFrom(fi.FieldType))
                {
                    continue;
                }
                var innerOpCode = (OpCode)fi.GetValue(null);
                if (innerOpCode.OpCodeType != OpCodeType.Nternal)
                {
                    dict.Add(innerOpCode.Value, innerOpCode);
                }
            }
            _opCodes = dict;
            return(_opCodes.TryGetValue(code, out opCode));
        }
Beispiel #3
0
        //private static bool IsAnonymousType(Type type)
        //{
        //    // may break in the future if compiler defined names change...
        //    const string CS_ANONYMOUS_PREFIX = "<>f__AnonymousType";
        //    const string VB_ANONYMOUS_PREFIX = "VB$AnonymousType";

        //    if (type == null)
        //        throw new ArgumentNullException("type");

        //    if (type.Name.StartsWith(CS_ANONYMOUS_PREFIX, StringComparison.Ordinal) || type.Name.StartsWith(VB_ANONYMOUS_PREFIX, StringComparison.Ordinal))
        //    {
        //        return type.IsDefined(typeof(CompilerGeneratedAttribute), false);
        //    }

        //    return false;
        //}
        #endregion

        internal void ResetPropertyCache()
        {
            _propertycache = new SafeDictionary <string, Dictionary <string, myPropInfo> >();
        }