TrimToSize() public method

public TrimToSize ( ) : void
return void
Example #1
0
 public MemberRoles(string member, string role)
 {
     _Member = member;
     _Roles = new ArrayList();
     _Roles.Add(role);
     _Roles.TrimToSize();
 }
Example #2
0
        public long m_lngGetSampleCodes(string p_strCheckNO, out string[] p_strSampleCodeArr)
        {
            p_strSampleCodeArr = null;
            if (p_strCheckNO == null)
            {
                return(-1);
            }

            long lngRes = -1;

            if (m_blnIsSampleCodeSeparator)
            {
                try
                {
                    p_strSampleCodeArr = p_strCheckNO.Split(m_strSampleCodeSeparator.ToCharArray());
                    System.Collections.ArrayList arl = new System.Collections.ArrayList();
                    for (int i = 0; i < p_strSampleCodeArr.Length; i++)
                    {
                        if (p_strSampleCodeArr[i] != null && p_strSampleCodeArr[i] != "")
                        {
                            arl.Add(p_strSampleCodeArr[i]);
                        }
                    }
                    arl.TrimToSize();
                    p_strSampleCodeArr = (string[])arl.ToArray(typeof(string));

                    lngRes = 1;
                }
                catch (Exception ex)
                {
                    lngRes             = 0;
                    p_strSampleCodeArr = null;
                }
            }
            else
            {
                try
                {
                    int intCehckNOLength = p_strCheckNO.Length;
                    if (System.Math.IEEERemainder(intCehckNOLength, m_intSampleCodeLength) != 0)
                    {
                        return(-1);
                    }
                    int intCount = intCehckNOLength / m_intSampleCodeLength;
                    p_strSampleCodeArr = new string[intCount];
                    for (int i = 0; i < intCount; i++)
                    {
                        p_strSampleCodeArr[i] = p_strCheckNO.Substring(i * m_intSampleCodeLength, m_intSampleCodeLength);
                    }
                    lngRes = 1;
                }
                catch (Exception ex)
                {
                    lngRes             = 0;
                    p_strSampleCodeArr = null;
                }
            }
            return(lngRes);
        }
        /// <summary>
        /// Gets a list of NFS config files (Nfs*.xml;Nfs*.config) from AppDomain.CurrentDomain.BaseDirectory including sub-directories
        /// </summary>
        /// <param name="returnPath">should the string[] contain the path to each file</param>
        /// <returns>a string array of file names optionally including their paths</returns>    
        public static string[] GetNFSConfigFilesInBaseDirectory(bool returnPath)
        {
            ArrayList configFiles = new ArrayList();
            configFiles.AddRange(GetFileListInBaseDirectory("Nfs*.xml", returnPath));
            configFiles.AddRange(GetFileListInBaseDirectory("Nfs*.config", returnPath));
            configFiles.TrimToSize();

            return (string[]) configFiles.ToArray(typeof (string));
        }
