vb.net - VB Collection Conversion to c# LinkedList -


hi how things?

i life of me haven't been able figure out. have been converting gis application. have collection in vb , need convert linkedlist in c#.

any getting started appreciated.

vb code below

imports esri.arcgis.esrisystem  public class clsfeature  private m_oid integer private m_geometry esri.arcgis.geometry.igeometry  public sub new(byref ioid integer, byref pgeometry esri.arcgis.geometry.igeometry)     m_oid = ioid     m_geometry = pgeometry end sub  public readonly property oid() integer             oid = m_oid     end end property  public readonly property geometry() esri.arcgis.geometry.igeometry             geometry = m_geometry     end end property end class  friend class clsfeaturecollection implements system.collections.ienumerable  ' linkedlist??????????????????????????????????????? private m_ocol collection private m_ocolreverse collection  public sub new()     mybase.new()     m_ocol = new collection     m_ocolreverse = new collection end sub  public sub add(byref pfeature esri.arcgis.geodatabase.ifeature, optional byref strbefore string = "", optional byref strafter string = "", optional byref breverse boolean = false)     'create new cfoo object based on parameters     'passed method, add new cfoo      'the private collection, , key     'unique identifier built cfoo     'so can retrieve later      'add new foo object collection      if breverse         m_ocolreverse.add(pfeature.oid.tostring().trim(), pfeature.oid.tostring().trim())     end if      if not containsitem(pfeature.oid.tostring().trim())         if strbefore <> ""             m_ocol.add(new clsfeature(pfeature.oid, pfeature.shapecopy), pfeature.oid.tostring().trim(), strbefore)         elseif strafter <> ""             m_ocol.add(new clsfeature(pfeature.oid, pfeature.shapecopy), pfeature.oid.tostring().trim())         else             m_ocol.add(new clsfeature(pfeature.oid, pfeature.shapecopy), pfeature.oid.tostring().trim())         end if     end if  end sub  public sub addbefore(byref pfeature esri.arcgis.geodatabase.ifeature, byref strbefore string, optional byref breverse boolean = false)     'create new cfoo object based on parameters     'passed method, add new cfoo     'the private collection, , key     'unique identifier built cfoo     'so can retrieve later      'add new foo object collection     if breverse         m_ocolreverse.add(pfeature.oid.tostring().trim(), pfeature.oid.tostring().trim())     end if      if not containsitem(pfeature.oid.tostring().trim())         if strbefore <> ""             m_ocol.add(new clsfeature(pfeature.oid, pfeature.shapecopy), pfeature.oid.tostring().trim(), strbefore)         else             m_ocol.add(new clsfeature(pfeature.oid, pfeature.shapecopy), pfeature.oid.tostring().trim())         end if     end if  end sub  public sub addafter(byref pfeature esri.arcgis.geodatabase.ifeature, byref strafter string, optional byref breverse boolean = false)     'create new cfoo object based on parameters     'passed method, add new cfoo     'the private collection, , key     'unique identifier built cfoo     'so can retrieve later      'add new foo object collection     if breverse         m_ocolreverse.add(pfeature.oid.tostring().trim(), pfeature.oid.tostring().trim())     end if      if not containsitem(pfeature.oid.tostring().trim())         if strafter <> ""             m_ocol.add(new clsfeature(pfeature.oid, pfeature.shapecopy), pfeature.oid.tostring().trim(), , strafter)         else             m_ocol.add(new clsfeature(pfeature.oid, pfeature.shapecopy), pfeature.oid.tostring().trim())         end if     end if  end sub  public readonly property count() short             'return number of objects in m_ocol         count = m_ocol.count()     end end property  public function getenumerator() system.collections.ienumerator implements system.collections.ienumerable.getenumerator     getenumerator = m_ocol.getenumerator end function  public sub remove(byref vindex object)     'remove specified object. note here     'that method operate on either     'the index of object want removed     'or key of object want removed     m_ocol.remove(vindex) end sub  public function item(byref vindex object) clsfeature     'retrieve specified object. note here     'that method operate on either     'the index of object want     'or key of object want     item = m_ocol.item(vindex) end function  public sub clear()     'remove objects private collection     m_ocol = new collection     m_ocolreverse = new collection end sub  public function reverse(byref val_renamed object) boolean     try         if m_ocolreverse.contains(val_renamed)             return true         else             return false         end if     catch ex exception         if typeof ex argumentexception or typeof ex indexoutofrangeexception             reverse = false         end if     end try end function  public function containsitem(byref val_renamed object) boolean     try         if m_ocol.contains(val_renamed)             return true         else             return false         end if      catch ex exception         if typeof ex argumentexception or typeof ex indexoutofrangeexception             containsitem = false         end if     end try end function 

c# code - once linked list correct should able finish rest

namespace nstdb_qc_utility  { public class clsfeature {     private int m_oid;     private igeometry m_geometry;      public clsfeature(int ioid, igeometry pgeometry)     {         m_oid = ioid;         m_geometry = pgeometry;     }      public int oid     {         { return m_oid; }     }      public igeometry geometry     {         { return m_geometry; }     } }  public class clsfeaturecollection : system.collections.ienumerable {     // used dictionary -> should use linked list because of strbefore , strafter     // possible need way handle m_ocol , strbefore - result reverse m_ocol on strbefore      public linkedlist<clsfeature> m_ocol;  //        public dictionary<int, object> m_ocol;     public dictionary<string, string> m_ocolreverse;      public clsfeaturecollection()         : base()     {         m_ocol = new linkedlist<clsfeature>();  //            m_ocol = new dictionary<int, object>();         m_ocolreverse = new dictionary<string, string>();     }      public ienumerator getenumerator()     {         return m_ocol.getenumerator();     } 

vb 'collection' strange beast in allows treating collection alternately keyed list or positional list single .net collection not capture everything. also, it's 1-based, unlike other collections. came following in order understand vb 'collection' type better - feel free use it. note it's intended drop-in replacement uses 1-based parameters (yuk). made replacement collection generic improvement - replace 'collection' 'collection<object>' exact vb equivalent, might want specify actual type though don't in vb.

public class collection<t> {     private system.collections.generic.list<t> objects = new system.collections.generic.list<t>();     private system.collections.generic.list<string> keys = new system.collections.generic.list<string>();      public void add(t newobject, string key = null, object before = null, object after = null)     {         if (after != null)         {             if (after string != null)                 insert(newobject, keys.indexof(after string) + 1, key);             else                 insert(newobject, (int)after, key);         }         else if (before != null)         {             if (before string != null)                 insert(newobject, keys.indexof(before string), key);             else                 insert(newobject, (int)before - 1, key);         }         else             insert(newobject, objects.count, key);     }      private void insert(t newobject, int index, string key)     {         objects.insert(index, newobject);         keys.insert(index, key);     }      public void clear()     {         objects.clear();         keys.clear();     }      public bool contains(string key)     {         return keys.contains(key);     }      public int count     {                 {             return objects.count;         }     }      public void remove(string key)     {         removeat(keys.indexof(key));     }      public void remove(int positiononebased)     {         removeat(positiononebased - 1);     }      private void removeat(int index)     {         objects.removeat(index);         keys.removeat(index);     }      public t this[int positiononebased]     {                 {             return objects[positiononebased - 1];         }     }      public t this[string key]     {                 {             return objects[keys.indexof(key)];         }     }      public system.collections.generic.ienumerator<t> getenumerator()     {         return objects.getenumerator();     } } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -