Map() public method

public Map ( ConstructorInfo constructor ) : IConstructor
constructor System.Reflection.ConstructorInfo
return IConstructor
Exemplo n.º 1
0
 public ExternalGenericParameter(TypeSystemServices tss, Type type) : base(tss, type)
 {
     if (type.DeclaringMethod != null)
     {
         _declaringMethod = (IMethod)tss.Map(type.DeclaringMethod);
     }
 }
Exemplo n.º 2
0
        Method CreateBeginInvokeExtension(ICallableType anonymousType, Method beginInvoke, out MethodInvocationExpression mie)
        {
            InternalMethod beginInvokeEntity = (InternalMethod)beginInvoke.Entity;

            Method extension = CodeBuilder.CreateMethod("BeginInvoke", TypeSystemServices.Map(typeof(IAsyncResult)),
                                                        TypeMemberModifiers.Public | TypeMemberModifiers.Static);

            extension.Attributes.Add(CodeBuilder.CreateAttribute(Types.ExtensionAttribute));

            ParameterDeclaration self = CodeBuilder.CreateParameterDeclaration(0, "self", beginInvokeEntity.DeclaringType);

            extension.Parameters.Add(self);
            CodeBuilder.DeclareParameters(extension, 1, anonymousType.GetSignature().Parameters);

            mie = CodeBuilder.CreateMethodInvocation(
                CodeBuilder.CreateReference(self),
                beginInvokeEntity);

            ParameterDeclarationCollection parameters = extension.Parameters;

            for (int i = 1; i < parameters.Count; ++i)
            {
                mie.Arguments.Add(CodeBuilder.CreateReference(parameters[i]));
            }
            extension.Body.Add(new ReturnStatement(mie));
            return(extension);
        }
Exemplo n.º 3
0
        public IEntity GetDefaultMember()
        {
            IType defaultMemberAttribute = _typeSystemServices.Map(typeof(DefaultMemberAttribute));

            foreach (Attribute attribute in _typeDefinition.Attributes)
            {
                IConstructor tag = TypeSystemServices.GetEntity(attribute) as IConstructor;
                if (null != tag)
                {
                    if (defaultMemberAttribute == tag.DeclaringType)
                    {
                        StringLiteralExpression memberName = attribute.Arguments[0] as StringLiteralExpression;
                        if (null != memberName)
                        {
                            List buffer = new List();
                            Resolve(buffer, memberName.Value, EntityType.Any);
                            return(NameResolutionService.GetEntityFromList(buffer));
                        }
                    }
                }
            }
            if (null != BaseType)
            {
                return(BaseType.GetDefaultMember());
            }
            return(null);
        }
Exemplo n.º 4
0
        public void Add(Type type)
        {
            Assembly assembly = type.Assembly;
            List     types    = (List)_assemblies[assembly];

            if (null == types)
            {
                types = new List();
                _assemblies[assembly] = types;
            }
            types.Add(type);

            if (_typeSystemServices.IsModule(type))
            {
                _externalModules.Add(_typeSystemServices.Map(type));
            }
        }
Exemplo n.º 5
0
 public virtual IParameter[] GetParameters()
 {
     if (null == _parameters)
     {
         _parameters = _typeSystemServices.Map(_mi.GetParameters());
     }
     return(_parameters);
 }
Exemplo n.º 6
0
 public ExternalGenericParameter(TypeSystemServices tss, Type type)
     : base(tss, type)
 {
     if (type.DeclaringMethod != null)
     {
         _declaringMethod = (IMethod)tss.Map(type.DeclaringMethod);
     }
 }
Exemplo n.º 7
0
 public IParameter[] GetParameters()
 {
     if (null == _parameters)
     {
         _parameters = _typeSystemServices.Map(_property.Parameters);
     }
     return(_parameters);
 }
Exemplo n.º 8
0
        Method CreateBeginInvokeMethod(ICallableType anonymousType)
        {
            Method method = CodeBuilder.CreateRuntimeMethod("BeginInvoke", TypeSystemServices.Map(typeof(IAsyncResult)),
                                                            anonymousType.GetSignature().Parameters, false);

            int delta = method.Parameters.Count;

            method.Parameters.Add(
                CodeBuilder.CreateParameterDeclaration(delta + 1, "callback", TypeSystemServices.Map(typeof(AsyncCallback))));
            method.Parameters.Add(
                CodeBuilder.CreateParameterDeclaration(delta + 1, "asyncState", TypeSystemServices.ObjectType));
            return(method);
        }
Exemplo n.º 9
0
        public IEntity GetDefaultMember()
        {
            IType defaultMemberAttribute = _typeSystemServices.Map(Types.DefaultMemberAttribute);

            foreach (Attribute attribute in _typeDefinition.Attributes)
            {
                IConstructor tag = TypeSystemServices.GetEntity(attribute) as IConstructor;
                if (null != tag)
                {
                    if (defaultMemberAttribute == tag.DeclaringType)
                    {
                        StringLiteralExpression memberName = attribute.Arguments[0] as StringLiteralExpression;
                        if (null != memberName)
                        {
                            List buffer = new List();
                            Resolve(buffer, memberName.Value, EntityType.Any);
                            return(NameResolutionService.GetEntityFromList(buffer));
                        }
                    }
                }
            }
            if (_typeDefinition.BaseTypes.Count > 0)
            {
                List buffer = new List();

                foreach (TypeReference baseType in _typeDefinition.BaseTypes)
                {
                    IType   tag           = TypeSystemServices.GetType(baseType);
                    IEntity defaultMember = tag.GetDefaultMember();
                    if (defaultMember != null)
                    {
                        if (tag.IsInterface)
                        {
                            buffer.AddUnique(defaultMember);
                        }
                        else                         //non-interface base class trumps interfaces
                        {
                            return(defaultMember);
                        }
                    }
                }
                return(NameResolutionService.GetEntityFromList(buffer));
            }
            return(null);
        }
