public InstantiatedParameterType (ProjectDom dom, ITypeParameterMember typeParameterMember, ITypeParameter tp)
		{
			IType outerType = typeParameterMember as IType ?? typeParameterMember.DeclaringType;
			typeparam = tp;
			compilationUnit = outerType.CompilationUnit;
			ClassType = ClassType.Class;
			Modifiers = Modifiers.Public;
			Name = tp.Name;
			Namespace = outerType.DecoratedFullName;
			Location = outerType.Location;
			DeclaringType = outerType;
			
			if (tp.Constraints.Count > 0)
				ClassType = ClassType.Interface;
			foreach (IReturnType rt in tp.Constraints) {
				if (FindCyclicReference (new HashSet<ITypeParameter> () { tp }, outerType, ((DomReturnType)rt).DecoratedFullName))
					continue;
				IType bt = dom.SearchType (typeParameterMember, rt);
				IReturnType resolvedType = rt;
				if (bt != null) {
					resolvedType = new DomReturnType (bt);
					if (bt.ClassType == ClassType.Interface || BaseType != null) {
						AddInterfaceImplementation (resolvedType);
					} else {
						ClassType = bt.ClassType;
						BaseType = resolvedType;
					}
				} else {
					AddInterfaceImplementation (resolvedType);
				}
			}
			if (BaseType == null)
				BaseType = DomReturnType.Object;
		}
Example #2
0
        public int GetParameterCount(int overload)
        {
            if (overload < 0 || overload >= OverloadCount)
            {
                return(0);
            }
            ITypeParameterMember type = types[overload] is InstantiatedType ? ((InstantiatedType)types[overload]).UninstantiatedType : types[overload];

            return(type.TypeParameters.Count);
        }
Example #3
0
        public string GetParameterMarkup(int overload, int paramIndex)
        {
            ITypeParameterMember type = types[overload] is InstantiatedType ? ((InstantiatedType)types[overload]).UninstantiatedType : types[overload];

            if (paramIndex < 0 || paramIndex >= type.TypeParameters.Count)
            {
                return("");
            }
            return(type.TypeParameters[paramIndex].Name);           //ambience.GetString (, OutputFlags.AssemblyBrowserDescription | OutputFlags.HideExtensionsParameter | OutputFlags.IncludeGenerics | OutputFlags.IncludeModifiers | OutputFlags.HighlightName);
        }
        public InstantiatedParameterType(ProjectDom dom, ITypeParameterMember typeParameterMember, ITypeParameter tp)
        {
            IType outerType = typeParameterMember as IType ?? typeParameterMember.DeclaringType;

            typeparam       = tp;
            compilationUnit = outerType.CompilationUnit;
            ClassType       = ClassType.Class;
            Modifiers       = Modifiers.Public;
            Name            = tp.Name;
            Namespace       = outerType.DecoratedFullName;
            Location        = outerType.Location;
            DeclaringType   = outerType;
            if (tp.ValueTypeRequired)
            {
                BaseType = new DomReturnType("System.ValueType");
            }

            if (tp.Constraints.Count > 0)
            {
                ClassType = ClassType.Interface;
            }
            foreach (IReturnType rt in tp.Constraints)
            {
                if (FindCyclicReference(new HashSet <ITypeParameter> ()
                {
                    tp
                }, outerType, ((DomReturnType)rt).DecoratedFullName))
                {
                    continue;
                }
                IType       bt           = dom.SearchType(typeParameterMember, rt);
                IReturnType resolvedType = rt;
                if (bt != null)
                {
                    resolvedType = new DomReturnType(bt);
                    if (bt.ClassType == ClassType.Interface || BaseType != null)
                    {
                        AddInterfaceImplementation(resolvedType);
                    }
                    else
                    {
                        ClassType = bt.ClassType;
                        BaseType  = resolvedType;
                    }
                }
                else
                {
                    AddInterfaceImplementation(resolvedType);
                }
            }
            if (BaseType == null)
            {
                BaseType = DomReturnType.Object;
            }
        }
Example #5
0
 IType FindGenericParameter(ICompilationUnit cu, ITypeParameterMember callingClass, string name)
 {
     foreach (TypeParameter tp in callingClass.TypeParameters)
     {
         if (tp.Name == name)
         {
             return(CreateInstantiatedParameterType(callingClass, tp));
         }
     }
     if (callingClass.DeclaringType != null)
     {
         return(FindGenericParameter(cu, callingClass.DeclaringType, name));
     }
     return(null);
 }
