GetEnumerator() публичный Метод

public GetEnumerator ( ) : System.Collections.Specialized.StringEnumerator
Результат System.Collections.Specialized.StringEnumerator
 private static bool CheckFileNameUsingPaths(string fileName, StringCollection paths, out string fullFileName)
 {
     fullFileName = null;
     string str = fileName.Trim(new char[] { '"' });
     FileInfo info = new FileInfo(str);
     if (str.Length != info.Name.Length)
     {
         if (info.Exists)
         {
             fullFileName = info.FullName;
         }
         return info.Exists;
     }
     using (StringEnumerator enumerator = paths.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             string str3 = enumerator.Current + Path.DirectorySeparatorChar + str;
             FileInfo info2 = new FileInfo(str3);
             if (info2.Exists)
             {
                 fullFileName = str3;
                 return true;
             }
         }
     }
     return false;
 }
Пример #2
0
 public void analyzeShortTermMemory()
 {
     purifyBotsMind();
     StringCollection sc = new StringCollection();
     botsMemory.Clear();
     if(fullPathName == "")
         sc = readBrainFile();
     else
         sc = readBrainFile(fullPathName);
     StringEnumerator ii = sc.GetEnumerator();
     while(ii.MoveNext())
     {
         if(!botsMemory.Contains(parseForThoughts(ii.Current)))
             botsMemory.Add(parseForThoughts(ii.Current), parseForWords(ii.Current));
     }
     writeToLogFile("Number of memo entries", botsMemory.Count.ToString());
     memorySize = botsMemory.Count;
     return;
 }
Пример #3
0
        /// <summary>
        /// Searches the StringCollection for the item's imagepath
        /// </summary>
        /// <param name="key">SL created key representing the Folder or Item</param>
        /// <param name="stringc">StringCollection of the current ImageLog file</param>
        /// <returns></returns>
        public static string Findfilepath(string key, StringCollection stringc)
        {
            string path = "";
            //Look for the entire line
            StringEnumerator SCE = stringc.GetEnumerator();
            while (SCE.MoveNext())
            {
                if (SCE.Current.Contains(key))
                    path = SCE.Current;
            }

            path = path.Substring(path.IndexOf(","), path.Length).Trim();

            return path;
        }
Пример #4
0
 //write brain file to disc
 protected void writeBrainFile(StringCollection memoryBuffer)
 {
     if(fullPathName != "")
     {
         writeBrainFile(memoryBuffer, fullPathName);
         return;
     }
     File.Delete(filePath);
     FileStream fs = new FileStream(filePath , FileMode.OpenOrCreate, FileAccess.Write);
     StreamWriter sw = new StreamWriter(fs);
     sw.BaseStream.Seek(0, SeekOrigin.End);
     System.Collections.Specialized.StringEnumerator ii = memoryBuffer.GetEnumerator();
     while(ii.MoveNext())
     {
         string dat = ii.Current;
         sw.WriteLine(dat);
     }
     sw.Flush();
     sw.Close();
     fs.Close();
 }
Пример #5
0
            /// <summary>
            /// Custom MessageBox call. Excepts some random objects from IronPython and converts to string.
            /// </summary>
            /// <param name="inobject">Output object from IronPython.</param>
            public static void MessageBoxIronPy(Object inobject)
            {
                Type itstype = inobject.GetType();

                switch (itstype.FullName)
                {
                    case "IronPython.Runtime.PythonDictionary":
                        //PythonDictionary IPDict = new PythonDictionary();
                       // IPDict = (PythonDictionary)inobject;
                       // MessageBox.Show(IPDict.ToString());
                        break;
                    case "IronPython.Runtime.List":
                       // List IPList = new List();
                      //  IPList = (List)inobject;
                       // MessageBox.Show(IPList.ToString());
                        break;
                    case "System.String":
                        MessageBox.Show(inobject.ToString());
                        break;
                    case "System.Int32":
                        MessageBox.Show(Convert.ToString(inobject));
                        break;
                    case "System.Collections.Specialized.StringCollection":
                        StringCollection IPSC = new StringCollection();
                        IPSC = (StringCollection)inobject;
                        StringEnumerator SCE = IPSC.GetEnumerator();
                        string output = "";
                        while (SCE.MoveNext())
                            output += SCE.Current.ToString();
                        MessageBox.Show(output);
                        break;
                    default:
                        MessageBox.Show(inobject.GetType().ToString() + " not yet implemented.");
                        break;
                }
            }
