Pregunta

I exported a source with reflector and i fix alot of problems there is one i haven't be able to.

    EnhancedTypeSubMenu!1.cs(28,27): error CS0305: Using the generic type 'Name.CoreDataTypes.EnhancedTypeSubMenu<T>.MenuItem<TT>' requires 1 type arguments
EnhancedTypeSubMenu!1.cs(86,22): (Related location)
EnhancedTypeSubMenu!1.cs(33,22): error CS0305: Using the generic type 'Name.CoreDataTypes.EnhancedTypeSubMenu<T>.MenuItem<TT>' requires 1 type arguments
\EnhancedTypeSubMenu!1.cs(86,22): (Related location)

Here is the class, i have the same problem in other class . Would appreciate any help.

  using System;
using System.Collections.Generic;
using System.Windows.Forms;

public abstract class EnhancedTypeSubMenu<T> : AGeeksToyToolStripMenuItem<EnhancedType<T>>
{
    public EnhancedTypeSubMenu(EnhancedType<T> DataItem, T[] ChoiceItems, string Text) : base(DataItem, Text, null)
    {
        if (ChoiceItems != null)
        {
            foreach (MenuItem<T, T> item in this.MenuItems(ChoiceItems))
            {
                base.DropDownItems.Add(new EnhancedTypeMenuItem<T, T>(DataItem, item));
            }
        }
    }

    public EnhancedTypeSubMenu(EnhancedType<T> DataItem, T[] ChoiceItems, string Text, Control ctrl) : base(DataItem, Text, ctrl)
    {
        foreach (MenuItem<T, T> item in this.MenuItems(ChoiceItems))
        {
            base.DropDownItems.Add(new EnhancedTypeMenuItem<T, T>(DataItem, item, ctrl));
        }
    }

    protected virtual MenuItem<T, T> GetMenuItem(T value)
    {
        return new MenuItem<T, T>(value);
    }

    private List<MenuItem<T, T>> MenuItems(T[] ChoiceItems)
    {
        List<MenuItem<T, T>> list = new List<MenuItem<T, T>>();
        foreach (T local in ChoiceItems)
        {
            list.Add(this.GetMenuItem(local));
        }
        return list;
    }

    public class EnhancedTypeMenuItem<TT> : AGeeksToyToolStripMenuItem<EnhancedType<TT>>
    {
        public bool CheckIfMatched;
        public readonly EnhancedTypeSubMenu<T>.MenuItem<TT> MenuItem;
        public string TranslationCategory;

        public EnhancedTypeMenuItem(EnhancedType<TT> Data, EnhancedTypeSubMenu<T>.MenuItem<TT> menuItem) : base(Data, menuItem.Text, null)
        {
            this.TranslationCategory = "Enhanced Menu";
            this.CheckIfMatched = true;
            this.MenuItem = menuItem;
        }

        public EnhancedTypeMenuItem(EnhancedType<TT> Data, EnhancedTypeSubMenu<T>.MenuItem<TT> menuItem, string translationCategory) : base(Data, menuItem.Text, null)
        {
            this.TranslationCategory = "Enhanced Menu";
            this.CheckIfMatched = true;
            this.MenuItem = menuItem;
            this.TranslationCategory = translationCategory;
        }

        public EnhancedTypeMenuItem(EnhancedType<TT> Data, EnhancedTypeSubMenu<T>.MenuItem<TT> menuItem, Control ctrl) : base(Data, menuItem.Text, ctrl)
        {
            this.TranslationCategory = "Enhanced Menu";
            this.CheckIfMatched = true;
            this.MenuItem = menuItem;
        }

        protected override void OnClick(EventArgs e)
        {
            base.MenuObject.Value = this.MenuItem.Data;
            base.OnClick(e);
        }

        public override void SetMenu()
        {
            base.Checked = this.CheckIfMatched && base.MenuObject.Equals(this.MenuItem.Data);
            this.Text = TranslationManager.Translate(this.TranslationCategory, this.MenuItem.Text.Replace('_', ' '));
            base.SetMenu();
            this.Enabled = !base.Checked;
        }
    }

