Example #1
0
    public void writeEntry(ArrayList entry)
    {
        mutex.WaitOne();

        IEnumerator line = entry.GetEnumerator();
        while (line.MoveNext())
           Console.WriteLine(line.Current);

        Console.WriteLine();

        mutex.ReleaseMutex();
    }
Example #2
0
    public static int AddVegetation(string filename)
    {
        string[] lines = OpenTextFile (filename);
        string trimmedLine;
        string result;

        Vector3 trans= Vector3.zero;
        ArrayList points= new ArrayList();
        int typeVegetation;

          		int n = 0;
        //		int lineNumber = 0;
        foreach (string line in lines) {
        //			Debug.Log (++lineNumber);
            trimmedLine = line.Trim();
            result = MatchItem(trimmedLine, "translation ");
            if ((null!=result) ) { trans = stringToVector3 (result); }
            result = MatchItem(trimmedLine, "points [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "pointsRemplis [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "typeVegetation ");
            if (null!=result) {
                typeVegetation=int.Parse(result);

                IEnumerator e = points.GetEnumerator();
                while (e.MoveNext()) {
                    n++;
                    GameObject tree = EditorUtility.InstantiatePrefab (prefabTrees[typeVegetation]) as GameObject;
                    tree.transform.parent=meshTrees.transform;

                    Vector3 v = (Vector3)e.Current+trans;
                    v.x=-v.x;
                    tree.transform.position=v;

                }

            }
        }
        return n;
    }
Example #3
0
    public static int Main(String[] args)
    {
        ArrayList objList = new ArrayList();
        objList.Add("hey");
        objList.Add(null);

        IEnumerator ienum = objList.GetEnumerator();
        int iCounter = 0;
        while (ienum.MoveNext())
        {
            iCounter++;
            Console.WriteLine(iCounter.ToString());
        }
        if (iCounter == 2)
        {
            Console.WriteLine("Passed");
            return 100;
        }
        else
        {
            Console.WriteLine("Failed");
            return 1;
        }
    }
Example #4
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(arInts.GetEnumerator());
 }
    public static void AddVegetation(string filename)
    {
        string[] lines = OpenTextFile (filename);
        string trimmedLine;
        string result;

        Vector3 trans= Vector3.zero;
        ArrayList points= new ArrayList();
        int typeVegetation=0;

           		Terrain terrain = getMainTerrain("TerrainArbres");
        TerrainData	terraindata = terrain.terrainData;
        TreeInstance tree;
        List<TreeInstance> newTrees = new List<TreeInstance>(terraindata.treeInstances);

        Vector3 deltaY=Vector3.zero;
        deltaY.y+=0.0f;

        //		int lineNumber = 0;
        foreach (string line in lines) {
        //			Debug.Log (++lineNumber);
            trimmedLine = line.Trim();
            result = MatchItem(trimmedLine, "translation ");
            if ((null!=result) ) { trans = stringToVector3 (result); }
            result = MatchItem(trimmedLine, "points [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "pointsRemplis [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "typeVegetation ");
            if (null!=result) {
                typeVegetation=int.Parse(result);

                IEnumerator e = points.GetEnumerator();
                float rnd;
                while (e.MoveNext()) {

                    // make more random
                    if ((typeVegetation<=11) && (typeVegetation!=6)  && (typeVegetation!=7)  && (typeVegetation!=8)) {
                        while ((rnd=Random.value)==1.0f);
                        typeVegetation = (typeVegetation/3)*3+(int) (rnd*3);
                    }

                    tree = new TreeInstance();
                    tree.position = WorldToTerrain(terrain,(Vector3)e.Current+trans+deltaY);

                    tree.prototypeIndex = typeVegetation;

                    if (typeVegetation==18) Debug.Log ("invalide vegetation");

                    if (typeVegetation<=5) rnd =  0.3f*(Random.value-1.0f)-0.1f;
                    else if (typeVegetation<=8) rnd =  0.2f*(Random.value-1.0f);
                    else if (typeVegetation==9) rnd =  0.2f*(Random.value-1.0f);
                    else rnd= 0.25f*(Random.value-1.0f);
        //		rnd=0.0f;

                    if ((typeVegetation>=6) && (typeVegetation<=8)) tree.widthScale = 1.0f;
                    else tree.widthScale = 1.0f+rnd;
                    tree.heightScale = 1.0f+rnd;

                    Color c = Color.white;
                    c[0] = 0.92f+Random.value*0.08f;
                    c[1] = 0.92f+Random.value*0.08f;
                    c[2] = 0.92f+Random.value*0.08f;
                    tree.color = c;

                    tree.lightmapColor = Color.white;

                    // 1, 3, 4, 5

                    //if (typeVegetation==5)
                    newTrees.Add(tree);
                }

            }
        }
        terraindata.treeInstances= newTrees.ToArray();
    }
Example #6
0
    public static void Main( String[] args )
    {
        if (args.Length != 5)
        {
            Console.WriteLine("Usage:   mono ClientSideSort <host name> "+
                       "<login dn> <password> <search base>\n"
                       + "         <search filter>");
            Console.WriteLine("Example: mono ClientSideSort Acme.com"
                       + " \"cn=admin,o=Acme\""
                       + " secret \"ou=sales,o=Acme\"\n"
                       + "         \"(objectclass=*)\"");
            Environment.Exit(0);
        }

        int ldapPort = LdapConnection.DEFAULT_PORT;
        int searchScope = LdapConnection.SCOPE_ONE;
        int ldapVersion  = LdapConnection.Ldap_V3;
        String ldapHost = args[0];
        String loginDN  = args[1];
        String password = args[2];
        String searchBase = args[3];
        String searchFilter = args[4];
        LdapConnection conn = new LdapConnection();

        try
        {
            // connect to the server
            conn.Connect( ldapHost, ldapPort );

            // bind to the server
            conn.Bind( ldapVersion, loginDN, password);

            LdapSearchResults searchResults = conn.Search(  searchBase,
                                                            searchScope,
                                                            searchFilter,
                                                            new String[] {"cn", "uid", "sn"}, //attributes
                                                            false);        // return attrs and values

            /* sortedResults will sort the entries according to the natural
             * ordering of LDAPEntry (by distiguished name).
             */

            ArrayList sortedResults = new ArrayList();
            while ( searchResults.hasMore())
            {
                try
                {
                    sortedResults.Add( searchResults.next() );
                }
                catch(LdapException e)
                {
                    Console.WriteLine("Error: " + e.ToString());
                    // Exception is thrown, go for next entry
                    continue;
                }
            }

            // print the sorted results
            Console.WriteLine( "\n"+
                       "****************************\n"+
                       "Search results sorted by DN:\n"+
                       "****************************");
            sortedResults.Sort();
            IEnumerator i = sortedResults.GetEnumerator(0,sortedResults.Count-1);
            while (i.MoveNext())
            {
                PrintEntry( (LdapEntry)(i.Current) );
            }

            /* resort the results an an array using a specific comparator */
            String[] namesToSortBy  = { "sn", "uid", "cn"  };
            bool[] sortAscending = { true, false, true };
            LdapCompareAttrNames myComparator = new LdapCompareAttrNames( namesToSortBy, sortAscending );

            Object[] sortedSpecial = sortedResults.ToArray();
            Array.Sort(sortedSpecial, myComparator);

            // print the re-sorted results
            Console.WriteLine( "\n" +
                   "*****************************************************\n" +
                   "Search results sorted by sn, uid(Descending), and cn:\n" +
                   "*****************************************************");
            for(int j=0; j< sortedSpecial.Length; j++)
            {
                PrintEntry( (LdapEntry) sortedSpecial[j] );
            }
            // disconnect with the server
            conn.Disconnect();
        }
        catch( LdapException e )
        {
            Console.WriteLine( "Error: " + e.ToString() );
        }
        catch( Exception e )
        {
            Console.WriteLine( "Error: " + e.ToString() );
        }
        Environment.Exit(0);
    }
Example #7
0
 internal OrderedDictionaryEnumerator(ArrayList array, int objectReturnType)
 {
     _arrayEnumerator = array.GetEnumerator();
     _objectReturnType = objectReturnType;
 }
Example #8
0
    static void Main(string[] args)
    {
        AssConfig config = new AssConfig();

            IList assemblyList = new ArrayList();
            IList outputList = new ArrayList();
            config.loadBundles(assemblyList, outputList);
            AssemblyBundle assemblyBundle = new AssemblyBundle(assemblyList);

            IEnumerator outputEnum = outputList.GetEnumerator();
            while (outputEnum.MoveNext()) {
                //String outputType = (String)outputEnum.Current;
                //Console.WriteLine(outputEnum.Current.GetType());
                OutputType outputType = (OutputType)outputEnum.Current;
                if (outputType.getOutputType() == "All") {
                    showAllAssemblyDependencies(assemblyBundle, outputType.getFile());
                } else if (outputType.getOutputType() == "Analyzed") {
                    showAllAnalyzedAssemblyDependencies(assemblyBundle, outputType.getFile());
                } else if (outputType.getOutputType() == "xml") {
                    outputXml(assemblyBundle, outputType.getFile());
                }
            }
    }
Example #9
0
 public IEnumerator GetEnumerator()
 {
     return(m_colMoves.GetEnumerator());
 }
Example #10
0
    public static void Main(String[] args)
    {
        if (args.Length != 5)
        {
            Console.WriteLine("Usage:   mono ClientSideSort <host name> " +
                              "<login dn> <password> <search base>\n"
                              + "         <search filter>");
            Console.WriteLine("Example: mono ClientSideSort Acme.com"
                              + " \"cn=admin,o=Acme\""
                              + " secret \"ou=sales,o=Acme\"\n"
                              + "         \"(objectclass=*)\"");
            Environment.Exit(0);
        }

        int            ldapPort     = LdapConnection.DEFAULT_PORT;
        int            searchScope  = LdapConnection.SCOPE_ONE;
        int            ldapVersion  = LdapConnection.Ldap_V3;
        String         ldapHost     = args[0];
        String         loginDN      = args[1];
        String         password     = args[2];
        String         searchBase   = args[3];
        String         searchFilter = args[4];
        LdapConnection conn         = new LdapConnection();

        try
        {
            // connect to the server
            conn.Connect(ldapHost, ldapPort);

            // bind to the server
            conn.Bind(ldapVersion, loginDN, password);

            LdapSearchResults searchResults = conn.Search(searchBase,
                                                          searchScope,
                                                          searchFilter,
                                                          new String[] { "cn", "uid", "sn" },                                          //attributes
                                                          false);                                                                      // return attrs and values

            /* sortedResults will sort the entries according to the natural
             * ordering of LDAPEntry (by distiguished name).
             */

            ArrayList sortedResults = new ArrayList();
            while (searchResults.hasMore())
            {
                try
                {
                    sortedResults.Add(searchResults.next());
                }
                catch (LdapException e)
                {
                    Console.WriteLine("Error: " + e.ToString());
                    // Exception is thrown, go for next entry
                    continue;
                }
            }

            // print the sorted results
            Console.WriteLine("\n" +
                              "****************************\n" +
                              "Search results sorted by DN:\n" +
                              "****************************");
            sortedResults.Sort();
            IEnumerator i = sortedResults.GetEnumerator(0, sortedResults.Count - 1);
            while (i.MoveNext())
            {
                PrintEntry((LdapEntry)(i.Current));
            }

            /* resort the results an an array using a specific comparator */
            String[]             namesToSortBy = { "sn", "uid", "cn" };
            bool[]               sortAscending = { true, false, true };
            LdapCompareAttrNames myComparator  = new LdapCompareAttrNames(namesToSortBy, sortAscending);

            Object[] sortedSpecial = sortedResults.ToArray();
            Array.Sort(sortedSpecial, myComparator);

            // print the re-sorted results
            Console.WriteLine("\n" +
                              "*****************************************************\n" +
                              "Search results sorted by sn, uid(Descending), and cn:\n" +
                              "*****************************************************");
            for (int j = 0; j < sortedSpecial.Length; j++)
            {
                PrintEntry((LdapEntry)sortedSpecial[j]);
            }
            // disconnect with the server
            conn.Disconnect();
        }
        catch (LdapException e)
        {
            Console.WriteLine("Error: " + e.ToString());
        }
        catch (Exception e)
        {
            Console.WriteLine("Error: " + e.ToString());
        }
        Environment.Exit(0);
    }
Example #11
0
 // IEnumerable implementation, delegates IEnumerator to
 // the ArrayList
 public IEnumerator GetEnumerator()
 {
     return(m_Employees.GetEnumerator());
 }
Example #12
0
 public IEnumerator GetEnumerator()
 {
     return(minus.GetEnumerator());
 }
Example #13
0
 public IEnumerator GetEnumerator()
 {
     return(union.GetEnumerator());
 }
Example #14
0
 public IEnumerator GetEnumerator()
 {
     return(intersection.GetEnumerator());
 }
Example #15
0
        public void TestArrayListWrappers02()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            ArrayList arrList = null;
            int ii = 0;
            bool bGetNext = false;
            object o1;

            IEnumerator ien1;

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

            //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of 
            //BinarySearch, Following variable cotains each one of these types of array lists

            ArrayList[] arrayListTypes = {
                                    (ArrayList)arrList.Clone(),
                                    (ArrayList)ArrayList.Adapter(arrList).Clone(),
                                    (ArrayList)arrList.GetRange(0, arrList.Count).Clone(),
                                    (ArrayList)ArrayList.Synchronized(arrList).Clone(),
                                    (ArrayList)(new MyArrayList((ICollection) strHeroes))};

            IEnumerator enu = null;
            foreach (ArrayList arrayListType in arrayListTypes)
            {
                arrList = arrayListType;
                //
                // [] Add the ArrayList itself to the ArrayList
                //
                try
                {
                    arrList.Add(arrList);
                    enu = arrList.GetEnumerator();

                    int index;

                    index = 0;
                    while (enu.MoveNext())
                    {
                        Assert.StrictEqual(enu.Current, arrList[index]);
                        ++index;
                    }

                    enu.Reset();

                    index = 0;
                    while (enu.MoveNext())
                    {
                        Assert.StrictEqual(enu.Current, arrList[index]);
                        ++index;
                    }
                }
                finally
                {
                    arrList.RemoveAt(arrList.Count - 1);
                }

                //
                // []  Vanila - Obtain and verify enumerator.
                //
                // Obtain the enumerator for the test range.
                enu = arrList.GetEnumerator();
                IEnumerator enuClone = arrList.GetEnumerator();

                IEnumerator[] enuArray = { enu, enuClone };

                //Verify both this instance and the cloned copy
                foreach (IEnumerator enumerator in enuArray)
                {
                    enu = enumerator;

                    for (int i = 0; i < 2; i++)
                    {
                        Assert.NotNull(enu);

                        // Verify the enumerator.
                        for (ii = 0; ; ii++)
                        {
                            bGetNext = enu.MoveNext();
                            if (bGetNext == false)
                                break;

                            Assert.Equal(0, strHeroes[ii].CompareTo((string)enu.Current));
                        }

                        Assert.Equal(strHeroes.Length, ii);

                        bGetNext = enu.MoveNext();
                        Assert.False(bGetNext);
                        Assert.False(enu.MoveNext());
                        Assert.False(enu.MoveNext());
                        Assert.False(enu.MoveNext());

                        enu.Reset();
                    }
                }

                //[]we'll make sure that the enumerator throws if the underlying collection is changed with MoveNext() but not at Current

                arrList.Clear();
                for (int i = 0; i < 100; i++)
                    arrList.Add(i);

                ien1 = arrList.GetEnumerator();
                ien1.MoveNext();
                ien1.MoveNext();
                arrList[10] = 1000;

                Assert.Equal(1, (int)ien1.Current);
                Assert.Throws<InvalidOperationException>(() => ien1.MoveNext());
                Assert.Throws<InvalidOperationException>(() => ien1.Reset());

                //[]we'll make sure that the enumerator throws before and after MoveNext returns false

                arrList.Clear();
                for (int i = 0; i < 100; i++)
                    arrList.Add(i);

                ien1 = arrList.GetEnumerator();

                Assert.Throws<InvalidOperationException>(() =>
                {
                    o1 = ien1.Current;
                });

                while (ien1.MoveNext()) ;
                Assert.Throws<InvalidOperationException>(() =>
                {
                    o1 = ien1.Current;
                });
            }
        }
Example #16
0
    public void WriteBuffer(ArrayList data) {
	IEnumerator iter = data.GetEnumerator();
	while (iter.MoveNext()) {
	    writer.WriteLine((String)iter.Current);
	}
    }
 public override IEnumerator GetEnumerator()
 {
     return(internalList.GetEnumerator());
 }
Example #18
0
 public virtual Color Shade(Vector3D p, Vector3D n, Vector3D v, ArrayList lights, 
     ArrayList objects, Color bgnd)
 {
     IEnumerator lightSources = lights.GetEnumerator();
     float r = 0;
     float g = 0;
     float b = 0;
     while (lightSources.MoveNext())
     {
         Light light = (Light)lightSources.Current;
         if (light.lightType == Light.AMBIENT)
         {
             r += ka * ir * light.ir;
             g += ka * ig * light.ig;
             b += ka * ib * light.ib;
         }
         else
         {
             Vector3D l;
             if (light.lightType == Light.POINT)
             {
                 l = new Vector3D(light.lvec.x - p.x, light.lvec.y - p.y, light.lvec.z - p.z);
                 l.Normalize();
             }
             else
             {
                 l = new Vector3D(-light.lvec.x, -light.lvec.y, -light.lvec.z);
             }
             // Check if the surface point is in shadow
             Vector3D poffset = new Vector3D(p.x + TINY * l.x, p.y + TINY * l.y, p.z + TINY *
                 l.z);
             Ray shadowRay = new Ray(poffset, l);
             if (shadowRay.Trace(objects))
             {
                 break;
             }
             float lambert = Vector3D.Dot(n, l);
             if (lambert > 0)
             {
                 if (kd > 0)
                 {
                     float diffuse = kd * lambert;
                     r += diffuse * ir * light.ir;
                     g += diffuse * ig * light.ig;
                     b += diffuse * ib * light.ib;
                 }
                 if (ks > 0)
                 {
                     lambert *= 2;
                     float spec = v.Dot(lambert * n.x - l.x, lambert * n.y - l.y, lambert * n.z - l.z);
                     if (spec > 0)
                     {
                         spec = ks * ((float)Math.Pow((double)spec, (double)ns));
                         r += spec * light.ir;
                         g += spec * light.ig;
                         b += spec * light.ib;
                     }
                 }
             }
         }
     }
     // Compute illumination due to reflection
     if (kr > 0)
     {
         float t = v.Dot(n);
         if (t > 0)
         {
             t *= 2;
             Vector3D reflect = new Vector3D(t * n.x - v.x, t * n.y - v.y, t * n.z - v.z);
             Vector3D poffset = new Vector3D(p.x + TINY * reflect.x, p.y + TINY * reflect.y, p
                 .z + TINY * reflect.z);
             Ray reflectedRay = new Ray(poffset, reflect);
             if (reflectedRay.Trace(objects))
             {
                 Color rcolor = reflectedRay.Shade(lights, objects, bgnd);
                 r += kr * rcolor.GetRed();
                 g += kr * rcolor.GetGreen();
                 b += kr * rcolor.GetBlue();
             }
             else
             {
                 r += kr * bgnd.GetRed();
                 g += kr * bgnd.GetGreen();
                 b += kr * bgnd.GetBlue();
             }
         }
     }
     // Add code for refraction here
     r = (r > 1f) ? 1f : r;
     g = (g > 1f) ? 1f : g;
     b = (b > 1f) ? 1f : b;
     return new Color(r, g, b);
 }
Example #19
0
 public IEnumerator GetEnumerator()
 {
     Instantiate();
     return(_values.GetEnumerator());
 }
Example #20
0
  public virtual bool M10_TwoRefsToOneObj()
  {
 	Console.WriteLine( "** "+ s_strTFAbbrev +" method: TwoRefsToOneObj()" );
 	Int32 nCntErrorsOrig = iCountErrors;
 	BinaryFormatter pmlformt2;
 	String strPreSerial;
 	String strPostDeserial;
 	ArrayList arlistPreSerial = new ArrayList();
 	ArrayList arlistPostDeserial = new ArrayList();
 	IEnumerator enumer2;
 	IEnumerator enumer3;
 	MemoryStream memstm3 = new MemoryStream( 16 );
 	Int32 nEqualPreSer = -2;
 	Int32 nEqualPostDeser = -3;
 	Int32[] nArrCountsPreSer = new Int32[98];
 	Int32[] nArrCountsPostDeser = new Int32[98];
 	Int32 nCurrSlot2 = -2;
 	Int32 nW = -3;
 	Object objDeserialized;
 	Co1011_root cbrootPreSer;
 	Co1011_root cbrootb1;
 	Co1011_root cbrootc1;
 	Co1011_root cbrootPostDeser;
   try
   {
   do
   {
 	o_strLoc="Loc_1010bik";
 	cbrootPreSer = new Co1011_root();
 	cbrootb1 = new Co1011_root();
 	cbrootc1 = new Co1011_root();
 	cbrootPreSer.m_cbrootb1 = cbrootb1;
 	cbrootPreSer.m_cbrootc1 = cbrootc1;
 	cbrootb1.m_cbrootc1 = cbrootc1;
 	o_strLoc="Loc_1020bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	cbrootPreSer.IncrementPreSerializationCountersRecursively();
 	o_strLoc="Loc_1030bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	arlistPreSerial.Add( (Object)cbrootPreSer );
 	arlistPreSerial.Add( (Object)cbrootPreSer.m_cbrootb1 );
 	arlistPreSerial.Add( (Object)cbrootPreSer.m_cbrootc1 );
 	arlistPreSerial.Add( (Object)cbrootPreSer.m_cbrootb1.m_cbrootc1 );
 	o_strLoc="Loc_1040bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	strPreSerial = cbrootPreSer.GM1SerizalizeToStringRecursively( true );
 	o_strLoc="Loc_1050bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	pmlformt2 = new BinaryFormatter();
 	o_strLoc="Loc_1060bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	pmlformt2.Serialize  
 			(
 			 memstm3
 			,cbrootPreSer
 			,(
 				  null
 			 )
 			);
 	o_strLoc="Loc_1070bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	memstm3.Position = 0;  
 	objDeserialized = pmlformt2.Deserialize(memstm3);  
 	cbrootPostDeser = ( Co1011_root )objDeserialized;
 	o_strLoc="Loc_1080bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strLoc="Loc_1090bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	cbrootPostDeser.IncrementPostDeserializationCountersRecursively();
 	o_strLoc="Loc_1100bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	arlistPostDeserial.Add( (Object)cbrootPostDeser );
 	arlistPostDeserial.Add( (Object)cbrootPostDeser.m_cbrootb1 );
 	arlistPostDeserial.Add( (Object)cbrootPostDeser.m_cbrootc1 );
 	arlistPostDeserial.Add( (Object)cbrootPostDeser.m_cbrootb1.m_cbrootc1 );
 	o_strLoc="Loc_1110bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	strPostDeserial = cbrootPostDeser.GM1SerizalizeToStringRecursively( true );
 	o_strLoc="Loc_1120bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strBaseLoc = o_strLoc + "_"; o_nBaseLocCount=0;
 	nEqualPreSer = 0;
 	enumer2 = arlistPreSerial.GetEnumerator();
 	while ( enumer2.MoveNext() == true )
 	{
 		o_strLoc=o_strBaseLoc+((o_nBaseLocCount++).ToString());
 		enumer3 = arlistPreSerial.GetEnumerator();
 		while ( enumer3.MoveNext() == true )
 		{
 			o_strLoc=o_strBaseLoc+((o_nBaseLocCount++).ToString());
 			if ( enumer2.Current == enumer3.Current )  
 			{
 				++nEqualPreSer;
 			}
 		}
 	}
 	o_strLoc="Loc_1130bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strBaseLoc = o_strLoc + "_"; o_nBaseLocCount=0;
 	nEqualPostDeser = 0;
 	enumer2 = arlistPostDeserial.GetEnumerator();
 	while ( enumer2.MoveNext() == true )
 	{
 		o_strLoc=o_strBaseLoc+((o_nBaseLocCount++).ToString());
 		enumer3 = arlistPostDeserial.GetEnumerator();
 		while ( enumer3.MoveNext() == true )
 		{
 			o_strLoc=o_strBaseLoc+((o_nBaseLocCount++).ToString());
 			if ( enumer2.Current == enumer3.Current )  
 			{
 				++nEqualPostDeser;
 			}
 		}
 	}
 	o_strLoc="Loc_1140bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	++iCountTestcases;
 	if ( nEqualPreSer != nEqualPostDeser )  
 	{
 		++iCountErrors;
 		Console.WriteLine( "Error_1012zeg ("+ s_strTFAbbrev +")!  nEqualPreSer="+ nEqualPreSer +" ,nEqualPostDeser="+ nEqualPostDeser );
 	}
 	o_strLoc="Loc_1150bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	++iCountTestcases;
 	if ( strPreSerial.Equals( strPostDeserial ) != true )  
 	{
 		++iCountErrors;
 		Console.WriteLine();
 		Console.WriteLine( "Error_1033wsx ("+ s_strTFAbbrev +")!" );
 		Console.WriteLine( "   strPreSerial   ="+ strPreSerial );
 		Console.WriteLine( "   strPostDeserial="+ strPostDeserial );
 		Console.WriteLine();
 	}
 	o_strLoc="Loc_1160bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	nArrCountsPreSer = new Int32[98];
 	nCurrSlot2 = 0;
 	cbrootPostDeser.PopulateArrayWithPreSerCountersRecursively( nArrCountsPreSer ,nCurrSlot2 );
 	o_strLoc="Loc_1161bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	nArrCountsPostDeser = new Int32[98];
 	nW = nCurrSlot2;
 	nCurrSlot2 = 0;
 	cbrootPostDeser.PopulateArrayWithPostDeserCountersRecursively( nArrCountsPostDeser ,nCurrSlot2 );
 	++iCountTestcases;
 	if ( nW != nCurrSlot2 )
 	{
 		Console.WriteLine( "Error_1068bik ("+ s_strTFAbbrev +")!  Slots_PreSer="+ nW +" ,Slots_PostDeser="+ nCurrSlot2 );
 	}
 	o_strLoc="Loc_1170bik"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strBaseLoc = o_strLoc + "_"; o_nBaseLocCount=0;
 	for (
 	       int qd=0
 	      ;    qd<nArrCountsPreSer.Length
 	       &&  qd<nArrCountsPostDeser.Length
 	       &&  qd<nCurrSlot2
 	       &&  nW == nCurrSlot2
 	      ;qd++
 	    )
 	{
 		o_strLoc=o_strBaseLoc+((qd).ToString());
 		++iCountTestcases;
 		if ( nArrCountsPreSer[qd] != nArrCountsPostDeser[qd] )
 		{
 			Console.WriteLine( "Error_1571bik ("+ s_strTFAbbrev +")!  qd="+ qd +" ,nArrCountsPreSer[qd]="+ nArrCountsPreSer[qd] +" ,nArrCountsPostDeser[qd]="+ nArrCountsPostDeser[qd] );
 		}
 	}
   } while ( false );
   }
   catch( Exception exc_general )
   {
 	++iCountErrors;
 	Console.WriteLine( "Error Err_8888bik ("+ s_strTFAbbrev +")!  Unexpected exception thrown sometime after o_strLoc=="+ o_strLoc +" ,exc_general=="+ exc_general );
   }
 	if ( ( iCountErrors - nCntErrorsOrig ) == 0 )
 	{
 		return true;
 	}
 	else
 	{
 		return false;
 	}
  }
