Example #1
0
 internal BfMember(BfCache cache, MemberReference memberRef, BfType type)
 {
     Name     = memberRef.Name;
     FullName = $"{type.FullName}.{Name}";
     _cache   = cache;
     _type    = type;
 }
Example #2
0
        private BfMethod GetBfMethod(MethodReference methodReference)
        {
            var bfType  = _cache.GetBfType(((TypeSpecification)methodReference.DeclaringType).ElementType);
            var hashSet = new HashSet <string>();

            BfMethod bfMethod = null;

            if (bfType != null)
            {
                bfType.GetTypeDefinition().GenericParameters.ForEach(g => hashSet.Add(g.FullName));

                MethodReference definition = null;
                var             list       = new List <MethodReference>();

                list.AddRange(bfType.GetTypeDefinition().Methods);

                foreach (var reference in list)
                {
                    var methodDefinition = (MethodDefinition)reference;

                    if (methodDefinition.Name == methodReference.Name && methodDefinition.Parameters.Count == methodReference.Parameters.Count)
                    {
                        var flag = true;

                        for (var index = 0; index < methodDefinition.Parameters.Count; ++index)
                        {
                            var parameterDefinition = methodDefinition.Parameters[index];
                            var parameterReference  = methodReference.Parameters[index];

                            if (hashSet.Contains(BfCache.GetTypeReference(parameterDefinition.ParameterType).FullName))
                            {
                                if (!parameterReference.ToString().StartsWith("A_"))
                                {
                                    flag = false;
                                }
                            }
                            else if (Regex.Replace(parameterReference.ParameterType.FullName, "<[^>]*>", "") != Regex.Replace(parameterDefinition.ParameterType.FullName, "<[^>]*>", ""))
                            {
                                flag = false;
                            }
                        }

                        if (flag)
                        {
                            definition = methodDefinition;
                        }
                    }
                }

                if (definition == null)
                {
                }
                else
                {
                    GetSignature(definition); // ???
                    bfMethod = _cache.GetBfMethod(definition);
                }
            }
            return(bfMethod);
        }
Example #3
0
        internal BfEvent(BfCache cache, EventDefinition eventDef, BfType type)
            : base(cache, eventDef, type)
        {
            _eventDefinition = eventDef;

            EventType = _cache.GetBfType(_eventDefinition.EventType);

            _typesUsed.Add(EventType);
            _typesUsed.AddRange(_cache.GetTypeCollection(_eventDefinition.EventType));
            _typesUsed.Clear();

            IsInternal  = _eventDefinition.AddMethod.IsAssembly;
            IsProtected = _eventDefinition.AddMethod.IsFamily;
            IsPrivate   = _eventDefinition.AddMethod.IsPrivate;
            IsPublic    = _eventDefinition.AddMethod.IsPublic;
            IsStatic    = _eventDefinition.AddMethod.IsStatic;

            _cache.Events.Add(this);
        }
Example #4
0
        internal BfField(BfCache cache, FieldDefinition fieldDef, BfType type)
            : base(cache, fieldDef, type)
        {
            _fieldDefinition       = fieldDef;
            IsInternal             = _fieldDefinition.IsAssembly;
            IsProtected            = _fieldDefinition.IsFamily;
            IsProtectedAndInternal = _fieldDefinition.IsFamilyAndAssembly;
            IsProtectedOrInternal  = _fieldDefinition.IsFamilyOrAssembly;
            IsPrivate  = _fieldDefinition.IsPrivate;
            IsPublic   = _fieldDefinition.IsPublic;
            IsStatic   = _fieldDefinition.IsStatic;
            IsConstant = _fieldDefinition.HasConstant;

            FieldType = _cache.GetBfType(_fieldDefinition.FieldType);

            _typesUsed.Add(FieldType);
            _typesUsed.AddRange(_cache.GetTypeCollection(_fieldDefinition.FieldType));
            _typesUsed.Clear();

            UniqueName = BfCache.GetKey(_fieldDefinition.DeclaringType);
        }
Example #5
0
        internal BfMethod(BfCache cache, MethodDefinition methodDef, BfType type)
            : base(cache, methodDef, type)
        {
            _methodDefinition = methodDef;
            _methodName       = GetSignature(_methodDefinition);

            if (!type.IsInCoreAssembly)
            {
                return;
            }

            ReturnType = cache.GetBfType(methodDef.ReturnType);

            _typesUsed.AddRange(_cache.GetTypeCollection(methodDef.ReturnType));
            _typesUsed.Add(ReturnType);
            _typesUsed.AddRange(_cache.GetTypeCollection(_methodDefinition));

            if (methodDef.Body != null)
            {
                foreach (var variableDefinition in methodDef.Body.Variables)
                {
                    _typesUsed.AddRange(_cache.GetTypeCollection(variableDefinition.VariableType));
                    _typesUsed.Add(_cache.GetBfType(variableDefinition.VariableType));
                }
            }

            foreach (var parameterDefinition in methodDef.Parameters)
            {
                _typesUsed.AddRange(_cache.GetTypeCollection(parameterDefinition.ParameterType));
                _typesUsed.Add(_cache.GetBfType(parameterDefinition.ParameterType));

                ParameterTypes.AddRange(_cache.GetTypeCollection(parameterDefinition.ParameterType));
                ParameterTypes.Add(_cache.GetBfType(parameterDefinition.ParameterType));
            }

            ParameterTypes.Clear();
        }
Example #6
0
        internal BfType(BfCache cache, TypeDefinition type, BfAssembly assembly)
        {
            _typeDefinition = type;
            _bfCache        = cache;

            Name      = _typeDefinition.Name;
            Assembly  = assembly;
            Namespace = cache.GetNamespace(this);

            IsClass     = _typeDefinition.IsClass;
            IsEnum      = _typeDefinition.IsEnum;
            IsValueType = _typeDefinition.IsValueType;
            IsInterface = _typeDefinition.IsInterface;

            if (_typeDefinition.IsNestedAssembly)
            {
                IsNested   = true;
                IsInternal = true;
            }

            if (_typeDefinition.IsNestedFamily)
            {
                IsNested    = true;
                IsProtected = true;
            }

            if (_typeDefinition.IsNestedFamilyAndAssembly)
            {
                IsNested = true;
                IsProtectedAndInternal = true;
            }

            if (_typeDefinition.IsNestedFamilyOrAssembly)
            {
                IsNested = true;
                IsProtectedOrInternal = true;
            }

            if (_typeDefinition.IsNestedPrivate)
            {
                IsNested  = true;
                IsPrivate = true;
            }

            if (_typeDefinition.IsNestedPublic)
            {
                IsNested = true;
                IsPublic = true;
            }

            IsInternal = _typeDefinition.IsNotPublic;
            IsPublic   = _typeDefinition.IsPublic;

            if ((!_typeDefinition.IsSealed ? 1 : (!_typeDefinition.IsAbstract ? 1 : 0)) == 0)
            {
                IsStatic = true;
            }
            else
            {
                IsSealed   = _typeDefinition.IsSealed;
                IsAbstract = _typeDefinition.IsAbstract;
            }
        }