    public class MenuItem<TT>
    {
        public readonly TT Data;

        public MenuItem(TT data)
        {
            this.Data = data;
        }

        public virtual string Text
        {
            get
            {
                return this.Data.ToString().Replace("__", " / ").Replace("_", " ");
            }
        }
    }
}

}

And here is a printscreen

![visual studio print][1]

http://i.stack.imgur.com/n9rpu.png

Cant post with image tag due to reputation, dont remenber my previous account :/

UPDATE //

i changed the to and that works but i have one last error.

private void ChangeStakingType(AGeeksToyToolStripMenuItem>.MenuData newType) { this.StakeBox.StakingType.Value = newType.Data.Value; }

requires 1 type argument Is the error.

Menudata class is this one:

   namespace AGeeksToy.CoreDataTypes
{
    using System;
    using System.Windows.Forms;

    public abstract class AGeeksToyToolStripMenuItem<T> : ToolStripMenuItem, AGeeksToyMenu
    {
        public MouseButtons LastMouseButton;
        public MenuData<T> menuData;
        public static readonly VoidEventWithParam<MenuData<T>> RightClicked;

        static AGeeksToyToolStripMenuItem()
        {
            AGeeksToyToolStripMenuItem<T>.RightClicked = new VoidEventWithParam<MenuData<T>>();
        }

        protected AGeeksToyToolStripMenuItem(T obj, string text) : this(obj, text, null)
        {
        }

        protected AGeeksToyToolStripMenuItem(T obj, string text, Control ctrl)
        {
            base.DropDown.ImageList = IconManager.m_ImageList;
            this.menuData = new MenuData<T>(obj, ctrl);
            this.Text = text;
        }

        protected override void Dispose(bool disposing)
        {
            base.DropDown.ImageList = null;
            base.Dispose(disposing);
        }

        protected override void OnClick(EventArgs e)
        {
            if (this.MenuControl != null)
            {
                this.MenuControl.Refresh();
            }
            base.OnClick(e);
            if (this.LastMouseButton == MouseButtons.Right)
            {
                AGeeksToyToolStripMenuItem<T>.RightClicked.TriggerEvent(this.menuData);
            }
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            this.LastMouseButton = e.Button;
            base.OnMouseDown(e);
        }

        public virtual void SetMenu()
        {
            this.LastMouseButton = MouseButtons.Left;
            if (this.MenuControl != null)
            {
                base.Visible = this.MenuControl.Visible;
                this.Enabled = this.MenuControl.Enabled;
            }
            foreach (ToolStripItem item in base.DropDownItems)
            {
                if (item is AGeeksToyMenu)
                {
                    (item as AGeeksToyMenu).SetMenu();
                }
            }
        }

        public T Menu_Data
        {
            get
            {
                return this.MenuObject;
            }
        }

        protected Control MenuControl
        {
            get
            {
                return this.menuData.Control;
            }
        }

        protected T MenuObject
        {
            get
            {
                return this.menuData.Data;
            }
            set
            {
                this.menuData.Data = value;
            }
        }


        public class MenuData<T>
        {
            public System.Windows.Forms.Control Control;
            public T Data;

            public MenuData(T obj, System.Windows.Forms.Control ctrl)
            {
                this.Data = obj;
                this.Control = ctrl;
            }
        }
    }

If anyone can run the project here and check the problem i would really appreciate here is the download link:

http://code.google.com/p/agt-betfair-bot/downloads/list

¿Fue útil?

Solución

Not sure if this was some sort of search and replace error, but try replacing all instances of this:

MenuItem<T, T> 

with this:

MenuItem<T>

This seems to be the source of the problem. This seems to be the correct name for the type parameter in the context I see the original.

Otros consejos

You have defined MenuItem<TT>.

But yet you are using MenuItem<T, T> which it is complaining about.

MenuItem only uses a single type argument, that's what the error says.

See the declaration of the class: MenuItem<TT>. So you only need to pass one type argument to it.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top