Example #21
0
        public bool Equal(SecurityElement other)
        {
            if (other == null)
            {
                return(false);
            }

            // Check if the tags are the same
            if (!String.Equals(m_strTag, other.m_strTag))
            {
                return(false);
            }

            // Check if the text is the same
            if (!String.Equals(m_strText, other.m_strText))
            {
                return(false);
            }

            // Check if the attributes are the same and appear in the same
            // order.

            // Maybe we can get away by only checking the number of attributes
            if (m_lAttributes == null || other.m_lAttributes == null)
            {
                if (m_lAttributes != other.m_lAttributes)
                {
                    return(false);
                }
            }
            else
            {
                int iMax = m_lAttributes.Count;
                Contract.Assert(iMax % 2 == 0, "Odd number of strings means the attr/value pairs were not added correctly");

                if (iMax != other.m_lAttributes.Count)
                {
                    return(false);
                }

                for (int i = 0; i < iMax; i++)
                {
                    String lhs = (String)m_lAttributes[i];
                    String rhs = (String)other.m_lAttributes[i];

                    if (!String.Equals(lhs, rhs))
                    {
                        return(false);
                    }
                }
            }

            // Finally we must check the child and make sure they are
            // equal and in the same order

            // Maybe we can get away by only checking the number of children
            if (m_lChildren == null || other.m_lChildren == null)
            {
                if (m_lChildren != other.m_lChildren)
                {
                    return(false);
                }
            }
            else
            {
                if (m_lChildren.Count != other.m_lChildren.Count)
                {
                    return(false);
                }

                this.ConvertSecurityElementFactories();
                other.ConvertSecurityElementFactories();

                // Okay, we'll need to go through each one of them
                IEnumerator lhs = m_lChildren.GetEnumerator();
                IEnumerator rhs = other.m_lChildren.GetEnumerator();

                SecurityElement e1, e2;
                while (lhs.MoveNext())
                {
                    rhs.MoveNext();
                    e1 = (SecurityElement)lhs.Current;
                    e2 = (SecurityElement)rhs.Current;
                    if (e1 == null || !e1.Equal(e2))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Example #22
0
 public virtual bool runTest()
 {
     int iCountErrors = 0;
     int iCountTestcases = 0;
     Console.Error.WriteLine( strName + ": " + strTest + " runTest started..." );
     ArrayList arrList = null;
     int ii = 0;
     int start = 3;
     int count = 15;
     bool bGetNext = false;
     String [] strHeroes =
         {
             "Aquaman",
             "Atom",
             "Batman",
             "Black Canary",
             "Captain America",
             "Captain Atom",
             "Catwoman",
             "Cyborg",
             "Flash",
             "Green Arrow",
             "Green Lantern",
             "Hawkman",
             "Huntress",
             "Ironman",
             "Nightwing",
             "Robin",
             "SpiderMan",
             "Steel",
             "Superman",
             "Thor",
             "Wildcat",
             "Wonder Woman",
     };
     String [] strResult =
         {
             "Aquaman",
             "Atom",
             "Batman",
             "Superman",
             "Thor",
             "Wildcat",
             "Wonder Woman",
     };
     do
     {
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Construct ArrayList" );
         try
         {
             arrList = new ArrayList( (ICollection) strHeroes );
             if ( arrList == null )
             {
                 Console.WriteLine( strTest+ "E_101: Failed to construct new ArrayList" );
                 ++iCountErrors;
                 break;
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10001: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Obtain and verify enumerator" );
         try
         {
             IEnumerator enu = (IEnumerator) arrList.GetEnumerator( start, count );
             if ( enu == null )
             {
                 Console.WriteLine( strTest+ "E_303: Failed to construct enumerator" );
                 ++iCountErrors;
                 break;
             }
             for ( ii = start; ii < start + count; ++ii )
             {
                 bGetNext = enu.MoveNext();
                 if ( bGetNext == false )
                     break;
                 if ( strHeroes[ii].CompareTo( (String)enu.Current ) != 0 )
                 {
                     String strInfo = strTest + " error: ";
                     strInfo = strInfo + "Expected Hero <"+ strHeroes[ii] + "> ";
                     strInfo = strInfo + "Returned Hero <"+ (String)enu.Current + "> ";
                     Console.WriteLine( strTest+ "E_404: " + strInfo );
                     ++iCountErrors;
                     break;
                 }
             }
             ii -= start;
             if ( ii != count )
             {
                 String strInfo = strTest + " error: ";
                 strInfo = strInfo + "Enumeration discrepancy\n";
                 strInfo = strInfo + "Expected Loop count==" + count;
                 strInfo = strInfo + "Returned Loop count==" + ii;
                 Console.WriteLine( strTest+ "E_303: Enumeration discrepancy.Failed to construct enumerator" );
                 ++iCountErrors;
                 break;
             }
             bGetNext = enu.MoveNext();
             if ( bGetNext != false )
             {
                 String strInfo = strTest + " error: ";
                 strInfo = strInfo + "Enumeration discrepancy\n";
                 strInfo = strInfo + "Expected Enumeration GetNext()==false ";
                 strInfo = strInfo + "Returned Enumeration GetNext()==" + bGetNext;
                 Console.WriteLine( strTest+ "E_404: " + strInfo );
                 ++iCountErrors;
                 break;
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10002: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Attempt bogus GetEnumerator" );
         try
         {
             IEnumerator enu = (IEnumerator) arrList.GetEnumerator( 0, 10000 );
             Console.WriteLine( strTest+ "E_707: Expected ArgumentException" );
             ++iCountErrors;
             break;
         }
         catch (ArgumentException ex)
         {
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10005: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
     }
     while ( false );
     Console.Error.Write( strName );
     Console.Error.Write( ": " );
     if ( iCountErrors == 0 )
     {
         Console.Error.WriteLine( strTest + " iCountTestcases==" + iCountTestcases + " paSs" );
         return true;
     }
     else
     {
         System.String strFailMsg = null;
         Console.WriteLine( strTest+ strPath );
         Console.WriteLine( strTest+ "FAiL" );
         Console.Error.WriteLine( strTest + " iCountErrors==" + iCountErrors );
         return false;
     }
 }
Example #23
0
 /// <summary>Returns an enumerator that can iterate through the collection.</summary>
 /// <returns>An <see cref="IEnumerator" /> for the entire <see cref="SubtitleCollection" />.</returns>
 public IEnumerator GetEnumerator()
 {
     return(subtitles.GetEnumerator());
 }
    static void AddVegetation(string filename)
    {
        string[] lines = OpenTextFile (filename);
        string trimmedLine;
        string result;
        int maxTrees = 10000;

        Vector3 trans= Vector3.zero;
        ArrayList points= new ArrayList();
        int typeVegetation;

           		Terrain terrain = getMainTerrain();

           		GameObject ft = GameObject.Find("ForTrees");
         		Terrain[] ters = ft.GetComponentsInChildren<Terrain>();

        Terrain t=getNextFreeTerrain(ters, maxTrees);
        TerrainData	terraindata = t.terrainData;
        TreeInstance tree;
        List<TreeInstance> newTrees = new List<TreeInstance>(terraindata.treeInstances);

        foreach (string line in lines) {
            trimmedLine = line.Trim();
            result = MatchItem(trimmedLine, "translation ");
            if (null!=result)  { trans = stringToVector3 (result); }
            result = MatchItem(trimmedLine, "points [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "pointsRemplis [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "typeVegetation ");
            if (null!=result) {
                typeVegetation=int.Parse(result);

                IEnumerator e = points.GetEnumerator();
                float rnd;
                while (e.MoveNext()) {

                    tree = new TreeInstance();
                    tree.position = WorldToTerrain(terrain,(Vector3)e.Current+trans);

                    tree.prototypeIndex = typeVegetation;
                    rnd= 0.5f*(Random.value-0.5f);
                    tree.widthScale = 1.0f+rnd;
                    tree.heightScale = 1.0f+rnd;

                    Color c = Color.white;
                    c[0] = 0.92f+Random.value*0.08f;
                    c[1] = 0.92f+Random.value*0.08f;
                    c[2] = 0.92f+Random.value*0.08f;
                    tree.color = c;

                    tree.lightmapColor = Color.white;

                    treeCount++;
                    newTrees.Add(tree);

                    if (newTrees.Count == maxTrees) {
                        terraindata.treeInstances= newTrees.ToArray();
                        t=getNextFreeTerrain(ters, maxTrees);
                        terraindata = t.terrainData;
                        newTrees = new List<TreeInstance>(terraindata.treeInstances);
                    }
                }

            }
        }
        terraindata.treeInstances= newTrees.ToArray();
    }
Example #25
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(dataList.GetEnumerator());
 }
Example #26
0
 private static TestIntfPrx createTestIntfPrx(ArrayList adapters)
 {
     ArrayList endpoints = new ArrayList();
     TestIntfPrx obj = null;
     IEnumerator p = adapters.GetEnumerator();
     while(p.MoveNext())
     {
         obj = ((RemoteObjectAdapterPrx)p.Current).getTestIntf();
         foreach(Ice.Endpoint e in obj.ice_getEndpoints())
         {
             endpoints.Add(e);
         }
     }
     return TestIntfPrxHelper.uncheckedCast(
         obj.ice_endpoints((Ice.Endpoint[])endpoints.ToArray(typeof(Ice.Endpoint))));
 }
Example #27
0
 public IEnumerator GetEnumerator()
 {
     return(Info.GetEnumerator());
 }
 // Нумератор для поддержи Foreach
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(_arPeople.GetEnumerator());
 }
Example #29
0
        /// <summary>
        /// Creates a {@link Section} instance from a byte array.
        /// </summary>
        /// <param name="src">Contains the complete property Set stream.</param>
        /// <param name="offset">The position in the stream that points To the
        /// section's format ID.</param>
        public Section(byte[] src, int offset)
        {
            int o1 = offset;

            /*
             * Read the format ID.
             */
            formatID = new ClassID(src, o1);
            o1      += ClassID.LENGTH;

            /*
             * Read the offset from the stream's start and positions To
             * the section header.
             */
            this.offset = LittleEndian.GetUInt(src, o1);
            o1          = (int)this.offset;

            /*
             * Read the section Length.
             */
            size = (int)LittleEndian.GetUInt(src, o1);
            o1  += LittleEndianConsts.INT_SIZE;

            /*
             * Read the number of properties.
             */
            int propertyCount = (int)LittleEndian.GetUInt(src, o1);

            o1 += LittleEndianConsts.INT_SIZE;

            /*
             * Read the properties. The offset is positioned at the first
             * entry of the property list. There are two problems:
             *
             * 1. For each property we have To Find out its Length. In the
             *    property list we Find each property's ID and its offset relative
             *    To the section's beginning. Unfortunately the properties in the
             *    property list need not To be in ascending order, so it is not
             *    possible To calculate the Length as
             *    (offset of property(i+1) - offset of property(i)). Before we can
             *    that we first have To sort the property list by ascending offsets.
             *
             * 2. We have To Read the property with ID 1 before we Read other
             *    properties, at least before other properties containing strings.
             *    The reason is that property 1 specifies the codepage. If it Is
             *    1200, all strings are in Unicode. In other words: Before we can
             *    Read any strings we have To know whether they are in Unicode or
             *    not. Unfortunately property 1 is not guaranteed To be the first in
             *    a section.
             *
             *    The algorithm below Reads the properties in two passes: The first
             *    one looks for property ID 1 and extracts the codepage number. The
             *    seconds pass Reads the other properties.
             */
            properties = new Property[propertyCount];

            /* Pass 1: Read the property list. */
            int               pass1OffSet  = o1;
            ArrayList         propertyList = new ArrayList(propertyCount);
            PropertyListEntry ple;

            for (int i = 0; i < properties.Length; i++)
            {
                ple = new PropertyListEntry();

                /* Read the property ID. */
                ple.id       = (int)LittleEndian.GetUInt(src, pass1OffSet);
                pass1OffSet += LittleEndianConsts.INT_SIZE;

                /* OffSet from the section's start. */
                ple.offset   = (int)LittleEndian.GetUInt(src, pass1OffSet);
                pass1OffSet += LittleEndianConsts.INT_SIZE;

                /* Add the entry To the property list. */
                propertyList.Add(ple);
            }

            /* Sort the property list by ascending offsets: */
            propertyList.Sort();

            /* Calculate the properties' Lengths. */
            for (int i = 0; i < propertyCount - 1; i++)
            {
                PropertyListEntry ple1 =
                    (PropertyListEntry)propertyList[i];
                PropertyListEntry ple2 =
                    (PropertyListEntry)propertyList[i + 1];
                ple1.Length = ple2.offset - ple1.offset;
            }
            if (propertyCount > 0)
            {
                ple        = (PropertyListEntry)propertyList[propertyCount - 1];
                ple.Length = size - ple.offset;
                //if (ple.Length <= 0)
                //{
                //    StringBuilder b = new StringBuilder();
                //    b.Append("The property Set claims To have a size of ");
                //    b.Append(size);
                //    b.Append(" bytes. However, it exceeds ");
                //    b.Append(ple.offset);
                //    b.Append(" bytes.");
                //    throw new IllegalPropertySetDataException(b.ToString());
                //}
            }

            /* Look for the codepage. */
            int codepage = -1;

            for (IEnumerator i = propertyList.GetEnumerator();
                 codepage == -1 && i.MoveNext();)
            {
                ple = (PropertyListEntry)i.Current;

                /* Read the codepage if the property ID is 1. */
                if (ple.id == PropertyIDMap.PID_CODEPAGE)
                {
                    /* Read the property's value type. It must be
                     * VT_I2. */
                    int  o    = (int)(this.offset + ple.offset);
                    long type = LittleEndian.GetUInt(src, o);
                    o += LittleEndianConsts.INT_SIZE;

                    if (type != Variant.VT_I2)
                    {
                        throw new HPSFRuntimeException
                                  ("Value type of property ID 1 is not VT_I2 but " +
                                  type + ".");
                    }

                    /* Read the codepage number. */
                    codepage = LittleEndian.GetUShort(src, o);
                }
            }

            /* Pass 2: Read all properties - including the codepage property,
             * if available. */
            int i1 = 0;

            for (IEnumerator i = propertyList.GetEnumerator(); i.MoveNext();)
            {
                ple = (PropertyListEntry)i.Current;
                Property p = new Property(ple.id, src,
                                          this.offset + ple.offset,
                                          ple.Length, codepage);
                if (p.ID == PropertyIDMap.PID_CODEPAGE)
                {
                    p = new Property(p.ID, p.Type, codepage);
                }
                properties[i1++] = p;
            }

            /*
             * Extract the dictionary (if available).
             * Tony changed the logic
             */
            this.dictionary = (IDictionary)GetProperty(0);
        }
 [TestMethod] // IEnumerable
 public void EnumerableTest()
 {
     int n = 2;
     ArrayList<object> data = new ArrayList<object>(n);
     data.Append(18);
     data.Append(1);
     data.GetEnumerator();
 }
 public override IEnumerator GetEnumerator()
 {
     return(_nodeArray.GetEnumerator());
 }
Example #32
0
        public void TestArrayListWrappers01()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            ArrayList arrList = null;
            int ii = 0;
            int start = 3;
            int count = 15;
            bool bGetNext = false;
            object[] tempArray1;

            //
            // Construct array lists.
            //
            arrList = new ArrayList((ICollection)strHeroes);
            Assert.NotNull(arrList);

            //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of 
            //BinarySearch, Following variable cotains each one of these types of array lists

            ArrayList[] arrayListTypes = {
                                    (ArrayList)arrList.Clone(),
                                    (ArrayList)ArrayList.Adapter(arrList).Clone(),
                                    (ArrayList)ArrayList.FixedSize(arrList).Clone(),
                                    (ArrayList)arrList.GetRange(0, arrList.Count).Clone(),
                                    (ArrayList)ArrayList.ReadOnly(arrList).Clone(),
                                    (ArrayList)ArrayList.Synchronized(arrList).Clone()};

            IEnumerator enu;
            foreach (ArrayList arrayListType in arrayListTypes)
            {
                arrList = arrayListType;

                // Obtain the enumerator for the test range.
                enu = (IEnumerator)arrList.GetEnumerator(start, count);
                Assert.NotNull(enu);

                // Verify the enumerator.
                for (ii = start; ii < start + count; ++ii)
                {
                    bGetNext = enu.MoveNext();
                    if (bGetNext == false)
                        break;

                    Assert.Equal(0, strHeroes[ii].CompareTo((string)enu.Current));
                }

                ii -= start;
                Assert.Equal(count, ii);

                bGetNext = enu.MoveNext();
                Assert.False(bGetNext);
                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());

                // Obtain and verify enumerator with 0 count");
                // Obtain the enumerator for the test range.
                enu = (IEnumerator)arrList.GetEnumerator(start, 0);
                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());

                enu.Reset();
                Assert.Throws<InvalidOperationException>(() =>
                {
                    object test = enu.Current;
                });

                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());

                //
                // []  Make Sure both MoveNext and Reset throw InvalidOperationException if underlying collection has been modified but Current should not throw
                //
                if (!arrList.IsReadOnly)
                {
                    object origValue = arrList[arrList.Count - 1];

                    // [] MoveNext and Reset throw if collection has been modified
                    try
                    {
                        IEnumerator enu1 = (IEnumerator)arrList.GetEnumerator(start, count);
                        enu1.MoveNext();

                        arrList[arrList.Count - 1] = "Underdog";
                        object myValue = enu1.Current;

                        Assert.Throws<InvalidOperationException>(() => enu1.MoveNext());
                        Assert.Throws<InvalidOperationException>(() => enu1.Reset());

                    }
                    finally
                    {
                        arrList[arrList.Count - 1] = origValue;
                    }
                }

                //
                // []  Verify Current throws InvalidOperationException when positioned before the first element or after the last
                //
                enu = (IEnumerator)arrList.GetEnumerator(start, count);
                Assert.Throws<InvalidOperationException>(() =>
                {
                    object myValue = enu.Current;
                });

                while (enu.MoveNext()) ;
                Assert.Throws<InvalidOperationException>(() =>
                {
                    object myValue = enu.Current;
                });

                //
                // []  Use invalid parameters.
                //
                Assert.Throws<ArgumentException>(() =>
                {
                    IEnumerator enu0 = (IEnumerator)arrList.GetEnumerator(0, 10000);
                });

                Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    IEnumerator enu1 = (IEnumerator)arrList.GetEnumerator(-1, arrList.Count);
                });

                Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    IEnumerator enu2 = (IEnumerator)arrList.GetEnumerator(0, -1);
                });

                Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    IEnumerator enu3 = (IEnumerator)arrList.GetEnumerator(-1, arrList.Count);
                });

                //[] Verify the eneumerator works correctly when the ArrayList itself is in the ArrayList
                if (!arrList.IsFixedSize)
                {
                    arrList.Insert(0, arrList);
                    arrList.Insert(arrList.Count, arrList);
                    arrList.Insert(arrList.Count / 2, arrList);

                    tempArray1 = new object[strHeroes.Length + 3];
                    tempArray1[0] = (object)arrList;
                    tempArray1[tempArray1.Length / 2] = arrList;
                    tempArray1[tempArray1.Length - 1] = arrList;

                    Array.Copy(strHeroes, 0, tempArray1, 1, strHeroes.Length / 2);
                    Array.Copy(strHeroes, strHeroes.Length / 2, tempArray1, (tempArray1.Length / 2) + 1, strHeroes.Length - (strHeroes.Length / 2));

                    //[] Enumerate the entire collection
                    enu = arrList.GetEnumerator(0, tempArray1.Length);

                    for (int loop = 0; loop < 2; ++loop)
                    {
                        for (int i = 0; i < tempArray1.Length; ++i)
                        {
                            enu.MoveNext();

                            Assert.StrictEqual(tempArray1[i], enu.Current);
                        }

                        Assert.False(enu.MoveNext());
                        enu.Reset();
                    }

                    //[] Enumerate only part of the collection
                    enu = arrList.GetEnumerator(1, tempArray1.Length - 2);

                    for (int loop = 0; loop < 2; ++loop)
                    {
                        for (int i = 1; i < tempArray1.Length - 1; ++i)
                        {
                            enu.MoveNext();

                            Assert.StrictEqual(tempArray1[i], enu.Current);
                        }

                        Assert.False(enu.MoveNext());
                        enu.Reset();
                    }
                }
            }
        }
Example #33
0
 public IEnumerator <SparseVector <double> .ReadOnly> GetEnumerator()
 {
     return(mBowVectors.GetEnumerator());
 }
Example #34
0
    Type get_type(XInterfaceTypeDescription2 xType)
    {
        if (xType.getName() == "com.sun.star.uno.XInterface")
        {
            return typeof(System.Object);
        }

        string cts_name = to_cts_name(xType.getName());
        Type ret_type = get_type(cts_name, false /* no exc */);
        if (ret_type == null)
        {
            TypeBuilder type_builder;

            TypeAttributes attr = (TypeAttributes.Public |
                                   TypeAttributes.Interface |
                                   TypeAttributes.Abstract |
                                   TypeAttributes.AnsiClass);

            ArrayList baseTypes = new ArrayList();
            if (xType.getBaseTypes().Length > 0)
            {
                foreach (XInterfaceTypeDescription2 xIfaceTd
                         in xType.getBaseTypes())
                {
                    if (!(xIfaceTd.getName() == "com.sun.star.uno.XInterface"))
                    {
                        baseTypes.Add(xIfaceTd);
                    }
                }

                Type[] base_interfaces = new Type[baseTypes.Count];

                int index = 0;
                for (IEnumerator iter = baseTypes.GetEnumerator(); iter.MoveNext();
                     index++)
                {
                    base_interfaces[index] =
                        get_type((XInterfaceTypeDescription2) iter.Current);
                }
                type_builder = m_module_builder.DefineType(
                    cts_name, attr, null, base_interfaces);
            }
            else
            {
                Console.WriteLine(
                    "warning: IDL interface {0} is not derived from " +
                    "com.sun.star.uno.XInterface!", xType.getName());
                type_builder = m_module_builder.DefineType(cts_name, attr);
            }

            // insert to be completed
            iface_entry entry = new iface_entry();
            entry.m_xType = xType;
            entry.m_type_builder = type_builder;
            m_incomplete_ifaces.Add(cts_name, entry);

            // type is incomplete
            ret_type = type_builder;
        }
        return ret_type;
    }
Example #35
0
        /// <summary>
        /// Writes the file system.
        /// </summary>
        /// <param name="stream">the OutputStream to which the filesystem will be
        /// written</param>
        public void WriteFileSystem(Stream stream)
        {
            // Get the property table Ready
            _property_table.PreWrite();

            // Create the small block store, and the SBAT
            SmallBlockTableWriter sbtw =
                new SmallBlockTableWriter(bigBlockSize, _documents, _property_table.Root);

            // Create the block allocation table
            BlockAllocationTableWriter bat =
                new BlockAllocationTableWriter(bigBlockSize);

            // Create a list of BATManaged objects: the documents plus the
            // property table and the small block table
            ArrayList bm_objects = new ArrayList();

            bm_objects.AddRange(_documents);
            bm_objects.Add(_property_table);
            bm_objects.Add(sbtw);
            bm_objects.Add(sbtw.SBAT);

            // walk the list, allocating space for each and assigning each
            // a starting block number
            IEnumerator iter = bm_objects.GetEnumerator();

            while (iter.MoveNext())
            {
                BATManaged bmo         = ( BATManaged )iter.Current;
                int        block_count = bmo.CountBlocks;

                if (block_count != 0)
                {
                    bmo.StartBlock = bat.AllocateSpace(block_count);
                }
                else
                {
                    // Either the BATManaged object is empty or its data
                    // is composed of SmallBlocks; in either case,
                    // allocating space in the BAT is inappropriate
                }
            }

            // allocate space for the block allocation table and take its
            // starting block
            int batStartBlock = bat.CreateBlocks();

            // Get the extended block allocation table blocks
            HeaderBlockWriter header_block_Writer = new HeaderBlockWriter(bigBlockSize);

            BATBlock[] xbat_blocks =
                header_block_Writer.SetBATBlocks(bat.CountBlocks,
                                                 batStartBlock);

            // Set the property table start block
            header_block_Writer.PropertyStart = _property_table.StartBlock;

            // Set the small block allocation table start block
            header_block_Writer.SBATStart = sbtw.SBAT.StartBlock;

            // Set the small block allocation table block count
            header_block_Writer.SBATBlockCount = sbtw.SBATBlockCount;

            // the header is now properly initialized. Make a list of
            // Writers (the header block, followed by the documents, the
            // property table, the small block store, the small block
            // allocation table, the block allocation table, and the
            // extended block allocation table blocks)
            ArrayList Writers = new ArrayList();

            Writers.Add(header_block_Writer);
            Writers.AddRange(_documents);
            Writers.Add(_property_table);
            Writers.Add(sbtw);
            Writers.Add(sbtw.SBAT);
            Writers.Add(bat);
            for (int j = 0; j < xbat_blocks.Length; j++)
            {
                Writers.Add(xbat_blocks[j]);
            }

            // now, Write everything out
            iter = Writers.GetEnumerator();
            while (iter.MoveNext())
            {
                BlockWritable Writer = ( BlockWritable )iter.Current;

                Writer.WriteBlocks(stream);
            }

            Writers = null;
            iter    = null;
        }
