c# - Load and save to text from IList<T> -


here code -

class appointments:iappointments {     private readonly ilist<iappointment> _list = new list<iappointment>();       public appointments()     {      }      public bool load()     {         throw new notimplementedexception();     }      public bool save()     {         throw new notimplementedexception();     }      public ienumerable<iappointment> getappointmentsondate(datetime date)     {         throw new notimplementedexception();     }      public int indexof(iappointment item)     {         return _list.indexof(item);     }      public void insert(int index, iappointment item)     {         _list.insert(index, item);     }      public void removeat(int index)     {         _list.removeat(index);     }      public iappointment this[int index]     {                 {             return _list[index];         }         set         {             _list[index] = value;         }     }      public void add(iappointment item)     {         _list.add(item);     }      public void clear()     {         _list.clear();     }      public bool contains(iappointment item)     {         return _list.contains(item);     }      public void copyto(iappointment[] array, int arrayindex)     {         _list.copyto(array, arrayindex);     }      public int count     {         { return _list.count; }     }      public bool isreadonly     {         { return _list.isreadonly; }     }      public bool remove(iappointment item)     {         return _list.remove(item);     }      public ienumerator<iappointment> getenumerator()     {         return _list.getenumerator();     }      system.collections.ienumerator system.collections.ienumerable.getenumerator()     {         foreach (iappointment item in _list)         {             if (item == null)             {                 break;             }              yield return item;         } 

i on how load , save methods. save method needs save text file. load method needs load txt file.

iappointment interface -

 namespace calendar     {         public interface iappointment         {             datetime start { get; }             int length { get; }             string displayabledescription { get; }             bool occursondate(datetime date);         }     } 

the website complaining code going write pointless sentence until goes away. thank patience.

looks need not simple system serialize / deserialize data, not need ilist current data , serialize in json or xml , de-serialize on other end object.

for such requirement simple json (newtonsoft) / xml serializer suffice

what expecting read complete schema, includes fields, properties, methods , recreate same code on other end.

you need use reflection, can read complete type , @ other end can emit class same details. can read data in format text / xml / json, till point same can understood / parsed while creating object using reflection.emit

the standard serializers data transforming in given format , converting relevant object. may check following articles:

relection in c#

how list of properties of class?

using reflection emit class:

how dynamically create class in c#?

hope helps, can update if stuck @ point


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -