public int GetDOType(string id)
 {
     if (this.dOTypeField == null)
     {
         return(-1);
     }
     for (int i = 0; i < this.dOTypeField.Length; i++)
     {
         tDOType dot = this.dOTypeField[i];
         if (dot.id.Equals(id))
         {
             return(i);
         }
     }
     return(-1);
 }
        AddDOType(tDOType[] tmpl)
        {
            var ignored = new System.Collections.Generic.List <tDOType> ();
            var toadd   = new System.Collections.ArrayList();

            tDOType dt = new tDOType();;

            if (tmpl == null)
            {
                dt.iedType = "TEMPLATE";
                dt.id      = "TEMPLATE.DOType" + tDataTypeTemplates.ndot++;
                dt.cdc     = "SPS";
            }

            if (dOTypeField == null && tmpl != null)
            {
                dOTypeField = new tDOType[tmpl.Length];
                tmpl.CopyTo(dOTypeField, 0);
                return(ignored);
            }

            if (dOTypeField == null && tmpl == null)
            {
                dOTypeField     = new tDOType[1];
                dOTypeField [0] = dt;
                return(ignored);
            }

            if (this.dOTypeField != null && tmpl != null)
            {
                for (int i = 0; i < tmpl.Length; i++)
                {
                    int j = this.GetDOType(tmpl [i].id);
                    if (j >= 0)
                    {
                        ignored.Add(tmpl [i]);
                        continue;
                    }
                    else
                    {
                        toadd.Add(tmpl [i]);
                    }
                }
            }

            if (dOTypeField != null && tmpl == null)
            {
                toadd.Add(dt);
            }

            int index = this.dOTypeField.Length;

            System.Array.Resize <tDOType>(ref this.dOTypeField,
                                          this.dOTypeField.Length + toadd.Count);

            for (int i = 0; i < toadd.Count; i++)
            {
                this.dOTypeField[i + index] = (tDOType)toadd[i];
            }
            return(ignored);
        }