Example #36
0
 public virtual bool Trace(ArrayList objects)
 {
     IEnumerator objList = objects.GetEnumerator();
     t = MAX_T;
     @object = null;
     while (objList.MoveNext())
     {
         Renderable @object2 = (Renderable)objList.Current;
         @object2.Intersect(this);
     }
     return (@object != null);
 }
Example #37
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(items.GetEnumerator());
 }
    /**
     * testIterationOfStringListWithIterator.
     *
     * @return
     */
    public static long testIterationOfClassWith1intArrayListWithIterator()
    {
        ClassWith1intb classWith1int = new ClassWith1intb();
        IList list = new ArrayList(SIZE);
        for (int j = SIZE; j != 0; j--)
        {
            list.Add(classWith1int);
        }
        int count = 0;
        DateTime start = DateTime.Now;
        for (int i = TESTS_LIST; i != 0; i--)
        {
            for (IEnumerator enumerator = list.GetEnumerator(); enumerator.MoveNext(); )
            {
                ClassWith1intb classWith1intb = (ClassWith1intb)enumerator.Current;

                // Write to force cpp not to optimize the code, never executed
                if (i % 2 == 2)
                {
                    classWith1intb.Int1 = i;
                }
                count += classWith1intb.Int1;
            }
        }
        DateTime end = DateTime.Now;
        TimeSpan executionTime = end - start;
        Console.WriteLine("[CollectionTest], Iteration of " + TESTS_LIST + " ArrayList(" + SIZE + ") With Iterator  for (IEnumerator enumerator = list.GetEnumerator()  enumerator.MoveNext()   )   iterator.hasNext()  ) count += ((ClassWith1intb)enumerator.Current).Int1  , count=" + count + ", snapshot time,"
            + executionTime.TotalMilliseconds);
        return (long)executionTime.TotalMilliseconds;
    }
Example #39
0
 public System.Collections.IEnumerator GetEnumerator()
 {
     return(videoModes.GetEnumerator());
 }
Example #40
0
  public virtual bool M20_SelfRef()
  {
 	Console.WriteLine( "** "+ s_strTFAbbrev +" method: M20_SelfRef()" );
 	Int32 nCntErrorsOrig = iCountErrors;
 	BinaryFormatter pmlformt2;
 	ArrayList arlistPreSerial = new ArrayList();
 	ArrayList arlistPostDeserial = new ArrayList();
 	IEnumerator enumer2;
 	IEnumerator enumer3;
 	MemoryStream memstm3 = new MemoryStream( 16 );
 	Int32 nEqualPreSer = -2;
 	Int32 nEqualPostDeser = -3;
 	Int32[] nArrCountsPreSer = new Int32[98];
 	Int32[] nArrCountsPostDeser = new Int32[98];
 	Object objDeserialized;
 	Co1011_root cbrootPreSer;
 	Co1011_root cbrootPostDeser;
   try
   {
   do
   {
 	o_strLoc="Loc_1010edc";
 	cbrootPreSer = new Co1011_root();
 	cbrootPreSer.m_cbroot_1 = cbrootPreSer;  
 	o_strLoc="Loc_1020edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strLoc="Loc_1030edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	arlistPreSerial.Add( (Object)cbrootPreSer );
 	arlistPreSerial.Add( (Object)cbrootPreSer.m_cbroot_1 );
 	o_strLoc="Loc_1040edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strLoc="Loc_1050edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	pmlformt2 = new BinaryFormatter();
 	o_strLoc="Loc_1060edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	pmlformt2.Serialize  
 			( memstm3 
 			 ,cbrootPreSer
 			,(
 				  null
 			 )
 			);
 	o_strLoc="Loc_1070edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	memstm3.Position = 0;  
 	objDeserialized = pmlformt2.Deserialize(memstm3);  
 	cbrootPostDeser = ( Co1011_root )objDeserialized;
 	o_strLoc="Loc_1080edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strLoc="Loc_1090edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strLoc="Loc_1100edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	arlistPostDeserial.Add( (Object)cbrootPostDeser );
 	arlistPostDeserial.Add( (Object)cbrootPostDeser.m_cbroot_1 );
 	o_strLoc="Loc_1110edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strLoc="Loc_1120edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strBaseLoc = o_strLoc + "_"; o_nBaseLocCount=0;
 	nEqualPreSer = 0;
 	enumer2 = arlistPreSerial.GetEnumerator();
 	while ( enumer2.MoveNext() == true )
 	{
 		o_strLoc=o_strBaseLoc+((o_nBaseLocCount++).ToString());
 		enumer3 = arlistPreSerial.GetEnumerator();
 		while ( enumer3.MoveNext() == true )
 		{
 			o_strLoc=o_strBaseLoc+((o_nBaseLocCount++).ToString());
 			if ( enumer2.Current == enumer3.Current )  
 			{
 				++nEqualPreSer;
 			}
 		}
 	}
 	o_strLoc="Loc_1130edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	o_strBaseLoc = o_strLoc + "_"; o_nBaseLocCount=0;
 	nEqualPostDeser = 0;
 	enumer2 = arlistPostDeserial.GetEnumerator();
 	while ( enumer2.MoveNext() == true )
 	{
 		o_strLoc=o_strBaseLoc+((o_nBaseLocCount++).ToString());
 		enumer3 = arlistPostDeserial.GetEnumerator();
 		while ( enumer3.MoveNext() == true )
 		{
 			o_strLoc=o_strBaseLoc+((o_nBaseLocCount++).ToString());
 			if ( enumer2.Current == enumer3.Current )  
 			{
 				++nEqualPostDeser;
 			}
 		}
 	}
 	o_strLoc="Loc_1140edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
 	++iCountTestcases;
 	if ( nEqualPreSer != nEqualPostDeser )
 	{
 		++iCountErrors;
 		Console.WriteLine( "Error_1762beg ("+ s_strTFAbbrev +")!  nEqualPreSer="+ nEqualPreSer +" ,nEqualPostDeser="+ nEqualPostDeser );
 	}
 	o_strLoc="Loc_1150edc"; if(DBGLEV>=2){Console.WriteLine(o_strLoc);}
   } while ( false );
   }
   catch( Exception exc_general )
   {
 	++iCountErrors;
 	Console.WriteLine( "Error Err_8888edc ("+ s_strTFAbbrev +")!  Unexpected exception thrown sometime after o_strLoc=="+ o_strLoc +" ,exc_general=="+ exc_general );
   }
 	if ( ( iCountErrors - nCntErrorsOrig ) == 0 )
 	{
 		return true;
 	}
 	else
 	{
 		return false;
 	}
  }
Example #41
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(InnerList.GetEnumerator());
 }
Example #42
0
    private void CompareObjects(ArrayList good, ArrayList bad, Hashtable hsh1)
    {
        //IList, this includes ICollection tests as well!!
        DoIListTests(good, bad, hsh1);

        //we will now test ArrayList specific methods
        good.Clear();
        for (int i = 0; i < 100; i++)
            good.Add(i);

        //AL's CopyTo methods
        int[] iArr1 = null;
        int[] iArr2 = null;
        iArr1 = new int[100];
        iArr2 = new int[100];
        good.CopyTo(iArr1);
        bad.CopyTo(iArr2);
        for (int i = 0; i < 100; i++)
        {
            if (iArr1[i] != iArr2[i])
                hsh1["CopyTo"] = "()";
        }

        iArr1 = new int[100];
        iArr2 = new int[100];
        good.CopyTo(0, iArr1, 0, 100);
        try
        {
            bad.CopyTo(0, iArr2, 0, 100);
            for (int i = 0; i < 100; i++)
            {
                if (iArr1[i] != iArr2[i])
                    hsh1["CopyTo"] = "()";
            }
        }
        catch
        {
            hsh1["CopyTo"] = "(int, Array, int, int)";
        }

        iArr1 = new int[200];
        iArr2 = new int[200];
        for (int i = 0; i < 200; i++)
        {
            iArr1[i] = 50;
            iArr2[i] = 50;
        }

        good.CopyTo(50, iArr1, 100, 20);
        try
        {
            bad.CopyTo(50, iArr2, 100, 20);
            for (int i = 0; i < 200; i++)
            {
                if (iArr1[i] != iArr2[i])
                    hsh1["CopyTo"] = "(Array, int, int)";
            }
        }
        catch
        {
            hsh1["CopyTo"] = "(int, Array, int, int)";
        }

        //Clone()
        ArrayList alstClone = (ArrayList)bad.Clone();
        //lets make sure that the clone is what it says it is
        if (alstClone.Count != bad.Count)
            hsh1["Clone"] = "Count";
        for (int i = 0; i < bad.Count; i++)
        {
            if (alstClone[i] != bad[i])
                hsh1["Clone"] = "[]";
        }

        //GerEnumerator()
        IEnumerator ienm1 = null;
        IEnumerator ienm2 = null;

        ienm1 = good.GetEnumerator(0, 100);
        try
        {
            ienm2 = bad.GetEnumerator(0, 100);
            DoIEnumerableTest(ienm1, ienm2, good, bad, hsh1, false);
        }
        catch
        {
            hsh1["GetEnumerator"] = "(int, int)";
        }

        ienm1 = good.GetEnumerator(50, 50);
        try
        {
            ienm2 = bad.GetEnumerator(50, 50);
            DoIEnumerableTest(ienm1, ienm2, good, bad, hsh1, false);
        }
        catch
        {
            hsh1["GetEnumerator"] = "(int, int)";
        }

        try
        {
            bad.GetEnumerator(50, 150);
            hsh1["GetEnumerator"] = "(int, int)";
        }
        catch (Exception)
        {
        }

        ienm1 = good.GetEnumerator(0, 100);
        try
        {
            ienm2 = bad.GetEnumerator(0, 100);
            good.RemoveAt(0);
            DoIEnumerableTest(ienm1, ienm2, good, bad, hsh1, true);
        }
        catch
        {
            hsh1["GetEnumerator"] = "(int, int)";
        }

        //GetRange
        good.Clear();
        for (int i = 0; i < 100; i++)
            good.Add(i);

        ArrayList alst1 = good.GetRange(0, good.Count);
        try
        {
            ArrayList alst2 = bad.GetRange(0, good.Count);
            for (int i = 0; i < good.Count; i++)
            {
                if (alst1[i] != alst2[i])
                    hsh1["GetRange"] = i;
            }
        }
        catch
        {
            hsh1["Range"] = "(int, int)";
        }

        //IndexOf(Object, int)

        if (bad.Count > 0)
        {
            for (int i = 0; i < good.Count; i++)
            {
                if (good.IndexOf(good[i], 0) != bad.IndexOf(good[i], 0))
                {
                    hsh1["IndexOf"] = "(Object, int)";
                }
                if (good.IndexOf(good[i], i) != bad.IndexOf(good[i], i))
                {
                    hsh1["IndexOf"] = "(Object, int)";
                }
                if (i < (good.Count - 1))
                {
                    if (good.IndexOf(good[i], i + 1) != bad.IndexOf(good[i], i + 1))
                    {
                        hsh1["IndexOf"] = "(Object, int)";
                    }
                }
            }

            try
            {
                bad.IndexOf(1, -1);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["IndexOf"] = ex;
            }

            try
            {
                bad.IndexOf(1, bad.Count);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["IndexOf"] = ex;
            }

            // IndexOf(Object, int, int)
            // The semantics of this method has changed, the 3rd parameter now refers to count instead of length
            for (int i = 0; i < good.Count; i++)
            {
                if (good.IndexOf(good[i], 0, good.Count - 1) != bad.IndexOf(good[i], 0, good.Count - 1))
                {
                    hsh1["IndexOf"] = "(Object, int, int)";
                }
                if (good.IndexOf(good[i], i, good.Count - i) != bad.IndexOf(good[i], i, good.Count - i))
                {
                    hsh1["IndexOf"] = "(Object, int)";
                }
                if (good.IndexOf(good[i], i, 0) != bad.IndexOf(good[i], i, 0))
                {
                    hsh1["IndexOf"] = "(Object, int)";
                }
                if (i < (good.Count - 1))
                {
                    if (good.IndexOf(good[i], i + 1, good.Count - (i + 1)) != bad.IndexOf(good[i], i + 1, good.Count - (i + 1)))
                    {
                        hsh1["IndexOf"] = "(Object, int)";
                    }
                }
            }

            try
            {
                bad.IndexOf(1, 0, -1);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["IndexOf"] = ex;
            }

            try
            {
                bad.IndexOf(1, 0, bad.Count);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["IndexOf"] = ex;
            }

            try
            {
                bad.IndexOf(1, bad.Count - 1, bad.Count - 2);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["IndexOf"] = ex;
            }

            //LastIndexOf(Object)
            for (int i = 0; i < good.Count; i++)
            {
                if (good.LastIndexOf(good[i]) != bad.LastIndexOf(good[i]))
                {
                    hsh1["LastIndexOf"] = "(Object)";
                }
                if (good.LastIndexOf(i + 1000) != bad.LastIndexOf(i + 1000))
                {
                    hsh1["LastIndexOf"] = "(Object)";
                }
            }

            try
            {
                bad.LastIndexOf(null);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["LastIndexOf"] = ex;
            }

            //LastIndexOf(Object, int)
            for (int i = 0; i < good.Count; i++)
            {
                if (good.LastIndexOf(good[i], good.Count - 1) != bad.LastIndexOf(good[i], good.Count - 1))
                {
                    hsh1["LastIndexOf"] = "(Object, int)";
                }
                if (good.LastIndexOf(good[i], 0) != bad.LastIndexOf(good[i], 0))
                {
                    hsh1["LastIndexOf"] = "(Object, int)";
                }
                if (good.LastIndexOf(good[i], i) != bad.LastIndexOf(good[i], i))
                {
                    hsh1["LastIndexOf"] = "(Object, int)";
                }
                if (i < (good.Count - 1))
                {
                    if (good.LastIndexOf(good[i], i + 1) != bad.LastIndexOf(good[i], i + 1))
                    {
                        hsh1["LastIndexOf"] = "(Object, int)";
                    }
                }
            }

            try
            {
                bad.LastIndexOf(1, -1);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["LastIndexOf"] = ex;
            }

            try
            {
                bad.LastIndexOf(1, bad.Count);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["LastIndexOf"] = ex;
            }

            //LastIndexOf(Object, int, int)
            for (int i = 0; i < good.Count; i++)
            {
                if (good.LastIndexOf(good[i], good.Count - 1, 0) != bad.LastIndexOf(good[i], good.Count - 1, 0))
                {
                    hsh1["LastIndexOf"] = "(Object, int, int)";
                }
                if (good.LastIndexOf(good[i], good.Count - 1, i) != bad.LastIndexOf(good[i], good.Count - 1, i))
                {
                    hsh1["LastIndexOf"] = "(Object, int)";
                }
                if (good.LastIndexOf(good[i], i, i) != bad.LastIndexOf(good[i], i, i))
                {
                    hsh1["LastIndexOf"] = "(Object, int)";
                }
                if (i < (good.Count - 1))
                {
                    if (good.LastIndexOf(good[i], good.Count - 1, i + 1) != bad.LastIndexOf(good[i], good.Count - 1, i + 1))
                    {
                        hsh1["LastIndexOf"] = "(Object, int)";
                    }
                }
            }

            try
            {
                bad.LastIndexOf(1, 1, -1);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["LastIndexOf"] = ex;
            }

            try
            {
                bad.LastIndexOf(1, bad.Count - 2, bad.Count - 1);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["LastIndexOf"] = ex;
            }
        }

        //ReadOnly()
        ArrayList alst3 = ArrayList.ReadOnly(bad);
        if (!alst3.IsReadOnly)
            hsh1["ReadOnly"] = "Not";

        IList ilst1 = ArrayList.ReadOnly((IList)bad);
        if (!ilst1.IsReadOnly)
            hsh1["ReadOnly"] = "Not";

        //Synchronized()
        alst3 = ArrayList.Synchronized(bad);
        if (!alst3.IsSynchronized)
            hsh1["Synchronized"] = "Not";

        ilst1 = ArrayList.Synchronized((IList)bad);
        if (!ilst1.IsSynchronized)
            hsh1["Synchronized"] = "Not";

        //ToArray()
        if (good.Count == bad.Count)
        {
            object[] oArr1 = good.ToArray();
            object[] oArr2 = bad.ToArray();
            for (int i = 0; i < good.Count; i++)
            {
                if ((int)oArr1[i] != (int)oArr2[i])
                    hsh1["ToArray"] = "()";
            }

            //ToArray(type)
            iArr1 = (int[])good.ToArray(typeof(int));
            iArr2 = (int[])bad.ToArray(typeof(int));
            for (int i = 0; i < good.Count; i++)
            {
                if (iArr1[i] != iArr2[i])
                    hsh1["ToArray"] = "(Type)";
            }
        }

        //Capacity - get
        if (good.Capacity != bad.Capacity)
        {
            hsh1["Capacity"] = "get";
        }

        //Fixed size methods
        if (!hsh1.ContainsKey("IsReadOnly"))
        {
            good.Clear();
            for (int i = 100; i > 0; i--)
                good.Add(i);
            //Sort() & BinarySearch(Object)
            bad.Sort();
            for (int i = 0; i < bad.Count - 1; i++)
            {
                if ((int)bad[i] > (int)bad[i + 1])
                    hsh1["Sort"] = "()";
            }

            for (int i = 0; i < bad.Count; i++)
            {
                if (bad.BinarySearch(bad[i]) != i)
                    hsh1["BinarySearch"] = "(Object)";
            }

            //Reverse()
            bad.Reverse();
            if (bad.Count > 0)
            {
                for (int i = 0; i < 99; i++)
                {
                    if ((int)bad[i] < (int)bad[i + 1])
                        hsh1["Reverse"] = "()";
                }

                good.Clear();
                for (int i = 100; i > 0; i--)
                    good.Add(i.ToString());
            }

            good.Clear();
            for (int i = 90; i > 64; i--)
                good.Add(((Char)i).ToString());

            try
            {
                bad.Sort(new CaseInsensitiveComparer());
                if (bad.Count > 0)
                {
                    for (int i = 0; i < (bad.Count - 1); i++)
                    {
                        if (((String)bad[i]).CompareTo(((String)bad[i + 1])) >= 0)
                            hsh1["Sort"] = "(IComparer)";
                    }
                    for (int i = 0; i < bad.Count; i++)
                    {
                        if (bad.BinarySearch(bad[i], new CaseInsensitiveComparer()) != i)
                            hsh1["BinarySearch"] = "(Object, IComparer)";
                    }
                }
                bad.Reverse();

                good.Clear();
                for (int i = 65; i < 91; i++)
                    good.Add(((Char)i).ToString());

                if (bad.Count > 0)
                {
                    for (int i = 0; i < good.Count; i++)
                    {
                        if (bad.BinarySearch(0, bad.Count, bad[i], new CaseInsensitiveComparer()) != i)
                            hsh1["BinarySearch"] = "(int, int, Object, IComparer)";
                    }
                }
            }
            catch (Exception)
            {
            }

            good.Clear();
            for (int i = 0; i < 100; i++)
                good.Add(i);

            Queue que = new Queue();
            for (int i = 0; i < 100; i++)
                que.Enqueue(i + 5000);

            try
            {
                bad.SetRange(0, que);
            }
            catch (Exception ex)
            {
                hsh1["SetRange"] = "Copy_ExceptionType, " + ex.GetType().Name;
            }
            for (int i = bad.Count; i < bad.Count; i++)
            {
                if ((int)bad[i] != (i + 5000))
                {
                    hsh1["SetRange"] = i;
                }
            }
        }
        else
        {
            //we make sure that the above methods throw here
            good.Clear();
            for (int i = 100; i > 0; i--)
                good.Add(i);

            try
            {
                bad.Sort();
                hsh1["Sort"] = "Copy";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception)
            {
                hsh1["Sort"] = "Copy_ExceptionType";
            }

            try
            {
                bad.Reverse();
                hsh1["Reverse"] = "Copy";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception ex)
            {
                hsh1["Reverse"] = "Copy_ExceptionType, " + ex.GetType().Name;
            }

            try
            {
                bad.Sort(new CaseInsensitiveComparer());
                hsh1["Sort"] = "Copy - Icomparer";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception)
            {
                hsh1["Sort"] = "Copy_ExceptionType";
            }

            try
            {
                bad.Sort(0, 0, new CaseInsensitiveComparer());
                hsh1["Sort"] = "Copy - int, int, IComparer";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception)
            {
                hsh1["Sort"] = "Copy_ExceptionType";
            }

            //BinarySearch
            try
            {
                for (int i = 0; i < bad.Count; i++)
                {
                    if (bad.BinarySearch(bad[i]) != i)
                        hsh1["BinarySearch"] = "(Object)";
                }
                hsh1["BinarySearch"] = "(Object)";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception ex)
            {
                hsh1["BinarySearch"] = ex.GetType().Name;
            }

            try
            {
                for (int i = 0; i < bad.Count; i++)
                {
                    if (bad.BinarySearch(bad[i], new CaseInsensitiveComparer()) != i)
                        hsh1["BinarySearch"] = "(Object)";
                }

                hsh1["BinarySearch"] = "Exception not thrown, (Object, IComparer)";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception ex)
            {
                hsh1["BinarySearch"] = ex.GetType().Name;
            }

            try
            {
                for (int i = 0; i < bad.Count; i++)
                {
                    if (bad.BinarySearch(0, bad.Count, bad[i], new CaseInsensitiveComparer()) != i)
                        hsh1["BinarySearch"] = "(Object)";
                }

                hsh1["BinarySearch"] = "Exception not thrown, (Object, IComparer)";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception ex)
            {
                hsh1["BinarySearch"] = ex.GetType().Name;
            }

            good.Clear();
            for (int i = 0; i < 100; i++)
                good.Add(i);

            Queue que = new Queue();
            for (int i = 0; i < 100; i++)
                que.Enqueue(i + 5000);

            try
            {
                bad.SetRange(0, que);
                hsh1["Sort"] = "Copy - int, int, IComparer";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception)
            {
                hsh1["Sort"] = "Copy_ExceptionType";
            }
        }

        //Modifiable methods
        if (!hsh1.ContainsKey("IsReadOnly") && !hsh1.ContainsKey("Fixed"))
        {
            good.Clear();
            for (int i = 0; i < 100; i++)
                good.Add(i);

            Queue que = new Queue();
            for (int i = 0; i < 100; i++)
                que.Enqueue(i + 5000);
            bad.InsertRange(0, que);
            for (int i = 0; i < 100; i++)
            {
                if ((int)bad[i] != i + 5000)
                {
                    hsh1["InsertRange"] = i;
                }
            }

            //AddRange()
            que = new Queue();
            for (int i = 0; i < 100; i++)
                que.Enqueue(i + 2222);
            bad.AddRange(que);
            for (int i = bad.Count - 100; i < bad.Count; i++)
            {
                if ((int)bad[i] != (i - (bad.Count - 100)) + 2222)
                {
                    hsh1["AddRange"] = i + " " + (int)bad[i];
                }
            }

            bad.RemoveRange(0, que.Count);
            for (int i = 0; i < 100; i++)
            {
                if ((int)bad[i] != i)
                {
                    hsh1["RemoveRange"] = i + " " + (int)bad[i];
                }
            }

            //Capacity
            try
            {
                bad.Capacity = bad.Capacity * 2;
            }
            catch (Exception ex)
            {
                hsh1["Capacity"] = ex.GetType().Name;
            }

            try
            {
                bad.Capacity = -1;
                hsh1["Capacity"] = "No_Exception_Thrown, -1";
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["Capacity"] = ex.GetType().Name;
            }

            int iMakeSureThisDoesNotCause = 0;
            while (bad.Capacity == bad.Count)
            {
                if (iMakeSureThisDoesNotCause++ > 100)
                    break;
                bad.Add(bad.Count);
            }
            if (iMakeSureThisDoesNotCause > 100)
                hsh1["TrimToSize"] = "Monekeyed, " + bad.Count + " " + bad.Capacity;

            //TrimToSize()
            try
            {
                bad.TrimToSize();
                if (bad.Capacity != bad.Count)
                {
                    hsh1["TrimToSize"] = "Problems baby";
                }
            }
            catch (Exception ex)
            {
                hsh1["TrimToSize"] = ex.GetType().Name;
            }
        }
        else
        {
            Queue que = new Queue();
            for (int i = 0; i < 100; i++)
                que.Enqueue(i + 5000);
            try
            {
                bad.AddRange(que);
                hsh1["AddRange"] = "Copy";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception)
            {
                hsh1["AddRange"] = "Copy_ExceptionType";
            }

            try
            {
                bad.InsertRange(0, que);
                hsh1["InsertRange"] = "Copy";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception)
            {
                hsh1["InsertRange"] = "Copy_ExceptionType";
            }

            good.Clear();
            for (int i = 0; i < 10; i++)
                good.Add(i);
            try
            {
                bad.RemoveRange(0, 10);
                hsh1["RemoveRange"] = "Copy";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception ex)
            {
                hsh1["RemoveRange"] = "Copy_ExceptionType, " + ex.GetType().Name;
            }

            try
            {
                bad.Capacity = bad.Capacity * 2;
                hsh1["Capacity"] = "No_Exception_Thrown, bad.Capacity*2";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception ex)
            {
                hsh1["Capacity"] = ex.GetType().Name;
            }

            try
            {
                bad.TrimToSize();
                hsh1["TrimToSize"] = "No_Exception_Thrown";
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception ex)
            {
                hsh1["TrimToSize"] = ex.GetType().Name;
            }
        }
    }
