public static Expression AppendMemberReference(this Expression expresion, IDebugMemberInfo memberInfo, params Expression[] args)
        {
            Expression target;

            if (memberInfo.IsStatic)
            {
                target = new TypeReferenceExpression(
                    memberInfo.DeclaringType.GetTypeReference()
                    );
            }
            else
            {
                target = expresion.CastTo((DebugType)memberInfo.DeclaringType);
            }

            if (memberInfo is DebugFieldInfo)
            {
                if (args.Length > 0)
                {
                    throw new DebuggerException("No arguments expected for a field");
                }
                return(new MemberReferenceExpression(target, memberInfo.Name).SetStaticType(memberInfo.MemberType));
            }

            if (memberInfo is MethodInfo)
            {
                return(new InvocationExpression(
                           new MemberReferenceExpression(target, memberInfo.Name),
                           AddExplicitTypes((MethodInfo)memberInfo, args)
                           ).SetStaticType(memberInfo.MemberType));
            }

            if (memberInfo is PropertyInfo)
            {
                PropertyInfo propInfo = (PropertyInfo)memberInfo;
                if (args.Length > 0)
                {
                    if (memberInfo.Name != "Item")
                    {
                        throw new DebuggerException("Arguments expected only for the Item property");
                    }
                    return(new IndexerExpression(
                               target,
                               AddExplicitTypes(propInfo.GetGetMethod() ?? propInfo.GetSetMethod(), args)
                               ).SetStaticType(memberInfo.MemberType));
                }
                else
                {
                    return(new MemberReferenceExpression(target, memberInfo.Name).SetStaticType(memberInfo.MemberType));
                }
            }

            throw new DebuggerException("Unknown member type " + memberInfo.GetType().FullName);
        }
Ejemplo n.º 2
0
        public static ImageSource GetImageForMember(IDebugMemberInfo memberInfo, out string imageName)
        {
            string name = string.Empty;

            if (memberInfo.IsPublic)
            {
            }
            else if (memberInfo.IsAssembly)
            {
                name += "Internal";
            }
            else if (memberInfo.IsFamily)
            {
                name += "Protected";
            }
            else if (memberInfo.IsPrivate)
            {
                name += "Private";
            }
            if (memberInfo is FieldInfo)
            {
                name += "Field";
            }
            else if (memberInfo is PropertyInfo)
            {
                name += "Property";
            }
            else if (memberInfo is MethodInfo)
            {
                name += "Method";
            }
            else
            {
                throw new DebuggerException("Unknown member type " + memberInfo.GetType().FullName);
            }

            imageName = "Icons.16x16." + name;
            return(ImageService.GetImage(imageName));
        }
Ejemplo n.º 3
0
        public static Image GetImageForMember(IDebugMemberInfo memberInfo)
        {
            if (memberInfo.IsPublic)
            {
            }
            else if (memberInfo.IsAssembly)
            {
                return(Properties.Resources.assembly);
            }
            else if (memberInfo.IsFamily)
            {
                return(Properties.Resources._namespace);
            }
            else if (memberInfo.IsPrivate)
            {
                return(Properties.Resources._namespace);
            }
            if (memberInfo is FieldInfo)
            {
                return(Properties.Resources.field);
            }
            else if (memberInfo is PropertyInfo)
            {
                return(Properties.Resources.Propriété);
            }
            else if (memberInfo is MethodInfo)
            {
                return(Properties.Resources.Fonction);
            }
            else
            {
                return(Properties.Resources._namespace);

                throw new DebuggerException("Unknown member type " + memberInfo.GetType().FullName);
            }
        }
Ejemplo n.º 4
0
 public static ImageSource GetImageForMember(IDebugMemberInfo memberInfo)
 {
     if (memberInfo is FieldInfo)
     {
         if (memberInfo.IsPublic)
         {
             return(ImageCache.GetIcon(MemberIcon.Field, BackgroundType.DebuggerToolTip));
         }
         else if (memberInfo.IsAssembly)
         {
             return(ImageCache.GetIcon(MemberIcon.FieldInternal, BackgroundType.DebuggerToolTip));
         }
         else if (memberInfo.IsFamily)
         {
             return(ImageCache.GetIcon(MemberIcon.FieldProtected, BackgroundType.DebuggerToolTip));
         }
         else if (memberInfo.IsPrivate)
         {
             return(ImageCache.GetIcon(MemberIcon.FieldPrivate, BackgroundType.DebuggerToolTip));
         }
         return(ImageCache.GetIcon(MemberIcon.Field, BackgroundType.DebuggerToolTip));
     }
     else if (memberInfo is PropertyInfo)
     {
         if (memberInfo.IsPublic)
         {
             return(ImageCache.GetIcon(MemberIcon.Property, BackgroundType.DebuggerToolTip));
         }
         else if (memberInfo.IsAssembly)
         {
             return(ImageCache.GetIcon(MemberIcon.PropertyInternal, BackgroundType.DebuggerToolTip));
         }
         else if (memberInfo.IsFamily)
         {
             return(ImageCache.GetIcon(MemberIcon.PropertyProtected, BackgroundType.DebuggerToolTip));
         }
         else if (memberInfo.IsPrivate)
         {
             return(ImageCache.GetIcon(MemberIcon.PropertyPrivate, BackgroundType.DebuggerToolTip));
         }
         return(ImageCache.GetIcon(MemberIcon.Property, BackgroundType.DebuggerToolTip));
     }
     else if (memberInfo is MethodInfo)
     {
         if (memberInfo.IsPublic)
         {
             return(ImageCache.GetIcon(MemberIcon.Method, BackgroundType.DebuggerToolTip));
         }
         else if (memberInfo.IsAssembly)
         {
             return(ImageCache.GetIcon(MemberIcon.MethodInternal, BackgroundType.DebuggerToolTip));
         }
         else if (memberInfo.IsFamily)
         {
             return(ImageCache.GetIcon(MemberIcon.MethodProtected, BackgroundType.DebuggerToolTip));
         }
         else if (memberInfo.IsPrivate)
         {
             return(ImageCache.GetIcon(MemberIcon.MethodPrivate, BackgroundType.DebuggerToolTip));
         }
         return(ImageCache.GetIcon(MemberIcon.Method, BackgroundType.DebuggerToolTip));
     }
     else
     {
         throw new DebuggerException("Unknown member type " + memberInfo.GetType().FullName);
     }
 }
Ejemplo n.º 5
0
 public static ImageSource GetImageForMember(IDebugMemberInfo memberInfo)
 {
     if (memberInfo is FieldInfo) {
         if (memberInfo.IsPublic)
             return ImageCache.GetIcon(MemberIcon.Field, BackgroundType.DebuggerToolTip);
         else if (memberInfo.IsAssembly)
             return ImageCache.GetIcon(MemberIcon.FieldInternal, BackgroundType.DebuggerToolTip);
         else if (memberInfo.IsFamily)
             return ImageCache.GetIcon(MemberIcon.FieldProtected, BackgroundType.DebuggerToolTip);
         else if (memberInfo.IsPrivate)
             return ImageCache.GetIcon(MemberIcon.FieldPrivate, BackgroundType.DebuggerToolTip);
         return ImageCache.GetIcon(MemberIcon.Field, BackgroundType.DebuggerToolTip);
     } else if (memberInfo is PropertyInfo) {
         if (memberInfo.IsPublic)
             return ImageCache.GetIcon(MemberIcon.Property, BackgroundType.DebuggerToolTip);
         else if (memberInfo.IsAssembly)
             return ImageCache.GetIcon(MemberIcon.PropertyInternal, BackgroundType.DebuggerToolTip);
         else if (memberInfo.IsFamily)
             return ImageCache.GetIcon(MemberIcon.PropertyProtected, BackgroundType.DebuggerToolTip);
         else if (memberInfo.IsPrivate)
             return ImageCache.GetIcon(MemberIcon.PropertyPrivate, BackgroundType.DebuggerToolTip);
         return ImageCache.GetIcon(MemberIcon.Property, BackgroundType.DebuggerToolTip);
     }
     else if (memberInfo is MethodInfo) {
         if (memberInfo.IsPublic)
             return ImageCache.GetIcon(MemberIcon.Method, BackgroundType.DebuggerToolTip);
         else if (memberInfo.IsAssembly)
             return ImageCache.GetIcon(MemberIcon.MethodInternal, BackgroundType.DebuggerToolTip);
         else if (memberInfo.IsFamily)
             return ImageCache.GetIcon(MemberIcon.MethodProtected, BackgroundType.DebuggerToolTip);
         else if (memberInfo.IsPrivate)
             return ImageCache.GetIcon(MemberIcon.MethodPrivate, BackgroundType.DebuggerToolTip);
         return ImageCache.GetIcon(MemberIcon.Method, BackgroundType.DebuggerToolTip);
     }
     else {
         throw new DebuggerException("Unknown member type " + memberInfo.GetType().FullName);
     }
 }
Ejemplo n.º 6
0
		public static ImageSource GetImageForMember(IDebugMemberInfo memberInfo, out string imageName)
		{
			string name = string.Empty;
			if (memberInfo.IsPublic) {
			} else if (memberInfo.IsAssembly) {
				name += "Internal";
			} else if (memberInfo.IsFamily) {
				name += "Protected";
			} else if (memberInfo.IsPrivate) {
				name += "Private";
			}
			if (memberInfo is FieldInfo) {
				name += "Field";
			} else if (memberInfo is PropertyInfo) {
				name += "Property";
			} else if (memberInfo is MethodInfo) {
				name += "Method";
			} else {
				throw new DebuggerException("Unknown member type " + memberInfo.GetType().FullName);
			}
			
			imageName = "Icons.16x16." + name;
			return ImageService.GetImage(imageName);
		}
Ejemplo n.º 7
0
        public static Expression AppendMemberReference(this Expression expresion, IDebugMemberInfo memberInfo, params Expression[] args)
        {
            Expression target;

            if (memberInfo.IsStatic)
            {
                target = new TypeReferenceExpression()
                {
                    Type = memberInfo.DeclaringType.GetTypeReference()
                };
            }
            else
            {
                target = CastTo(expresion, (DebugType)memberInfo.DeclaringType);
            }

            if (memberInfo is DebugFieldInfo)
            {
                if (args.Length > 0)
                {
                    throw new DebuggerException("No arguments expected for a field");
                }

                var mre = new MemberReferenceExpression()
                {
                    Target = target.Clone(), MemberName = memberInfo.Name
                };
                return(mre.SetStaticType(memberInfo.MemberType));
            }

            if (memberInfo is MethodInfo)
            {
                var mre = new MemberReferenceExpression()
                {
                    Target = target, MemberName = memberInfo.Name
                };
                var ie = new InvocationExpression()
                {
                    Target = mre.Clone()
                };
                ie.Arguments.AddRange(AddExplicitTypes((MethodInfo)memberInfo, args));

                return(ie.SetStaticType(memberInfo.MemberType));
            }

            if (memberInfo is PropertyInfo)
            {
                PropertyInfo propInfo = (PropertyInfo)memberInfo;
                if (args.Length > 0)
                {
                    if (memberInfo.Name != "Item")
                    {
                        throw new DebuggerException("Arguments expected only for the Item property");
                    }
                    var ie = new IndexerExpression()
                    {
                        Target = target.Clone()
                    };
                    ie.Arguments.AddRange(AddExplicitTypes(propInfo.GetGetMethod() ?? propInfo.GetSetMethod(), args));

                    return(ie.SetStaticType(memberInfo.MemberType));
                }
                else
                {
                    return((new MemberReferenceExpression()
                    {
                        Target = target.Clone(),
                        MemberName = memberInfo.Name
                    }).SetStaticType(memberInfo.MemberType));
                }
            }

            throw new DebuggerException("Unknown member type " + memberInfo.GetType().FullName);
        }