此语言功能(';缺少类型';)尚未在Roslyn中实现

本文关键字:实现 Roslyn 功能 语言 类型 | 更新日期: 2023-09-27 18:29:08

我在代码中使用的是Rosyln 1.1版本。

当我编译我的viewModel(C#)代码时,Roslyn出现了一个错误。

错误:

异常:系统。异常:此语言功能("缺少类型")为尚未在Roslyn实施。此语言功能("缺失类型")尚未在Roslyn实施。

代码:

/// <summary>
/// ViewModel of APPTIMGDEF.xaml
/// </summary>
[Serializable]
public class APPTIMGDEFVM : BaseListItemEditViewModel
{
    #region Private Members
    private ObservableCollection<DTOBackgroundImageModel> _items = new ObservableCollection<DTOBackgroundImageModel>();
    private DTOBackgroundImage _filter = new DTOBackgroundImage();
    private DTOBackgroundImageModel _selectedDTO = new DTOBackgroundImageModel();
    private bool _isDateVisible;
    private string _filePath_1;
    private string _filePath_2;
    private string _filePath_3;
    private bool _isInsertEnable;
    private DelegateCommand _showImageCommand;
    private bool _isCodeReadOnly;
    #endregion Private Members
    #region Private Methods

    private byte[] convertToByteArray(string hex)
    {
        string[] arr = hex.Split('-');
        byte[] data = new byte[arr.Length];
        for (int i = 0; i < arr.Length; i++) data[i] = Convert.ToByte(arr[i], 16);
        return data;
    }

    private void ShowImage(object parameter)
    {
        object[] prm = Array.ConvertAll((object[])parameter, s => (object)s);
        string buttonColumn = prm[0] as string;
        DTOBackgroundImageModel DTOBackgroundImageModel = prm[1] as DTOBackgroundImageModel;
        Window popUp = new Window();
        popUp.Height = 300; popUp.Width = 512;
        byte[] newByte = null ;
        switch (buttonColumn)
        {
            case "WHT":
               newByte = convertToByteArray(DTOBackgroundImageModel.WhiteImage.Data);         
                break;
            case "LGRAY":
                newByte = convertToByteArray(DTOBackgroundImageModel.LightGrayImage.Data);
                break;
            case "DARK":
                newByte = convertToByteArray(DTOBackgroundImageModel.DarkGrayImage.Data);
                break;
        }
        MemoryStream memStream = new MemoryStream(newByte);
        System.Drawing.Image image = System.Drawing.Image.FromStream(memStream);
        var bitmap = new System.Drawing.Bitmap(image);
        var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(),
                                                                IntPtr.Zero,
                                                                Int32Rect.Empty,
                                                                BitmapSizeOptions.FromEmptyOptions());
        bitmap.Dispose();
        var brush = new ImageBrush(bitmapSource);
        popUp.Background = brush;
        double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
        double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
        double windowWidth = popUp.Width;
        double windowHeight = popUp.Height;
        popUp.Left = (screenWidth / 2) - (windowWidth / 2);
        popUp.Top = (screenHeight / 2) - (windowHeight / 2);
        popUp.ShowDialog();    
    }
    #endregion Private Methods
    #region Constructors
    /// <summary>
    /// Constructor
    /// </summary>
    public APPTIMGDEFVM(UListItemEditScreen screen)
        : base(screen)
    {
        _showImageCommand = new DelegateCommand(ShowImage);
    }
    #endregion Constructors
    #region Public Properties

    /// <summary>
    /// 
    /// </summary>
    public bool IsInsertEnable
    {
        get { return _isInsertEnable; }
        set
        {
            if (_isInsertEnable != value)
            {
                _isInsertEnable = value;
                OnPropertyChanged("IsInsertEnable");
            }
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public DelegateCommand ShowImageCommand
    {
        get { return _showImageCommand; }
        set
        {
            if (_showImageCommand != value)
            {
                _showImageCommand = value;
                OnPropertyChanged("ShowImageCommand");
            }
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public string FilePath_1
    {
        get { return _filePath_1; }
        set
        {
            if (_filePath_1 != value)
            {
                _filePath_1 = value;
                OnPropertyChanged("FilePath_1");
            }
        }
    }
    public string FilePath_2
    {
        get { return _filePath_2; }
        set
        {
            if (_filePath_2 != value)
            {
                _filePath_2 = value;
                OnPropertyChanged("FilePath_2");
            }
        }
    }
    public string FilePath_3
    {
        get { return _filePath_3; }
        set
        {
            if (_filePath_3 != value)
            {
                _filePath_3 = value;
                OnPropertyChanged("FilePath_3");
            }
        }
    }

    /// <summary>
    /// 
    /// </summary>
    public DTOBackgroundImageModel SelectedDTO
    {
        get { return _selectedDTO; }
        set
        {
            if (_selectedDTO != value)
            {
                IsCodeReadOnly = true;
                _selectedDTO = value;
                IsInsertEnable = false;
                OnPropertyChanged("SelectedDTO");
            }
        }
    }

    /// <summary>
    /// 
    /// </summary>
    public bool IsDateVisible
    {
        get { return _isDateVisible; }
        set
        {
            if (_isDateVisible != value)
            {
                _isDateVisible = value;
                OnPropertyChanged("IsDateVisible");
            }
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public bool IsCodeReadOnly
    {
        get { return _isCodeReadOnly; }
        set
        {
            if (_isCodeReadOnly != value)
            {
                _isCodeReadOnly = value;
                OnPropertyChanged("IsCodeReadOnly");
            }
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public DTOBackgroundImage Filter
    {
        get { return _filter; }
        set
        {
            if (_filter != value)
            {
                _filter = value;
                OnPropertyChanged("Filter");
            }
        }
    }

    /// <summary>
    /// 
    /// </summary>
    public ObservableCollection<DTOBackgroundImageModel> Items
    {
        get { return _items; }
        set
        {
            if (_items != value)
            {
                _items = value;
                OnPropertyChanged("Items");
            }
        }
    }

    #endregion Public Properties
    #region Public Methods
    public override bool NewQuery()
    {
        IsDateVisible = false;
        IsCodeReadOnly = false;
        IsInsertEnable = true;
        return base.NewQuery();
    }
    public override bool Load()
    {
        IsDateVisible = false;
        IsCodeReadOnly = false;
        IsInsertEnable = true;
        return true;
    }
    public override bool Clear()
    {
        IsDateVisible = false;
        IsCodeReadOnly = false;
        IsInsertEnable = true;
        return base.Clear();
    }
    public override bool AddNewItem()
    {
        IsCodeReadOnly = false;
        IsInsertEnable = true;
        return base.AddNewItem();
    }
    public override void AfterRead()
    {
        if (Filter.CategoryCode == "SPC")
        {
            IsDateVisible = true;
        }
    }
    public override bool Read()
    {
        this.Request.Add(Filter);
        ResponseMessage response;
        using (ISApplication proxy = Service.CreateProxy<ISApplication>(this))
        {
            response = proxy.ReadListBackgroundImageBy(this.Request);
        }
        List<DTOBackgroundImage> images = response.Get<List<DTOBackgroundImage>>();
        ObservableCollection<DTOBackgroundImageModel> temp = new ObservableCollection<DTOBackgroundImageModel>();
        foreach (var item in images.GroupBy(x => x.Code.Substring(0, x.Code.Length - 2)))
        {
            DTOBackgroundImageModel DTOBackgroundImageModel = new DTOBackgroundImageModel();
            DTOBackgroundImageModel.Code = item.Key;
            DTOBackgroundImageModel.CategoryCode = Filter.CategoryCode;
            DTOBackgroundImageModel.WhiteImage = images.Find(x => x.Code == item.Key + "_1");
            DTOBackgroundImageModel.LightGrayImage = images.Find(x => x.Code == item.Key + "_2");
            DTOBackgroundImageModel.DarkGrayImage = images.Find(x => x.Code == item.Key + "_3");
            DTOBackgroundImageModel.Link = DTOBackgroundImageModel.DarkGrayImage.Link;
            DTOBackgroundImageModel.Tooltip = DTOBackgroundImageModel.DarkGrayImage.Tooltip;
              if(Filter.CategoryCode == "SPC")
              {
                  RequestMessage request = new RequestMessage();
                 DTOSpecialDaybackground dtosdb = new DTOSpecialDaybackground();
                 dtosdb.ImageCode = item.Key;
                 request.Add(dtosdb);
                 using (ISApplication proxy = Service.CreateProxy<ISApplication>(this))
                 {
                     response = proxy.ReadSpecialDaybackground(request);
                 }      
                  DTOSpecialDaybackground dtoSpecialBackground = response.Get<DTOSpecialDaybackground>();
                  DTOBackgroundImageModel.BeginDate = dtoSpecialBackground.BeginDate;
                  DTOBackgroundImageModel.EndDate = dtoSpecialBackground.EndDate;
                 }
            temp.Add(DTOBackgroundImageModel);
        }
        Items = temp;
        return true;
    }
    public override bool Insert()
    {
        #region Image DTO  
        int i = 1;
        List<DTOBackgroundImage> dtoList = new List<DTOBackgroundImage>();
        DTOBackgroundImage dtoWhiteImage = new DTOBackgroundImage();
        dtoWhiteImage.CategoryCode = Filter.CategoryCode;
        dtoWhiteImage.Link = SelectedDTO.Link;
        dtoWhiteImage.Tooltip =  SelectedDTO.Tooltip;
        dtoWhiteImage.Code = String.Format("{0}_{1}", SelectedDTO.Code, i++);
        dtoWhiteImage.Data = BitConverter.ToString(File.ReadAllBytes(FilePath_1)); 

        DTOBackgroundImage dtoLightGrayImage = new DTOBackgroundImage();
        dtoLightGrayImage.CategoryCode = Filter.CategoryCode;
        dtoLightGrayImage.Link = SelectedDTO.Link;
        dtoLightGrayImage.Tooltip =  SelectedDTO.Tooltip;
        dtoLightGrayImage.Code = String.Format("{0}_{1}", SelectedDTO.Code, i++);
        dtoLightGrayImage.Data = BitConverter.ToString(File.ReadAllBytes(FilePath_2));

        DTOBackgroundImage dtoDarkGrayImage = new DTOBackgroundImage();
           dtoDarkGrayImage.CategoryCode = Filter.CategoryCode;
        dtoDarkGrayImage.Link = SelectedDTO.Link;
        dtoDarkGrayImage.Tooltip =  SelectedDTO.Tooltip;
        dtoDarkGrayImage.Code = String.Format("{0}_{1}", SelectedDTO.Code, i++);
        dtoDarkGrayImage.Data = BitConverter.ToString(File.ReadAllBytes(FilePath_3));
        dtoList.Add(dtoLightGrayImage);
        dtoList.Add(dtoWhiteImage);
        dtoList.Add(dtoDarkGrayImage);
        #endregion Image DTO
        ResponseMessage response;
        this.Request.Add(dtoList);
        using (ISApplication proxy = Service.CreateProxy<ISApplication>(this))
        {
            response = proxy.InsertBackgroundImage(this.Request);
        }
        if(Filter.CategoryCode == "SPC")
        {
            DTOSpecialDaybackground dtoSpecialDayBackground = new DTOSpecialDaybackground();
            dtoSpecialDayBackground.ImageCode = SelectedDTO.Code;
            dtoSpecialDayBackground.BeginDate = SelectedDTO.BeginDate;
            dtoSpecialDayBackground.EndDate = SelectedDTO.EndDate;
            this.Request.Add(dtoSpecialDayBackground);
            using (ISApplication proxy = Service.CreateProxy<ISApplication>(this))
            {
                response = proxy.InsertSpecialDaybackground(this.Request);
            }                
        }
        return Read();
    }
    public override bool Update()
    {
        ResponseMessage response;
        List<DTOBackgroundImage> imageList = new List<DTOBackgroundImage>();
        SelectedDTO.WhiteImage.Link = SelectedDTO.Link;
        SelectedDTO.WhiteImage.Tooltip = SelectedDTO.Tooltip;          
        if (FilePath_1 != String.Empty)
         SelectedDTO.WhiteImage.Data = BitConverter.ToString(File.ReadAllBytes(FilePath_1));
        imageList.Add(SelectedDTO.WhiteImage);
        SelectedDTO.LightGrayImage.Link = SelectedDTO.Link;
        SelectedDTO.LightGrayImage.Tooltip = SelectedDTO.Tooltip;        
        if (FilePath_2 != String.Empty)
            SelectedDTO.LightGrayImage.Data = BitConverter.ToString(File.ReadAllBytes(FilePath_2));               
         imageList.Add(SelectedDTO.LightGrayImage);

        SelectedDTO.DarkGrayImage.Link = SelectedDTO.Link;
        SelectedDTO.DarkGrayImage.Tooltip = SelectedDTO.Tooltip;
        if (FilePath_3 != String.Empty)
            SelectedDTO.DarkGrayImage.Data = BitConverter.ToString(File.ReadAllBytes(FilePath_3));      
        imageList.Add(SelectedDTO.DarkGrayImage);
        this.Request.Add(imageList);
        using (ISApplication proxy = Service.CreateProxy<ISApplication>(this))
        {
                response = proxy.UpdateBackgroundImage(this.Request);
         }

        if (Filter.CategoryCode == "SPC")
        {
            DTOSpecialDaybackground dtoSpecialDayBackground = new DTOSpecialDaybackground();
            dtoSpecialDayBackground.ImageCode = SelectedDTO.Code;
            dtoSpecialDayBackground.BeginDate = SelectedDTO.BeginDate;
            dtoSpecialDayBackground.EndDate = SelectedDTO.EndDate;
            this.Request.Add(dtoSpecialDayBackground);
            using (ISApplication proxy = Service.CreateProxy<ISApplication>(this))
            {
                response = proxy.UpdateSpecialDaybackground(this.Request);
            }
        }
        return Read();
    }
    public override bool Delete()
    {
        int i= 1;
        SelectedDTO.WhiteImage.Code = String.Format("{0}_{1}",SelectedDTO.Code,i++);
        SelectedDTO.LightGrayImage.Code = String.Format("{0}_{1}", SelectedDTO.Code, i++);
        SelectedDTO.DarkGrayImage.Code = String.Format("{0}_{1}", SelectedDTO.Code, i);
        List<DTOBackgroundImage> imageList = new List<DTOBackgroundImage>();
        imageList.Add(SelectedDTO.WhiteImage);
        imageList.Add(SelectedDTO.LightGrayImage);
        imageList.Add(SelectedDTO.DarkGrayImage);

        this.Request.Add(imageList);
        ResponseMessage response;
        using (ISApplication proxy = Service.CreateProxy<ISApplication>(this))
        {
            response = proxy.DeleteBackgroundImage(this.Request);
        }

        if (Filter.CategoryCode == "SPC")
        {
            DTOSpecialDaybackground dtoSpecialDayBackground = new DTOSpecialDaybackground();
            dtoSpecialDayBackground.ImageCode = SelectedDTO.Code;
            this.Request.Add(dtoSpecialDayBackground);
            using (ISApplication proxy = Service.CreateProxy<ISApplication>(this))
            {
                response = proxy.DeleteSpecialDaybackground(this.Request);
            }
        }
        return Read();
    }

    #endregion Public Methods
}

谢谢。

此语言功能(';缺少类型';)尚未在Roslyn中实现

升级到Roslyn的新版本。在我们重命名之前,您可能仍在使用名为"Roslyn"的NuGet包。最新的在这里。