Inheritance: ExternalMethod, IConstructor
Example #1
0
        public IConstructor Map(ConstructorInfo constructor)
        {
            object       key    = GetCacheKey(constructor);
            IConstructor entity = (IConstructor)_entityCache[key];

            if (null == entity)
            {
                entity            = new ExternalConstructor(this, constructor);
                _entityCache[key] = entity;
            }
            return(entity);
        }
Example #2
0
 public virtual IConstructor[] GetConstructors()
 {
     if (null == _constructors)
     {
         BindingFlags      flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
         ConstructorInfo[] ctors = _type.GetConstructors(flags);
         _constructors = new IConstructor[ctors.Length];
         for (int i = 0; i < _constructors.Length; ++i)
         {
             _constructors[i] = new ExternalConstructor(_typeSystemServices, ctors[i]);
         }
     }
     return(_constructors);
 }
Example #3
0
 public virtual IConstructor[] GetConstructors()
 {
     if (null == _constructors)
     {
         BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
         ConstructorInfo[] ctors = _type.GetConstructors(flags);
         _constructors = new IConstructor[ctors.Length];
         for (int i=0; i<_constructors.Length; ++i)
         {
             _constructors[i] = new ExternalConstructor(_typeSystemServices, ctors[i]);
         }
     }
     return _constructors;
 }
        private void ReplaceWithComponentReference(Node node, string name)
        {
            Expression argument;
            ConstructorInfo constructorInfo;

            name = name.Substring(1);
            var entity = NameResolutionService.ResolveQualifiedName(name);

            if (node.ParentNode.NodeType == NodeType.GenericReferenceExpression)
            {
                var genericRef = (GenericReferenceExpression)(node = node.ParentNode);
                entity = NameResolutionService.ResolveGenericReferenceExpression(genericRef, entity);
                name = genericRef.ToCodeString();
            }

            if (entity == null || entity.EntityType != EntityType.Type)
            {
                constructorInfo = _componentReferenceConstructor;
                argument = CodeBuilder.CreateStringLiteral(name);
            }
            else
            {
                constructorInfo = _componentReferenceTypeConstructor;
                argument = CodeBuilder.CreateReference(entity);
            }
            var constructor = new ExternalConstructor(My<IReflectionTypeSystemProvider>.Instance, constructorInfo);
            var invocation = CodeBuilder.CreateConstructorInvocation(constructor, argument);
            node.ParentNode.Replace(node, invocation);
        }
        private void ReplaceWithComponentReference(Node node, string name)
        {
            Expression argument;
            ConstructorInfo constructorInfo;

            name = name.Substring(1);
            IEntity entity = NameResolutionService.ResolveQualifiedName(name);

            if (entity == null || entity.EntityType != EntityType.Type)
            {
                constructorInfo = _componentReferenceConstructor;
                argument = CodeBuilder.CreateStringLiteral(name);
            }
            else
            {
                constructorInfo = _componentReferenceTypeConstructor;
                argument = CodeBuilder.CreateReference(entity);
            }
            ExternalConstructor constructor = new ExternalConstructor(TypeSystemServices, constructorInfo);
            MethodInvocationExpression invocation = CodeBuilder.CreateConstructorInvocation(constructor, argument);
            node.ParentNode.Replace(node, invocation);
        }
Example #6
0
 public IConstructor Map(ConstructorInfo constructor)
 {
     object key = GetCacheKey(constructor);
     IConstructor entity = (IConstructor)_entityCache[key];
     if (null == entity)
     {
         entity = new ExternalConstructor(this, constructor);
         _entityCache[key] = entity;
     }
     return entity;
 }