Exemplo n.º 10
0
        private IMember FindByMetadataToken(IMember source, ExternalType targetType)
        {
            // HACK: since the API doesn't provide a way to correlate members on a generic type
            // with the mapped members on a constructed type, we have to rely on them sharing the same
            // metadata token.

            MemberInfo   sourceMemberInfo = ((IExternalEntity)source).MemberInfo;
            MemberFilter filter           = delegate(MemberInfo candidate, object metadataToken)
            {
                return(candidate.MetadataToken.Equals(metadataToken));
            };

            BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;

            bindingFlags |= (source.IsStatic ? BindingFlags.Static : BindingFlags.Instance);

            MemberInfo[] mappedMemberInfos = targetType.ActualType.FindMembers(
                sourceMemberInfo.MemberType, bindingFlags, filter, sourceMemberInfo.MetadataToken);

            return((IMember)TypeSystemServices.Map(mappedMemberInfos[0]));
        }
Exemplo n.º 11
0
        public Method CreateEndInvokeMethod(ICallableType anonymousType)
        {
            CallableSignature signature = anonymousType.GetSignature();
            Method            method    = CodeBuilder.CreateRuntimeMethod("EndInvoke", signature.ReturnType);

            int delta = 1;

            foreach (IParameter p in signature.Parameters)
            {
                if (p.IsByRef)
                {
                    method.Parameters.Add(
                        CodeBuilder.CreateParameterDeclaration(++delta,
                                                               p.Name,
                                                               p.Type,
                                                               true));
                }
            }
            delta = method.Parameters.Count;
            method.Parameters.Add(
                CodeBuilder.CreateParameterDeclaration(delta + 1, "result", TypeSystemServices.Map(typeof(IAsyncResult))));
            return(method);
        }
Exemplo n.º 12
0
        bool IsAttributeDefined(System.Type attributeType)
        {
            IType entity = _typeSystemServices.Map(attributeType);

            return(MetadataUtil.IsAttributeDefined(_method, entity));
        }
Exemplo n.º 13
0
        Method CreateBeginInvokeCallbackOnlyExtension(ICallableType anonymousType, Method beginInvoke)
        {
            MethodInvocationExpression mie;

            Method overload = CreateBeginInvokeExtension(anonymousType, beginInvoke, out mie);
            ParameterDeclaration callback = CodeBuilder.CreateParameterDeclaration(overload.Parameters.Count,
                                                                                   "callback", TypeSystemServices.Map(typeof(AsyncCallback)));

            overload.Parameters.Add(callback);

            mie.Arguments.Add(CodeBuilder.CreateReference(callback));
            mie.Arguments.Add(CodeBuilder.CreateNullLiteral());

            return(overload);
        }
Exemplo n.º 14
0
 public virtual IType GetElementType()
 {
     return(_typeSystemServices.Map(_type.GetElementType()));
 }
Exemplo n.º 15
0
 public Attribute CreateAttribute(System.Type type)
 {
     return(CreateAttribute(TypeSystemServices.Map(type)));
 }
Exemplo n.º 16
0
 public ReferenceExpression CreateReference(LexicalInfo li, System.Type type)
 {
     return(CreateReference(li, TypeSystemServices.Map(type)));
 }
Exemplo n.º 17
0
 public TypeReference CreateTypeReference(LexicalInfo li, Type type)
 {
     return(CreateTypeReference(li, TypeSystemServices.Map(type)));
 }
Exemplo n.º 18
0
 public TypeReference CreateTypeReference(Type type)
 {
     return(CreateTypeReference(TypeSystemServices.Map(type)));
 }
Exemplo n.º 19
0
 public MethodInvocationExpression CreateMethodInvocation(MethodInfo staticMethod, Expression arg0, Expression arg1)
 {
     return(CreateMethodInvocation(TypeSystemServices.Map(staticMethod), arg0, arg1));
 }
Exemplo n.º 20
0
 public Expression CreateTypeofExpression(System.Type type)
 {
     return(CreateTypeofExpression(_tss.Map(type)));
 }
Exemplo n.º 21
0
 protected IType Map(Type type)
 {
     return(_typeSystemServices.Map(type));
 }
Exemplo n.º 22
0
 internal ExternalCallableType(TypeSystemServices typeSystemServices, Type type)
     : base(typeSystemServices, type)
 {
     _invoke = typeSystemServices.Map(type.GetMethod("Invoke"));
 }
Exemplo n.º 23
0
 internal ExternalCallableType(TypeSystemServices typeSystemServices, Type type) : base(typeSystemServices, type)
 {
     _invoke = typeSystemServices.Map(type.GetMethod("Invoke"));
 }
Exemplo n.º 24
0
 public Expression CreateTypeofExpression(System.Type type)
 {
     return(CreateTypeofExpression(TypeSystemServices.Map(type)));
 }
Exemplo n.º 25
0
 public Attribute CreateAttribute(System.Type type)
 {
     return(CreateAttribute(_tss.Map(type)));
 }
Exemplo n.º 26
0
 public MethodInvocationExpression CreateMethodInvocation(Expression target, MethodInfo method)
 {
     return(CreateMethodInvocation(target, TypeSystemServices.Map(method)));
 }