Пример #6
0
        /// <summary>
        /// Returns aa ArrayList from a StringCollection  
        /// </summary>
        /// <param name="StringColin">Incoming StringCollection.</param>
        public ArrayList Convert_StringCollectiontoArrayList(StringCollection StringColin)
        {
            ArrayList newArrayList = new ArrayList();

            StringEnumerator myEnumerator = StringColin.GetEnumerator();
            while (myEnumerator.MoveNext())
                newArrayList.Add(myEnumerator.Current.ToString());

            return newArrayList;
        }
Пример #7
0
        /// <summary>
        /// Returns a string retrieved from a StringCollection.
        /// </summary>
        /// <param name="inCol">StringCollection to be searched.</param>
        /// <param name="index">index of StringCollection to retrieve.</param>
        public string GetStringCollectValue(StringCollection inCol, int index)
        {
            string value = "";
            int count = 0;
            var myEnumerator = inCol.GetEnumerator();
            while (myEnumerator.MoveNext())
            {
                if (index == count)
                {
                    value = myEnumerator.Current;
                }

                count = count + 1;
            }

            return value;
        }
Пример #8
0
        public void Test01()
        {
            StringCollection sc;
            StringEnumerator en;

            string curr;        // Eumerator.Current value

            // simple string values
            string[] values =
            {
                "a",
                "aa",
                "",
                " ",
                "text",
                "     spaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            // [] StringCollection GetEnumerator()
            //-----------------------------------------------------------------

            sc = new StringCollection();

            // [] Enumerator for empty collection
            //
            en = sc.GetEnumerator();
            string type = en.GetType().ToString();
            if (type.IndexOf("StringEnumerator", 0) == 0)
            {
                Assert.False(true, string.Format("Error, type is not StringEnumerator"));
            }

            //
            //  MoveNext should return false
            //
            bool res = en.MoveNext();
            if (res)
            {
                Assert.False(true, string.Format("Error, MoveNext returned true"));
            }

            //
            //  Attempt to get Current should result in exception
            //
            Assert.Throws<InvalidOperationException>(() => { curr = en.Current; });

            //
            //   Filled collection
            // [] Enumerator for filled collection
            //
            sc.AddRange(values);

            en = sc.GetEnumerator();
            type = en.GetType().ToString();
            if (type.IndexOf("StringEnumerator", 0) == 0)
            {
                Assert.False(true, string.Format("Error, type is not StringEnumerator"));
            }

            //
            //  MoveNext should return true
            //

            for (int i = 0; i < sc.Count; i++)
            {
                res = en.MoveNext();
                if (!res)
                {
                    Assert.False(true, string.Format("Error, MoveNext returned false", i));
                }

                curr = en.Current;
                if (String.Compare(curr, sc[i]) != 0)
                {
                    Assert.False(true, string.Format("Error, Current returned \"{1}\" instead of \"{2}\"", i, curr, sc[i]));
                }
                // while we didn't MoveNext, Current should return the same value
                string curr1 = en.Current;
                if (String.Compare(curr, curr1) != 0)
                {
                    Assert.False(true, string.Format("Error, second call of Current returned different result", i));
                }
            }

            // next MoveNext should bring us outside of the collection
            //
            res = en.MoveNext();
            res = en.MoveNext();
            if (res)
            {
                Assert.False(true, string.Format("Error, MoveNext returned true"));
            }

            //
            //  Attempt to get Current should result in exception
            //
            Assert.Throws<InvalidOperationException>(() => { curr = en.Current; });

            en.Reset();

            //
            //  Attempt to get Current should result in exception
            //
            Assert.Throws<InvalidOperationException>(() => { curr = en.Current; });

            //
            //  [] Modify collection when enumerating
            //
            if (sc.Count < 1)
                sc.AddRange(values);

            en = sc.GetEnumerator();
            res = en.MoveNext();
            if (!res)
            {
                Assert.False(true, string.Format("Error, MoveNext returned false"));
            }
            int cnt = sc.Count;
            sc.RemoveAt(0);
            if (sc.Count != cnt - 1)
            {
                Assert.False(true, string.Format("Error, didn't remove 0-item"));
            }

            // will return just removed item
            curr = en.Current;
            if (String.Compare(curr, values[0]) != 0)
            {
                Assert.False(true, string.Format("Error, current returned {0} instead of {1}", curr, values[0]));
            }

            // exception expected
            Assert.Throws<InvalidOperationException>(() => { res = en.MoveNext(); });
        }
Пример #9
0
    /// <summary>
    /// Extract flags, named and numbered parameters from a string array of arguments
    /// </summary>
    /// <param name="named">The found named parameters</param>
    /// <param name="numbered">The found numbered parameters</param>
    /// <param name="input">The arguments</param>
    /// <param name="flags">Allowed flags to find</param>
    public static void ExtractParameters(out StringDictionary named, out string[] numbered, string[] input, string[] flags)
    {
      named = new StringDictionary();
      StringCollection numberedColl = new StringCollection();
      StringCollection args = new StringCollection();
      args.AddRange(input);

      // Pull out flags first
      if (flags != null)
      {
        for (int i = 0; i < flags.Length; i++)
        {
          int ind = -1;
          if ((ind = args.IndexOf("-" + flags[i])) >= 0)
          {
            named.Add(flags[i], string.Empty);
            //	args.RemoveAt(ind);
            args[ind] = null;
          }
        }
      }

      // pull out named parameters
      StringEnumerator e = args.GetEnumerator();
      string name = string.Empty;
      while (e.MoveNext())
      {
        if (e.Current != null)
        {
          if (name != string.Empty)
          {
            string nextname = string.Empty;
            string value = e.Current;
            if (value == null)
              value = string.Empty;

            if (value.StartsWith("-") && value.Length > 1)
            {
              nextname = value.Substring(1);
              value = string.Empty;
            }

            if (value.StartsWith("\\-"))
              value = "-" + value.Substring(2);

            named.Add(name, value);

            if (nextname != string.Empty)
              name = nextname;
            else
              name = string.Empty;
          }
          else if (e.Current.StartsWith("-") && e.Current.Length > 1)
            name = e.Current.Substring(1);
          else
          {
            string value = e.Current;
            if (value.StartsWith("\\-"))
              value = "-" + value.Substring(2);

            numberedColl.Add(value);
          }
        }
        else
        {
          if (name != string.Empty)
          {
            named.Add(name, string.Empty);
            name = string.Empty;
          }
        }
      }

      if (name != string.Empty)
        named.Add(name, string.Empty);

      // Pull out numbered parameters
      numbered = new string[numberedColl.Count];
      numberedColl.CopyTo(numbered, 0);
    }
 private bool FindUser(StringCollection users, string principal)
 {
     using (StringEnumerator enumerator = users.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             if (string.Equals(enumerator.Current, principal, StringComparison.OrdinalIgnoreCase))
             {
                 return true;
             }
         }
     }
     return false;
 }
