示例#1
0
 public static DataStructures Detail()
 {
     if (obj == null)
     {
         obj = new DataStructures();
     }
     return(obj);
 }
示例#2
0
        static void Main(string[] args)
        {
            PatientDetails pobject = new PatientDetails();

            DataStructures dataobject = DataStructures.Detail(); //Create Singleton Object in Main


            Dictionary <int, PatientDetails> adddictionary = dataobject.Getpatient_detail(); //Create a Dictionary to add data using GET method

            dataobject.Setpatient_detail(adddictionary);


            pobject = AddMethod(101, "Jim", 768987677, 77, "Fever", "YES");

            Program programObj = new Program();

            //Invoke the CovidCheck method
            programObj.CovidCheck(adddictionary);


            //Creating a resource file .JSON file to add data
            var assembly     = Assembly.GetExecutingAssembly();
            var resourcename = "NewCovid.InputData.Input.json"; //file path

            // Path C:\Users\user\source\repos\NewCovid\NewCovid\InputData\Input.json

            var    resources = assembly.GetManifestResourceNames();
            string result;

            using (Stream stream = assembly.GetManifestResourceStream(resourcename))
                using (StreamReader reader = new StreamReader(stream))
                {
                    result = reader.ReadToEnd();
                }

            JObject o1 = JObject.Parse((result));

            //Data is in Json formatt add it to List and loop through each element to ADD Patient Data
            var listPatientData = (JArray)o1["PatientDetails"];
            List <PatientDetails> listofElements = new List <PatientDetails>();

            foreach (var variable in listPatientData)
            {
                PatientDetails obj1 = JsonConvert.DeserializeObject <PatientDetails>(variable.ToString());

                PatientDetails store = AddMethod(obj1.Getpatient_ID(), obj1.Getpatient_Name(), obj1.Getpatient_phone(), obj1.Getpatient_age(),
                                                 obj1.Getsymptoms(), obj1.GetcovidPt());

                listofElements.Add(store);
            }



            //Dictionary<int, PatientDetails> newdic = pobject.Getpatient_detail();
            //pobject.Setpatient_detail(newdic);
            //  AddMethod(101,"Jim",768987677,77,"Fever","YES");
        }