Example #43
0
 public SRTreeEnumerator(ArrayList list)
 {
     _list = list;
     _ide  = _list.GetEnumerator();
 }
Example #44
0
        /// <summary>
        /// Creates the portal.
        /// </summary>
        /// <param name="templateID">The template ID.</param>
        /// <param name="templateAlias">The template alias.</param>
        /// <param name="portalAlias">The portal alias.</param>
        /// <param name="portalName">Name of the portal.</param>
        /// <param name="portalPath">The portal path.</param>
        /// <returns></returns>
        private int CreatePortal(int templateID, string templateAlias, string portalAlias, string portalName,
                                 string portalPath)
        {
            int newPortalID;

            PortalsDB portals = new PortalsDB();
            PagesDB   tabs    = new PagesDB();
            ModulesDB modules = new ModulesDB();
            UsersDB   users   = new UsersDB();

            // create an Array to stores modules ID and GUID for finding them later
            ArrayList      templateModules = new ArrayList();
            moduleTemplate module;
            // create an Array to stores tabs ID for finding them later
            ArrayList   templateTabs = new ArrayList();
            tabTemplate tab;

            // Create a new portal
            newPortalID = portals.AddPortal(portalAlias, portalName, portalPath);

            // Open the connection to the PortalTemplates Database
            SqlConnection myConnection    = GetConnection();
            SqlConnection my2ndConnection = GetConnection();
            SqlConnection my3rdConnection = GetConnection();

            myConnection.Open();
            my2ndConnection.Open();
            my3rdConnection.Open();

            // get module definitions and save them in the new portal
            SqlDataReader myReader = GetTemplateModuleDefinitions(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                module.id     = (int)myReader["ModuleDefID"];
                module.GuidID = GetGeneralModuleDefinitionByName(myReader["FriendlyName"].ToString(), my2ndConnection);
                try {
                    // save module definitions in the new portal
                    modules.UpdateModuleDefinitions(module.GuidID, newPortalID, true);
                    // Save the modules into a list for finding them later
                    templateModules.Add(module);
                } catch {
                    // tried to add a Module thas doesn´t exists in this implementation of the portal
                }
            }

            myReader.Close();

            // TODO: Is this still valid? Admin user will be created the first time the portal is accessed
            //if (!Config.UseSingleUserBase)
            //{
            //    // TODO: multiple portals still not supported
            //    Guid userID;

            //    // Create the "admin" User for the new portal
            //    string AdminEmail = "*****@*****.**";
            //    userID = users.AddUser("admin", AdminEmail, "admin", newPortalID);

            //    // Create a new row in a many to many table (userroles)
            //    // giving the "admins" role to the "admin" user
            //    users.AddUserRole("admin", userID);
            //}

            // Get all the Tabs in the Template Portal, store IDs in a list for finding them later
            // and create the Tabs in the new Portal
            myReader = GetTabsByPortal(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                // Save the tabs into a list for finding them later
                tab.oldID = (int)myReader["PageID"];
                tab.newID =
                    tabs.AddPage(newPortalID, myReader["PageName"].ToString(),
                                 Int32.Parse(myReader["PageOrder"].ToString()));
                templateTabs.Add(tab);
            }
            myReader.Close();

            //Clear SiteMaps Cache
            AppleseedSiteMapProvider.ClearAllAppleseedSiteMapCaches();

            // now I have to get them again to set up the ParentID for each Tab
            myReader = GetTabsByPortal(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                // Find the news TabID and ParentTabID
                IEnumerator myEnumerator   = templateTabs.GetEnumerator();
                int         newTabID       = -1;
                int         newParentTabID = -1;

                while (myEnumerator.MoveNext() && (newTabID == -1 || newParentTabID == -1))
                {
                    tab = (tabTemplate)myEnumerator.Current;
                    if (tab.oldID == (int)myReader["PageID"])
                    {
                        newTabID = tab.newID;
                    }
                    if (tab.oldID == Int32.Parse("0" + myReader["ParentPageID"]))
                    {
                        newParentTabID = tab.newID;
                    }
                }

                if (newParentTabID == -1)
                {
                    newParentTabID = 0;
                }

                // Update the Tab in the new portal
                tabs.UpdatePage(newPortalID, newTabID, newParentTabID, myReader["PageName"].ToString(),
                                Int32.Parse(myReader["PageOrder"].ToString()), myReader["AuthorizedRoles"].ToString(),
                                myReader["MobilePageName"].ToString(), (bool)myReader["ShowMobile"]);

                // Finally use GetPortalSettings to access each Tab and its Modules in the Template Portal
                // and create them in the new Portal
                SqlDataReader result;

                try {
                    result = GetPageModules(Int32.Parse(myReader["PageID"].ToString()), my2ndConnection);

                    object myValue;

                    while (result.Read())
                    {
                        ModuleSettings m = new ModuleSettings();
                        m.ModuleID    = (int)result["ModuleID"];
                        m.ModuleDefID = (int)result["ModuleDefID"];
                        m.PageID      = newTabID;
                        m.PaneName    = (string)result["PaneName"];
                        m.ModuleTitle = (string)result["ModuleTitle"];

                        myValue = result["AuthorizedEditRoles"];
                        m.AuthorizedEditRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedViewRoles"];
                        m.AuthorizedViewRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedAddRoles"];
                        m.AuthorizedAddRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedDeleteRoles"];
                        m.AuthorizedDeleteRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedPropertiesRoles"];
                        m.AuthorizedPropertiesRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedMoveModuleRoles"];
                        m.AuthorizedMoveModuleRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedDeleteModuleRoles"];
                        m.AuthorizedDeleteModuleRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedPublishingRoles"];
                        m.AuthorizedPublishingRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue           = result["SupportWorkflow"];
                        m.SupportWorkflow = !Convert.IsDBNull(myValue) ? (bool)myValue : false;

                        myValue = result["AuthorizedApproveRoles"];
                        m.AuthorizedApproveRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue          = result["WorkflowState"];
                        m.WorkflowStatus = !Convert.IsDBNull(myValue)
                                               ? (WorkflowState)(0 + (byte)myValue)
                                               : WorkflowState.Original;

                        try {
                            myValue = result["SupportCollapsable"];
                        } catch {
                            myValue = DBNull.Value;
                        }
                        m.SupportCollapsable = DBNull.Value != myValue ? (bool)myValue : false;

                        try {
                            myValue = result["ShowEveryWhere"];
                        } catch {
                            myValue = DBNull.Value;
                        }
                        m.ShowEveryWhere = DBNull.Value != myValue ? (bool)myValue : false;

                        m.CacheTime   = int.Parse(result["CacheTime"].ToString());
                        m.ModuleOrder = int.Parse(result["ModuleOrder"].ToString());

                        myValue      = result["ShowMobile"];
                        m.ShowMobile = !Convert.IsDBNull(myValue) ? (bool)myValue : false;

                        // Find the new ModuleDefID assigned to the module in the new portal
                        myEnumerator = templateModules.GetEnumerator();
                        int newModuleDefID = 0;

                        while (myEnumerator.MoveNext() && newModuleDefID == 0)
                        {
                            module = (moduleTemplate)myEnumerator.Current;
                            if (module.id == m.ModuleDefID)
                            {
                                newModuleDefID = modules.GetModuleDefinitionByGuid(newPortalID, module.GuidID);
                            }
                        }

                        if (newModuleDefID > 0)
                        {
                            // add the module to the new tab
                            int newModuleID = modules.AddModule(newTabID, m.ModuleOrder, m.PaneName, m.ModuleTitle,
                                                                newModuleDefID, m.CacheTime, m.AuthorizedEditRoles,
                                                                m.AuthorizedViewRoles,
                                                                m.AuthorizedAddRoles, m.AuthorizedDeleteRoles,
                                                                m.AuthorizedPropertiesRoles,
                                                                m.AuthorizedMoveModuleRoles,
                                                                m.AuthorizedDeleteModuleRoles,
                                                                m.ShowMobile, m.AuthorizedPublishingRoles,
                                                                m.SupportWorkflow,
                                                                m.ShowEveryWhere, m.SupportCollapsable);
                            // At the end, get all ModuleSettings and save them in the new module
                            SqlDataReader dr = GetModuleSettings(m.ModuleID, my3rdConnection);

                            while (dr.Read())
                            {
                                Framework.Site.Configuration.ModuleSettings.UpdateModuleSetting(newModuleID, dr["SettingName"].ToString(),
                                                                                                dr["SettingValue"].ToString());
                            }
                            dr.Close();
                        }
                    }

                    result.Close();
                } catch {
                    // Error? ignore Tab ...
                }
            }
            myReader.Close();

            // Set the CustomSettings of the New Portal based in the Template Portal
            myReader = GetPortalCustomSettings(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                PortalSettings.UpdatePortalSetting(newPortalID, myReader["SettingName"].ToString(),
                                                   myReader["SettingValue"].ToString());
            }

            myReader.Close();

            // close the conections
            myConnection.Close();
            my2ndConnection.Close();
            my3rdConnection.Close();

            // Create paths
            portals.CreatePortalPath(portalPath);

            return(newPortalID);
        }
 /// <summary>
 /// It creates a new instance of the class <see cref="ListenerEnumerator"/>.
 /// </summary>
 /// <param name="listeners">
 /// It's the table which contains the listeners.
 /// </param>
 public ListenerEnumerator(ArrayList listeners)
 {
     _listenerEnumerator = listeners.GetEnumerator();
 }