Пример #11
0
 private void ProcessRemoteUrls(DiscoveryClientProtocol client, StringCollection urls, XmlSchemas schemas, ServiceDescriptionCollection descriptions)
 {
     StringEnumerator enumerator = urls.GetEnumerator();
     while (enumerator.MoveNext())
     {
         string current = enumerator.Current;
         try
         {
             DiscoveryDocument document = client.DiscoverAny(current);
             client.ResolveAll();
             continue;
         }
         catch (Exception exception)
         {
             throw new InvalidOperationException("General Error " + current, exception);
         }
     }
     IDictionaryEnumerator enumerator2 = client.Documents.GetEnumerator();
     while (enumerator2.MoveNext())
     {
         DictionaryEntry entry = (DictionaryEntry)enumerator2.Current;
         this.AddDocument((string)entry.Key, entry.Value, schemas, descriptions);
     }
 }
Пример #12
0
 private void ProcessLocalPaths(DiscoveryClientProtocol client, StringCollection localPaths, XmlSchemas schemas, ServiceDescriptionCollection descriptions)
 {
     StringEnumerator enumerator = localPaths.GetEnumerator();
     while (enumerator.MoveNext())
     {
         string current = enumerator.Current;
         string extension = Path.GetExtension(current);
         if (string.Compare(extension, ".discomap", true) == 0)
         {
             client.ReadAll(current);
         }
         else
         {
             object document = null;
             if (string.Compare(extension, ".wsdl", true) == 0)
             {
                 document = this.ReadLocalDocument(false, current);
             }
             else
             {
                 if (string.Compare(extension, ".xsd", true) != 0)
                 {
                     throw new InvalidOperationException("Unknown file type " + current);
                 }
                 document = this.ReadLocalDocument(true, current);
             }
             if (document != null)
             {
                 this.AddDocument(current, document, schemas, descriptions);
             }
         }
     }
 }