Example #4
0
	public ArrayList pop_all_since_marker() {
		ArrayList result = new ArrayList();
		object o = pop();
		while (o != this.MARKER) {
			result.Add(o);
			o = pop();
		}
		result.TrimToSize();
		result.Reverse();
		return result;
	}
 static public int TrimToSize(IntPtr l)
 {
     try {
         System.Collections.ArrayList self = (System.Collections.ArrayList)checkSelf(l);
         self.TrimToSize();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        //分割函数开始
        public static string[] split(string strinput, string sp)
        {
            string tmp="";
            int strlen=0, splen=0;
            int found=0;
            string[] rt = null;
            try
            {
                if (strinput == null || sp == null || strinput.Length == 0 || sp.Length == 0)
                    return null;

                //初始化一个数组列表(当做动态数组)
                ArrayList tmp3 = new ArrayList();
                strlen = strinput.Length;
                splen = sp.Length;
                for (int i = 0; i < splen; i++)
                {
                    //查找分隔符
                    found = strinput.IndexOf(sp, i);
                    if (found >= 0)
                    {
                        tmp = "";
                        //取分隔符前的字符串
                        tmp = strinput.Substring(i, found - i);
                        //添加到数组列表
                        tmp3.Add(tmp);
                        i = found + splen - 1;
                    }
                    else
                    {
                        string tmp2 = "";
                        //取最后的字符串
                        tmp2 = strinput.Substring(i);
                        if (tmp2 != "")
                            tmp3.Add(tmp2);
                        break;
                    }
                }

                //将动态数组的维数设置成实际存在的元素个数,因为数组列表是以16的倍数递增维数的
                tmp3.TrimToSize();
                //转换数组列表为字符串数组,并返回。
                rt = (string[])tmp3.ToArray(typeof(String));
                tmp3.Clear();
            }
            catch (Exception e)
            {
                //Console.WriteLine("{0}", e.Message);
                throw e;
            }
            return rt;
        }
        static void Main(string[] args)
        {
            ArrayList al = new ArrayList();
            al.Add("Paris");
            al.Add("Ottowa");
            al.AddRange(new string[] { "Rome", "Tokyo", "Tunis", "Canberra" });

            Console.WriteLine("Count:    {0}", al.Count);
            Console.WriteLine("Capacity: {0}", al.Capacity);

            Console.WriteLine("Print values using foreach");
            PrintValues(al);
            Console.WriteLine("Print values using IEnumerator");
            PrintValuesByEnumerator(al);

            // Get second item in list as string
            string str = (string)al[1];    // need to cast, would also unbox if stored type was value type
            Console.WriteLine("al[1] = {0}", str);

            // Get first three items
            ArrayList firstThree = al.GetRange(0, 3);
            PrintValues(firstThree);

            // Remove next two
            al.RemoveRange(3, 2);
            PrintValues(al);

            // Get, insert and remove
            object itemOne = al[1];
            al.Insert(1, "Moscow");
            al.RemoveAt(2);
            PrintValues(al);

            // Sort
            al.Sort();
            PrintValues(al);

            // Search
            int targetIndex = al.BinarySearch("Moscow");
            Console.WriteLine("Index of Moscow: {0}", targetIndex);

            // Trim capacity
            al.TrimToSize();
            Console.WriteLine("Count:    {0}", al.Count);
            Console.WriteLine("Capacity: {0}", al.Capacity);

            // Creates a new ArrayList with five elements and initialize each element with a value.
            ArrayList al2 = ArrayList.Repeat("Boston", 5);   // static method
            PrintValues(al2);
        }
Example #8
0
        //Main_7_9_3
        //˵��ArrayList�������Ƕ�̬��
        public static void Main_7_9_3()
        {
            //��ʼ��arrs����Ϊ2
            ArrayList arrs = new ArrayList(2);

            arrs.Add(1);
            arrs.Add(2);
            arrs.Add(3);

            Console.WriteLine("��ǰ������{0}", arrs.Capacity);         //���Ϊ4

            arrs.TrimToSize();
            Console.WriteLine("ѹ�����������{0}", arrs.Capacity);  //���Ϊ3
        }
Example #9
0
 static int TrimToSize(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Collections.ArrayList obj = (System.Collections.ArrayList)ToLua.CheckObject(L, 1, typeof(System.Collections.ArrayList));
         obj.TrimToSize();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #10
0
        public void TestTrimToSizeBasic()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            ArrayList arrList = null;

            string[] strHeroes =
            {
                "Green Arrow",
                "Atom",
                "Batman",
                "Steel",
                "Superman",
                "Wonder Woman",
                "Hawkman",
                "Flash",
                "Aquaman",
                "Green Lantern",
                "Catwoman",
                "Huntress",
                "Robin",
                "Captain Atom",
                "Wildcat",
                "Nightwing",
                "Ironman",
                "SpiderMan",
                "Black Canary",
                "Thor",
                "Cyborg",
                "Captain America",
            };

            //
            // Construct array list.
            //
            arrList = new ArrayList((ICollection)strHeroes);

            //
            // []  Verify TrimToSize.
            //
            // Set capacity greater than the size of the ArrayList.
            arrList.Capacity = 2 * arrList.Count;
            Assert.True(arrList.Capacity > arrList.Count);

            // Verify TrimToSize
            arrList.TrimToSize();
            Assert.Equal(arrList.Count, arrList.Capacity);
        }
 /// <summary>
 ///  Factory method. Creates ScatterViewItemViews of items out from given ls
 /// </summary>
 /// <param name="ls"></param>
 /// <param name="deviceName"></param>
 /// <param name="startingPosition"></param>
 /// <returns></returns>
 public ScatterViewItem[] createFileList(ArrayList ls, String deviceName)
 {
     ls.TrimToSize();
     ScatterViewItem[] items = new ScatterViewItem[ls.Count];
     for (int i = 0; i < ls.Count; i++)
     {
         IndexObject item = ls[i] as IndexObject;
         ScatterViewItem temp = this.getItemView(item, deviceName);
         if (temp != null)
         {
             items[i] = temp;
         }
     }
         return items;
 }
Example #12
0
        private static IIDConvertor[] GetConvertorInstances()
        {
            Assembly source = Assembly.GetAssembly(typeof(IIDConvertor));
            if ( source == null ) return new IIDConvertor[] { new Inferis2IDConvertor() };

            // Look for IIDConvertor classes
            ArrayList list = new ArrayList();
            IEnumerator iter = source.GetExportedTypes().GetEnumerator();
            while ( iter.MoveNext() ) {
                if ( ((Type)iter.Current).GetInterface( typeof(IIDConvertor).Name ) != null ) {
                    list.Add( System.Activator.CreateInstance(((Type)iter.Current)) );
                }
            }

            // Assign result
            IIDConvertor[] result = new IIDConvertor[list.Count];
            list.TrimToSize();
            list.CopyTo( result, 0 );
            return result;
        }
		public TemplateMappingConfig(XmlNode section)
		{
			foreach (XmlElement mapElement in section.SelectNodes("map"))
			{
				string templateName = mapElement.GetAttribute("templateName");
				ArrayList conds = new ArrayList(5);

				foreach (XmlElement mapConditions in mapElement.SelectNodes("*"))
					switch (mapConditions.Name)
					{
						case "regexMatch": 
							conds.Add(new RegexTemplateMappingCondition(mapConditions));
							break;
						default:
							throw new ConfigurationException("Map condition not recognized: " + mapConditions.Name, mapConditions);
					}

				conds.TrimToSize();
				maps.Add(templateName, conds);
			}
		}
Example #14
0
        static void Main(string[] args)
        {
            ArrayList nomes = new ArrayList();

            nomes.Add("adão");
            nomes.Add("eva");
            nomes.Add("caim");
            nomes.Add("abel");
            nomes.Add(42);

            foreach (var item in nomes)
            {
                Console.WriteLine(item);
            }

            var numeros = new ArrayList { 1, 2, 3, 45 };

            int soma = 0;

            foreach (var item in numeros)
            {
                soma += (int)item;
            }

            Console.WriteLine(soma);

            numeros.Reverse();

            numeros.Sort();

            Console.WriteLine(nomes.Count);
            Console.WriteLine(nomes.Capacity);

            nomes.TrimToSize();

            Console.WriteLine(nomes.Capacity);

            Console.ReadKey();
        }
Example #15
0
		public void TrimToSize ()
		{
			ArrayList al1 = new ArrayList ();
		// Capacity is 0 under 2.0
		int capacity = 4;
			int size = capacity / 2;
			for (int i = 1; i <= size; i++) {
				al1.Add ('?');
			}
			al1.RemoveAt (0);
			al1.TrimToSize ();
			Assert.AreEqual (size - 1, al1.Capacity, "no capacity match");

			al1.Clear ();
			al1.TrimToSize ();
			Assert.AreEqual (capacity, al1.Capacity, "no default capacity");
		}
Example #16
0
        private void CreateFromNameAndManifests (ApplicationIdentity applicationIdentity, string[] manifestPaths)
        {
            if (applicationIdentity == null) 
                throw new ArgumentNullException("applicationIdentity");
            if (manifestPaths == null) 
                throw new ArgumentNullException("manifestPaths"); 
            Contract.EndContractBlock();
 
            _applicationIdentity = applicationIdentity;

            // ISSUE - need validation on manifestPaths
 
            IEnumDefinitionIdentity idenum = _applicationIdentity.Identity.EnumAppPath();
 
            _manifests = new ArrayList(DefaultComponentCount); 
            _manifestPaths = new String[manifestPaths.Length];
 
            IDefinitionIdentity[] asbId = new IDefinitionIdentity[1];
            int i=0;
            while (idenum.Next(1, asbId) == 1)
            { 
                ICMS cms = (ICMS) IsolationInterop.ParseManifest(manifestPaths[i], null, ref IsolationInterop.IID_ICMS);
 
                if (IsolationInterop.IdentityAuthority.AreDefinitionsEqual(0, cms.Identity, asbId[0])) 
                {
                    _manifests.Add(cms); 
                    _manifestPaths[i]=manifestPaths[i];
                }
                else
                { 
#if ISOLATION_IN_MSCORLIB
                    throw new ArgumentException(Environment.GetResourceString("Argument_IllegalAppIdMismatch")); 
#else 
                    throw new ArgumentException("Application Identity does not match identity in manifests");
#endif 
                }
                i++;
            }
            if (i!=manifestPaths.Length) 
            {
#if ISOLATION_IN_MSCORLIB 
                throw new ArgumentException(Environment.GetResourceString("Argument_IllegalAppId")); 
#else
                throw new ArgumentException("Application Identity does not have same number of components as manifest paths"); 
#endif
            }
            _manifests.TrimToSize();
            if (_manifests.Count <= 1) 
            {
#if ISOLATION_IN_MSCORLIB 
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidAppId")); 
#else
                throw new ArgumentException("Invalid identity: no deployment/app identity specified"); 
#endif
            }

            _definitionIdentities = null; 
            _actContext = null;
            _form = ContextForm.Loose; 
            _appRunState = ApplicationStateDisposition.Undefined; 

#if ISOLATION_IN_MSCORLIB 
            Contract.Assert(_manifests.Count == 2, "An application must have exactly 1 deployment component and 1 application component in Whidbey");
#endif
        }
Example #17
0
		//funcao que retorna um arraylist com todas as linhas marcadas como modified, added e deleted provenientes do dataset principal
		public ArrayList getAlteracoes(DataSet ds, ArrayList sortedTables)
		{
			long start = 0;
			start = DateTime.Now.Ticks;

			DataTable dt = null;
			ArrayList changedRowsArrayList = new ArrayList();

			DataSet gisaBackup = new DataSet();
            gisaBackup.EnforceConstraints = false;
			gisaBackup.CaseSensitive = true;

			//processamento efectuado tabela a tabela (o array resultante desta operação já vai ordenado para o save de linhas marcadas como added e deleted)
			foreach (object o in sortedTables)
			{
				dt = GisaDataSetHelper.GetInstance().Tables[((TableDepthOrdered.tableDepth)o).tab.TableName];
				//so prossegue a operação se existir alguma linha alterada
				if (dt.Select("", "", DataViewRowState.ModifiedOriginal | DataViewRowState.Added | DataViewRowState.Deleted).Length > 0)
				{
					//array de suporte onde vao ser guardadas as linhas marcadas como modified e added
					ArrayList modif = new ArrayList();

					if (! (gisaBackup.Tables.Contains(dt.TableName)))
						gisaBackup.Tables.Add(dt.Clone());

					//por cada linha modificada verifica se foi realmente alterada; se sim, adiciona-se ao array
					DataRow[] rows = dt.Select("", "", DataViewRowState.ModifiedOriginal);
					foreach (DataRow dr in rows)
					{
						if (! (isModifiedRow(dr)))
							dr.AcceptChanges();
						else
						{
							modif.Add(dr);
							gisaBackup.Tables[dt.TableName].ImportRow(dr);
						}
					}

					ArrayList add = new ArrayList();
					//adicionar as linhas marcadas como added ao array
					foreach (DataRow dr in dt.Select("", "", DataViewRowState.Added))
					{
						add.Add(dr);
						gisaBackup.Tables[dt.TableName].ImportRow(dr);
					}

					//adicionar as linhas marcadas como deleted ao array
					ArrayList del = new ArrayList();
					foreach (DataRow dr in dt.Select("", "", DataViewRowState.Deleted))
					{
						del.Add(dr);
						gisaBackup.Tables[dt.TableName].ImportRow(dr);
					}

					//adiciona uma tabela com as respectivas linhas alteradas ao arraylist que mantem a lista de todas as linhas alteradas
					add.TrimToSize();
					modif.TrimToSize();
					del.TrimToSize();

					if (add.Count > 0 || modif.Count > 0 || del.Count > 0)
					{
						changedRowsArrayList.Add(new changedRows(dt.TableName, add, modif, del));
						mGisaBackup = gisaBackup;
					}
				}
			}
			Debug.WriteLine("<<getAlteracoes>>: " + new TimeSpan(DateTime.Now.Ticks - start).ToString());
			return changedRowsArrayList;
		}
	public void TestTrimToSize() {
		{
			bool errorThrown = false;
			try {
				ArrayList al1 = 
					ArrayList.ReadOnly(new ArrayList());
				al1.TrimToSize();
			} catch (NotSupportedException) {
				errorThrown = true;
			}
			Assert("trim read only error not thrown", 
			       errorThrown);
		}
		{
			ArrayList al1 = new ArrayList();
			int capacity = al1.Capacity;
			int size = capacity / 2;
			for (int i = 1; i <=size; i++) {
				al1.Add('?');
			}
			al1.RemoveAt(0);
			al1.TrimToSize();
			AssertEquals("no capacity match", 
				     size - 1, al1.Capacity);

			al1.Clear();
			al1.TrimToSize();
			AssertEquals("no default capacity", 
				     capacity, al1.Capacity);
		}
	}
Example #19
0
        private void CountLines(FileSet TargetFileSet, string label)
        {
            _lineCount = 0;
            _commentLineCount = 0;
            _emptyLinesCount = 0;
            _fileNames = new ArrayList();
            _fileNames.Capacity = TargetFileSet.FileNames.Count;

            FileCodeCountInfo fileInfo;

            foreach(string file in TargetFileSet.FileNames) {
                fileInfo = CountFile(file);
                _lineCount += fileInfo.LineCount;
                _emptyLinesCount += fileInfo.EmptyLineCount;
                _commentLineCount += fileInfo.CommentLineCount;
                _fileNames.Add(fileInfo);
            }

            _fileNames.TrimToSize();
            Log(Level.Info, "Totals:\t[{0}] \t[T] {1}\t[C] {2}\t[E] {3}",
                label, _lineCount, _commentLineCount, _emptyLinesCount);
        }
		//-------------------------------------------------------------------
		void PopulateFromSnapshot(
			MemManager.Log.Log log,
			MemManager.Log.SnapShot snap,
			string filter,
            int size,
            bool dir
			)
		{
			// Make copy of view, ready to sort and collapse
            ArrayList view = new ArrayList(snap.Count);
			if (filter == "")
			{
				for (int i = 0, e = snap.Count; i < e; i++)
				{
					int logindex = snap[i];
					MemManager.Log.LogEntry le = log[ logindex ];
                    System.Diagnostics.Debug.Assert(le.type == 'A', "Error! All entries in snapshot should be allocations!");
                    if (le.index != (uint)logindex)
                        System.Diagnostics.Debug.Print("Something wrong with indexing");
					view.Add( le );
				}
			}
			else
			{
				Regex r = new Regex(filter, RegexOptions.Compiled|RegexOptions.IgnoreCase);
				for (int i = 0, e = snap.Count; i < e; i++)
				{
					int logindex = snap[i];
					MemManager.Log.LogEntry le = log[ logindex ];
                    //   le.index = (uint)logindex;
                    string name = mLog.GetString(le.nameString);
                    if (r.IsMatch(name))
                    {
                        if (size == 0)
                            view.Add(le);
                        else if (dir == false && le.allocSize >= size)
                            view.Add(le);
                        else if (dir == true && le.allocSize <= size)
                            view.Add(le);
                    }
                }
			}

            view.TrimToSize();

			// Sort view by category, size, and name-string
			view.Sort(new CompareCategorySizeAndName());

			// Create collapsed view
            mCollapsedView = new ArrayList(view.Count / 2);
			if (view.Count > 0)
			{
				MemManager.Log.LogEntry lastE = new MemManager.Log.LogEntry();
				lastE.category = 127;
                view.Add( lastE );	// append extra last object to make end logic easier!

				MemManager.Log.LogEntry last = (MemManager.Log.LogEntry)view[0];
				int count = 1;
				for (int i = 1, e = view.Count; i < e; i++)
				{
					MemManager.Log.LogEntry le = (MemManager.Log.LogEntry)view[i];
					if (last.category == le.category
						&& last.allocSize == le.allocSize
						&& last.nameString == le.nameString
				//		&& last.alignment == le.alignment
                 //	    &&	last.reqSize == le.reqSize)
                   )
					{
						count++;
					}
					else
					{
						Item it;

						it.count = count;
                        it.index = (int)last.index;

                        mCollapsedView.Add(it);
						last = le;
						count = 1;
					}
				}
			}

            mCollapsedView.TrimToSize();
            mCollapsedView.Sort(new CollapsedViewSort());
			PopulateDB(log);
		}
        public ReadFromXml(string instr)
        {
            string sOID = ""; //start object id
            string sPID = ""; //start point id
            string eOID = ""; //end object id
            string ePID = ""; //end point id

            cdList = new ArrayList();
            cnList = new ArrayList();
            ccList = new ArrayList();

            Node a = new Node("123","789"); //dummy
            cnList.Add(a);

            //Create XML DOM instance
            XmlDocument document = new XmlDocument();
            document.LoadXml(instr);
            //Select all graphic object elements and connections
            XmlNodeList objList1 = document.SelectNodes("//graphicObject");
            XmlNodeList objList2 = document.SelectNodes("//connection");

            int countDevice=0;

            int countResistor=1;
            int countCapacitor=1;
            int countInductor=1;
            int countTransitor=1;
            int countVDC=1;
            int countVAC=1;
            int countCsource=1;
            int countGround =1;
            int countJFET =1;
            int countOpamp=1;
            int countDiode=1;

            foreach(XmlNode objNode in objList1)
            {
                XmlNodeReader objNodeReader = new XmlNodeReader(objNode);

                while(objNodeReader.Read())	//read thru all child nodes of this node
                {
                    if(objNodeReader.NodeType == XmlNodeType.Element)	//	***READING NODES AND DEVICE***
                    {
                        if(objNodeReader.Name == "graphicObject")
                        {
                            objID = objNodeReader.GetAttribute("id");	// to read the id attribute of the element
                            template = objNodeReader.GetAttribute("template");	// to read the template attribute of the element, test if it is Capacitor, Resistor or others
                            type = objNodeReader.GetAttribute("type");	// to read the type attribute of the element, test if it is a link node.

                            switch ( template )	// typecast to specific type of device.
                            {
                                case "Resistor" :
                                    device = (Resistor)new Resistor(objID, "" + countDevice);    //chester
                                    countDevice++;
                                    countResistor++;
                                    break;

                                case "VsourceDC" :
                                    device = (VsourceDC)new VsourceDC(objID, ""+countDevice);       //chester
                                    countDevice++;
                                    countVDC++;
                                    break;

                                case "Inductor" :
                                    //device = (Inductor) new Inductor(objID,""+countDevice);
                                    device = (Inductor) new Inductor(objID,""+countInductor);
                                    countInductor++;
                                    //countDevice++;
                                    break;
                                case "Capacitor" :
                                    //device = (Capacitor) new Capacitor(objID,""+countDevice);
                                    device = (Capacitor)new Capacitor(objID, "" + countCapacitor);
                                    countCapacitor++;
                                    //countDevice++;
                                    break;
                                case "VsourceAC" :
                                    //device = (VsourceAC) new VsourceAC(objID,""+countDevice);
                                    device = (VsourceAC) new VsourceAC(objID,""+countVAC);
                                    countVAC++;
                                    //countDevice++;
                                    break;
                                case "Csource" :
                                    //device = (Csource) new Csource(objID,""+countDevice);
                                    device = (Csource) new Csource(objID,""+countCsource);
                                    countCsource++;
                                    break;
                                case "Diode" :
                                    device = (Diode) new Diode(objID,""+countDiode);
                                    countDiode++;
                                    break;
                                case "Transitor" :
                                    //device = (Transitor) new Transitor(objID,""+countDevice);
                                    device = (Transitor)new Transitor(objID, "" + countTransitor);
                                    countTransitor++;
                                    //countDevice++;
                                    break;
                                case "Ground" :
                                    device = (Ground) new Ground(objID,""+countGround);
                                    countGround++;
                                    break;
                                case "JFET" :
                                    device = (JFET) new JFET(objID,""+countJFET);
                                    countJFET++;
                                    break;

                                case "Opamp" :
                                    device = (Opamp) new Opamp(objID,""+countOpamp);
                                    countOpamp++;
                                    break;
                                default:
                                    device = new Device();
                                    device.SetID(objID);
                                    break;
                            }

                            #region "Chester for new device implementation"
                                 device.convert(objNodeReader);
                            #endregion

                            if (!cdList.Contains(device))
                            {
                                cdList.Add(device);
                            }

                        }
                    }
                }
            }

            //reading connection
            int countNode=0;
            IEnumerator cnEnum;

            foreach(XmlNode objNode in objList2)
            {
                XmlNodeReader objNodeReader = new XmlNodeReader(objNode);
                Node startNode = new Node();
                Node endNode = new Node();

                int cnt=0;

                while(objNodeReader.Read())	//read thru all child nodes of this node
                {
                    if(objNodeReader.NodeType == XmlNodeType.Element)
                    {

                        //Console.WriteLine(cnList.Count);
                        if(objNodeReader.Name == "point" && cnt%2==0 )
                        {
                            sOID = objNodeReader.GetAttribute("objectID");
                            sPID = objNodeReader.GetAttribute("pointID");

                            startNode.SetObjID(sOID);
                            startNode.SetPtID(sPID);
                            startNode.setstart(true);
                            cnEnum = cnList.GetEnumerator();

                            int countAll1=1;
                            while(cnEnum.MoveNext())
                            {
                                string currentObjID = ((Node)cnEnum.Current).GetObjID();
                                string currentPtID = ((Node)cnEnum.Current).GetPtID();
                                if(sOID!=null && sPID!=null)
                                {
                                    if(currentObjID.Equals(sOID) && currentPtID.Equals(sPID))
                                    {
                                        startNode.SetName(((Node)cnEnum.Current).GetName());
                                        break;
                                    }
                                    else
                                    {
                                        if(cnList.Count==countAll1)
                                        {
                                            //string name = "N"+countNode;
                                            string name = countNode+"";
                                            startNode.SetName(name);
                                            countNode++;
                                            cnList.Add(startNode);
                                            countAll1++;
                                            break;
                                        }

                                    }
                                }
                                countAll1++;
                                //Console.WriteLine("cnList count "+cnList.Count+" count 1 " + countAll1 );

                            }

                            cnt++;
                        }
                        else if(objNodeReader.Name == "point")
                        {
                            eOID = objNodeReader.GetAttribute("objectID");
                            ePID = objNodeReader.GetAttribute("pointID");
                            endNode.SetObjID(eOID);
                            endNode.SetPtID(ePID);
                            cnEnum = cnList.GetEnumerator();

                            int countAll2=1;
                            while(cnEnum.MoveNext())
                            {
                                string currentObjID = ((Node)cnEnum.Current).GetObjID();
                                string currentPtID = ((Node)cnEnum.Current).GetPtID();
                                if(eOID!=null && ePID!=null)
                                {
                                    if(currentObjID.Equals(eOID) && currentPtID.Equals(ePID))
                                    {
                                        endNode.SetName(((Node)cnEnum.Current).GetName());
                                        break;
                                    }
                                    else
                                    {
                                        if(cnList.Count==countAll2)
                                        {
                                            //string name = "N"+countNode;
                                            string name = ""+countNode;
                                            endNode.SetName(name);
                                            countNode++;
                                            cnList.Add(endNode);

                                            countAll2++;
                                            break;

                                        }
                                    }

                                }
                                countAll2++;
                                //Console.WriteLine(cnList.Count+" count 2 " + countAll2 );
                            }
                            if(eOID!=null && ePID!=null)
                            {
                                Connection connection = new Connection(startNode,endNode);
                                ccList.Add(connection);
                                startNode = new Node();
                                endNode = new Node();
                            }
                            cnt=0;

                        }

                    }
                }
            }
            cnList.RemoveAt(0);
            cnList.TrimToSize();

            IEnumerator cEnum = ccList.GetEnumerator();
            IEnumerator dEnum = cdList.GetEnumerator();
            IEnumerator nEnum = cnList.GetEnumerator();

            //to set the device name of the node
            while(nEnum.MoveNext())
            {
                dEnum = cdList.GetEnumerator();
                while(dEnum.MoveNext())
                {
                    if(((Node)nEnum.Current).GetObjID().Equals(((Device)dEnum.Current).GetID()))
                    {
                        ((Node)nEnum.Current).SetDeviceName(((Device)dEnum.Current).GetName());

                        if(((Device)dEnum.Current).GetNodeCount() == 0)
                        {
                            ((Device)dEnum.Current).SetNode1((Node)nEnum.Current);
                        }
                        else if(((Device)dEnum.Current).GetNodeCount() == 1)
                        {
                            ((Device)dEnum.Current).SetNode2((Node)nEnum.Current);
                        }
                        else if(((Device)dEnum.Current).GetNodeCount() == 2)
                        {
                            ((Device)dEnum.Current).SetNode3((Node)nEnum.Current);
                        }

                    }

                }
            }
            cEnum = ccList.GetEnumerator();
            dEnum = cdList.GetEnumerator();
            nEnum = cnList.GetEnumerator();
            //to set nodes in to the device
        }
Example #22
0
        /// <summary>
        /// CSVをArrayListに変換
        /// </summary>
        /// <param name="csvText">CSVの内容が入ったString</param>
        /// <returns>変換結果のArrayList</returns>
        public ArrayList CsvToArrayList1(string csvText)
        {
            System.Collections.ArrayList csvRecords =
                new System.Collections.ArrayList();

            //前後の改行を削除しておく
            csvText = csvText.Trim(new char[] { '\r', '\n' });

            //一行取り出すための正規表現
            System.Text.RegularExpressions.Regex regLine =
                new System.Text.RegularExpressions.Regex(
                    "^.*(?:\\n|$)",
                    System.Text.RegularExpressions.RegexOptions.Multiline);

            //1行のCSVから各フィールドを取得するための正規表現
            System.Text.RegularExpressions.Regex regCsv =
                new System.Text.RegularExpressions.Regex(
                    "\\s*(\"(?:[^\"]|\"\")*\"|[^,]*)\\s*,",
                    System.Text.RegularExpressions.RegexOptions.None);

            System.Text.RegularExpressions.Match mLine = regLine.Match(csvText);
            while (mLine.Success)
            {
                //一行取り出す
                string line = mLine.Value;
                //改行記号が"で囲まれているか調べる
                while ((CountString(line, "\"") % 2) == 1)
                {
                    mLine = mLine.NextMatch();
                    if (!mLine.Success)
                    {
                        throw new ApplicationException("不正なCSV");
                    }
                    line += mLine.Value;
                }
                //行の最後の改行記号を削除
                line = line.TrimEnd(new char[] { '\r', '\n' });
                //最後に「,」をつける
                line += ",";

                //1つの行からフィールドを取り出す
                System.Collections.ArrayList csvFields =
                    new System.Collections.ArrayList();
                System.Text.RegularExpressions.Match m = regCsv.Match(line);
                while (m.Success)
                {
                    string field = m.Groups[1].Value;
                    //前後の空白を削除
                    field = field.Trim();
                    //"で囲まれている時
                    if (field.StartsWith("\"") && field.EndsWith("\""))
                    {
                        //前後の"を取る
                        field = field.Substring(1, field.Length - 2);
                        //「""」を「"」にする
                        field = field.Replace("\"\"", "\"");
                    }
                    csvFields.Add(field);
                    m = m.NextMatch();
                }

                csvFields.TrimToSize();
                csvRecords.Add(csvFields);

                mLine = mLine.NextMatch();
            }

            csvRecords.TrimToSize();
            return(csvRecords);
        }
Example #23
0
File: Util.cs Project: vbyte/fmq
 /// <summary>
 /// 转换ArrayList为字符串数组
 /// </summary>
 /// <param name="arr">ArrayList数组</param>
 /// <returns>对等字符串数组</returns>
 public static string[] GetObjString(ArrayList arr)
 {
     if (arr == null) return null;
     arr.TrimToSize();
     return (string[])arr.ToArray(typeof(string));
 }
Example #24
0
        // function calls its self recursively
        /// <summary>
        /// The ifp reader.
        /// </summary>
        /// <param name="xtr">The xtr.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        private object[] IFPReader(ref XmlTextReader xtr)
        {
            ArrayList IFPElements = new ArrayList(0);
            int offset = 0;
            bool visible;
            int dependencyOffset = -1;
            bool endElement = false;
            while (xtr.Read())
            {
                visible = xtr.GetAttribute("visible") != null
                              ? xtr.GetAttribute("visible").ToLower() == "false" ? false : true
                              : true;
                switch (xtr.NodeType.ToString())
                {
                    case "Element":
                        {
                            switch (xtr.Name.ToLower())
                            {
                                    // <plugin class="bipd" author="Iron_Forge" version="0.3">
                                case "plugin":
                                    {
                                        author = xtr.GetAttribute("author");
                                        version = xtr.GetAttribute("version");
                                        classType = xtr.GetAttribute("class");
                                        break;
                                    }

                                    // <revision author="Iron_Forge" version="0.3">Added some known values...</revision>
                                case "revision":
                                    {
                                        alRevisions.Add(xtr.GetAttribute("author"));
                                        alRevisions.Add(xtr.GetAttribute("version"));
                                        alRevisions.Add(xtr.ReadString());
                                        break;
                                    }

                                    // <struct name="Predicted Resources24" offset="32" visible="true" size="8">
                                case "struct":
                                    {
                                        bool temp = true;
                                        string i = xtr.GetAttribute("HasCount");
                                        if (i != null)
                                        {
                                            temp = bool.Parse(i);
                                        }

                                        IFPElements.Add(
                                            new Reflexive(
                                                xtr.LineNumber,
                                                offset,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                xtr.GetAttribute("label"),
                                                IFPReader(ref xtr),
                                                size,
                                                temp,
                                                -1,
                                                -1));
                                        if (temp == false)
                                        {
                                            offset += 4;
                                        }
                                        else
                                        {
                                            offset += 8;
                                        }

                                        break;
                                    }

                                    // <tag name="" visible="false"/>
                                case "block":
                                    {
                                        IFPElements.Add(
                                            new TagBlock(
                                                xtr.GetAttribute("name"), visible, offset, xtr.LineNumber, -1, -1));
                                        offset += 8;
                                        break;
                                    }

                                case "tag":
                                    {
                                        IFPElements.Add(
                                            new TagType(
                                                offset, visible, xtr.GetAttribute("name"), xtr.LineNumber, -1, -1));
                                        offset += 4;
                                        dependencyOffset = offset;
                                        break;
                                    }

                                    // <id name="" visible="false"/>
                                case "id":
                                    {
                                        bool isDependency = dependencyOffset == offset ? true : false;
                                        IFPElements.Add(
                                            new Ident(
                                                xtr.GetAttribute("name"),
                                                visible,
                                                offset,
                                                isDependency,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 4;
                                        break;
                                    }

                                    // <stringid name="" visible="false" />
                                case "stringid":
                                    {
                                        IFPElements.Add(
                                            new SID(xtr.GetAttribute("name"), visible, offset, xtr.LineNumber, -1, -1));
                                        offset += 4;
                                        break;
                                    }

                                case "script":
                                    {
                                        goto case "stringid";
                                    }

                                    // <unused size="32" default="0" />
                                case "unused":
                                    {
                                        int sizeOfUnusedSpace = Convert.ToInt32(xtr.GetAttribute("size"));
                                        IFPElements.Add(new Unused(offset, sizeOfUnusedSpace, xtr.LineNumber, -1, -1));
                                        offset += sizeOfUnusedSpace;
                                        break;
                                    }

                                    // <undefined name="Unknown" visible="false" />
                                case "undefined":
                                    {
                                        IFPElements.Add(
                                            new Unknown(
                                                offset, visible, xtr.GetAttribute("name"), xtr.LineNumber, -1, -1));
                                        offset += 4;
                                        break;
                                    }

                                    // <float name="" visible="false" />
                                case "float":
                                    {
                                        IFPElements.Add(
                                            new IFPFloat(
                                                offset, visible, xtr.GetAttribute("name"), xtr.LineNumber, -1, -1));
                                        offset += 4;
                                        break;
                                    }

                                    // <int name="Unknown" visible="false" />
                                case "int":
                                    {
                                        IFPElements.Add(
                                            new IFPInt(
                                                offset,
                                                ObjectEnum.Int,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                makeIndex(ref xtr, "int"),
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 4;
                                        break;
                                    }

                                    // <uint name="Structure BSP Offset" />
                                case "uint":
                                    {
                                        IFPElements.Add(
                                            new IFPInt(
                                                offset,
                                                ObjectEnum.UInt,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                makeIndex(ref xtr, "uint"),
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 4;
                                        break;
                                    }

                                    // <short name="Palette Chunk #" visible="true" />
                                case "short":
                                    {
                                        IFPElements.Add(
                                            new IFPInt(
                                                offset,
                                                ObjectEnum.Short,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                makeIndex(ref xtr, "short"),
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 2;
                                        break;
                                    }

                                    // <ushort name="Palette Chunk #" visible="true" />
                                case "ushort":
                                    {
                                        IFPElements.Add(
                                            new IFPInt(
                                                offset,
                                                ObjectEnum.UShort,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                makeIndex(ref xtr, "ushort"),
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 2;
                                        break;
                                    }

                                    // <byte name="Unknown" visible="false" />
                                case "byte":
                                    {
                                        IFPElements.Add(
                                            new IFPByte(
                                                offset,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                makeIndex(ref xtr, "byte"),
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 1;
                                        break;
                                    }

                                    // <bitmask name="Spawns in (none means all)">
                                case "bitmask":
                                    {
                                        goto case "bitmask32";
                                    }

                                    // <bitmask32 name="Spawns in (none means all)">
                                    // added 6-9-06 start
                                case "bitmask32":
                                    {
                                        IFPElements.Add(
                                            new Bitmask(
                                                offset,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                xtr.IsEmptyElement == false ? Options(ref xtr) : null,
                                                32,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 4;
                                        break;
                                    }

                                    // <bitmask16 name="Spawns in (none means all)">
                                case "bitmask16":
                                    {
                                        IFPElements.Add(
                                            new Bitmask(
                                                offset,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                xtr.IsEmptyElement == false ? Options(ref xtr) : null,
                                                16,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 2;
                                        break;
                                    }

                                case "bitmask8":
                                    {
                                        IFPElements.Add(
                                            new Bitmask(
                                                offset,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                xtr.IsEmptyElement == false ? Options(ref xtr) : null,
                                                8,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 1;
                                        break;
                                    }

                                    // <enum name="Only Use Once">
                                case "enum":
                                    {
                                        goto case "enum32";
                                    }

                                    // <enum32 name="Only Use Once">
                                case "enum32":
                                    {
                                        IFPElements.Add(
                                            new IFPEnum(
                                                offset,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                xtr.IsEmptyElement == false ? Options(ref xtr) : null,
                                                32,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 4;
                                        break;
                                    }

                                    // <enum16 name="Only Use Once">
                                case "enum16":
                                    {
                                        IFPElements.Add(
                                            new IFPEnum(
                                                offset,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                xtr.IsEmptyElement == false ? Options(ref xtr) : null,
                                                16,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 2;
                                        break;
                                    }

                                case "enum8":
                                    {
                                        IFPElements.Add(
                                            new IFPEnum(
                                                offset,
                                                visible,
                                                xtr.GetAttribute("name"),
                                                xtr.IsEmptyElement == false ? Options(ref xtr) : null,
                                                8,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 1;
                                        break;
                                    }

                                    // end
                                    // <string name="Tag Name" or whatever size you wish />
                                case "string":
                                    {
                                        int sizeOfString = Convert.ToInt32(xtr.GetAttribute("size"));
                                        if (sizeOfString == 0)
                                        {
                                            // Default value of 256
                                            sizeOfString = 256;
                                        }

                                        IFPElements.Add(
                                            new IFPString(
                                                xtr.GetAttribute("name"),
                                                visible,
                                                offset,
                                                sizeOfString,
                                                false,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += sizeOfString;
                                        break;
                                    }

                                    // <string32 name="Profile Name" />
                                case "string32":
                                    {
                                        IFPElements.Add(
                                            new IFPString(
                                                xtr.GetAttribute("name"),
                                                visible,
                                                offset,
                                                32,
                                                false,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 32;
                                        break;
                                    }

                                    // <string256 name="Scenario Path" />
                                case "string256":
                                    {
                                        IFPElements.Add(
                                            new IFPString(
                                                xtr.GetAttribute("name"),
                                                visible,
                                                offset,
                                                256,
                                                false,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 256;
                                        break;
                                    }

                                    // <unicode64 name="English Name" />
                                case "unicode64":
                                    {
                                        IFPElements.Add(
                                            new IFPString(
                                                xtr.GetAttribute("name"),
                                                visible,
                                                offset,
                                                64,
                                                true,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 64;
                                        break;
                                    }

                                    // <unicode256 name="English Name" />
                                case "unicode256":
                                    {
                                        IFPElements.Add(
                                            new IFPString(
                                                xtr.GetAttribute("name"),
                                                visible,
                                                offset,
                                                256,
                                                true,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 256;
                                        break;
                                    }
                                case "rgb_color":
                                    {
                                        IFPElements.Add(
                                            new IFPColor(
                                                xtr.GetAttribute("name"),
                                                visible,
                                                false,
                                                ObjectEnum.Int,
                                                offset,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 12;
                                        break;
                                    }
                                case "argb_color":
                                    {
                                        IFPElements.Add(
                                            new IFPColor(
                                                xtr.GetAttribute("name"),
                                                visible,
                                                true,
                                                ObjectEnum.Int,
                                                offset,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 16;
                                        break;
                                    }
                                case "real_rgb_color":
                                    {
                                        IFPElements.Add(
                                            new IFPColor(
                                                xtr.GetAttribute("name"),
                                                visible,
                                                false,
                                                ObjectEnum.Float,
                                                offset,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 12;
                                        break;
                                    }
                                case "real_argb_color":
                                    {
                                        IFPElements.Add(
                                            new IFPColor(
                                                xtr.GetAttribute("name"),
                                                visible,
                                                true,
                                                ObjectEnum.Float,
                                                offset,
                                                xtr.LineNumber,
                                                -1,
                                                -1));
                                        offset += 16;
                                        break;
                                    }

                                default:
                                    MessageBox.Show(
                                        "Unknown class: \"" + xtr.Name + "\"\n Name: " + xtr.GetAttribute("name") +
                                        "\n Offset: " + offset,
                                        classType + ".ent");
                                    break;
                            }

                            break;
                        }

                    case "EndElement":
                        {
                            switch (xtr.Name)
                            {
                                case "struct":
                                    {
                                        endElement = true;
                                        break;
                                    }

                                case "plugin":
                                    {
                                        goto case "struct";
                                    }
                            }

                            break;
                        }
                }

                if (endElement)
                {
                    break;
                }
            }

            size = offset;
            IFPElements.TrimToSize();
            object[] tempobjectarray = IFPElements.ToArray();
            return tempobjectarray;
        }
Example #25
0
File: Util.cs Project: vbyte/fmq
 /// <summary>
 /// 图片上传服务器端验证
 /// </summary>
 /// <param name="imgFile">上传文件域</param>
 /// <param name="maxWidth">最大宽度,忽视为0。</param>
 /// <param name="maxHeight">最大高度,忽视为0。</param>
 /// <param name="maxFileSize">最大文件大小,忽视为0。</param>
 /// <param name="validExt">有效的文件扩展名,如"gif|jpg|png",忽视为空字符。</param>
 /// <returns>如果符合要求,则返回的数组长度为0。</returns>
 public static string[] ValidateImage(System.Web.HttpPostedFile imgFile, int maxWidth, int maxHeight, int maxFileSize, string validExt)
 {
     System.Collections.ArrayList errList = new System.Collections.ArrayList(5);
     try
     {
         System.Drawing.Image img = System.Drawing.Image.FromStream(imgFile.InputStream, false, false);
         if (maxWidth != 0 && img.Width > maxWidth)
         {
             errList.Add("图片宽度超过" + maxWidth.ToString() + "像素");
         }
         if (maxHeight != 0 && img.Height > maxHeight)
         {
             errList.Add("图片高度超过" + maxHeight.ToString() + "像素");
         }
         if (maxFileSize != 0 && imgFile.ContentLength > maxFileSize)
         {
             errList.Add("图片文件大小超过" + (maxFileSize / 1024).ToString("f1") + "KB");
         }
         if (validExt != string.Empty)
         {
             Regex regEx = new Regex(@"\.(" + validExt + ")$", RegexOptions.IgnoreCase);
             if (!regEx.Match(imgFile.FileName).Success)
             {
                 errList.Add("图片文件类型不是" + validExt.Replace("|", "、") + "格式的文件");
             }
         }
         //img.Dispose();
     }
     catch (Exception)
     {
         errList.Add("不是一个有效的图片格式");
     }
     errList.TrimToSize();
     return (string[])errList.ToArray(typeof(string));
 }
Example #26
0
			public static Array Shrink(Array arr, object removeValue)
			{
				ArrayList arrNew = new ArrayList(arr.Length - 1);
				foreach(object o in arr)
				{
					if (o != removeValue)
						arrNew.Add(o);
				}
				arrNew.TrimToSize();
				return arrNew.ToArray(arr.GetType().GetElementType());
			}
Example #27
0
            public UnionCollection(ICollection c1, ICollection c2)
            {
                Hashtable table1 = new Hashtable(c1.Count);
                foreach(object obj in c1)
                {
                    if(!table1.Contains(obj))
                    {
                        table1.Add(obj, null);
                    }
                }

                Hashtable table2 = new Hashtable(c2.Count);
                foreach(object obj in c2)
                {
                    if(!table2.Contains(obj))
                    {
                        table2.Add(obj, null);
                    }
                }

                // building the union
                union = new ArrayList(Math.Max(table1.Count, table2.Count));
                union.AddRange(table1.Keys);
                foreach(object obj in c2)
                {
                    if(!table1.Contains(obj))
                    {
                        union.Add(obj);
                    }
                }

                union.TrimToSize();
            }
Example #28
0
        private void CreateFromName (ApplicationIdentity applicationIdentity) 
        {
            if (applicationIdentity == null) 
                throw new ArgumentNullException("applicationIdentity"); 
            Contract.EndContractBlock();
 
            _applicationIdentity = applicationIdentity;

            IEnumDefinitionIdentity idenum = _applicationIdentity.Identity.EnumAppPath();
 
            _definitionIdentities = new ArrayList(DefaultComponentCount);
 
            IDefinitionIdentity[] asbId = new IDefinitionIdentity[1]; 
            while (idenum.Next(1, asbId) == 1)
            { 
                _definitionIdentities.Add(asbId[0]);
            }
            _definitionIdentities.TrimToSize();
            if (_definitionIdentities.Count <= 1) 
            {
#if ISOLATION_IN_MSCORLIB 
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidAppId")); 
#else
                throw new ArgumentException("Invalid identity: no deployment/app identity specified"); 
#endif
            }

            _manifestPaths = null; 
            _manifests = null;
 
            // Construct real IActContext from store. 
            _actContext = IsolationInterop.CreateActContext(_applicationIdentity.Identity);
            _form = ContextForm.StoreBounded; 
            _appRunState = ApplicationStateDisposition.Undefined;

#if ISOLATION_IN_MSCORLIB
            Contract.Assert(_definitionIdentities.Count == 2, "An application must have exactly 1 deployment component and 1 application component in Whidbey"); 
#endif
        } 
Example #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemberRoles"/> class.
 /// </summary>
 /// <param name="member">The member.</param>
 /// <param name="role">The role.</param>
 public MemberRoles(string member, string role)
 {
     Username = member;
     _roles = new ArrayList { role };
     _roles.TrimToSize();
 }
Example #30
0
    // 未使用 ----

    // http://dobon.net/vb/dotnet/file/readcsvfile.html
    /// <summary>
    /// CSVをArrayListに変換
    /// </summary>
    /// <param name="csvText">CSVの内容が入ったString</param>
    /// <returns>変換結果のArrayList</returns>
    public static System.Collections.ArrayList CsvToArrayList2(string csvText)
    {
        //前後の改行を削除しておく
        csvText = csvText.Trim(new char[] { '\r', '\n' });

        System.Collections.ArrayList csvRecords =
            new System.Collections.ArrayList();
        System.Collections.ArrayList csvFields =
            new System.Collections.ArrayList();

        int    csvTextLength = csvText.Length;
        int    startPos = 0, endPos = 0;
        string field = "";

        while (true)
        {
            //空白を飛ばす
            while (startPos < csvTextLength &&
                   (csvText[startPos] == ' ' || csvText[startPos] == '\t'))
            {
                startPos++;
            }

            //データの最後の位置を取得
            if (startPos < csvTextLength && csvText[startPos] == '"')
            {
                //"で囲まれているとき
                //最後の"を探す
                endPos = startPos;
                while (true)
                {
                    endPos = csvText.IndexOf('"', endPos + 1);
                    if (endPos < 0)
                    {
                        throw new ApplicationException("\"が不正");
                    }
                    //"が2つ続かない時は終了
                    if (endPos + 1 == csvTextLength || csvText[endPos + 1] != '"')
                    {
                        break;
                    }
                    //"が2つ続く
                    endPos++;
                }

                //一つのフィールドを取り出す
                field = csvText.Substring(startPos, endPos - startPos + 1);
                //""を"にする
                field = field.Substring(1, field.Length - 2).Replace("\"\"", "\"");

                endPos++;
                //空白を飛ばす
                while (endPos < csvTextLength &&
                       csvText[endPos] != ',' && csvText[endPos] != '\r')
                {
                    endPos++;
                }
            }
            else
            {
                //"で囲まれていない
                //カンマか改行の位置
                endPos = startPos;
                while (endPos < csvTextLength &&
                       csvText[endPos] != ',' && csvText[endPos] != '\r')
                {
                    endPos++;
                }

                //一つのフィールドを取り出す
                field = csvText.Substring(startPos, endPos - startPos);
                //後の空白を削除
                field = field.TrimEnd();
            }

            //フィールドの追加
            csvFields.Add(field);

            //行の終了か調べる
            if (endPos >= csvTextLength || csvText[endPos] == '\r')
            {
                //行の終了
                //レコードの追加
                csvFields.TrimToSize();
//				Debug.LogWarning ("csvFields: "+csvFields);
                csvRecords.Add(csvFields);
                csvFields = new System.Collections.ArrayList(
                    csvFields.Count);

                if (endPos >= csvTextLength)
                {
                    //終了
                    break;
                }
            }

            //次のデータの開始位置
            startPos = endPos + 1;
        }

        csvRecords.TrimToSize();
        return(csvRecords);
    }
        private void btnZipRecurse_Click(object sender, System.EventArgs e)
        {
            //NOTE:
            //Consult the zip32 limits provided in the documentation

            textBox1.Text = string.Empty;
            textBox2.Text = string.Empty;

            //Instantiate the Zip object
            m_ZipObj = new Zip();

            //_____________________________________________________________________________
            //WORK AROUND:
            //The InfoZip documentation states that the zip32.dll can recurse directories if the -r or -R flag is specified.
            //In code this is specified by setting the fRecurse flag of the ZPOPT structure to 1 (-r) or 2 (-R).
            //However, in my test, when I specified either of the recurse flags I frequently received errors coming
            //back from the ZpArchive function.  My work around is to recurse the specified directories and prepare
            //an array of file names and pass that array to zip32.  Everything seems to work OK if I do this.

            //If you want to try the recurse option, below is an example of how to do it.

            //			string [] files = new string[1];
            //
            //			//NOTE:
            //			//Change this to whatever is appropriate
            //			System.IO.Directory.SetCurrentDirectory(@"C:\TmpTest");
            //
            //			//Specify the file mask you want to use.  Consult the zip32.dll documentation for the
            //			//-r and -R options
            //			files[0] = @"*.*";
            //
            //			m_ZipObj.FilesToZip = files;
            //			m_ZipObj.Recurse = RecurseEnum.Level2;
            //			m_ZipObj.Verbose = VerboseMessagesEnum.True;
            //			m_ZipObj.Level = CompressionLevelEnum.Level6;
            //
            //			//NOTE:
            //			//File name of the resulting zip file.  Change this as appropriate
            //			m_ZipObj.ZipFileName = @"c:\tmp\zip\csharprecurse.zip";
            //
            //			//Wire the event handlers to receive the events from the Zip class
            //			m_ZipObj.ReceivePrintMessage +=new ZipDLLPrintMessageEventHandler(zipObj_ReceivePrintMessage);
            //			m_ZipObj.ReceiveServiceMessage +=new ZipDLLServiceMessageEventHandler(zipObj_ReceiveServiceMessage);
            //
            //			btnStop.Enabled = true;
            //
            //			//Zip the files
            //			int ret = m_ZipObj.ZipFiles();
            //
            //			//Examine the return code
            //			MessageBox.Show("Done. Ret: " + ret.ToString());

            //_____________________________________________________________________________
            //Prepare an array of all the files in the directory

            //NOTE:
            //Change this to whatever is appropriate
            string root = @"C:\Tmp\TestZip";

            ArrayList fileList = new ArrayList();
            RecurseGetDirsAndFiles(root, fileList);
            fileList.TrimToSize();

            //Build the files array.  Practically, the .NET limit here is your RAM
            string [] files = new string[fileList.Count];
            int idx = 0;

            IEnumerator en = fileList.GetEnumerator();
            while ( en.MoveNext() )
            {
                files[idx] = en.Current.ToString();
                idx++;
            }

            //Set the Zip object properties
            m_ZipObj.FilesToZip = files;
            m_ZipObj.Verbose = VerboseMessagesEnum.True;
            m_ZipObj.Level = CompressionLevelEnum.Level6;

            //This is optional.  This is how to add a comment
            m_ZipObj.Comment = "Test Comment";
            m_ZipObj.CommentOption = CommentEnum.True;

            //NOTE:
            //File name of the resulting zip file.  Change this as appropriate
            m_ZipObj.ZipFileName = @"c:\tmp\zip\csharpzip2.zip";

            //Wire the event handlers to receive the events from the Zip class
            m_ZipObj.ReceivePrintMessage +=new ZipDLLPrintMessageEventHandler(zipObj_ReceivePrintMessage);
            m_ZipObj.ReceiveServiceMessage +=new ZipDLLServiceMessageEventHandler(zipObj_ReceiveServiceMessage);

            btnStop.Enabled = true;

            //Zip the files
            int ret = m_ZipObj.ZipFiles();

            //Examine the return code
            MessageBox.Show("Done. Ret: " + ret.ToString());
        }
Example #32
0
            public InterCollection(ICollection c1, ICollection c2)
            {
                // swap in order to have <c>c1.Count <= c2.Count</c>
                if(c1.Count > c2.Count)
                {
                    ICollection c1Bis = c1;
                    c1 = c2;
                    c2 = c1Bis;
                }

                Hashtable table = new Hashtable(c1.Count);
                foreach(object obj in c1)
                {
                    if(!table.Contains(obj))
                    {
                        table.Add(obj, null);
                    }
                }

                // building the intersection
                intersection = new ArrayList();
                foreach(object obj in c2)
                {
                    if(table.Contains(obj))
                    {
                        intersection.Add(obj);
                        table.Remove(obj);
                    }
                }

                intersection.TrimToSize();
            }
Example #33
0
		/// <summary>
		/// Gets an arraylist of ImageGuys that make up the current graphic.
		/// </summary>
		/// <returns></returns>
		private ArrayList GetImagePattern()
		{
			string[] chunks =  mPatternTextBox.Text.Split("\r\n, ".ToCharArray());
			ArrayList theChunks = new ArrayList(chunks.Length);
			for(int i = 0; i < chunks.Length; i++ )
			{
				if( chunks[i].Length > 0 )
					theChunks.Add(chunks[i]);
			}
			theChunks.TrimToSize();
			return theChunks;
		}
Example #34
0
            public MinusCollection(ICollection c1, ICollection c2)
            {
                Hashtable table1 = new Hashtable(c1.Count);
                foreach(object obj in c1)
                {
                    if(!table1.Contains(obj))
                    {
                        table1.Add(obj, null);
                    }
                }

                Hashtable table2 = new Hashtable(c2.Count);
                foreach(object obj in c2)
                {
                    if(!table2.Contains(obj))
                    {
                        table2.Add(obj, null);
                    }
                }

                // building minus collection
                minus = new ArrayList(Math.Max(c1.Count - c2.Count, 10));
                foreach(object obj in table1.Keys)
                {
                    if(!table2.Contains(obj))
                    {
                        minus.Add(obj);
                    }
                }

                minus.TrimToSize();
            }
Example #35
0
        /// <summary>
        /// Creates the bytes after the destination address bytes.  This also inserts the TLV
        /// table data.  Common to both submit and submit multiple.
        /// </summary>
        /// <returns>The bytes in the Pdu before the destination address(es).</returns>
        protected ArrayList GetBytesAfterDestination()
        {
            ArrayList pdu = new ArrayList();
            pdu.Add(EsmClass);
            pdu.Add((byte)ProtocolId);
            pdu.Add((byte)PriorityFlag);
            pdu.AddRange(SmppStringUtil.ArrayCopyWithNull(Encoding.ASCII.GetBytes(ScheduleDeliveryTime)));
            pdu.AddRange(SmppStringUtil.ArrayCopyWithNull(Encoding.ASCII.GetBytes(ValidityPeriod)));
            pdu.Add((byte)RegisteredDelivery);

            if(ReplaceIfPresentFlag == true)
            {
                pdu.Add((byte)0x01);
            }
            else
            {
                pdu.Add((byte)0x00);
            }

            pdu.Add((byte)DataCoding);
            pdu.Add(SmDefaultMessageId);
            _SmLength = PduUtil.InsertShortMessage(pdu, DataCoding, ShortMessage);

            pdu.TrimToSize();

            return pdu;
        }