IType CreateAnonymousClass (CollectionInitializerExpression initializer) { DomType result; if (!anonymousTypes.TryGetValue (initializer, out result)) { result = new AnonymousType (); result.SourceProjectDom = resolver.Dom; foreach (Expression expr in initializer.CreateExpressions) { var oldPos = resolver.ResolvePosition; if (!expr.StartLocation.IsEmpty) resolver.resolvePosition = new DomLocation (expr.StartLocation.Line + resolver.CallingMember.Location.Line, expr.StartLocation.Column); DomProperty newProperty = new DomProperty (GetAnonymousTypeFieldName (expr), MonoDevelop.Projects.Dom.Modifiers.Public, DomLocation.Empty, DomRegion.Empty, ResolveType (expr)); newProperty.DeclaringType = result; result.Add (newProperty); resolver.resolvePosition = oldPos; } anonymousTypes[initializer] = result; } return result; }
IType CreateAnonymousClass (CollectionInitializerExpression initializer) { DomType result = new AnonymousType (); result.SourceProjectDom = resolver.Dom; foreach (Expression expr in initializer.CreateExpressions) { DomProperty newProperty = new DomProperty (GetAnonymousTypeFieldName (expr), MonoDevelop.Projects.Dom.Modifiers.Public, DomLocation.Empty, DomRegion.Empty, ResolveType(expr)); newProperty.DeclaringType = result; result.Add (newProperty); } return result; }