Пример #13
0
		private void AppendSwitchFileCollection(StringWriter writer, string name, StringCollection collection)
		{
			if (collection != null)
			{
				StringEnumerator enumerator = collection.GetEnumerator();
				while (enumerator.MoveNext())
				{
					string item = enumerator.Current;
					AppendSwitchFileIfNotNull(writer, name, item);
				}
			}
		}
        private SvnLookOutputParser(StringCollection infoLines, StringCollection changedLines, StringCollection diffLines)
        {
            StringEnumerator strings = infoLines.GetEnumerator();
            strings.MoveNext();  // move to first
            strings.MoveNext();  // skip first
            FindAuthor(strings);
            FindTimestamp(strings);
            FindLogMessageSize(strings);
            FindLogMessage(strings);

            strings = changedLines.GetEnumerator();
            bool hasMoreLines = SkipBlanks(strings);
            if (!hasMoreLines)
                throw new ArgumentException("Unexpected: no changes recorded, aborting fatally");

            FindChanges(strings);

            if(diffLines != null && diffLines.Count > 0)
            {
                strings = diffLines.GetEnumerator();
                hasMoreLines = SkipBlanks(strings);

                if (hasMoreLines)
                    FillDiffCollection(strings);
            }
        }
Пример #15
0
        /// <summary>
        /// Appends a .inv formatted StringCollection to the OrderedDictionary OD_MyInventory
        /// </summary>
        /// <param name="SC_inv">.inv formatted StringCollection</param>
        public static void ConvertToOD(StringCollection SC_inv)
        {
            //Reset the OD_MyInventory
            OD_MyInventory.Clear();
            int icount = 0;

            // Enumerates the elements in the StringCollection.
            StringEnumerator myEnumerator = SC_inv.GetEnumerator();
            while (myEnumerator.MoveNext())
            {
                if (myEnumerator.Current != "")
                {
                    if (GetInvType(myEnumerator.Current) == INV_TYPE.FOLDER)
                    {
                        ///Folder tempf = Folder.Create(myEnumerator.Current);
                        ///Convert to Folder and assign in MD
                        ///OD_MyInventory.Add(tempf.cat_id, Folder.Create(myEnumerator.Current));
                        OD_MyInventory.Add(icount, Folder.Create(myEnumerator.Current));
                    }
                    else if (GetInvType(myEnumerator.Current) == INV_TYPE.ITEM)
                    {
                        ///Item tempi = Item.Create(myEnumerator.Current);
                        if (icount == 16)
                            icount = icount + 0;
                        OD_MyInventory.Add(icount, Item.Create(myEnumerator.Current));
                    }
                    else
                    {
                        MessageBox.Show("ConvertToOD exception: " + myEnumerator.Current + " is INV_TYPE.NULL");
                    }
                }
                icount = icount + 1;
            }
        }
