0

I have this issue in my project.

I have declared a class as a singleton to use it as xml parser. I wanted to return list of pois parsed but I wasn't able to change the return type without getting an error so I tried to declared a global variable to read it from other classes but I am receiving this error.

namespace XML_Parser
{
    public sealed class XMLParserPOI_Wiki
    {
        private List<POI> places;

        private static readonly XMLParserPOI_Wiki uniqueInstance = new XMLParserPOI_Wiki();

        public List<POI> getPlaces()
        {
            return places;
        }

        //Constructor
        private XMLParserPOI_Wiki(){
            System.Diagnostics.Debug.WriteLine("Constructor singleton created");
        }

        public static XMLParserPOI_Wiki getInstance()
        {
            return uniqueInstance;
        }

        public void parseWikitude(string url)
        {
            places = null;
            WebClient wc = new WebClient();
            wc.DownloadStringCompleted += HttpsCompleted;
            wc.DownloadStringAsync(new Uri(url));


        }

        private void HttpsCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None);
                XNamespace ns = "http://www.opengis.net/kml/2.2";
                XNamespace ns2 = "http://www.openarml.org/wikitude/1.0";
                var placemarkers = xdoc.Root.Descendants(ns + "Placemark");

                places =
                (....).ToList();



            }
        }

    }
}

complete error is:

Error   1   Inconsistent accessibility: 
field type 'System.Collections.Generic.List<XML_Parser.POI>' is 
less accessible than field 
'XML_Parser.XMLParserPOI_Wiki.places'   
C:\Users\vindi_000\documents\visual studio 2012\Projects\XML_Parser\XML_Parser\XMLParserPOI_Wiki.cs 
13  27  XML_Parser
Biribu
  • 3,615
  • 13
  • 43
  • 79

1 Answers1

1

This error usually means that you're exposing internal classes in public members, which is not possible.

I guess the class XML_Parser.POI is not marked as public?

yasen
  • 3,580
  • 13
  • 25
  • It is marked as public class POI – Biribu Jun 04 '14 at 15:33
  • I guess that was the problem. I had to clean project and then it worked. Maybe I added public to POI later and I didn't clean. Thanks man! – Biribu Jun 04 '14 at 15:37
  • @Biribu Glad I could help. :) Btw, as mentioned in another answer that was deleted, if you plan to do a lot of C# coding, I'd suggest you read a book or something, so that you would know about the features that are at your disposal. For example, in C#, the singleton pattern is normally implemented using a property. – yasen Jun 04 '14 at 16:01
  • Thanks. I have to. We still are not developing for Winpho8 but I was doing some trials to see how it works and if I can start to include in my job. I found this singleton in a tutorial. I don't know if it is the best. I will check it. – Biribu Jun 04 '14 at 16:19
  • How this answer is different/better than many related (like http://stackoverflow.com/questions/12990309/inconsistent-accessibility-field-type-world-is-less-accessible-than-field-fr?rq=1)? – Alexei Levenkov Jun 04 '14 at 16:26
  • @AlexeiLevenkov I guess it's not. I just saw the question and answered it... you know, trying to be helpful when I can... but I guess that's a bad thing nowadays, sorry. – yasen Jun 04 '14 at 16:31