Example #46
0
 public virtual bool runTest()
 {
     int iCountErrors = 0;
     int iCountTestcases = 0;
     Console.Error.WriteLine( strName + ": " + strTest + " runTest started..." );
     ArrayList arrList = null;
     int ii = 0;
     bool bGetNext = false;
     Object o1;
     String [] strHeroes =
         {
             "Aquaman",
             "Atom",
             "Batman",
             "Black Canary",
             "Captain America",
             "Captain Atom",
             "Catwoman",
             "Cyborg",
             "Flash",
             "Green Arrow",
             "Green Lantern",
             "Hawkman",
             "Huntress",
             "Ironman",
             "Nightwing",
             "Robin",
             "SpiderMan",
             "Steel",
             "Superman",
             "Thor",
             "Wildcat",
             "Wonder Woman",
     };
     ArrayList list;
     IEnumerator ien1;
     do
     {
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Construct ArrayList" );
         try
         {
             arrList = new ArrayList( (ICollection) strHeroes );
             if ( arrList == null )
             {
                 Console.WriteLine( strTest+ "E_101: Failed to construct new ArrayList" );
                 ++iCountErrors;
                 break;
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10001: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Obtain and verify enumerator" );
         try
         {
             IEnumerator enu = arrList.GetEnumerator();
             if ( enu == null )
             {
                 Console.WriteLine( strTest+ "E_303: Failed to construct enumerator" );
                 ++iCountErrors;
                 break;
             }
             for ( ii = 0; ;ii++ )
             {
                 bGetNext = enu.MoveNext();
                 if ( bGetNext == false )
                     break;
                 if ( strHeroes[ii].CompareTo( (String)enu.Current ) != 0 )
                 {
                     String strInfo = strTest + " error: ";
                     strInfo = strInfo + "Expected Hero <"+ strHeroes[ii] + "> ";
                     strInfo = strInfo + "Returned Hero <"+ (String)enu.Current + "> ";
                     Console.WriteLine( strTest+ "E_404: " + strInfo );
                     ++iCountErrors;
                     break;
                 }
             }
             if ( ii != strHeroes.Length )
             {
                 String strInfo = strTest + " error: ";
                 strInfo = strInfo + "Enumeration discrepancy\n";
                 strInfo = strInfo + "Expected Loop count==" + strHeroes.Length;
                 strInfo = strInfo + "Returned Loop count==" + ii;
                 Console.WriteLine( strInfo );
                 Console.WriteLine( strTest+ "E_303: Enumeration discrepancy.Failed to construct enumerator " );
                 ++iCountErrors;
                 break;
             }
             bGetNext = enu.MoveNext();
             if ( bGetNext != false )
             {
                 String strInfo = strTest + " error: ";
                 strInfo = strInfo + "Enumeration discrepancy\n";
                 strInfo = strInfo + "Expected Enumeration GetNext()==false ";
                 strInfo = strInfo + "Returned Enumeration GetNext()==" + bGetNext;
                 Console.WriteLine( strTest+ "E_404: " + strInfo );
                 ++iCountErrors;
                 break;
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10002: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         iCountTestcases++;
         list = new ArrayList();
         for(int i=0; i<100; i++)
             list.Add(i);
         ien1= list.GetEnumerator();
         ien1.MoveNext();
         ien1.MoveNext();
         list[10]=1000;
         if((int)ien1.Current!=1)
         {
             ++iCountErrors;
             Console.WriteLine("Err_3857tsgfg! Wrong value returned! " + ien1.Current);
         }
         try
         {
             ien1.MoveNext();
         }
         catch(InvalidOperationException)
         {
         }
         catch(Exception ex)
         {
             ++iCountErrors;
             Console.WriteLine( "Err_357dg! Unexpected exception thrown, " + ex.GetType().Name);
         }
         iCountTestcases++;
         list = new ArrayList();
         for(int i=0; i<100; i++)
             list.Add(i);
         ien1= list.GetEnumerator();
         try
         {
             o1 = ien1.Current;
         }
         catch(InvalidOperationException)
         {
         }
         catch(Exception ex)
         {
             ++iCountErrors;
             Console.WriteLine( "Err_357dg! Unexpected exception thrown, " + ex.GetType().Name);
         }
     while(ien1.MoveNext());
         try
         {
             o1 = ien1.Current;
         }
         catch(InvalidOperationException)
         {
         }
         catch(Exception ex)
         {
             ++iCountErrors;
             Console.WriteLine( "Err_357dg! Unexpected exception thrown, " + ex.GetType().Name);
         }
     }
     while ( false );
     Console.Error.Write( strName );
     Console.Error.Write( ": " );
     if ( iCountErrors == 0 )
     {
         Console.Error.WriteLine( strTest + " iCountTestcases==" + iCountTestcases + " paSs" );
         return true;
     }
     else
     {
         Console.WriteLine( strTest+ strPath );
         Console.WriteLine( strTest+ "FAiL" );
         Console.Error.WriteLine( strTest + " iCountErrors==" + iCountErrors );
         return false;
     }
 }
Example #47
0
        /**
         * The run method for the BNS process
         */
        public void run()
        {
            // Create the channel to receive incoming messages on. The index is 2.
            NetAltingChannelInput In = NetChannel.numberedNet2One(2, new BNSNetworkMessageFilter.FilterRX());

            // We now wish to alternate upon this channel and the link lost channel
            Alternative alt = new Alternative(new Guard[] { this.lostLink, In });

            // Loop forever
            while (true)
            {
                // Select next available Guard. Give priority to link failure
                switch (alt.priSelect())
                {
                // We have lost the connection to a Node
                case 0:
                    // Read in the NodeID of the lost Node
                    NodeID lostNode = (NodeID)this.lostLink.read();

                    // Log loss of connection
                    Node.log.log(this.GetType(), "Lost Link to: " + lostNode.toString());

                    // Remove the logged client
                    this.loggedClients.Remove(lostNode);

                    // Next get the ArrayList of any barriers registered by that Node
                    ArrayList registeredBars = (ArrayList)this.barrierRegister[lostNode];

                    // If this ArrayList is null, we have no registrations
                    if (registeredBars != null)
                    {
                        // There are registered barriers

                        // Remove the list from the Hashmap
                        this.barrierRegister.Remove(lostNode);

                        // Now remove all the barriers registered by the Node
                        for (IEnumerator enumerator = registeredBars.GetEnumerator(); enumerator.MoveNext();)
                        {
                            String toRemove = (String)enumerator.Current;
                            this.registeredBarriers.Remove(toRemove);
                            Node.log.log(this.GetType(), toRemove + " deregistered");
                        }
                    }
                    break;

                // We have received a new incoming message
                case 1:
                {
                    // Read in the message
                    BNSMessage message = (BNSMessage)In.read();

                    // Now behave based on the type of the message
                    switch (message.type)
                    {
                    // We have received a logon message
                    case BNSMessageProtocol.LOGON_MESSAGE:
                    {
                        // Log the logon attempt
                        Node.log.log(this.GetType(), "Logon received from: "
                                     + message.serviceLocation.getNodeID().toString());

                        // try-catch loop. We don't want the BNS to fail
                        try
                        {
                            // Check if the node is already logged on
                            NetChannelOutput Out = (NetChannelOutput)this.loggedClients[message.serviceLocation.getNodeID()];

                            // If out is null, no previous logon received
                            if (Out != null)
                            {
                                // This Node is already logged on. Send fail message
                                // Log failed attempt
                                Node.err.log(this.GetType(), message.serviceLocation.getNodeID().toString()
                                             + " already logged on.  Rejecting");

                                // Create reply channel to the Node
                                NetChannelOutput toNewRegister = NetChannel.one2net(message.serviceLocation,
                                                                                    new BNSNetworkMessageFilter.FilterTX());

                                // Create the reply message
                                BNSMessage reply = new BNSMessage();
                                reply.type    = BNSMessageProtocol.LOGON_REPLY_MESSAGE;
                                reply.success = false;

                                // Asynchronously write to Node. We don't want the BNS to block
                                toNewRegister.asyncWrite(reply);
                                // Destroy the temporary channel
                                toNewRegister.destroy();
                            }
                            else
                            {
                                // Node hasn't previously registered
                                // Log registration
                                Node.log.log(this.GetType(), message.serviceLocation.getNodeID().toString()
                                             + " successfully logged on");

                                // Create the reply channel
                                NetChannelOutput toNewRegister = NetChannel.one2net(message.serviceLocation,
                                                                                    new BNSNetworkMessageFilter.FilterTX());

                                // Add the Node and reply channel to the logged clients map
                                this.loggedClients.Add(message.serviceLocation.getNodeID(), toNewRegister);

                                // Create a reply message
                                BNSMessage reply = new BNSMessage();
                                reply.type    = BNSMessageProtocol.LOGON_REPLY_MESSAGE;
                                reply.success = true;

                                // Write reply asynchronously to the logging on Node
                                toNewRegister.asyncWrite(reply);
                            }
                        }
                        catch (JCSPNetworkException jne)
                        {
                            // Catch any JCSPNetworkException. We don't let the BNS go down
                        }
                        break;
                    }

                    // A Node is attempting to register a Barrier
                    case BNSMessageProtocol.REGISTER_REQUEST:
                    {
                        // Log registration attempt
                        Node.log.log(this.GetType(), "Registeration for " + message.name + " received");

                        // Catch any JCSPNetworkException
                        try
                        {
                            // Get the reply channel from our logged clients map
                            NetChannelOutput Out = (NetChannelOutput)this.loggedClients[message.serviceLocation.getNodeID()];

                            // Check if the Node has logged on with us
                            if (Out == null)
                            {
                                // The Node is not logged on. Send failure message
                                Node.err.log(this.GetType(), "Registration failed. "
                                             + message.serviceLocation.getNodeID()
                                             + " not logged on");

                                // Create the channel to reply to
                                Out = NetChannel.one2net(message.serviceLocation,
                                                         new BNSNetworkMessageFilter.FilterTX());

                                // Create the reply message
                                BNSMessage reply = new BNSMessage();
                                reply.type    = BNSMessageProtocol.REGISTER_REPLY;
                                reply.success = false;

                                // Write message asynchronously to the Node
                                Out.asyncWrite(reply);

                                // Destroy the temporary channel
                                Out.destroy();
                            }

                            // The Node is registered. Now check if the name is
                            else if (this.registeredBarriers.ContainsKey(message.name))
                            {
                                // The name is already registered. Inform the register
                                // Log the failed registration
                                Node.err.log(this.GetType(), "Registration failed. " + message.name
                                             + " already registered");

                                // Create reply message
                                BNSMessage reply = new BNSMessage();
                                reply.type    = BNSMessageProtocol.RESOLVE_REPLY;
                                reply.success = false;

                                // Write the reply asynchronously. Do not block the BNS
                                Out.asyncWrite(reply);
                            }
                            else
                            {
                                BNSMessage reply;
                                // The name is not registered
                                // Log successful registration
                                Node.log.log(this.GetType(), "Registration of " + message.name + " succeeded.");

                                // First check if any client end is waiting for this name
                                ArrayList pending = (ArrayList)this.waitingResolves[message.name];

                                if (pending != null)
                                {
                                    // We have waiting resolves. Complete
                                    for (IEnumerator enumerator = pending.GetEnumerator(); enumerator.MoveNext();)
                                    {
                                        NetChannelOutput toPending = null;

                                        // We now catch internally any JCSPNetworkException
                                        try
                                        {
                                            // Get the next waiting message
                                            BNSMessage msg = (BNSMessage)enumerator.Current;

                                            // Log resolve completion
                                            Node.log.log(this.GetType(), "Queued resolve of " + message.name
                                                         + " by "
                                                         + msg.serviceLocation.getNodeID()
                                                         + " completed");

                                            // Create channel to the resolver
                                            toPending = NetChannel.one2net(msg.serviceLocation,
                                                                           new BNSNetworkMessageFilter.FilterTX());

                                            // Create the reply message
                                            reply          = new BNSMessage();
                                            reply.type     = BNSMessageProtocol.RESOLVE_REPLY;
                                            reply.location = message.location;
                                            reply.success  = true;

                                            // Write the reply asynchronously to the waiting resolver
                                            toPending.asyncWrite(reply);
                                        }
                                        catch (JCSPNetworkException jne)
                                        {
                                            // Something went wrong as we tried to send the resolution complete
                                            // message
                                            // Do nothing
                                        }
                                        finally
                                        {
                                            // Check if we need to destroy the temporary channel
                                            if (toPending != null)
                                            {
                                                toPending.destroy();
                                            }
                                        }
                                    }

                                    // Remove the name from the pending resolves
                                    this.waitingResolves.Remove(message.name);
                                }

                                // We have completed any pending resolves. Now register the barrier
                                this.registeredBarriers.Add(message.name, message.location);

                                // Now add the registered barrier to the barriers registered by this Node
                                ArrayList registered = (ArrayList)this.barrierRegister[message.serviceLocation.getNodeID()];

                                // If the ArrayList is null, we have no previous registrations
                                if (registered == null)
                                {
                                    // Create a new ArrayList to store the registered names
                                    registered = new ArrayList();
                                    // Add it to the barrier register
                                    this.barrierRegister.Add(message.location.getNodeID(), registered);
                                }

                                // Add the name to the ArrayList
                                registered.Add(message.name);

                                // Log the successful registration
                                Node.log.log(this.GetType(), message.name + " registered to " + message.location);

                                // Create the reply message
                                reply         = new BNSMessage();
                                reply.type    = BNSMessageProtocol.REGISTER_REPLY;
                                reply.success = true;

                                // Write the reply asynchronously to the Node
                                Out.asyncWrite(reply);
                            }
                        }
                        catch (JCSPNetworkException jne)
                        {
                            // Do nothing. Do not let the BNS break
                        }
                        break;
                    }

                    // We have received a resolve request
                    case BNSMessageProtocol.RESOLVE_REQUEST:
                    {
                        // Log resolve request
                        Node.log.log(this.GetType(), "Resolve request for " + message.name + " received");

                        // Catch any JCSPNetworkException
                        try
                        {
                            // Check if the resolving Node is logged on
                            NetChannelOutput Out = (NetChannelOutput)this.loggedClients[message.serviceLocation.getNodeID()];

                            // If the channel is null, then the Node has yet to log on with us
                            if (Out == null)
                            {
                                // Node is not logged on
                                // Log failed resolution
                                Node.err.log(this.GetType(), "Resolve failed. "
                                             + message.serviceLocation.getNodeID()
                                             + " not logged on");

                                // Create connection to the receiver
                                Out = NetChannel.one2net(message.serviceLocation,
                                                         new BNSNetworkMessageFilter.FilterTX());

                                // Create the reply message
                                BNSMessage reply = new BNSMessage();
                                reply.type    = BNSMessageProtocol.RESOLVE_REPLY;
                                reply.success = false;

                                // Write message asynchronously to the Node
                                Out.asyncWrite(reply);

                                // Destroy the temporary channel
                                Out.destroy();
                            }
                            else
                            {
                                // Node is logged on. Now check if the name is already registered
                                NetBarrierLocation loc = (NetBarrierLocation)this.registeredBarriers[message.name];

                                // If the location is null, then the name has not yet been registered
                                if (loc == null)
                                {
                                    // The name is not registered. We need to queue the resolve until it is
                                    // Log the queueing of the resolve
                                    Node.log.log(this.GetType(), message.name
                                                 + " not registered. Queueing resolve by "
                                                 + message.serviceLocation.getNodeID().toString());

                                    // Check if any other resolvers are waiting for the channel
                                    ArrayList pending = (ArrayList)this.waitingResolves[message.name];

                                    // If the ArrayList is null, no one else is waiting
                                    if (pending == null)
                                    {
                                        // No one else is waiting. Create a new list and add it to the waiting
                                        // resolves
                                        pending = new ArrayList();
                                        this.waitingResolves.Add(message.name, pending);
                                    }

                                    // Add this resolve message to the list of waiting resolvers
                                    pending.Add(message);
                                }
                                else
                                {
                                    // The location is not null. Send it to the resolver
                                    Node.log.log(this.GetType(), "Resolve request completed. " + message.name
                                                 + " location being sent to "
                                                 + message.serviceLocation.getNodeID());

                                    // Create channel to the resolver
                                    NetChannelOutput toPending = NetChannel.one2net(message.serviceLocation,
                                                                                    new BNSNetworkMessageFilter.FilterTX());

                                    // Create the reply message
                                    BNSMessage reply = new BNSMessage();
                                    reply.type     = BNSMessageProtocol.RESOLVE_REPLY;
                                    reply.location = loc;
                                    reply.success  = true;

                                    // Write the reply to the resolver asynchronously
                                    toPending.asyncWrite(reply);

                                    // Destroy the temporary channel
                                    toPending.destroy();
                                }
                            }
                        }
                        catch (JCSPNetworkException jne)
                        {
                            // Something went wrong during the resolution. Ignore
                        }
                        break;
                    }
                    }
                    break;
                }
                }
            }
        }
Example #48
0
    public static void AddVegetationVignes(string filename)
    {
        string[] lines = OpenTextFile (filename);
        string trimmedLine;
        string result;

        maxH = 0.0f;

        Vector3 trans= Vector3.zero;
        ArrayList points= new ArrayList();
        int typeVegetation=0;
        typeVegetation+=0; // avoid a warning

           		Terrain terrain = getMainTerrain("TerrainVignes");
        TerrainData	terraindata = terrain.terrainData;
        TreeInstance tree;
        List<TreeInstance> newTrees = new List<TreeInstance>(terraindata.treeInstances);

        //		int lineNumber = 0;
        foreach (string line in lines) {
        //			Debug.Log (++lineNumber);
            trimmedLine = line.Trim();
            result = MatchItem(trimmedLine, "translation ");
            if ((null!=result) ) { trans = stringToVector3 (result); }
            result = MatchItem(trimmedLine, "points [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "pointsRemplis [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "typeVegetation ");
            if (null!=result) {
                typeVegetation=int.Parse(result);

                IEnumerator e = points.GetEnumerator();
                float rnd;
                while (e.MoveNext()) {

                    tree = new TreeInstance();
                    tree.position = WorldToTerrain(terrain,(Vector3)e.Current+trans);

                    tree.prototypeIndex = 1;
                    rnd= 0.25f*(Random.value-1.0f);
        //		rnd=0.5f;
                    tree.widthScale = 1.0f+rnd;
                    tree.heightScale = 1.0f+rnd;

                    Color c = Color.white;
                    c[0] = 0.92f+Random.value*0.08f;
                    c[1] = 0.92f+Random.value*0.08f;
                    c[2] = 0.92f+Random.value*0.08f;
                    tree.color = c;

                    tree.lightmapColor = Color.white;

                    newTrees.Add(tree);
                }

            }
        }
        terraindata.treeInstances= newTrees.ToArray();
        Debug.Log (maxH);
    }
 public IEnumerator GetEnumerator()
 {
     return(indices.GetEnumerator());
 }
Example #50
0
 private void CompareObjects(ArrayList good, ArrayList bad, Hashtable hsh1)
 {
     DoIListTests(good, bad, hsh1);
     good.Clear();
     for(int i=0; i<100; i++)
         good.Add(i);
     if(fVerbose)
         Console.WriteLine("CopyTo()");
     Int32[] iArr1 = null;
     Int32[] iArr2 = null;
     iArr1 = new Int32[100];
     iArr2 = new Int32[100];
     good.CopyTo(iArr1);
     bad.CopyTo(iArr2);
     for(int i=0; i<100; i++)
     {
         if(iArr1[i] != iArr2[i])
             hsh1["CopyTo"] = "()";
     }
     iArr1 = new Int32[100];
     iArr2 = new Int32[100];
     good.CopyTo(0, iArr1, 0, 100);
     try
     {
         bad.CopyTo(0, iArr2, 0, 100);
         for(int i=0; i<100; i++)
         {
             if(iArr1[i] != iArr2[i])
                 hsh1["CopyTo"] = "()";
         }
     }
     catch
     {
         hsh1["CopyTo"] = "(Int32, Array, Int32, Int32)";
     }
     iArr1 = new Int32[200];
     iArr2 = new Int32[200];
     for(int i=0; i<200; i++)
     {
         iArr1[i]=50;
         iArr2[i]=50;
     }
     good.CopyTo(50, iArr1, 100, 20);
     try
     {
         bad.CopyTo(50, iArr2, 100, 20);
         for(int i=0; i<200; i++)
         {
             if(iArr1[i] != iArr2[i])
                 hsh1["CopyTo"] = "(Array, Int32, Int32)";
         }
     }
     catch
     {
         hsh1["CopyTo"] = "(Int32, Array, Int32, Int32)";
     }
     if(fVerbose)
         Console.WriteLine("Clone()");
     ArrayList alstClone = (ArrayList)bad.Clone();
     if(alstClone.Count != bad.Count)
         hsh1["Clone"] = "Count";
     for(int i=0; i<bad.Count; i++)
     {
         if(alstClone[i] != bad[i])
             hsh1["Clone"] = "[]";
     }
     if(fVerbose)
         Console.WriteLine("GetEnumerator()");
     IEnumerator ienm1 = null;
     IEnumerator ienm2 = null;
     ienm1 = good.GetEnumerator(0, 100);
     try
     {
         ienm2 = bad.GetEnumerator(0, 100);
         DoIEnumerableTest(ienm1, ienm2, hsh1, false);
     }
     catch
     {
         hsh1["GetEnumerator"] = "(Int32, Int32)";
     }
     ienm1 = good.GetEnumerator(50, 50);
     try
     {
         ienm2 = bad.GetEnumerator(50, 50);
         DoIEnumerableTest(ienm1, ienm2, hsh1, false);
     }
     catch
     {
         hsh1["GetEnumerator"] = "(Int32, Int32)";
     }
     try
     {
         bad.GetEnumerator(50, 150);
         hsh1["GetEnumerator"] = "(Int32, Int32)";
     }
     catch(Exception)
     {
     }
     ienm1 = good.GetEnumerator(0, 100);
     try
     {
         ienm2 = bad.GetEnumerator(0, 100);
         good.RemoveAt(0);
         DoIEnumerableTest(ienm1, ienm2, hsh1, true);
     }
     catch
     {
         hsh1["GetEnumerator"] = "(Int32, Int32)";
     }
     good.Clear();
     for(int i=0; i<100; i++)
         good.Add(i);
     if(fVerbose)
         Console.WriteLine("GetRange()");
     ArrayList alst1 = good.GetRange(0, good.Count);
     try
     {
         ArrayList alst2 = bad.GetRange(0, good.Count);
         for(int i=0; i<good.Count; i++)
         {
             if(alst1[i] != alst2[i])
                 hsh1["GetRange"] = i;
         }
     }
     catch
     {
         hsh1["Range"] = "(Int32, Int32)";
     }
     if(bad.Count>0)
     {
         if(fVerbose)
             Console.WriteLine("IndexOf()");
         for(int i=0; i<good.Count; i++)
         {
             if(good.IndexOf(good[i], 0) != bad.IndexOf(good[i], 0))
             {
                 Console.WriteLine(good .Count + " " + bad.Count + " " + good[i] + " " + bad[i] + " " + good.IndexOf(good[i], 0) + " " + bad.IndexOf(good[i], 0));
                 hsh1["IndexOf"] = "(Object, Int32)";
             }
             if(good.IndexOf(good[i], i) != bad.IndexOf(good[i], i))
             {
                 Console.WriteLine("2" + good.IndexOf(good[i], i) + " " + bad.IndexOf(good[i], i));
                 hsh1["IndexOf"] = "(Object, Int32)";
             }
             if(i<(good.Count-1))
             {
                 if(good.IndexOf(good[i], i+1) != bad.IndexOf(good[i], i+1))
                 {
                     Console.WriteLine("3" + good.IndexOf(good[i], i+1) + " " + bad.IndexOf(good[i], i+1));
                     hsh1["IndexOf"] = "(Object, Int32)";
                 }
             }			
         }
         try
         {
             bad.IndexOf(1, -1);
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["IndexOf"] = ex;
         }
         try
         {
             bad.IndexOf(1, bad.Count);
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["IndexOf"] = ex;
         }
         for(int i=0; i<good.Count; i++)
         {
             if(good.IndexOf(good[i], 0, good.Count-1) != bad.IndexOf(good[i], 0, good.Count-1))
             {
                 hsh1["IndexOf"] = "(Object, Int32, Int32)";
             }
             if(good.IndexOf(good[i], i, good.Count-i) != bad.IndexOf(good[i], i, good.Count-i))
             {
                 hsh1["IndexOf"] = "(Object, Int32)";
             }
             if(good.IndexOf(good[i], i, 0) != bad.IndexOf(good[i], i, 0))
             {
                 hsh1["IndexOf"] = "(Object, Int32)";
             }
             if(i<(good.Count-1))
             {
                 if(good.IndexOf(good[i], i+1, good.Count-(i+1)) != bad.IndexOf(good[i], i+1, good.Count-(i+1)))
                 {
                     hsh1["IndexOf"] = "(Object, Int32)";
                 }
             }
         }
         try
         {
             bad.IndexOf(1, 0, -1);
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["IndexOf"] = ex;
         }
         try
         {
             bad.IndexOf(1, 0, bad.Count);
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["IndexOf"] = ex;
         }
         try
         {
             bad.IndexOf(1, bad.Count-1, bad.Count-2);
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["IndexOf"] = ex;
         }
         if(fVerbose)
             Console.WriteLine("LastIndexOf(), " + good.Count + " " + bad.Count);
         for(int i=0; i<good.Count; i++)
         {
             if(good.LastIndexOf(good[i]) != bad.LastIndexOf(good[i]))
             {
                 hsh1["LastIndexOf"] = "(Object)";
             }
             if(good.LastIndexOf(i+1000) != bad.LastIndexOf(i+1000))
             {
                 hsh1["LastIndexOf"] = "(Object)";
             }
         }
         try
         {
             bad.LastIndexOf(null);
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["LastIndexOf"] = ex;
         }
         if(fVerbose)
             Console.WriteLine("LastIndexOf(Object, Int32)");
         for(int i=0; i<good.Count; i++)
         {
             if(good.LastIndexOf(good[i], good.Count-1) != bad.LastIndexOf(good[i], good.Count-1))
             {
                 hsh1["LastIndexOf"] = "(Object, Int32)";
             }
             if(good.LastIndexOf(good[i], 0) != bad.LastIndexOf(good[i], 0))
             {
                 hsh1["LastIndexOf"] = "(Object, Int32)";
             }
             if(good.LastIndexOf(good[i], i) != bad.LastIndexOf(good[i], i))
             {
                 hsh1["LastIndexOf"] = "(Object, Int32)";
             }
             if(i<(good.Count-1))
             {
                 if(good.LastIndexOf(good[i], i+1) != bad.LastIndexOf(good[i], i+1))
                 {
                     hsh1["LastIndexOf"] = "(Object, Int32)";
                 }
             }			
         }
         try
         {
             bad.LastIndexOf(1, -1);
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["LastIndexOf"] = ex;
         }
         try
         {
             bad.LastIndexOf(1, bad.Count);
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["LastIndexOf"] = ex;
         }
         for(int i=0; i<good.Count; i++)
         {
             if(good.LastIndexOf(good[i], good.Count-1, 0) != bad.LastIndexOf(good[i], good.Count-1, 0))
             {
                 hsh1["LastIndexOf"] = "(Object, Int32, Int32)";
             }
             if(good.LastIndexOf(good[i], good.Count-1, i) != bad.LastIndexOf(good[i], good.Count-1, i))
             {
                 hsh1["LastIndexOf"] = "(Object, Int32)";
             }
             if(good.LastIndexOf(good[i], i, i) != bad.LastIndexOf(good[i], i, i))
             {
                 hsh1["LastIndexOf"] = "(Object, Int32)";
             }
             if(i<(good.Count-1))
             {
                 if(good.LastIndexOf(good[i], good.Count-1, i+1) != bad.LastIndexOf(good[i], good.Count-1, i+1))
                 {
                     hsh1["LastIndexOf"] = "(Object, Int32)";
                 }
             }
         }
         try
         {
             bad.LastIndexOf(1, 1, -1);
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["LastIndexOf"] = ex;
         }
         try
         {
             bad.LastIndexOf(1, bad.Count-2, bad.Count-1);
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["LastIndexOf"] = ex;
         }
     }
     if(fVerbose)
         Console.WriteLine("ReadOnly()");
     ArrayList alst3 = ArrayList.ReadOnly(bad);
     if(!alst3.IsReadOnly)
         hsh1["ReadOnly"] = "Not";
     IList ilst1 = ArrayList.ReadOnly((IList)bad);
     if(!ilst1.IsReadOnly)
         hsh1["ReadOnly"] = "Not";
     if(fVerbose)
         Console.WriteLine("Synchronized()");
     alst3 = ArrayList.Synchronized(bad);
     if(!alst3.IsSynchronized)
         hsh1["Synchronized"] = "Not";
     ilst1 = ArrayList.Synchronized((IList)bad);
     if(!ilst1.IsSynchronized)
         hsh1["Synchronized"] = "Not";
     if(good.Count == bad.Count)
     {
         if(fVerbose)
             Console.WriteLine("ToArray()");
         Object[] oArr1 = good.ToArray();
         Object[] oArr2 = bad.ToArray();
         for(int i=0; i<good.Count; i++)
         {
             if((Int32)oArr1[i] != (Int32)oArr2[i])
                 hsh1["ToArray"] = "()";
         }
         iArr1 = (Int32[])good.ToArray(typeof(Int32));
         iArr2 = (Int32[])bad.ToArray(typeof(Int32));
         for(int i=0; i<good.Count; i++)
         {
             if(iArr1[i] != iArr2[i])
                 hsh1["ToArray"] = "(Type)";
         }
     }
     if(fVerbose)
         Console.WriteLine("Capacity()");
     if(good.Capacity != bad.Capacity)
     {
         hsh1["Capacity"] = "get";
     }
     if(!hsh1.ContainsKey("IsReadOnly"))
     {
         good.Clear();
         for(int i=100; i>0; i--)
             good.Add(i);
         if(fVerbose)
             Console.WriteLine("Sort() & BinarySearch()");
         bad.Sort();
         for(int i=0; i<bad.Count-1; i++)
         {
             if((Int32)bad[i] > (Int32)bad[i+1])
                 hsh1["Sort"] = "()";
         }			
         for(int i=0; i<bad.Count; i++)
         {
             if(bad.BinarySearch(bad[i]) != i)
                 hsh1["BinarySearch"] = "(Object)";
         }
         bad.Reverse();
         if(bad.Count>0)
         {
             for(int i=0; i<99; i++)
             {
                 if((Int32)bad[i] < (Int32)bad[i+1])
                     hsh1["Reverse"] = "()";
             }
             good.Clear();
             for(int i=100; i>0; i--)
                 good.Add(i.ToString());
         }
         good.Clear();
         for(int i=90; i>64; i--)
             good.Add(((Char)i).ToString());
         try
         {
             bad.Sort(new CaseInsensitiveComparer());
             if(bad.Count>0)
             {
                 for(int i=0; i<(bad.Count-1); i++)
                 {
                     if(((String)bad[i]).CompareTo(((String)bad[i+1])) >= 0)
                         hsh1["Sort"] = "(IComparer)";
                 }			
                 for(int i=0; i<bad.Count; i++)
                 {
                     if(bad.BinarySearch(bad[i], new CaseInsensitiveComparer()) != i)
                         hsh1["BinarySearch"] = "(Object, IComparer)";
                 }
             }
             bad.Reverse();			
             good.Clear();
             for(int i=65; i<91; i++)
                 good.Add(((Char)i).ToString());
             if(bad.Count>0)
             {
                 for(int i=0; i<good.Count; i++)
                 {
                     if(bad.BinarySearch(0, bad.Count, bad[i], new CaseInsensitiveComparer()) != i)
                         hsh1["BinarySearch"] = "(Int32, Int32, Object, IComparer)";
                 }
             }
         }
         catch(Exception)
         {
         }
         good.Clear();
         for(int i=0; i<100; i++)
             good.Add(i);
         if(fVerbose)
             Console.WriteLine("SetRange()");
         Queue que = new Queue();
         for(int i=0; i<100; i++)
             que.Enqueue(i+5000);
         try
         {
             bad.SetRange(0, que);
         }
         catch(Exception ex)
         {
             hsh1["SetRange"] = "Copy_ExceptionType, " + ex.GetType().Name;
         }
         for(int i=bad.Count; i<bad.Count; i++)
         {
             if((Int32)bad[i] != (i + 5000))
             {
                 hsh1["SetRange"] = i;
             }
         }
     }
     else
     {
         good.Clear();
         for(int i=100; i>0; i--)
             good.Add(i);
         try
         {
             bad.Sort();
             hsh1["Sort"] = "Copy";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception)
         {
             hsh1["Sort"] = "Copy_ExceptionType";
         }
         try
         {
             bad.Reverse();
             hsh1["Reverse"] = "Copy";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception ex)
         {
             hsh1["Reverse"] = "Copy_ExceptionType, " + ex.GetType().Name;
         }
         try
         {
             bad.Sort(new CaseInsensitiveComparer());
             hsh1["Sort"] = "Copy - Icomparer";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception)
         {
             hsh1["Sort"] = "Copy_ExceptionType";
         }
         try
         {
             bad.Sort(0, 0, new CaseInsensitiveComparer());
             hsh1["Sort"] = "Copy - Int32, Int32, IComparer";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception)
         {
             hsh1["Sort"] = "Copy_ExceptionType";
         }
         try
         {
             for(int i=0; i<bad.Count; i++)
             {
                 if(bad.BinarySearch(bad[i]) != i)
                     hsh1["BinarySearch"] = "(Object)";
             }
             hsh1["BinarySearch"] = "(Object)";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception ex)
         {
             hsh1["BinarySearch"] = ex.GetType().Name;
         }
         try
         {
             for(int i=0; i<bad.Count; i++)
             {
                 if(bad.BinarySearch(bad[i], new CaseInsensitiveComparer()) != i)
                     hsh1["BinarySearch"] = "(Object)";
             }
             hsh1["BinarySearch"] = "Exception not thrown, (Object, IComparer)";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception ex)
         {
             hsh1["BinarySearch"] = ex.GetType().Name;
         }
         try
         {
             for(int i=0; i<bad.Count; i++)
             {
                 if(bad.BinarySearch(0, bad.Count, bad[i], new CaseInsensitiveComparer()) != i)
                     hsh1["BinarySearch"] = "(Object)";
             }
             hsh1["BinarySearch"] = "Exception not thrown, (Object, IComparer)";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception ex)
         {
             hsh1["BinarySearch"] = ex.GetType().Name;
         }
         good.Clear();
         for(int i=0; i<100; i++)
             good.Add(i);
         Queue que = new Queue();
         for(int i=0; i<100; i++)
             que.Enqueue(i+5000);
         try
         {
             bad.SetRange(0, que);
             hsh1["Sort"] = "Copy - Int32, Int32, IComparer";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception)
         {
             hsh1["Sort"] = "Copy_ExceptionType";
         }
     }
     if(!hsh1.ContainsKey("IsReadOnly") && !hsh1.ContainsKey("Fixed"))
     {
         good.Clear();
         for(int i=0; i<100; i++)
             good.Add(i);
         if(fVerbose)
             Console.WriteLine("InsertRange()");
         Queue que = new Queue();
         for(int i=0; i<100; i++)
             que.Enqueue(i+5000);
         bad.InsertRange(0, que);
         for(int i=0; i<100; i++)
         {
             if((Int32)bad[i] != i + 5000)
             {
                 hsh1["InsertRange"] = i;
             }
         }
         if(fVerbose)
             Console.WriteLine("AddRange()");
         que = new Queue();
         for(int i=0; i<100; i++)
             que.Enqueue(i+2222);
         bad.AddRange(que);
         for(int i=bad.Count-100; i<bad.Count; i++)
         {
             if((Int32)bad[i] != (i-(bad.Count-100)) + 2222)
             {
                 hsh1["AddRange"] = i + " " + (Int32)bad[i];
             }
         }
         if(fVerbose)
             Console.WriteLine("RemoveRange()");
         bad.RemoveRange(0, que.Count);
         for(int i=0; i<100; i++)
         {
             if((Int32)bad[i] != i)
             {
                 hsh1["RemoveRange"] = i + " " + (Int32)bad[i];
             }
         }
         try
         {
             bad.Capacity = bad.Capacity*2;
         }
         catch(Exception ex)
         {
             hsh1["Capacity"] = ex.GetType().Name;
         }
         try
         {
             bad.Capacity = -1;
             hsh1["Capacity"] = "No_Exception_Thrown, -1";
         }
         catch(ArgumentException)
         {
         }
         catch(Exception ex)
         {
             hsh1["Capacity"] = ex.GetType().Name;
         }
         Int32 iMakeSureThisDoesNotCause = 0;
         while(bad.Capacity == bad.Count)
         {
             if(iMakeSureThisDoesNotCause++>100)
                 break;
             bad.Add(bad.Count);
         }
         if(iMakeSureThisDoesNotCause>100)
             hsh1["TrimToSize"] = "Monekeyed, " + bad.Count + " " + bad.Capacity;
         try
         {
             bad.TrimToSize();
             if(bad.Capacity != bad.Count)
             {
                 hsh1["TrimToSize"] = "Problems baby";
             }
         }
         catch(Exception ex)
         {
             hsh1["TrimToSize"] = ex.GetType().Name;
         }
     }
     else
     {
         Queue que = new Queue();
         for(int i=0; i<100; i++)
             que.Enqueue(i+5000);
         try
         {
             bad.AddRange(que);
             hsh1["AddRange"] = "Copy";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception)
         {
             hsh1["AddRange"] = "Copy_ExceptionType";
         }
         try
         {
             bad.InsertRange(0, que);
             hsh1["InsertRange"] = "Copy";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception)
         {
             hsh1["InsertRange"] = "Copy_ExceptionType";
         }
         good.Clear();
         for(int i=0; i<10; i++)
             good.Add(i);
         try
         {
             bad.RemoveRange(0, 10);
             hsh1["RemoveRange"] = "Copy";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception ex)
         {
             hsh1["RemoveRange"] = "Copy_ExceptionType, " + ex.GetType().Name;
         }
         try
         {
             bad.Capacity = bad.Capacity*2;
             hsh1["Capacity"] = "No_Exception_Thrown, bad.Capacity*2";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception ex)
         {
             hsh1["Capacity"] = ex.GetType().Name;
         }
         try
         {
             bad.TrimToSize();
             hsh1["TrimToSize"] = "No_Exception_Thrown";
         }
         catch(NotSupportedException)
         {
         }
         catch(Exception ex)
         {
             hsh1["TrimToSize"] = ex.GetType().Name;
         }
     }
 }
Example #51
0
 public IEnumerator GetEnumerator()
 {
     return(m_list.GetEnumerator());
 }
Example #52
0
    /**
     * Get am iterator of listeners for a particular document
     *
     * @param path the document path
     * @param name the name of the document
     *
     * @return an Iterator POIFSReaderListeners; may be empty
     */

    public IEnumerator GetListeners(POIFSDocumentPath path, String name)
    {
        ArrayList rval = new ArrayList(omnivorousListeners);
        ArrayList selectiveListeners =
            (ArrayList)chosenDocumentDescriptors[new DocumentDescriptor(path,
                name)];

        if (selectiveListeners != null)
        {
            rval.AddRange(selectiveListeners);
        }
        return rval.GetEnumerator();
    }
Example #53
0
 /// <summary>
 /// Returns an enumerator that can iterate through the PropertySpecCollection.
 /// </summary>
 /// <returns>An IEnumerator for the entire PropertySpecCollection.</returns>
 public IEnumerator GetEnumerator()
 {
     return(_innerArray.GetEnumerator());
 }
Example #54
0
 private static void deactivate(RemoteCommunicatorPrx communicator, ArrayList adapters)
 {
     IEnumerator p = adapters.GetEnumerator();
     while(p.MoveNext())
     {
         communicator.deactivateObjectAdapter((RemoteObjectAdapterPrx)p.Current);
     }
 }
Example #55
0
        public MapReduceTask(CacheBase parent, TaskCallback callback,
                             IMapper mapper,
                             ICombinerFactory combiner,
                             IReducerFactory reducer,
                             MapReduceInput inputProvider,
                             MapReduceOutput outputProvider,
                             Filter filter, CacheRuntimeContext context, int chunkSize, int maxExceps)
        {
            this._parent       = parent;
            this.Callback      = callback;
            this._context      = context;
            this.maxExceptions = maxExceps;

            this.mapperTask = new MapperTask(mapper, inputProvider, filter != null ? filter.KeyFilter : null, this);

            if (reducer != null)
            {
                ReducerConfigured = true;
                this.reducerTask  = new ReducerTask(reducer, this);
            }
            else
            {
                ReducerConfigured = true;
                this.reducerTask  = new ReducerTask(new IdentityReducerFactory(), this);
            }
            if (combiner != null)
            {
                CombinerConfigured = true;
                this.combinerTask  = new CombinerTask(combiner, this);
            }

            throttlingMgr       = new MapReduceThrottlingManager(chunkSize, this);
            this.outputProvider = outputProvider;

            if (_parent != null && _parent is LocalCacheImpl)
            {
                isLocal      = true;
                participants = new Hashtable();
                participants.Add(new Address(_parent.Context.Render.IPAddress, _parent.Context.Render.Port), new NodeTaskStatus());
            }
#if !CLIENT
            if (_parent != null && _parent is ClusterCacheBase)
            {
                ArrayList   list = ((ClusterCacheBase)_parent).ActiveServers;
                IEnumerator it   = list.GetEnumerator();
                participants = new Hashtable();
                while (it.MoveNext())
                {
                    participants.Add(it.Current, new NodeTaskStatus());
                }

                if (parent is PartitionedServerCache)
                {
                    distributionMgr = ((PartitionedServerCache)parent).DistributionMgr;
                }
            }
#endif

            //Queue initialization and synchronization
            Queue syncQueue = Queue.Synchronized(reducerDataQueue);
            this.reducerDataQueue = syncQueue;
        }
 public Boolean runTest()
 {
     int iCountErrors = 0;
     int iCountTestcases = 0;
     ArrayList lAdapter = null;
     IEnumerator ienumList = null;
     IEnumerator ienumWrap = null;
     Console.WriteLine( strName + ": " + strTest + " runTest started..." );
     Console.WriteLine( "To run the test in verbose mode try /v" );
     if ( strActiveBugs.Length != 0 )
     {
         Console.WriteLine( "ACTIVE BUGS " + strActiveBugs );
     }
     ++iCountTestcases;
     if ( verbose ) Console.Error.WriteLine( "[] check for ArgumentNullException when argument null" );
     try
     {
         lAdapter = ArrayList.Adapter( null );
     }
     catch ( ArgumentNullException )
     {}
     catch (Exception ex)
     {
         Console.WriteLine( "Err_001a, unexpected exception " + ex.ToString() );
         ++iCountErrors;
     }
     ++iCountTestcases;
     if ( verbose ) Console.Error.WriteLine( "[] make sure changes Through listAdapter show up in list" );
     try
     {
         ArrayList tempList = new ArrayList();
         for ( int i = 0; i < 10; i++ )
         {
             tempList.Add( i.ToString() + " from before" );
         }
         lAdapter = ArrayList.Adapter( tempList );
         lAdapter.Reverse(0, lAdapter.Count);
         int j = 9;
         for ( int i = 0; i < lAdapter.Count; i++ )
         {
             if ( ! lAdapter[i].Equals( j.ToString() + " from before" ) )
             {
                 Console.WriteLine( "Err_002b,  Element from listadapter '" + lAdapter[i] + "' should equal element from ilist '" + j.ToString() + " from before' but it does not" );
                 ++iCountErrors;
             }
             j--;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine( "Err_002a,  unexpected exception " + ex.ToString() );
         ++iCountErrors;
     }
     ++iCountTestcases;
     if ( verbose ) Console.Error.WriteLine( "[] make sure changes Through list show up in listAdapter" );
     try
     {
         ArrayList tempList = new ArrayList();
         for ( int i = 0; i < 10; i++ )
         {
             tempList.Add( i.ToString() + " from before" );
         }
         lAdapter = ArrayList.Adapter( tempList );
         tempList.Clear();
         if ( lAdapter.Count != 0 )
         {
             Console.WriteLine( "Err_003b,  listadapter does not have changes made to templist should have count 0 but has count " + lAdapter.Count );
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine( "Err_003a,  unexpected exception " + ex.ToString() );
         ++iCountErrors;
     }
     ++iCountTestcases;
     if ( verbose ) Console.Error.WriteLine( "[] test to see if enumerators are correctly enumerate through elements" );
     try
     {
         ArrayList tempList = new ArrayList();
         for ( int i = 0; i < 10; i++ )
         {
             tempList.Add( i.ToString() );
         }
         ienumList = tempList.GetEnumerator();
         lAdapter = ArrayList.Adapter( tempList );
         ienumWrap = tempList.GetEnumerator();
         int j = 0;
         while ( ienumList.MoveNext() )
         {
             if ( ! ienumList.Current.Equals( j.ToString() ) )
             {
                 Console.WriteLine( "Err_004a,  enumerator on list expected to return " + j + " but returned " + ienumList.Current );
                 ++iCountErrors;
             }
             j++;
         }
         j = 0;
         while ( ienumWrap.MoveNext() )
         {
             if ( ! ienumWrap.Current.Equals( j.ToString() ) )
             {
                 Console.WriteLine( "Err_004b,  enumerator on listadapter expected to return " + j + " but returned " + ienumWrap.Current );
                 ++iCountErrors;
             }
             j++;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine( "Err_004c,  unexpected exception " + ex.ToString() );
         ++iCountErrors;
     }
     ++iCountTestcases;
     if ( verbose ) Console.Error.WriteLine( "[] test to see if enumerators are correctly enumerate through elements" );
     try
     {
         ArrayList tempList = new ArrayList();
         for ( int i = 0; i < 10; i++ )
         {
             tempList.Add( i.ToString() );
         }
         ienumList = tempList.GetEnumerator();
         lAdapter = ArrayList.Adapter( tempList );
         ienumWrap = tempList.GetEnumerator();
         int j = 0;
         while ( ienumList.MoveNext() )
         {
             if ( ! ienumList.Current.Equals( j.ToString() ) )
             {
                 Console.WriteLine( "Err_004a,  enumerator on list expected to return " + j + " but returned " + ienumList.Current );
                 ++iCountErrors;
             }
             j++;
         }
         j = 0;
         while ( ienumWrap.MoveNext() )
         {
             if ( ! ienumWrap.Current.Equals( j.ToString() ) )
             {
                 Console.WriteLine( "Err_004b,  enumerator on listadapter expected to return " + j + " but returned " + ienumWrap.Current );
                 ++iCountErrors;
             }
             j++;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine( "Err_004c,  unexpected exception " + ex.ToString() );
         ++iCountErrors;
     }
     ++iCountTestcases;
     if ( verbose ) Console.Error.WriteLine( "[] test to see if enumerators are correctly getting invalidated with list modified through list" );
     try
     {
         ArrayList tempList = new ArrayList();
         for ( int i = 0; i < 10; i++ )
         {
             tempList.Add( i.ToString() );
         }
         ienumList = tempList.GetEnumerator();
         lAdapter = ArrayList.Adapter( tempList );
         ienumWrap = tempList.GetEnumerator();
         ienumList.MoveNext();
         ienumWrap.MoveNext();
         tempList.Add( "Hey this is new element" );
         try
         {
             ienumList.MoveNext();
             Console.WriteLine( "Err_006b, ienumList.MoveNext should have thrown since list was modified" );
             ++iCountErrors;
         }
         catch ( InvalidOperationException )
         {}
         try
         {
             ienumWrap.MoveNext();
             Console.WriteLine( "Err_006c, ienumWrap.MoveNext should have thrown since list was modified" );
             ++iCountErrors;
         }
         catch ( InvalidOperationException )
         {}
     }
     catch (Exception ex)
     {
         Console.WriteLine( "Err_006c,  unexpected exception " + ex.ToString() );
         ++iCountErrors;
     }
     ++iCountTestcases;
     if ( verbose ) Console.Error.WriteLine( "[] test to see if enumerators are correctly getting invalidated with list modified through listAdapter" );
     try
     {
         ArrayList tempList = new ArrayList();
         for ( int i = 0; i < 10; i++ )
         {
             tempList.Add( i.ToString() );
         }
         ienumList = tempList.GetEnumerator();
         lAdapter = ArrayList.Adapter( tempList );
         ienumWrap = tempList.GetEnumerator();
         ienumList.MoveNext();
         ienumWrap.MoveNext();
         lAdapter.Add( "Hey this is new element" );
         try
         {
             ienumList.MoveNext();
             Console.WriteLine( "Err_007b, ienumList.MoveNext should have thrown since list was modified" );
             ++iCountErrors;
         }
         catch ( InvalidOperationException )
         {}
         try
         {
             ienumWrap.MoveNext();
             Console.WriteLine( "Err_007c, ienumWrap.MoveNext should have thrown since list was modified" );
             ++iCountErrors;
         }
         catch ( InvalidOperationException )
         {}
     }
     catch (Exception ex)
     {
         Console.WriteLine( "Err_007c,  unexpected exception " + ex.ToString() );
         ++iCountErrors;
     }
     ++iCountTestcases;
     if ( verbose ) Console.Error.WriteLine( "[] to see if listadaptor modified using InsertRange works" );
     try
     {
         ArrayList tempList = new ArrayList();
         for ( int i = 0; i < 10; i++ )
         {
             tempList.Add( i.ToString() );
         }
         lAdapter = ArrayList.Adapter ( tempList );
         ArrayList tempListSecond = new ArrayList();
         for ( int i = 10; i < 20; i++ )
         {
             tempListSecond.Add( i.ToString() );
         }
         lAdapter.InsertRange( lAdapter.Count, tempListSecond );
         if ( lAdapter.Count != 20 )
         {
             Console.WriteLine( "Err_008a,  lAdapter should have had count 20 but had count " + lAdapter.Count );
             ++iCountErrors;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine( "Err_008b,  unexpected exception " + ex.ToString() );
         ++iCountErrors;
     }
     Console.Error.Write( strName );
     Console.Error.Write( ": " );
     if ( iCountErrors == 0 )
     {
         Console.Error.WriteLine( strTest + " iCountTestcases==" + iCountTestcases.ToString() + " paSs" );
         return true;
     }
     else
     {
         Console.WriteLine( strTest + " FAiL");
         Console.Error.WriteLine( strTest + " iCountErrors==" + iCountErrors.ToString() );
         return false;
     }
 }
Example #57
0
        public void testLobSeekWrite6()
        {
            String str = "Hello, world!";

            byte[] bytes = System.Text.Encoding.Default.GetBytes(str);

            int       begin   = 1024 * 3 + 11;
            int       step    = 1024 * 4 * 2;
            int       max     = 1024 * 256;
            ArrayList posList = new ArrayList();

            for (int pos = begin; pos <= max; pos += step)
            {
                posList.Add(pos);
            }

            Random    rand     = new Random(DateTime.Now.Millisecond);
            ArrayList writePos = new ArrayList(posList);

            ObjectId id  = ObjectId.GenerateNewId();
            DBLob    lob = cl.CreateLob(id);

            while (writePos.Count != 0)
            {
                int         index = rand.Next(writePos.Count);
                IEnumerator ie    = writePos.GetEnumerator(index, 1);
                ie.MoveNext();
                int pos = (int)ie.Current;
                writePos.RemoveAt(index);
                lob.Seek(pos, DBLob.SDB_LOB_SEEK_SET);
                lob.Write(bytes);
            }
            lob.Close();

            long lobSize = lob.GetSize();

            DBCursor     cursor = cl.ListLobs();
            BsonDocument obj    = cursor.Next();

            Assert.IsNotNull(obj);
            ObjectId oid = obj.GetValue("Oid").AsObjectId;

            Assert.AreEqual(id, oid);
            Assert.IsNull(cursor.Next());

            lob = cl.OpenLob(id);
            Assert.AreEqual(lobSize, lob.GetSize());

            ArrayList readPos = new ArrayList(posList);

            while (readPos.Count != 0)
            {
                int index = rand.Next(readPos.Count);
                Console.WriteLine("index is: " + index);
                IEnumerator ie = readPos.GetEnumerator(index, 1);
                ie.MoveNext();
                int pos = (int)ie.Current;
                readPos.RemoveAt(index);
                lob.Seek(pos, DBLob.SDB_LOB_SEEK_SET);
                byte[] bytes2 = new byte[str.Length];
                lob.Read(bytes2);
                String str2 = System.Text.Encoding.Default.GetString(bytes2);
                Assert.AreEqual(str, str2);
            }
            lob.Close();

            cl.RemoveLob(id);
            cursor = cl.ListLobs();
            Assert.IsNull(cursor.Next());
        }