Пример #16
0
        public void Test01()
        {
            StringCollection sc;
            StringEnumerator en;
            string curr;        // Enumerator.Current value
            bool res;           // boolean result of MoveNext()
            // simple string values
            string[] values =
            {
                "a",
                "aa",
                "",
                " ",
                "text",
                "     spaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            // [] StringEnumerator.Reset()
            //-----------------------------------------------------------------

            sc = new StringCollection();

            //
            // [] on Empty Collection
            //

            //
            //  no exception
            //
            en = sc.GetEnumerator();
            en.Reset();

            //
            //  Attempt to get Current should result in exception
            //
            Assert.Throws<InvalidOperationException>(() => { curr = en.Current; });

            //
            // [] Add item to collection and Reset()
            //
            int cnt = sc.Count;
            sc.Add(values[0]);
            if (sc.Count != 1)
            {
                Assert.False(true, string.Format("Error, failed to add item"));
            }

            Assert.Throws<InvalidOperationException>(() => { en.Reset(); });

            //
            // [] on Filled collection
            //
            sc.AddRange(values);
            en = sc.GetEnumerator();

            //
            //  Reset() should not result in any exceptions
            //
            en.Reset();
            en.Reset();

            //
            // [] Move to 0th item and Reset()
            //
            if (!en.MoveNext())
            {
                Assert.False(true, string.Format("Error, MoveNext() returned false"));
            }
            curr = en.Current;
            if (String.Compare(curr, values[0]) != 0)
            {
                Assert.False(true, string.Format("Error, Current returned wrong value"));
            }

            // Reset() and repeat two checks
            en.Reset();
            if (!en.MoveNext())
            {
                Assert.False(true, string.Format("Error, MoveNext() returned false"));
            }
            if (String.Compare(en.Current, curr) != 0)
            {
                Assert.False(true, string.Format("Error, Current returned wrong value"));
            }


            //
            // [] Move to Count/2 item and Reset()
            //
            int ind = sc.Count / 2;

            en.Reset();
            for (int i = 0; i < ind + 1; i++)
            {
                res = en.MoveNext();
                if (!res)
                {
                    Assert.False(true, string.Format("Error, MoveNext returned false", i));
                }

                curr = en.Current;
                if (String.Compare(curr, sc[i]) != 0)
                {
                    Assert.False(true, string.Format("Error, Current returned \"{1}\" instead of \"{2}\"", i, curr, sc[i]));
                }
                // while we didn't MoveNext, Current should return the same value
                string curr1 = en.Current;
                if (String.Compare(curr, curr1) != 0)
                {
                    Assert.False(true, string.Format("Error, second call of Current returned different result", i));
                }
            }

            // Reset() and check 0th item
            en.Reset();
            if (!en.MoveNext())
            {
                Assert.False(true, string.Format("Error, MoveNext() returned false"));
            }
            if (String.Compare(en.Current, sc[0]) != 0)
            {
                Assert.False(true, string.Format("Error, Current returned wrong value"));
            }

            //
            // [] Move to the last item and Reset()
            //
            ind = sc.Count;

            en.Reset();
            for (int i = 0; i < ind; i++)
            {
                res = en.MoveNext();
                if (!res)
                {
                    Assert.False(true, string.Format("Error, MoveNext returned false", i));
                }

                curr = en.Current;
                if (String.Compare(curr, sc[i]) != 0)
                {
                    Assert.False(true, string.Format("Error, Current returned \"{1}\" instead of \"{2}\"", i, curr, sc[i]));
                }
                // while we didn't MoveNext, Current should return the same value
                string curr1 = en.Current;
                if (String.Compare(curr, curr1) != 0)
                {
                    Assert.False(true, string.Format("Error, second call of Current returned different result", i));
                }
            }

            // Reset() and check 0th item
            en.Reset();
            if (!en.MoveNext())
            {
                Assert.False(true, string.Format("Error, MoveNext() returned false"));
            }
            if (String.Compare(en.Current, sc[0]) != 0)
            {
                Assert.False(true, string.Format("Error, Current returned wrong value"));
            }

            //
            // [] Move beyond the last item and Reset()
            //
            en.Reset();
            for (int i = 0; i < ind; i++)
            {
                res = en.MoveNext();
            }
            // next MoveNext should bring us outside of the collection
            //
            res = en.MoveNext();
            res = en.MoveNext();
            if (res)
            {
                Assert.False(true, string.Format("Error, MoveNext returned true"));
            }
            // Reset() and check 0th item
            en.Reset();
            if (!en.MoveNext())
            {
                Assert.False(true, string.Format("Error, MoveNext() returned false"));
            }
            if (String.Compare(en.Current, sc[0]) != 0)
            {
                Assert.False(true, string.Format("Error, Current returned wrong value"));
            }

            //
            //  Attempt to get Current should result in exception
            //
            en.Reset();
            Assert.Throws<InvalidOperationException>(() => { curr = en.Current; });

            //
            // [] Modify collection when enumerating
            //
            if (sc.Count < 1)
                sc.AddRange(values);

            //
            // modify the collection and call Reset() before first MoveNext()
            //
            en = sc.GetEnumerator();
            sc.RemoveAt(0);
            Assert.Throws<InvalidOperationException>(() => { en.Reset(); });

            //
            // Enumerate to the middle item of the collection, modify the collection,
            //  and call Reset()
            //
            // create valid enumerator
            //
            en = sc.GetEnumerator();
            for (int i = 0; i < sc.Count / 2; i++)
            {
                res = en.MoveNext();
            }
            curr = en.Current;
            sc.RemoveAt(0);

            // will return previous current
            if (String.Compare(curr, en.Current) != 0)
            {
                Assert.False(true, string.Format("Error, current returned {0} instead of {1}", en.Current, curr));
            }

            // exception expected
            Assert.Throws<InvalidOperationException>(() => { en.Reset(); });

            //
            // Enumerate to the last item of the collection, modify the collection,
            //  and call Reset()
            //
            // create valid enumerator
            //
            en = sc.GetEnumerator();
            for (int i = 0; i < sc.Count; i++)
            {
                res = en.MoveNext();
            }
            sc.RemoveAt(0);

            // exception expected
            Assert.Throws<InvalidOperationException>(() => { en.Reset(); });

            //
            // [] Modify collection after enumerating beyond the end
            //
            if (sc.Count < 1)
                sc.AddRange(values);

            en = sc.GetEnumerator();
            for (int i = 0; i < sc.Count; i++)
            {
                res = en.MoveNext();
            }
            res = en.MoveNext();              // should be beyond the end
            if (res)
            {
                Assert.False(true, string.Format("Error, MoveNext returned true after moving beyond the end"));
            }

            cnt = sc.Count;
            sc.RemoveAt(0);
            if (sc.Count != cnt - 1)
            {
                Assert.False(true, string.Format("Error, didn't remove 0-item"));
            }

            // exception expected
            Assert.Throws<InvalidOperationException>(() => { en.Reset(); });
        }
Пример #17
0
        private static void ImportSchemasAsClasses(CodeDomProvider codeProvider, System.IO.Stream xsdStream, string ns, string uri, CodeGenerationOptions options, IList elements, StringCollection schemaImporterExtensions)
        {
            XmlSchemas userSchemas = new XmlSchemas();

            Hashtable uris = new Hashtable();
            XmlSchema schema = ReadSchema(xsdStream);

            Uri uri2 = new Uri("http://www.w3.org/2001/XMLSchema/temp");
            uris.Add(schema, uri2);
            userSchemas.Add(schema, uri2);

            Hashtable includeSchemas = new Hashtable();
            Compile(userSchemas, uris, includeSchemas);
            try
            {
                CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
                CodeNamespace namespace2 = new CodeNamespace(ns);
                codeCompileUnit.Namespaces.Add(namespace2);
                GenerateVersionComment(namespace2);
                XmlCodeExporter codeExporter = new XmlCodeExporter(namespace2, codeCompileUnit, codeProvider, options, null);
                XmlSchemaImporter schemaImporter = new XmlSchemaImporter(userSchemas, options, codeProvider, new ImportContext(new CodeIdentifiers(), false));
                schemaImporter.Extensions.Add(new System.Data.DataSetSchemaImporterExtension());

                {
                    StringEnumerator enumerator2 = schemaImporterExtensions.GetEnumerator();
                    {
                        while (enumerator2.MoveNext())
                        {
                            Type type = Type.GetType(enumerator2.Current.Trim(), true, false);
                            schemaImporter.Extensions.Add(type.FullName, type);
                        }
                    }
                }
                AddImports(namespace2, GetNamespacesForTypes(new Type[] { typeof(XmlAttributeAttribute) }));
                for (int i = 0; i < userSchemas.Count; i++)
                {
                    ImportSchemaAsClasses(userSchemas[i], uri, elements, schemaImporter, codeExporter);
                }
                foreach (XmlSchema schema2 in includeSchemas.Values)
                {
                    ImportSchemaAsClasses(schema2, uri, elements, schemaImporter, codeExporter);
                }

                CompilerParameters compilePrams = new CompilerParameters();
                CompilerResults compileResults = codeProvider.CompileAssemblyFromDom(compilePrams, codeCompileUnit);

                if (compileResults.Errors.Count > 0)
                {
                    throw new ArgumentException("Compile Error of " + compileResults.Errors[0].ToString());
                }
                // Feng.Windows.Utils.ReflectionHelper.CreateInstanceFromType(compileResults.CompiledAssembly.GetTypes()[0])

                //CodeTypeDeclarationCollection types = namespace2.Types;
                //CodeGenerator.ValidateIdentifiers(namespace2);
                //TextWriter writer = this.CreateOutputWriter(outputdir, fileName, fileExtension);
                //codeProvider.GenerateCodeFromCompileUnit(codeCompileUnit, writer, null);
                //writer.Close();
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Compile Xsd Error!", ex);
            }
        }
 public StringCollectionReader(StringCollection stringCollection, string newLine)
 {
     stringEnumerator = stringCollection.GetEnumerator();
     this.newLine = newLine ?? Environment.NewLine;
     GetNextLine();
 }
Пример #19
0
 private void InitAvailableStyles()
 {
     int[] numArray = new int[] { 0x44, 0xca };
     int[] numArray2 = new int[2];
     StringCollection strings = new StringCollection();
     strings.AddRange(new string[] { "System.Web.UI.MobileControls.PagerStyle," + Constants.MobileAssemblyFullName, "System.Web.UI.MobileControls.Style," + Constants.MobileAssemblyFullName });
     StringEnumerator enumerator = strings.GetEnumerator();
     while (enumerator.MoveNext())
     {
         Type type = Type.GetType(enumerator.Current, true);
         string[] items = new string[] { type.Name, type.Namespace };
         ListViewItem item = new ListViewItem(items);
         this._lvAvailableStyles.Items.Add(item);
     }
     foreach (string str2 in this._styleSheet.get_Styles())
     {
         Type type2 = this._styleSheet.get_Item(str2).GetType();
         if (!strings.Contains(type2.FullName + "," + type2.Assembly.FullName))
         {
             string[] strArray2 = new string[] { type2.Name, type2.Namespace };
             ListViewItem item2 = new ListViewItem(strArray2);
             this._lvAvailableStyles.Items.Add(item2);
             numArray2[0] = 0x44;
             if (numArray2[0] > numArray[0])
             {
                 numArray[0] = numArray2[0];
             }
             numArray2[1] = 0xca;
             if (numArray2[1] > numArray[1])
             {
                 numArray[1] = numArray2[1];
             }
         }
     }
     this._lvAvailableStyles.Columns[0].Width = numArray[0] + 4;
     this._lvAvailableStyles.Columns[1].Width = numArray[1] + 4;
     this._lvAvailableStyles.Sort();
     this._lvAvailableStyles.Items[0].Selected = true;
     this._currentNewStyleType = Type.GetType(this._lvAvailableStyles.Items[0].SubItems[1].Text + "." + this._lvAvailableStyles.Items[0].Text + ", " + Constants.MobileAssemblyFullName, true);
 }
Пример #20
0
        /// <summary>
        /// Returns a string retrieved from a StringCollection.
        /// </summary>
        /// <param name="inCol">StringCollection to be searched.</param>
        public string StringCollectionTostring(StringCollection inCol)
        {
            string value = "";
            var myEnumerator = inCol.GetEnumerator();
            while (myEnumerator.MoveNext())
            {
                value += myEnumerator.Current;
            }

            return value;
        }
Пример #21
0
 private void LoadDataSourceFields()
 {
     using (new MobileComponentEditorPage.LoadingModeResource(this))
     {
         ObjectList baseControl = base.GetBaseControl();
         this._cmbLabelField.SelectedIndex = -1;
         this._cmbLabelField.Items.Clear();
         this._cmbLabelField.EnsureNotSetItem();
         this._xLists.Clear();
         if (this._currentDataSource != null)
         {
             StringCollection strings = new StringCollection();
             foreach (ObjectListField field in baseControl.get_Fields())
             {
                 this._cmbLabelField.AddItem(field.get_Name());
                 strings.Add(field.get_Name());
             }
             if (baseControl.get_AutoGenerateFields())
             {
                 PropertyDescriptorCollection fields = this._currentDataSource.Fields;
                 if (fields != null)
                 {
                     IEnumerator enumerator = fields.GetEnumerator();
                     while (enumerator.MoveNext())
                     {
                         PropertyDescriptor current = (PropertyDescriptor) enumerator.Current;
                         if (this.IsBindableType(current.PropertyType))
                         {
                             this._cmbLabelField.AddItem(current.Name);
                             strings.Add(current.Name);
                         }
                     }
                 }
             }
             if ((baseControl.get_TableFields() != string.Empty) && !this._dataSourceDirty)
             {
                 char[] separator = new char[] { ';' };
                 foreach (string str in baseControl.get_TableFields().Split(separator))
                 {
                     for (int i = 0; i < strings.Count; i++)
                     {
                         string strB = strings[i];
                         if (string.Compare(str, strB, true) == 0)
                         {
                             this._xLists.AddToSelectedList(strB);
                             strings.RemoveAt(i);
                             break;
                         }
                     }
                 }
             }
             StringEnumerator enumerator3 = strings.GetEnumerator();
             while (enumerator3.MoveNext())
             {
                 string str3 = enumerator3.Current;
                 this._xLists.AddToAvailableList(str3);
             }
             this._xLists.Initialize();
         }
     }
 }
Пример #22
0
        /// <summary>
        /// ImportPaths
        /// </summary>
        /// <param name="arg"></param>
        public void ImportPaths(string arg)
        {
            StringCollection scMiscDirs = new StringCollection();
            scMiscDirs.Add(UIIronTextBox.Paths.MiscDirs.ConceptNet);
            scMiscDirs.Add(UIIronTextBox.Paths.MiscDirs.montylingua);
            scMiscDirs.Add(UIIronTextBox.Paths.MiscDirs.vs_Projects);
            StringEnumerator SCEMiscDirs = scMiscDirs.GetEnumerator();

            StringCollection scPython24Dirs = new StringCollection();
            scPython24Dirs.Add(UIIronTextBox.Paths.Python24Dirs.Python24_DLLs);
            scPython24Dirs.Add(UIIronTextBox.Paths.Python24Dirs.Python24_Lib);
            scPython24Dirs.Add(UIIronTextBox.Paths.Python24Dirs.Python24_Lib_lib_tk);
            scPython24Dirs.Add(UIIronTextBox.Paths.Python24Dirs.Python24_libs);
            scPython24Dirs.Add(UIIronTextBox.Paths.Python24Dirs.Python24_Tools);
            scPython24Dirs.Add(UIIronTextBox.Paths.Python24Dirs.Python24_Tools_Scripts);
            StringEnumerator SCEPython24Dirs = scPython24Dirs.GetEnumerator();

            StringCollection scIronPythonDirs = new StringCollection();
            scIronPythonDirs.Add(UIIronTextBox.Paths.IronPythonDirs.IronPython_Tutorial);
            //scIronPythonDirs.Add(UIIronTextBox.Paths.IronPythonDirs.Runtime);
            StringEnumerator SCEIronPythonDirs = scIronPythonDirs.GetEnumerator();

            //Create All SC
            StringCollection scAll = new StringCollection();
            while (SCEMiscDirs.MoveNext())
            {
                scAll.Add(SCEMiscDirs.Current);
            }
            while (SCEPython24Dirs.MoveNext())
            {
                scAll.Add(SCEPython24Dirs.Current);
            }
            while (SCEIronPythonDirs.MoveNext())
            {
                scAll.Add(SCEIronPythonDirs.Current);
            }
            StringEnumerator SCEAll = scAll.GetEnumerator();

            //Reset Enums
            SCEMiscDirs.Reset();
            SCEPython24Dirs.Reset();
            SCEIronPythonDirs.Reset();

            //Check to see if sys is loaded
            if (!Evaluate("dir()").ToString().Contains("sys"))
            {
                consoleTextBox.PrintPrompt();
                consoleTextBox.WriteText("import sys");
                SimEnter();
            }
            else
                consoleTextBox.PrintPrompt();

            try
            {
                switch (arg)
                {
                    case "misc":
                        {
                            while (SCEMiscDirs.MoveNext())
                            {
                                //consoleTextBox.PrintPrompt();
                                consoleTextBox.WriteText("sys.path.append(\"" + SCEMiscDirs.Current + "\")");
                                SimEnter();
                            }
                            break;
                        }
                    case "python24":
                        {
                            while (SCEPython24Dirs.MoveNext())
                            {
                                //consoleTextBox.PrintPrompt();
                                consoleTextBox.WriteText("sys.path.append(\"" + SCEPython24Dirs.Current + "\")");
                                SimEnter();
                            }
                            break;
                        }
                    case "ironpython":
                        {
                            while (SCEIronPythonDirs.MoveNext())
                            {
                                //consoleTextBox.PrintPrompt();
                                consoleTextBox.WriteText("sys.path.append(\"" + SCEIronPythonDirs.Current + "\")");
                                SimEnter();
                            }
                            break;
                        }
                    case "all":
                        {
                            while (SCEAll.MoveNext())
                            {
                                //consoleTextBox.PrintPrompt();
                                consoleTextBox.WriteText("sys.path.append(\"" + SCEAll.Current + "\")");
                                SimEnter();
                            }
                            break;
                        }
                    case "paths":
                        {
                            while (SCEAll.MoveNext())
                            {
                                //consoleTextBox.PrintPrompt();
                                consoleTextBox.WriteText("sys.path.append(\"" + SCEAll.Current + "\")");
                                SimEnter();
                            }
                            break;
                        }
                    default:
                        consoleTextBox.WriteText("Invalid arg. Only: -misc, -python24, -ironpython, -all");
                        break;
                }
            }
            catch (Exception e)
            {
                // Let the user know what went wrong.
                consoleTextBox.WriteText("ImportPaths error: ");
                consoleTextBox.WriteText(e.Message);
            }
        }
        private void ProcessLocalPaths(DiscoveryClientProtocol client, StringCollection localPaths, XmlSchemas schemas, ServiceDescriptionCollection descriptions)
        {
            var enumerator = localPaths.GetEnumerator();
            while (enumerator.MoveNext())
            {
                var current = enumerator.Current;
                var ext = Path.GetExtension(current);
                object document = null;
                if (string.Compare(ext, ".wsdl", true) == 0)
                {
                    document = ReadLocalDocument(false, current);
                }
                // todo: add support for other file types?

                if (document != null)
                    AddDocument(current, document, schemas, descriptions);
            }
        }