当前位置: 首页>>代码示例>>C#>>正文


C# DomReturnType类代码示例

本文整理汇总了C#中DomReturnType的典型用法代码示例。如果您正苦于以下问题:C# DomReturnType类的具体用法?C# DomReturnType怎么用?C# DomReturnType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DomReturnType类属于命名空间,在下文中一共展示了DomReturnType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InstantiatedParameterType

		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;
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:34,代码来源:InstantiatedParameterType.cs

示例2: InstantiatedMethodByParameterTest

		public void InstantiatedMethodByParameterTest ()
		{
			// build "T MyMethod<T> (T[] a)"
			DomMethod method = new DomMethod ();
			method.Name = "MyMethod";
			method.ReturnType = new DomReturnType ("T");
			method.AddTypeParameter (new TypeParameter ("T"));
			DomReturnType returnType = new DomReturnType ("T");
			returnType.ArrayDimensions = 1;
			method.Add (new DomParameter (method, "a", returnType));
			
			// give int[] as param type.
			List<IReturnType> genArgs = new List<IReturnType> ();
			List<IReturnType> args    = new List<IReturnType> ();
			returnType = new DomReturnType (DomReturnType.Int32.FullName);
			returnType.ArrayDimensions = 1;
			args.Add (returnType);
			
			IMethod instMethod = DomMethod.CreateInstantiatedGenericMethod (method, genArgs, args);
			
			// check (note that return type should be int and not int[])
			Assert.AreEqual (DomReturnType.Int32.FullName, instMethod.ReturnType.FullName);
			Assert.AreEqual (0, instMethod.ReturnType.ArrayDimensions);
			Assert.AreEqual (DomReturnType.Int32.FullName, instMethod.Parameters[0].ReturnType.FullName);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:25,代码来源:DomTests.cs

示例3: NSObjectInfoService

		static NSObjectInfoService ()
		{
			string wrapperRootNamespace = "MonoTouch";
			string foundation = wrapperRootNamespace + ".Foundation";
			connectAttType = new DomReturnType (foundation, "ConnectAttribute");
			exportAttType = new DomReturnType (foundation, "ExportAttribute");
			registerAttType = new DomReturnType (foundation, "RegisterAttribute");
			modelAttType = new DomReturnType (foundation, "ModelAttribute");
			nsobjectType = new DomReturnType (foundation, "NSObject");
		}
开发者ID:thild,项目名称:monodevelop,代码行数:10,代码来源:NSObjectInfoService.cs

示例4: NSObjectInfoService

		public NSObjectInfoService (string wrapperRoot)
		{
			this.WrapperRoot = wrapperRoot;
			string foundation = wrapperRoot + ".Foundation";
			connectAttType = new DomReturnType (foundation, "ConnectAttribute");
			exportAttType = new DomReturnType (foundation, "ExportAttribute");
			iboutletAttType = new DomReturnType (foundation, "OutletAttribute");
			ibactionAttType = new DomReturnType (foundation, "ActionAttribute");
			registerAttType = new DomReturnType (foundation, "RegisterAttribute");
			modelAttType = new DomReturnType (foundation, "ModelAttribute");
			nsobjectType = new DomReturnType (foundation, "NSObject");
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:12,代码来源:NSObjectInfoService.cs

示例5: GetTypeSafe

		public IReturnType GetTypeSafe (Expression expression)
		{
			ResolveResult result = Resolve (expression);
			if (expression is LambdaExpression) {
				var lambda = (LambdaExpression)expression; 
				var bodyType = GetTypeSafe (lambda.ExpressionBody);
				DomReturnType constructedLambdaType = new DomReturnType (bodyType.FullName == DomReturnType.Void.FullName ? "System.Action" : "System.Func");
				foreach (var param in lambda.Parameters) {
					var typeParam = GetTypeSafe (param);
					// add void place holder for types that can't be resolved.
					if (typeParam == null || string.IsNullOrEmpty (typeParam.FullName))
						typeParam = DomReturnType.Void;
					constructedLambdaType.AddTypeParameter (typeParam);
				}
				if (bodyType.FullName != DomReturnType.Void.FullName)
					constructedLambdaType.AddTypeParameter (bodyType ?? result.ResolvedType);
				return constructedLambdaType;
			}
			return result.ResolvedType ?? DomReturnType.Void;
		}
开发者ID:raufbutt,项目名称:monodevelop-old,代码行数:20,代码来源:ResolveVisitor.cs

示例6: NSObjectInfoTracker

		public NSObjectInfoTracker (DotNetProject project, string wrapperRootNamespace)
		{
			this.project = project;
			
			string foundation = wrapperRootNamespace + ".Foundation";
			connectAttType = new DomReturnType (foundation, "ConnectAttribute");
			exportAttType = new DomReturnType (foundation, "ExportAttribute");
			registerAttType = new DomReturnType (foundation, "RegisterAttribute");
			modelAttType = new DomReturnType (foundation, "ModelAttribute");
			nsobjectType = new DomReturnType (foundation, "NSObject");
			
			//FIXME: might there be a race here?
			var dom = ProjectDomService.GetProjectDom (project);
			if (dom == null) {
				subscribedDomLoaded = true;
				ProjectDomService.DomRegistered += DomLoaded;
			} else {
				System.Threading.ThreadPool.QueueUserWorkItem (delegate {
					DomLoaded (dom);
				});
			}
		}
开发者ID:poke,项目名称:monodevelop,代码行数:22,代码来源:NSObjectInfoTracker.cs

示例7: ConvertToReturnType

		public static DomReturnType ConvertToReturnType (this TypeReference typeRef)
		{
			if (typeRef == null)
				return null;
			DomReturnType result;
			if (typeRef is InnerClassTypeReference) {
				InnerClassTypeReference innerTypeRef = (InnerClassTypeReference)typeRef;
				result = innerTypeRef.BaseType.ConvertToReturnType ();
				result.Parts.Add (new ReturnTypePart (typeRef.Type));
			} else {
				result = new DomReturnType (typeRef.Type);
			}
			foreach (TypeReference genericArgument in typeRef.GenericTypes) {
				result.AddTypeParameter (ConvertToReturnType (genericArgument));
			}
			result.PointerNestingLevel = typeRef.PointerNestingLevel;
			if (typeRef.IsArrayType) {
				result.ArrayDimensions = typeRef.RankSpecifier.Length;
				for (int i = 0; i < typeRef.RankSpecifier.Length; i++) {
					result.SetDimension (i, typeRef.RankSpecifier[i]);
				}
			}
			return result;
		}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:24,代码来源:HelperMethods.cs

示例8: GetGenericType

		public void GetGenericType ()
		{
			List<IReturnType> args = new List<IReturnType> ();
			DomReturnType rt = new DomReturnType ("System.String");
			args.Add (rt);
			IType type = mainProject.GetType ("CompletionDbTest.SomeGeneric", args);
			Assert.IsNotNull (type);
			Assert.AreEqual ("CompletionDbTest.SomeGeneric[System.String]", type.FullName);
			Assert.AreEqual (0, type.TypeParameters.Count);

			IMethod met = FindMember (type, "Run") as IMethod;
			Assert.IsNotNull (met);
			Assert.AreEqual (1, met.Parameters.Count);
			Assert.AreEqual ("System.String", met.Parameters[0].ReturnType.FullName);
			Assert.IsNotNull (met.ReturnType);
			Assert.AreEqual ("System.String", met.ReturnType.FullName);
			
			type = mainProject.GetType ("Library2.GenericWidget");
			Assert.IsNotNull (type);
			Assert.AreEqual ("Library2.GenericWidget", type.FullName);
			Assert.AreEqual (0, type.TypeParameters.Count);
			
			type = mainProject.GetType ("Library2.GenericWidget", 1, true);
			Assert.IsNotNull (type);
			Assert.AreEqual ("Library2.GenericWidget", type.FullName);
			Assert.AreEqual (1, type.TypeParameters.Count);
			
			type = mainProject.GetType ("Library2.GenericWidget", 2, true);
			Assert.IsNotNull (type);
			Assert.AreEqual ("Library2.GenericWidget", type.FullName);
			Assert.AreEqual (2, type.TypeParameters.Count);
			
			type = mainProject.GetType ("Library2.GenericWidget", 3, true);
			Assert.IsNull (type);

			// Inner generic type
			
			type = mainProject.GetType ("Library2.Container.InnerClass1", 1, true);
			Assert.IsNotNull (type);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:40,代码来源:CompletionDatabaseTests.cs

示例9: AddType

		internal static void AddType (ProjectDom dom, List<object> result, IReturnType returnType, IMember callingMember, bool showStatic)
		{
			if (returnType == null || returnType.FullName == "System.Void")
				return;
			if (returnType.ArrayDimensions > 0) {
				DomReturnType elementType = new DomReturnType (returnType.FullName);
				elementType.ArrayDimensions = returnType.ArrayDimensions - 1;
				for (int i = 0; i < elementType.ArrayDimensions; i++) {
					elementType.SetDimension (i, returnType.ArrayDimensions - 1);
				}
				elementType.PointerNestingLevel = returnType.PointerNestingLevel;
				
				AddType (dom, result, dom.GetArrayType (elementType), callingMember, showStatic);
				return;
			}
			IType type = dom.GetType (returnType);
			
			AddType (dom, result, type, callingMember, showStatic);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:19,代码来源:ResolveResult.cs

示例10: ResolveIdentifier

        public ResolveResult ResolveIdentifier(ResolveVisitor visitor, string identifier)
        {
            ResolveResult result = null;
             			if (resultTable.TryGetValue (identifier, out result))
             				return result;
             			resultTable[identifier] = result;

            foreach (KeyValuePair<string, List<LocalLookupVariable>> pair in this.lookupTableVisitor.Variables) {
             				if (identifier == pair.Key) {
             					LocalLookupVariable var = null;
            // 					Console.WriteLine ("--- RP:" + this.resolvePosition + "/" + pair.Value.Count);
                    foreach (LocalLookupVariable v2 in pair.Value) {
                        DomLocation varStartPos = new DomLocation (lookupVariableLine + v2.StartPos.Line, v2.StartPos.Column - 1);
                        DomLocation varEndPos   = new DomLocation (lookupVariableLine + v2.EndPos.Line, v2.EndPos.Column - 1);
            //						Console.WriteLine (v2.Name + ":" + varStartPos + " <> " + varEndPos);
                        if (varStartPos > this.resolvePosition || (!v2.EndPos.IsEmpty && varEndPos < this.resolvePosition))
                            continue;
                        var = v2;
                    }
            //					Console.WriteLine ("var:" + var);
                    if (var == null)
                        continue;
                    IReturnType varType = null;
                    IReturnType varTypeUnresolved = null;
                    if (var.IsQueryContinuation) {
                        QueryExpression query = var.Initializer as QueryExpression;

                        QueryExpressionGroupClause grouBy = query.SelectOrGroupClause as QueryExpressionGroupClause;
                        DomLocation old = resolvePosition;
                        try {
                            resolvePosition = new DomLocation (lookupVariableLine + grouBy.Projection.StartLocation.Line,
                                                               grouBy.Projection.StartLocation.Column);
                            ResolveResult initializerResolve = visitor.Resolve (grouBy.Projection);
                            ResolveResult groupByResolve = visitor.Resolve (grouBy.GroupBy);
                            DomReturnType resolved = new DomReturnType (dom.GetType ("System.Linq.IGrouping", new IReturnType [] {
                                DomType.GetComponentType (dom, initializerResolve.ResolvedType), groupByResolve.ResolvedType}));
                        varTypeUnresolved = varType = resolved;
                        } finally {
                            resolvePosition = old;
                        }

                    } else if ((var.TypeRef == null || var.TypeRef.Type == "var" || var.TypeRef.IsNull)) {
                        if (var.ParentLambdaExpression != null) {
                            ResolveResult lambdaResolve = ResolveLambda (visitor, var.ParentLambdaExpression);
                            if (lambdaResolve != null) {
                                varType           = lambdaResolve.ResolvedType;
                                varTypeUnresolved = lambdaResolve.UnresolvedType;
                            } else {
                                varType = varTypeUnresolved = DomReturnType.Void;
                            }
                        }
                        if (var.Initializer != null) {
                            ResolveResult initializerResolve = visitor.Resolve (var.Initializer);
            //							Console.WriteLine ("initializer : "+ var.Initializer + " result:" + initializerResolve);
                            varType           = var.IsLoopVariable ? DomType.GetComponentType (dom, initializerResolve.ResolvedType) : initializerResolve.ResolvedType;
                            varTypeUnresolved = var.IsLoopVariable ? DomType.GetComponentType (dom, initializerResolve.UnresolvedType) : initializerResolve.UnresolvedType;
            //							Console.WriteLine ("resolved type:" + initializerResolve.ResolvedType + " is loop : " + var.IsLoopVariable);
            //							Console.WriteLine (varType);
            //							Console.WriteLine ("----------");
                        }
                    } else {
                        varTypeUnresolved = varType = ConvertTypeReference (var.TypeRef);
                    }
            //					Console.WriteLine ("-----");
            //					Console.WriteLine (varType);
                    varType = ResolveType (varType);
                    result = new LocalVariableResolveResult (
                        new LocalVariable (CallingMember, identifier, varType,
                            new DomRegion (lookupVariableLine + var.StartPos.Line - 1, var.StartPos.Column - 1,
                                           lookupVariableLine + var.StartPos.Line - 1, var.EndPos.Column - 1)),
                            var.IsLoopVariable);

                    result.ResolvedType = varType;
                    result.UnresolvedType = varTypeUnresolved;
                    goto end;
                }
            }
            if (this.callingMember != null) {
                // special handling of property or field return types, they can have the same name as the return type
                // ex.: MyType MyType { get; set; }  Type1 Type1;
                if ((callingMember is IProperty || callingMember is IField) && identifier == callingMember.Name) {
                    int pos = editor.GetPositionFromLineColumn (resolvePosition.Line, resolvePosition.Column);
                    while (pos < editor.TextLength && !Char.IsWhiteSpace (editor.GetCharAt (pos)))
                        pos++;
                    while (pos < editor.TextLength && Char.IsWhiteSpace (editor.GetCharAt (pos)))
                        pos++;
                    StringBuilder memberName = new StringBuilder ();
                    while (pos < editor.TextLength && (Char.IsLetterOrDigit (editor.GetCharAt (pos)) || editor.GetCharAt (pos) == '_') ) {
                        memberName.Append (editor.GetCharAt (pos));
                        pos++;
                    }
                    //Console.WriteLine ("id: '" + identifier + "' : '" + memberName.ToString () +"'" + (memberName.ToString () == identifier));
                    if (memberName.ToString () == identifier) {
                        result = visitor.CreateResult (callingMember.ReturnType);
                        goto end;
                    }
                }

                if (identifier == "value" && this.callingMember is IProperty) {
                    result = new MemberResolveResult (this.callingMember);
//.........这里部分代码省略.........
开发者ID:vasili,项目名称:FSharpBinding,代码行数:101,代码来源:NRefactoryResolver.cs

示例11: if

		/*
			// Check if 'type' has some decorations applied to it
				if (type is Mono.Cecil.TypeSpecification) {
					// Go through all levels of 'indirection', 'array dimensions'
					// and 'generic types' - in the end, we should get the actual
					// type of the ReturnType (but all data about its array
					// dimensions, levels of indirection and even its generic
					// parameters is correctly stored within ArrayCount and
					// ArrayDimensions, PointerNestingLevel and GenericArguments
					// respectively).
					if (type is ArrayType) {
						// This return type is obviously an array - add the rank
						ArrayType at = (ArrayType) type;
						if (arrays == null)
							arrays = new Stack<int>();
						arrays.Push(at.Rank);
						type = at.ElementType;
					} else else if (type is Mono.Cecil.ReferenceType) {
						Mono.Cecil.ReferenceType rt = (Mono.Cecil.ReferenceType) type;
						byRef = true;
						type = rt.ElementType;
					} else if (type is PointerType) {
						// The type is a pointer
						PointerType pt = (PointerType) type;
						++pointerNestingLevel;
						type = pt.ElementType;
						// Go down one level
					} else {
						// TODO: Check if we loose some relevant info here
						type = ((TypeSpecification)type).ElementType;
					}*/
		public static DomReturnType GetReturnType (TypeReference typeReference)
		{
			if (typeReference == null)
				return new DomReturnType (DomReturnType.Void.ToInvariantString ());
			
			if (typeReference is Mono.Cecil.GenericInstanceType) {
				Mono.Cecil.GenericInstanceType genType = (Mono.Cecil.GenericInstanceType)typeReference;
				DomReturnType result = GetReturnType (genType.ElementType);
				
				foreach (TypeReference typeRef in genType.GenericArguments) {
					DomReturnType param = GetReturnType (typeRef);
					
					foreach (ReturnTypePart part in result.Parts) {
						if (part.Tag is TypeDefinition) {
							TypeDefinition typeDef = (TypeDefinition)part.Tag;
							foreach (TypeReference typeParam in typeDef.GenericParameters) {
								if (typeParam.Name == param.Name) {
									part.AddTypeParameter (param);
									goto skip;
								}
							}
						}
					}
					result.AddTypeParameter (param);
				skip:;
				}
				return result;
			}
			
			if (typeReference is Mono.Cecil.ArrayType) {
				Mono.Cecil.ArrayType arrType = (Mono.Cecil.ArrayType)typeReference;
				DomReturnType result = GetReturnType (arrType.ElementType);
				result.ArrayDimensions++;
				result.SetDimension (result.ArrayDimensions - 1, arrType.Rank - 1);
				return result;
			}
			
			if (typeReference is Mono.Cecil.PointerType) {
				Mono.Cecil.PointerType ptrType = (Mono.Cecil.PointerType)typeReference;
				DomReturnType result = GetReturnType (ptrType.ElementType);
				if (result.ArrayDimensions > 0)
					result.ArrayPointerNestingLevel++;
				else 
					result.PointerNestingLevel++;
				return result;
			}
			if (typeReference is Mono.Cecil.ByReferenceType)
				return GetReturnType (((Mono.Cecil.ByReferenceType)typeReference).ElementType);
			
			if (typeReference is Mono.Cecil.TypeDefinition) {
				Mono.Cecil.TypeDefinition typeDefinition = (Mono.Cecil.TypeDefinition)typeReference;
				DomReturnType result;
				if (typeDefinition.DeclaringType != null) {
					result = GetReturnType (typeDefinition.DeclaringType);
					result.Parts.Add (new ReturnTypePart (typeDefinition.Name));
					result.Tag = typeDefinition;
				} else {
					result = new DomReturnType (typeDefinition.Name);
					result.Namespace = typeDefinition.Namespace;
					result.Tag = typeDefinition;
				}
				return result;
			}
			
			return new DomReturnType (DomCecilType.RemoveGenericParamSuffix (typeReference.FullName)); 
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:97,代码来源:DomCecilMethod.cs

示例12: GetType

		public virtual IType GetType (IReturnType returnType)
		{
			if (returnType == null)
				return null;
			
			if (returnType.ArrayDimensions > 0) {
				DomReturnType newType = new DomReturnType (returnType.FullName);
				// dimensions are correctly updated when cropped
				newType.ArrayDimensions = returnType.ArrayDimensions - 1;
				newType.PointerNestingLevel = returnType.PointerNestingLevel;
				return GetArrayType (newType);
			}
			
			IType type = returnType.Type ?? GetType (((DomReturnType)returnType).DecoratedFullName, returnType.GenericArguments, true, true);
			if (type != null)  {
				if (type.Kind == TypeKind.GenericInstantiation || type.Kind == TypeKind.GenericParameter)
					return type;
				if (!returnType.Parts.Any (part => part.GenericArguments.Count != 0))
					return type;
				List<IReturnType> aggregatedGenerics = new List<IReturnType> ();
				foreach (IReturnTypePart part in returnType.Parts) {
					aggregatedGenerics.AddRange (part.GenericArguments);
				}
				
				return CreateInstantiatedGenericType (type, aggregatedGenerics);
			}
			return type;
/*			
			IReturnTypePart part = returnType.Parts [0];
			string name = !string.IsNullOrEmpty (returnType.Namespace) ? returnType.Namespace + "." + part.Name : part.Name;
			IType ptype = GetType (name, part.GenericArguments, true, true);
			if (ptype == null)
				return null;
			for (int n=1; n < returnType.Parts.Count; n++) {
				part = returnType.Parts [n];
				ptype = SearchInnerType (ptype, part.Name, part.GenericArguments.Count, true);
				if (ptype != null)
					break;
				if (ptype == null)
					return null;
				if (part.GenericArguments.Count > 0)
					ptype = CreateInstantiatedGenericType (ptype, part.GenericArguments);
			}
			return ptype;
			*/
			
			
		}
开发者ID:kmarecki,项目名称:monodevelop,代码行数:48,代码来源:ProjectDom.cs

示例13: ConvertReturnType

			IReturnType ConvertReturnType (Mono.CSharp.Expression typeName)
			{
				if (typeName is TypeExpression) {
					var typeExpr = (Mono.CSharp.TypeExpression)typeName;
					return new DomReturnType (keywordTable [(int)typeExpr.Type.BuiltinType]);
				}
				
				if (typeName is Mono.CSharp.QualifiedAliasMember) {
					var qam = (Mono.CSharp.QualifiedAliasMember)typeName;
					// TODO: Overwork the return type model - atm we don't have a good representation
					// for qualified alias members.
					return new DomReturnType (qam.Name);
				}
				
				if (typeName is MemberAccess) {
					MemberAccess ma = (MemberAccess)typeName;
					var baseType = (DomReturnType)ConvertReturnType (ma.LeftExpression);
					baseType.Parts.Add (new ReturnTypePart (ma.Name));
					AddTypeArguments (ma, baseType);
					return baseType;
				}
				
				if (typeName is SimpleName) {
					var sn = (SimpleName)typeName;
					var result = new DomReturnType (sn.Name);
					AddTypeArguments (sn, result);
					return result;
				}
				
				if (typeName is ComposedCast) {
					var cc = (ComposedCast)typeName;
					var baseType = (DomReturnType)ConvertReturnType (cc.Left);
					if (cc.Spec.IsNullable) {
						return new DomReturnType ("System.Nullable", true, new IReturnType[] { baseType });
					} else if (cc.Spec.IsPointer) {
						baseType.PointerNestingLevel++;
					} else {
						baseType.ArrayDimensions++;
						baseType.SetDimension (baseType.ArrayDimensions - 1, cc.Spec.Dimension - 1);
					}
					return baseType;
				}
				MonoDevelop.Core.LoggingService.LogError ("Error while converting :" + typeName + " - unknown type name");
				return new DomReturnType (DomReturnType.Void.FullName);
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:45,代码来源:McsParser.cs

示例14: ImplementMember

		public override IMember ImplementMember (RefactorerContext ctx, IType cls, IMember member, IReturnType privateImplementationType)
		{
			if (privateImplementationType != null) {
				// Workaround for bug in the code generator. Generic private implementation types are not generated correctly when they are generic.
				Ambience amb = new CSharpAmbience ();
				string tn = amb.GetString (privateImplementationType, OutputFlags.IncludeGenerics | OutputFlags.UseFullName | OutputFlags.UseIntrinsicTypeNames);
				privateImplementationType = new DomReturnType (tn);
			}
			return base.ImplementMember (ctx, cls, member, privateImplementationType);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:10,代码来源:CodeGenerator.cs

示例15: ImplementInterface

		public IType ImplementInterface (ICompilationUnit pinfo, IType klass, IType iface, bool explicitly, IType declaringClass, IReturnType hintReturnType)
		{
			if (klass == null)
				throw new ArgumentNullException ("klass");
			if (iface == null)
				throw new ArgumentNullException ("iface");
			RefactorerContext gctx = GetGeneratorContext (klass);
			klass = GetUpdatedClass (gctx, klass);
			
			bool alreadyImplemented;
			IReturnType prefix = null;
			
			List<KeyValuePair<IMember,IReturnType>> toImplement = new List<KeyValuePair<IMember,IReturnType>> ();
			
			prefix = new DomReturnType (iface);
			
			// Stub out non-implemented events defined by @iface
			foreach (IEvent ev in iface.Events) {
				if (ev.IsSpecialName)
					continue;
				bool needsExplicitly = explicitly;
				
				alreadyImplemented = gctx.ParserContext.GetInheritanceTree (klass).Any (x => x.ClassType != ClassType.Interface && x.Events.Any (y => y.Name == ev.Name));
				
				if (!alreadyImplemented)
					toImplement.Add (new KeyValuePair<IMember,IReturnType> (ev, needsExplicitly ? prefix : null));
			}
			
			// Stub out non-implemented methods defined by @iface
			foreach (IMethod method in iface.Methods) {
				if (method.IsSpecialName)
					continue;
				bool needsExplicitly = explicitly;
				alreadyImplemented = false;
				foreach (IType t in gctx.ParserContext.GetInheritanceTree (klass)) {
					if (t.ClassType == ClassType.Interface)
						continue;
					foreach (IMethod cmet in t.Methods) {
						if (cmet.Name == method.Name && Equals (cmet.Parameters, method.Parameters)) {
							if (!needsExplicitly && !cmet.ReturnType.Equals (method.ReturnType))
								needsExplicitly = true;
							else
								alreadyImplemented |= !needsExplicitly || (iface.FullName == GetExplicitPrefix (cmet.ExplicitInterfaces));
						}
					}
				}
				
				if (!alreadyImplemented) 
					toImplement.Add (new KeyValuePair<IMember,IReturnType> (method, needsExplicitly ? prefix : null));
			}
			
			// Stub out non-implemented properties defined by @iface
			foreach (IProperty prop in iface.Properties) {
				if (prop.IsSpecialName)
					continue;
				bool needsExplicitly = explicitly;
				alreadyImplemented = false;
				foreach (IType t in gctx.ParserContext.GetInheritanceTree (klass)) {
					if (t.ClassType == ClassType.Interface)
						continue;
					foreach (IProperty cprop in t.Properties) {
						if (cprop.Name == prop.Name) {
							if (!needsExplicitly && !cprop.ReturnType.Equals (prop.ReturnType))
								needsExplicitly = true;
							else
								alreadyImplemented |= !needsExplicitly || (iface.FullName == GetExplicitPrefix (cprop.ExplicitInterfaces));
						}
					}
				}
				if (!alreadyImplemented)
					toImplement.Add (new KeyValuePair<IMember,IReturnType> (prop, needsExplicitly ? prefix : null)); 				}
			
			Ambience ambience = AmbienceService.GetAmbienceForFile (klass.CompilationUnit.FileName);
			//implement members
			ImplementMembers (klass, toImplement, ambience.GetString (iface, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters) +  " implementation");
			gctx.Save ();
			
			klass = GetUpdatedClass (gctx, klass);
			foreach (IType baseClass in iface.SourceProjectDom.GetInheritanceTree (iface)) {
				if (baseClass.Equals (iface) || baseClass.FullName == "System.Object")
					continue;
				klass = ImplementInterface (pinfo, klass, baseClass, explicitly, declaringClass, hintReturnType);
			}
			
			
			return klass;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:87,代码来源:CodeRefactorer.cs


注:本文中的DomReturnType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。