Example #6
0
 public virtual void TranslateMember(ITypeParameterMember typeParamMember)
 {
     if (typeParamMember is IMethodSignatureTypeParameterMember)
     {
         this.TranslateMember((IMethodSignatureTypeParameterMember)typeParamMember);
     }
     else if (typeParamMember is IMethodTypeParameterMember)
     {
         this.TranslateMember((IMethodTypeParameterMember)typeParamMember);
     }
     else if (typeParamMember is ITypeParameterMember <CodeTypeDelegate> )
     {
         this.TranslateMember((ITypeParameterMember <CodeTypeDelegate>)typeParamMember);
     }
     else if (typeParamMember is ITypeParameterMember <CodeTypeDeclaration> )
     {
         this.TranslateMember((ITypeParameterMember <CodeTypeDeclaration>)typeParamMember);
     }
 }
Example #7
0
 public void TranslateConstraints(ITypeParameterMember typeParamMember)
 {
     if (typeParamMember is IMethodSignatureTypeParameterMember)
     {
         this.TranslateConstraints((IMethodSignatureTypeParameterMember)typeParamMember);
     }
     else if (typeParamMember is IMethodTypeParameterMember)
     {
         this.TranslateConstraints((IMethodTypeParameterMember)typeParamMember);
     }
     else if (typeParamMember is ITypeParameterMember <CodeTypeDelegate> )
     {
         this.TranslateConstraints <CodeTypeParameter, IDeclaredType <CodeTypeDelegate> >((ITypeParameterMember <CodeTypeDelegate>)typeParamMember);
     }
     else if (typeParamMember is ITypeParameterMember <CodeTypeDeclaration> )
     {
         this.TranslateConstraints((ITypeParameterMember <CodeTypeDeclaration>)typeParamMember);
     }
     else
     {
         throw new NotSupportedException("Unknown type-parameter.");
     }
 }
		public override IType CreateInstantiatedParameterType (ITypeParameterMember typeParameterMember, TypeParameter tp)
		{
			return decorated.CreateInstantiatedParameterType (typeParameterMember, tp);
		}
Example #9
0
 public abstract void TranslateConstraints <TDom, TParent>(ITypeParameterMember <TDom, TParent> ambigTypeParamMember)
     where TDom :
 CodeTypeParameter,
 new()
     where TParent :
 IDeclaration;
Example #10
0
 public virtual void TranslateConstraints(ITypeParameterMember <CodeTypeDeclaration> ambigTypeParameter)
 {
     TranslateConstraints <CodeTypeParameter, IDeclaredType <CodeTypeDeclaration> >(ambigTypeParameter);
 }
Example #11
0
 public override void TranslateConceptTypeName(ITypeParameterMember type, ITypeReferenceCollection typeParameters)
 {
     this.Provider.GenerateCodeFromExpression(type.GetTypeReference(typeParameters).GetTypeExpression().GenerateCodeDom(this.Options), base.Target, this.Options.Options);
 }
Example #12
0
 public abstract void TranslateConceptTypeName(ITypeParameterMember type, ITypeReferenceCollection typeParameters);
Example #13
0
 public virtual IType CreateInstantiatedParameterType(ITypeParameterMember typeParameterMember, TypeParameter tp)
 {
     return(new InstantiatedParameterType(this, typeParameterMember, tp));
 }
Example #14
0
 public override IType CreateInstantiatedParameterType(ITypeParameterMember typeParameterMember, TypeParameter tp)
 {
     return(decorated.CreateInstantiatedParameterType(typeParameterMember, tp));
 }
Example #15
0
 public override void TranslateConstraints <TDom, TParent>(ITypeParameterMember <TDom, TParent> ambigTypeParamMember)
 {
     throw new NotSupportedException("The method or operation is not supported.");
 }
Example #16
0
		IType FindGenericParameter (ICompilationUnit cu, ITypeParameterMember callingClass, string name)
		{
			foreach (TypeParameter tp in callingClass.TypeParameters) {
				if (tp.Name == name)
					return CreateInstantiatedParameterType (callingClass, tp);
			}
			if (callingClass.DeclaringType != null)
				return FindGenericParameter (cu, callingClass.DeclaringType, name);
			return null;
		}
Example #17
0
		public virtual IType CreateInstantiatedParameterType (ITypeParameterMember typeParameterMember, TypeParameter tp)
		{
			return new InstantiatedParameterType (this, typeParameterMember, tp);
		}
Example #18
0
 public override void TranslateMember <TDom, TParent>(ITypeParameterMember <TDom, TParent> typeParamMember)
 {
     Target.Write(typeParamMember.Name);
 }