ToArray() private method

private ToArray ( Type type ) : Array
type Type
return Array
コード例 #1
1
		/// <summary>
		/// Creates a NDataReader from a <see cref="IDataReader" />
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader" /> to get the records from the Database.</param>
		/// <param name="isMidstream"><see langword="true" /> if we are loading the <see cref="IDataReader" /> in the middle of reading it.</param>
		/// <remarks>
		/// NHibernate attempts to not have to read the contents of an <see cref="IDataReader"/> into memory until it absolutely
		/// has to.  What that means is that it might have processed some records from the <see cref="IDataReader"/> and will
		/// pick up the <see cref="IDataReader"/> midstream so that the underlying <see cref="IDataReader"/> can be closed 
		/// so a new one can be opened.
		/// </remarks>
		public NDataReader(IDataReader reader, bool isMidstream)
		{
			ArrayList resultList = new ArrayList(2);

			try
			{
				// if we are in midstream of processing a DataReader then we are already
				// positioned on the first row (index=0)
				if (isMidstream)
				{
					currentRowIndex = 0;
				}

				// there will be atleast one result 
				resultList.Add(new NResult(reader, isMidstream));

				while (reader.NextResult())
				{
					// the second, third, nth result is not processed midstream
					resultList.Add(new NResult(reader, false));
				}

				results = (NResult[]) resultList.ToArray(typeof(NResult));
			}
			catch (Exception e)
			{
				throw new ADOException("There was a problem converting an IDataReader to NDataReader", e);
			}
			finally
			{
				reader.Close();
			}
		}
コード例 #2
0
        /// <summary>
        /// 查找知道文件夹下所有数据库的名称集合
        /// </summary>
        /// <param name="strFileName">文件夹名</param>
        /// <returns>返回数据库名称</returns>
        public string[] FindAllMDBOfFile(string strFileName)
        {
            ArrayList alst = new System.Collections.ArrayList();//建立ArrayList对象

            try
            {
                string[] files = Directory.GetFiles(strFileName);                       //得到文件
                foreach (string file in files)                                          //循环文件
                {
                    string exname = file.Substring(file.LastIndexOf(".") + 1);          //得到后缀名
                    if (".mdb".IndexOf(file.Substring(file.LastIndexOf(".") + 1)) > -1) //如果后缀名为.mdb文件
                    {
                        FileInfo fi = new FileInfo(file);                               //建立FileInfo对象
                        alst.Add(fi.FullName);                                          //把.mdb文件全名加人到FileInfo对象
                        fi = null;
                    }
                    alst.Sort();
                }
            }
            catch (Exception ex)
            {
                if (ErrorMessage != null)
                {
                    ErrorMessage(6020004, ex.StackTrace, "[AccessImport:FindAllMDBOfFile]", ex.Message);
                }
                return((string[])alst.ToArray(typeof(string)));
            }
            return((string[])alst.ToArray(typeof(string)));//把ArrayList转化为string[]
        }
コード例 #3
0
 internal bool ImportComComponent(string path, OutputMessageCollection outputMessages, string outputDisplayName)
 {
     ComImporter importer = new ComImporter(path, outputMessages, outputDisplayName);
     if (importer.Success)
     {
         ArrayList list = new ArrayList();
         if (this.typeLibs != null)
         {
             list.AddRange(this.typeLibs);
         }
         if (importer.TypeLib != null)
         {
             list.Add(importer.TypeLib);
         }
         this.typeLibs = (TypeLib[]) list.ToArray(typeof(TypeLib));
         list.Clear();
         if (this.comClasses != null)
         {
             list.AddRange(this.comClasses);
         }
         if (importer.ComClasses != null)
         {
             list.AddRange(importer.ComClasses);
         }
         this.comClasses = (ComClass[]) list.ToArray(typeof(ComClass));
     }
     return importer.Success;
 }
コード例 #4
0
ファイル: Navigator.asmx.cs プロジェクト: killbug2004/WSProf
		public Item[] ListChildrenOf(string url)
		{
			Logger.LogMethod();
			try
			{
				using (new UserImpersonator())
				{
					ArrayList list = new ArrayList();
					object o = SharePointHelper.GetSharePointObject(url);
					if (o is SPWeb)
					{
						using (SPWeb web = o as SPWeb)
						{
							PopulateListOfSubWebs(web, ref list);
							PopulateListOfDocumentLibraries(web, ref list);
							return (Item[]) list.ToArray(typeof(Item));
						}
					}
					else if (o is SPFolder)
					{
                        SPFolder folder = o as SPFolder;
                        PopulateListOfSubfolders( folder, ref list );
                        PopulateListOfFiles( folder, ref list );
						return (Item[]) list.ToArray(typeof(Item));
					}
					return new Item[0];
				}
			}
			catch (Exception ex)
			{
				Logger.LogException(ex.Message, ex);
				throw;
			}
		}
コード例 #5
0
    private void reloadBase() {
      this.removeAll ();

      SideMenu = new ArrayList ();

      Window = new ViewWindow ("");
      Window.setWidth (800);
      Window.setHeight (Screen.height - 200);
      Window.setLeft ((Screen.width-800)/2);
      Window.setTop (100);

      this.addComponent (Window);

      SideMenu.Add(new ViewButton("Current State", LoadCurrentState));
      SideMenu.Add(new ViewButton("Space Stations", LoadSpaceStations));
      SideMenu.Add(new ViewButton("Bases", LoadBases));
      SideMenu.Add(new ViewButton("Sat Coverage", LoadSatelliteCoverage));
      SideMenu.Add(new ViewButton("Science Stations", LoadScienceStations));
      SideMenu.Add(new ViewButton("Mining Rigs", LoadMiningRigs));
      SideMenu.Add(new ViewButton("Rovers", LoadRovers));
      SideMenu.Add(new ViewButton("Kerbals", LoadKerbals));
      SideMenu.Add(new ViewButton("Past Reviews", LoadPastReviews));

      for (var i = 0; i < SideMenu.ToArray ().Length; i++) {
        ViewButton Btn = (ViewButton)SideMenu.ToArray () [i];
        Btn.setRelativeTo (Window);
        Btn.setLeft (10);
        Btn.setTop (10 + i * 45);
        Btn.setWidth (120);
        Btn.setHeight (35);
        this.addComponent (Btn);
      }
    }
コード例 #6
0
        public override ClassDefinition GetClassDefinition(object instance)
        {
            Type type = instance.GetType();
            BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.Instance;
            PropertyInfo[] propertyInfos = type.GetProperties(bindingAttr);
#if !(NET_1_1)
            List<ClassMember> classMemberList = new List<ClassMember>();
#else
            ArrayList classMemberList = new ArrayList();
#endif
            for (int i = 0; i < propertyInfos.Length; i++)
            {
                PropertyInfo propertyInfo = propertyInfos[i];
                if (propertyInfo.Name != "HelpLink" && propertyInfo.Name != "TargetSite")
                {
                    ClassMember classMember = new ClassMember(propertyInfo.Name, bindingAttr, propertyInfo.MemberType, null);
                    classMemberList.Add(classMember);
                }
            }
            string customClassName = type.FullName;
            customClassName = FluorineConfiguration.Instance.GetCustomClass(customClassName);
#if !(NET_1_1)
            ClassMember[] classMembers = classMemberList.ToArray();
#else
			ClassMember[] classMembers = classMemberList.ToArray(typeof(ClassMember)) as ClassMember[];
#endif
			ClassDefinition classDefinition = new ClassDefinition(customClassName, classMembers, GetIsExternalizable(instance), GetIsDynamic(instance));
            return classDefinition;
        }
コード例 #7
0
    private void GetadminGridRows()
    {
        DataTable dt;

        if (ViewState["Data"] != null)
        {
            dt = (DataTable)ViewState["Data"];
        }
        else
        {
            dt = TempTable();
        }
        for (int i = 0; i < adminGrid.Rows.Count; i++)
        {
            CheckBox chk = (CheckBox)adminGrid.Rows[i].Cells[0].FindControl("chk");
            if (chk.Checked)
            {
                dt = AddRow(adminGrid.Rows[i], dt);

                String result = string.Join(",", (string[])emailList.ToArray(Type.GetType("System.String")));
                TextBox1.Text = result;
            }
            else
            {
                dt = RemoveRow(adminGrid.Rows[i], dt);

                String result = string.Join(",", (string[])emailList.ToArray(Type.GetType("System.String")));
                TextBox1.Text = result;
            }
        }
        ViewState["Data"] = dt;
    }
コード例 #8
0
 // Methods
 public void ReadTextStream(TextReader tr, StringBuilder errs)
 {
     GcodeOpCode code = null;
     ArrayList list = new ArrayList();
     ArrayList list2 = new ArrayList();
     long linenum = 1L;
     while (true)
     {
         GcodeToken token;
         do
         {
             token = GcodeToken.ReadToken(tr, errs, linenum);
             if (token.ID == 0xffff)
             {
                 if (code != null)
                 {
                     code.Parameter = (GcodeParameter[])list2.ToArray(typeof(GcodeParameter));
                     list.Add(code);
                 }
                 goto Label_0150;
             }
         }
         while (token.ID == 'N');
         if (token.ID == '\n')
         {
             linenum += 1L;
             if (code != null)
             {
                 code.Parameter = (GcodeParameter[])list2.ToArray(typeof(GcodeParameter));
                 list.Add(code);
                 code = null;
             }
         }
         else if ((token.ID == 'G') || (token.ID == 'M'))
         {
             if (code != null)
             {
                 code.Parameter = (GcodeParameter[])list2.ToArray(typeof(GcodeParameter));
                 list.Add(code);
             }
             code = new GcodeOpCode(string.Format("{0}{1:02}", token.ID, token.Value.ToString("00")));
             list2.Clear();
         }
         else
         {
             if (code == null)
             {
                 code = new GcodeOpCode(GcodeOpCode.OpCodes.Unknown);
             }
             GcodeParameter parameter = new GcodeParameter(token);
             if (parameter.OpCode != GcodeOpCode.OpCodes.Unknown)
             {
                 list2.Add(parameter);
             }
         }
     }
     Label_0150:
     this.GCodes = (GcodeOpCode[])list.ToArray(typeof(GcodeOpCode));
 }
    /// <summary>
    /// Sections:
    /// GUIVideoArtistInfo, FanArt, IMDBposter, IMDBActors,
    /// IMPAwardsposter, TMDBPosters, TMDBActorImages
    /// IMDBActorInfoMain, IMDBActorInfoDetails, IMDBActorInfoMovies
    /// </summary>
    /// <param name="section"></param>
    /// <returns></returns>
    public static string[] GetParserStrings(string section)
    {
      ArrayList result = new ArrayList();
      
      try
      {
        string parserIndexFile = Config.GetFile(Config.Dir.Config, "scripts\\VDBParserStrings.xml");
        string parserIndexUrl = @"http://install.team-mediaportal.com/MP1/VDBParserStrings.xml";
        XmlDocument doc = new XmlDocument();
        
        if (!File.Exists(parserIndexFile))
        {
          if (DownloadFile(parserIndexFile, parserIndexUrl) == false)
          {
            string parserIndexFileBase = Config.GetFile(Config.Dir.Base, "VDBParserStrings.xml");

            if (File.Exists(parserIndexFileBase))
            {
              File.Copy(parserIndexFileBase, parserIndexFile, true);
            }
            else
            {
              return result.ToArray(typeof(string)) as string[];
            }
          }
        }

        doc.Load(parserIndexFile);

        if (doc.DocumentElement != null)
        {
          string sec = "/section/" + section;
          XmlNode dbSections = doc.DocumentElement.SelectSingleNode(sec);
          
          if (dbSections == null)
          {
            return result.ToArray(typeof(string)) as string[];
          }

          XmlNodeList parserStrings = dbSections.SelectNodes("string");

          if (parserStrings != null)
          {
            foreach (XmlNode parserString in parserStrings)
            {
              result.Add(parserString.InnerText);
            }
          }
        }
      }
      catch (Exception ex)
      {
        Log.Error(ex.Message);
      }
      return result.ToArray(typeof(string)) as string[];
    }
コード例 #10
0
ファイル: AddBlogPost.aspx.cs プロジェクト: sffogg/Xenosynth
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (!IsPostBack) {
         IList galleries = CmsImageGallery.FindAllRoot();
         ArrayList paths = new ArrayList();
         foreach (CmsImageGallery g in galleries) {
             paths.Add(g.FullPath);
         }
         TextBoxText.ImagesPaths = (string[])paths.ToArray(typeof(string));
         TextBoxText.UploadImagesPaths = (string[])paths.ToArray(typeof(string));
     }
 }
コード例 #11
0
ファイル: ScriptCompiler.cs プロジェクト: zydronium/TigerMUD
        /// <summary>
        /// Returns all the Command and Action objects from an Assembly.
        /// </summary>
        /// <param name="Code">String containing the source code.</param>
        /// <returns>Objects in an array.</returns>
        private Object[] GetObjectsFromAssembly(System.Reflection.Assembly ScriptAssembly, out string errors)
        {
            errors = "";
            System.Collections.ArrayList ScriptArray = new System.Collections.ArrayList();
            if (ScriptAssembly == null)
            {
                return(null);
            }

            try
            {
                foreach (Type type in ScriptAssembly.GetTypes())
                {
                    try
                    {
                        if (type.GetInterface("ICommand") != null)
                        {
                            ICommand Command = (Command)Activator.CreateInstance(type);
                            ScriptArray.Add(Command);
                        }
                        if (type.GetInterface("IAction") != null)
                        {
                            IAction Action = (Action)Activator.CreateInstance(type);
                            ScriptArray.Add(Action);
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("Failed to get Objects from Assembly.  Exception: " + ex.Message + ex.StackTrace + ex.StackTrace);
                    }
                }
            }
            catch (ReflectionTypeLoadException e)
            {
                foreach (Exception ex in e.LoaderExceptions)
                {
                    Lib.PrintLine("ReflectionTypeLoadException in ScriptLoader: GetObjectsFromAssembly crashed with the error: " + ex.Message + ex.StackTrace + ex.StackTrace);
                }
                return((Object[])ScriptArray.ToArray(typeof(Object)));
            }
            catch (Exception ex)
            {
                Lib.PrintLine("Exception in ScriptCompiler: GetObjectsFromAssembly crashed with the error: " + ex.Message + ex.StackTrace + ex.StackTrace);
                return((Object[])ScriptArray.ToArray(typeof(Object)));
            }

            return((Object[])ScriptArray.ToArray(typeof(Object)));
        }
コード例 #12
0
        public DateTime[] GetTipTimes(string inFile)
        {
            ArrayList tipTimes = new ArrayList();
            //open file

            if (!File.Exists(inFile))
            {
                throw new Exception("file doesn't exist");
            }

            // Open the file to read from.for each line, add tip time to an array
            using (StreamReader sr = File.OpenText(inFile))
            {
                string s = "";
                while ((s = sr.ReadLine()) != null)
                {
                    if(DateIsValid(s))
                    {
                        tipTimes.Add(DateTime.Parse(s));
                    }
                    else
                        Debug.WriteLine(s);
                }
            }

            return tipTimes.ToArray(Type.GetType("System.DateTime")) as DateTime [];
        }
コード例 #13
0
        public void Initialize(bool _includeDrafts)
        {
            // get the list of blogs, determine how many items we will be displaying,
            // and then have that drive the view mode
            string[] blogIds = BlogSettings.GetBlogIds();
            int itemCount = (_includeDrafts ? 1 : 0) + 1 + blogIds.Length;
            _showLargeIcons = itemCount <= 5;

            // configure owner draw
            DrawMode = DrawMode.OwnerDrawFixed;
            SelectionMode = SelectionMode.One;
            HorizontalScrollbar = false;
            IntegralHeight = false;
            ItemHeight = CalculateItemHeight(_showLargeIcons);

            // populate list
            if (_includeDrafts)
                _draftsIndex = Items.Add(new PostSourceItem(new LocalDraftsPostSource(), this));
            _recentPostsIndex = Items.Add(new PostSourceItem(new LocalRecentPostsPostSource(), this));

            ArrayList blogs = new ArrayList();
            foreach (string blogId in BlogSettings.GetBlogIds())
            {
                blogs.Add(new PostSourceItem(Res.Get(StringId.Blog), new RemoteWeblogBlogPostSource(blogId), this));
            }
            blogs.Sort();
            Items.AddRange(blogs.ToArray());
        }
コード例 #14
0
        public WebsiteInstaller()
        {
            InstallerInfo info = InstallerInfo.GetInstallerInfo();

            // Add a default one that we can always fall back to
            EventLogInstaller myEventLogInstaller = new EventLogInstaller();
            myEventLogInstaller.Source = InstallerInfo.DefaultEventLogSource;
            Installers.Add(myEventLogInstaller);

            foreach (EventLogInfo source in info.EventLogInfos)
            {
                myEventLogInstaller = new EventLogInstaller();
                myEventLogInstaller.Source = source.Source;
                Installers.Add(myEventLogInstaller);
            }

            foreach (PerformanceCounterCategoryInfo performanceCounter in info.PerformanceCounterCategoryInfos)
            {
                PerformanceCounterInstaller myCounterInstaller = new PerformanceCounterInstaller();
                myCounterInstaller.CategoryHelp = performanceCounter.CategoryHelp;
                myCounterInstaller.CategoryName = performanceCounter.CategoryName;
                ArrayList counters = new ArrayList();
                foreach (CounterCreationDataInfo creationDataInfo in performanceCounter.CounterCreationDataInfos)
                    counters.Add(new CounterCreationData(creationDataInfo.CounterName, creationDataInfo.CounterHelp,
                                                         creationDataInfo.CounterType));

                myCounterInstaller.Counters.AddRange(
                    (CounterCreationData[]) counters.ToArray(typeof (CounterCreationData)));
                Installers.Add(myCounterInstaller);
            }
        }
コード例 #15
0
//		/// <summary>
//		/// </summary>
//		/// <returns></returns>
//		public static string getPathName()
//		{
//			//return DocsPaWebService.Path + "\\report";
//			string basePathFiles = System.Configuration.ConfigurationManager.AppSettings["REPORTS_PATH"];
//			basePathFiles = basePathFiles.Replace("%DATA", DateTime.Now.ToString("yyyyMMdd"));
//
//			return basePathFiles;
//		}
        #endregion

        /// <summary>
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static byte[] toByteArray(string str)
        {
            char[] charArray = str.ToCharArray();
            System.Collections.ArrayList byteArr = new System.Collections.ArrayList();
            //byte[] res=new byte[charArray.Length];
            for (int i = 0; i < charArray.Length; i++)
            {
                if ((int)charArray[i] > 255)
                {
                    string utf      = "\\u" + ((int)charArray[i]) + "G";
                    char[] utfChars = utf.ToCharArray();
                    for (int j = 0; j < utfChars.Length; j++)
                    {
                        byteArr.Add((byte)utfChars[j]);
                    }
                }
                else
                {
                    byteArr.Add((byte)charArray[i]);
                }
                //res[i]=(byte) charArray[i];
            }
            byte[] res = (byte[])byteArr.ToArray(typeof(byte));
            return(res);
        }
コード例 #16
0
        //yawn don't feel like fully cleaning it...
        //inputs may contain any combination of input per each item
        //ie, i,>,A,A>,S,etc
        //so a straight comparison won't do, it has to be checked char by char
        //now, if it finds a bad char, should it remove it, or drop the input entirely?
        //and in any case, if th euser inserted two equal inputs (even with unordered chars)
        //we should find out and remove the duplicates
        //YAWN
        public void CleanInputList(ref string[] inputs)
        {
            string allowedInputs = GetUsableInputsAsString();

            System.Collections.ArrayList inputsArray = new System.Collections.ArrayList();
            bool missed;

            for (int i = 0; i < inputs.Length; i++)
            {
                if (inputs[i] == "i")
                {
                    inputsArray.Add("");
                    continue;
                }
                missed = false;
                for (int k = 0; k < inputs[i].Length; k++)
                {
                    if (allowedInputs.IndexOfAny(inputs[i][k].ToString().ToCharArray()) > -1)
                    {
                        continue;
                    }
                    missed = true;
                    break;
                }
                if (!missed)
                {
                    inputsArray.Add(inputs[i]);
                }
            }
            inputs = (string[])inputsArray.ToArray(typeof(string));
        }
コード例 #17
0
        /// <summary>
        /// List转DataTable
        /// </summary>
        /// <param name="list">列表</param>
        /// <returns></returns>
        public static DataTable ToDataTable(System.Collections.IList list)
        {
            DataTable dataTable = new DataTable();

            if (list.Count > 0)
            {
                System.Reflection.PropertyInfo[] properties = list[0].GetType().GetProperties();
                System.Reflection.PropertyInfo[] array      = properties;
                for (int i = 0; i < array.Length; i++)
                {
                    System.Reflection.PropertyInfo propertyInfo = array[i];
                    if (!DxPublic.IsNullableType(propertyInfo.PropertyType))
                    {
                        dataTable.Columns.Add(propertyInfo.Name, propertyInfo.PropertyType);
                    }
                }
                for (int j = 0; j < list.Count; j++)
                {
                    System.Collections.ArrayList     arrayList = new System.Collections.ArrayList();
                    System.Reflection.PropertyInfo[] array2    = properties;
                    for (int k = 0; k < array2.Length; k++)
                    {
                        System.Reflection.PropertyInfo propertyInfo2 = array2[k];
                        if (!DxPublic.IsNullableType(propertyInfo2.PropertyType))
                        {
                            object value = propertyInfo2.GetValue(list[j], null);
                            arrayList.Add(value);
                        }
                    }
                    object[] values = arrayList.ToArray();
                    dataTable.LoadDataRow(values, true);
                }
            }
            return(dataTable);
        }
コード例 #18
0
        private void caricaAttributiDisponibili()
        {
            for (int i = 1; i <= 5; i++)
            {
                //				DropDownList ddlControl;
                //				ddlControl=(DropDownList)this.FindControl("DDLFiltro"+i.ToString());
                //				ddlControl.DataSource = Enum.GetNames(typeof(DocsPAWA.DocsPaWR.FiltriFascicolazione));
                //				ddlControl.DataMember="";
                //				ddlControl.DataBind();

                DropDownList ddlControl  = (DropDownList)this.FindControl("DDLFiltro" + i.ToString());
                string[]     arrayFiltri = Enum.GetNames(typeof(DocsPAWA.DocsPaWR.FiltriFascicolazione));
                if (ConfigSettings.getKey(ConfigSettings.KeysENUM.VISUALIZZA_ID_LEG) != null &&
                    ConfigSettings.getKey(ConfigSettings.KeysENUM.VISUALIZZA_ID_LEG).Equals("1"))
                {
                    Utils.populateDdlWithEnumValuesANdKeys(ddlControl, arrayFiltri);
                }
                else
                {
                    System.Collections.ArrayList arrayFiltriCorr = new System.Collections.ArrayList();
                    for (int j = 0; j < arrayFiltri.Length; j++)
                    {
                        if (!arrayFiltri[j].Equals("CODICE_LEGISLATURA"))
                        {
                            arrayFiltriCorr.Add(arrayFiltri[j]);
                        }
                    }
                    string[] arrayFiltri1 = (string[])arrayFiltriCorr.ToArray(typeof(string));
                    Utils.populateDdlWithEnumValuesANdKeys(ddlControl, arrayFiltri1);
                }
            }
        }
コード例 #19
0
        /// <summary>
        /// Poll the DoW Playback folder for new replays
        /// </summary>
        /// <param name="resursive"></param>
        /// <returns>Returns an array of objects holding the filename and hashcode of each replay</returns>
        public object[] PollPlaybackFolder(bool resursive)
        {
            string[] files = null;
            try
            {
                files = Directory.GetFiles(DoWPlaybackFolder, "*.rec");
            }
            catch
            {
                MessageBox.Show(null, "It appears as if your DoWPlaybackFolder setting is incorrect. Please change it in the DoWRM.exe.Config file.", "Playback folder incorrect...", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            System.Collections.ArrayList list = new System.Collections.ArrayList();

            if (files != null)
            {
                foreach (string file in files)
                {
                    FileStream fs   = File.OpenRead(file);
                    byte[]     data = new byte[fs.Length];
                    fs.Read(data, 0, data.Length);
                    fs.Close();

                    MD5    md5  = new MD5CryptoServiceProvider();
                    byte[] hash = md5.ComputeHash(data);

                    ReplayHash replayHash = new ReplayHash();
                    replayHash.Filename = file;
                    replayHash.HashCode = hash;
                    list.Add(replayHash);
                }
            }

            return(list.ToArray());
        }
コード例 #20
0
ファイル: DnsMx.cs プロジェクト: argodev/AzureGACViewer
        public static string[] GetMXRecords(string domain)
        {
            IntPtr ptr1 = IntPtr.Zero;
            IntPtr ptr2 = IntPtr.Zero;
            MXRecord recMx;

            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
                throw new NotSupportedException();

            ArrayList list1 = new ArrayList();
            int num1 = DnsMx.DnsQuery(ref domain, QueryTypes.DNS_TYPE_MX, QueryOptions.DNS_QUERY_BYPASS_CACHE, 0, ref ptr1, 0);
            if (num1 != 0)
                throw new Win32Exception(num1);

            for (ptr2 = ptr1; !ptr2.Equals(IntPtr.Zero); ptr2 = recMx.pNext)
            {
                recMx = (MXRecord)Marshal.PtrToStructure(ptr2, typeof(MXRecord));
                if (recMx.wType == 15)
                {
                    string text1 = Marshal.PtrToStringAuto(recMx.pNameExchange);
                    list1.Add(text1);
                }
            }

            DnsMx.DnsRecordListFree(ptr1, 0);
            return (string[])list1.ToArray(typeof(string));
        }
コード例 #21
0
        public RandomVariable GetRandomVariable(object owner, IContextLookup globalVars)
        {
            Domain objDomain;

            switch (DomainType)
            {
            case RandomVariableDomainType.Boolean:
                objDomain = new BooleanDomain();
                break;

            case RandomVariableDomainType.FiniteInteger:

                objDomain =
                    new FiniteIntegerDomain(IntValues.ConvertAll <Integer>(intObj => new Integer(intObj)).ToArray());
                break;

            case RandomVariableDomainType.ArbitraryToken:
                var enumerable = ArbitraryValues.EvaluateTyped(owner, globalVars);
                var asList     = new System.Collections.ArrayList();
                foreach (object o in enumerable)
                {
                    asList.Add(o);
                }
                objDomain =
                    new ArbitraryTokenDomain(asList.ToArray());
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(new RandVar(Name, objDomain));
        }
コード例 #22
0
 ///<summary>
 ///</summary>
 ///<param name="args"></param>
 public CommandLine(string[] args)
 {
     ArrayList list = new ArrayList();
     for (int i = 0; i < args.Length; i++)
     {
         char ch = args[i][0];
         if ((ch != '/') && (ch != '-'))
         {
             list.Add(args[i]);
         }
         else
         {
             int index = args[i].IndexOf(':');
             if (index == -1)
             {
                 string strA = args[i].Substring(1);
                 if ((string.Compare(strA, "help", StringComparison.OrdinalIgnoreCase) == 0) || strA.Equals("?"))
                 {
                     _showHelp = true;
                 }
                 else
                 {
                     Options[strA] = string.Empty;
                 }
             }
             else
             {
                 Options[args[i].Substring(1, index - 1)] = args[i].Substring(index + 1);
             }
         }
     }
     _arguments = (string[]) list.ToArray(typeof (string));
 }
コード例 #23
0
        public string[] GetFileList(string SourcePath, bool Subdir)
        {
            SourcePath = SourcePath.Trim().TrimEnd(new char[] { Path.DirectorySeparatorChar });
            string sourceDir  = null;
            string fileFilter = "*";

            if (Directory.Exists(SourcePath))
            {             // Source is a Directory
                sourceDir = SourcePath;
            }
            else if (Directory.Exists(Path.GetDirectoryName(SourcePath)))
            {             // Source is a File Filter
                sourceDir  = Path.GetDirectoryName(SourcePath);
                fileFilter = Path.GetFileName(SourcePath);
            }
            else
            {             // Source not found
                throw new DirectoryNotFoundException("Cannot find \"" + Path.GetDirectoryName(SourcePath) + "\".");
            }

            System.Collections.ArrayList fileList = new System.Collections.ArrayList();
            fileList.AddRange(System.IO.Directory.GetFiles(sourceDir, fileFilter));
            if (Subdir)
            {
                foreach (string subDir in System.IO.Directory.GetDirectories(sourceDir))
                {
                    fileList.AddRange(GetFileList(Path.Combine(subDir, fileFilter), Subdir));
                }
            }

            return((string[])fileList.ToArray(Type.GetType("System.String")));
        }
コード例 #24
0
    public static Hashtable GetHashByEntityIDs(int contact_type_group_id, int[] entity_ids, int contact_type_id = -1, int site_id = -1, bool orderByShippingBeforeBilling = false)
    {
        Contact[] list = GetByEntityIDs(contact_type_group_id, entity_ids, contact_type_id, site_id, orderByShippingBeforeBilling);
        System.Collections.Hashtable hash = new System.Collections.Hashtable();
        for (int i = 0; i < list.Length; i++)
        {
            if (hash[list[i].EntityID] == null)
            {
                hash[list[i].EntityID] = new System.Collections.ArrayList();
            }
            ((System.Collections.ArrayList)hash[list[i].EntityID]).Add(list[i]);
        }

        System.Collections.ArrayList keys = new System.Collections.ArrayList();
        foreach (int key in hash.Keys)
        {
            keys.Add(key);
        }
        for (int i = 0; i < keys.Count; i++)
        {
            System.Collections.ArrayList item = (System.Collections.ArrayList)hash[(int)keys[i]];
            hash[(int)keys[i]] = (Contact[])item.ToArray(typeof(Contact));
        }

        return(hash);
    }
コード例 #25
0
 public static string[] AllSites()
 {
     ArrayList allSites = new ArrayList();
     allSites.AddRange(BatchSearchSites);
     string[] allSitesArray = (string[]) allSites.ToArray(typeof (string));
     return allSitesArray;
 }
コード例 #26
0
ファイル: LogComponentImpl.cs プロジェクト: qwinner/NetBPM
		public IList FindProcessInstances(DateTime startedAfter, DateTime startedBefore, String initiatorActorId, String actorId, Int64 processDefinitionId, Relations relations, DbSession dbSession)
		{
			IList processInstances = null;
			String query = queryFindAllProcessInstances;
			ArrayList parameters = new ArrayList();
			ArrayList types = new ArrayList();

			if (startedAfter != DateTime.MinValue)
			{
				query += "and pi.StartNullable > ? ";
				parameters.Add(startedAfter);
				types.Add(DbType.DATE);
			}

			if (startedBefore != DateTime.MinValue)
			{
				query += "and pi.StartNullable < ? ";
				parameters.Add(startedBefore);
				types.Add(DbType.DATE);
			}

			if (initiatorActorId != null && initiatorActorId != "")
			{
				query += "and pi.InitiatorActorId = ? ";
				parameters.Add(initiatorActorId);
				types.Add(DbType.STRING);
			}

			if (actorId != null && actorId != "")
			{
				query += "and f.ActorId = ? ";
				parameters.Add(actorId);
				types.Add(DbType.STRING);
			}

			if (processDefinitionId != 0)
			{
				query += "and pi.ProcessDefinition.Id = ? ";
				parameters.Add(processDefinitionId);
				types.Add(DbType.LONG);
			}

			query += "order by pi.StartNullable desc";

			log.Debug("query for searching process instances : '" + query + "'");

			Object[] parameterArray = parameters.ToArray();
			IType[] typeArray = (IType[]) types.ToArray(typeof (IType));

			processInstances = dbSession.Find(query, parameterArray, typeArray);

			if (relations != null)
			{
				relations.Resolve(processInstances);
			}

			log.Debug("process instances : '" + processInstances + "'");

			return processInstances;
		}
コード例 #27
0
		public static string[] Split( string src, char delimiter, params char[] quotedelims )
		{
			ArrayList		strings = new ArrayList();
			StringBuilder	sb = new StringBuilder();
			ArrayList		ar = new ArrayList(quotedelims);
			char			quote_open = Char.MinValue;

			foreach (char c in src) 
			{
				if (c == delimiter && quote_open == Char.MinValue) 
				{
					strings.Add( sb.ToString() );
					sb.Remove( 0, sb.Length );
				}
					
				else if (ar.Contains(c)) 
				{
					if (quote_open == Char.MinValue)
						quote_open = c;
					else if (quote_open == c)
						quote_open = Char.MinValue;
					sb.Append(c);
				}
				else
					sb.Append( c );
			}

			if (sb.Length > 0)
				strings.Add( sb.ToString());

			return (string[])strings.ToArray(typeof(string));
		}
コード例 #28
0
ファイル: TreasureMessage.cs プロジェクト: greeduomacro/annox
        private static void LoadLocations()
        {
            string filePath = Path.Combine(Core.BaseDirectory, "Data/treasure.cfg");

            ArrayList list = new ArrayList();
            ArrayList havenList = new ArrayList();

            if (File.Exists(filePath))
            {
                using (StreamReader ip = new StreamReader(filePath))
                {
                    string line;

                    while ((line = ip.ReadLine()) != null)
                    {
                        try
                        {
                            string[] split = line.Split(' ');

                            int x = Convert.ToInt32(split[0]), y = Convert.ToInt32(split[1]);

                            Point2D loc = new Point2D(x, y);
                            list.Add(loc);
                        }
                        catch
                        {
                        }
                    }
                }
            }

            m_Locations = (Point2D[])list.ToArray(typeof(Point2D));
        }
コード例 #29
0
		public static PropertyDescriptorCollection GetMethodProperties( object obj )
		{
			System.Type type = obj.GetType();

			if ( obj is MethodPropertyDescriptor.MethodPropertyValueHolder )
			{
				MethodPropertyDescriptor.MethodPropertyValueHolder mobj = obj as MethodPropertyDescriptor.MethodPropertyValueHolder;
//				if ( mobj.Method.IsVoidMethdod )
//					return null;
				return mobj.Method.GetChildProperties( null, null );
			}

			MethodInfo[] methods = type.GetMethods ( BindingFlags.Instance|BindingFlags.InvokeMethod|BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.FlattenHierarchy );

			ArrayList methodDesc = new ArrayList();
			
			for ( int i = 0; i < methods.Length; i++ )
			{
				MethodInfo method = methods[i];
				if ( /*method.IsPublic &&*/ !method.IsSpecialName )
				{
					methodDesc.Add( new MethodPropertyDescriptor( obj, method ) );
				}
			}

			methodDesc.Sort( new MethodNameComparer() );

			MethodPropertyDescriptor[] methodsDesc = (MethodPropertyDescriptor[])methodDesc.ToArray ( typeof(MethodPropertyDescriptor));
			return new PropertyDescriptorCollection(methodsDesc);
		}
コード例 #30
0
		/// <summary>
		/// parse the config section
		/// </summary>
		/// <param name="parent"></param>
		/// <param name="configContext"></param>
		/// <param name="section"></param>
		/// <returns>an array of <see cref="MemCacheConfig"/> objects</returns>
		public object Create(object parent, object configContext, XmlNode section)
		{
			var configs = new ArrayList();
			if (section != null)
			{
				XmlNodeList nodes = section.SelectNodes("memcached");
				foreach (XmlNode node in nodes)
				{
					XmlAttribute h = node.Attributes["host"];
					XmlAttribute p = node.Attributes["port"];
					XmlAttribute w = node.Attributes["weight"];
					if (h == null || p == null)
					{
						if (log.IsWarnEnabled)
						{
							log.Warn("incomplete node found - each memcached element must have a 'host' and a 'port' attribute.");
						}
						continue;
					}
					string host = h.Value;
					int port = ((string.IsNullOrEmpty(p.Value)) ? 0 : Convert.ToInt32(p.Value));
					int weight = ((w == null || string.IsNullOrEmpty(w.Value)) ? 0 : Convert.ToInt32(w.Value));
					configs.Add(new MemCacheConfig(host, port, weight));
				}
			}
			return configs.ToArray(typeof (MemCacheConfig));
		}
コード例 #31
0
ファイル: OneWireBus.cs プロジェクト: janmechan/Gadgeteer
        public static Device[] Scan(OneWire ow, params Family[] includeFamilies)
        {
            var addr = new byte[8];
            var list = new ArrayList();
            var all = false;
            var devs = ow.FindAllDevices();

            if (includeFamilies != null)
            {
                foreach (var f in includeFamilies)
                {
                    if (f == Family.Unknown)
                        all = true;
                }
            }

            foreach (byte[] da in devs)
            {
                if (includeFamilies == null || includeFamilies.Length == 0 || all)
                {
                    list.Add(new Device(da));
                }
                else
                {
                    foreach (var f in includeFamilies)
                    {
                        if (addr[0] == (byte)f)
                            list.Add(new Device(da));
                    }
                }
            }

            return (Device[])list.ToArray(typeof(Device));
        }
コード例 #32
0
ファイル: Variant.cs プロジェクト: neobox3000/UA-.NET
        /// <summary>
        /// Returns the object stored in the Variant (makes a copy).
        /// </summary>
        public object ToObject()
        {
            if (Value == null || Value.Nodes == null || Value.Nodes.Length == 0)
            {
                return(null);
            }

            XmlElement parent = Value.Nodes[0] as XmlElement;

            if (parent == null)
            {
                return(null);
            }

            if (parent.Name.StartsWith("ListOf"))
            {
                System.Collections.ArrayList elements = new System.Collections.ArrayList();

                for (XmlNode child = parent.FirstChild; child != null; child = child.NextSibling)
                {
                    XmlElement element = child as XmlElement;

                    if (element != null)
                    {
                        object value = ToObject(element);
                        elements.Add(value);
                    }
                }

                Type elementType = GetTypeFromXmlName(parent.Name.Substring("ListOf".Length));
                return(elements.ToArray(elementType));
            }

            return(ToObject(parent));
        }
コード例 #33
0
        /// <summary>
        /// Parse and filter the supplied modifications.  The position of each modification in the list is used as the ChangeNumber.
        /// </summary>
        /// <param name="history"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public Modification[] Parse(TextReader history, DateTime from, DateTime to)
        {
            StringReader sr = new StringReader(string.Format(@"<ArrayOfModification xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">{0}</ArrayOfModification>"
                , history.ReadToEnd()));

            XmlSerializer serializer = new XmlSerializer(typeof(Modification[]));
            Modification[] mods;
            try
            {
                mods = (Modification[])serializer.Deserialize(sr);
            }
            catch (Exception ex)
            {
                throw new CruiseControlException("History Parsing Failed", ex);
            }

            ArrayList results = new ArrayList();
            int change = 0;
            foreach (Modification mod in mods)
            {
                change++;
                mod.ChangeNumber = change;
                if ((mod.ModifiedTime >= from) & (mod.ModifiedTime <= to))
                {
                    results.Add(mod);
                }
            }
            return (Modification[])results.ToArray(typeof(Modification));
        }
コード例 #34
0
 /// <summary>
 /// Prepare realtime inputs, and place them in an understandable one jagged input neuron array.
 /// you can use this method if you have many inputs and need to format them as inputs with a specified "window"/input size.
 /// You can add as many inputs as wanted to this input layer (parametrable inputs).
 /// </summary>
 /// <param name="inputsize">The inputsize.</param>
 /// <param name="firstinputt">The firstinputt.</param>
 /// <returns>a ready to use jagged array with all the inputs setup.</returns>
 public static double[][] AddInputs(int inputsize, params double[][] firstinputt)
 {
     ArrayList arlist = new ArrayList(4);
     ArrayList FirstList = new ArrayList();
     List<double> listused = new List<double>();
     int lenghtofArrays = firstinputt[0].Length;
     //There must be NO modulo...or the arrays would not be divisile by this input size.
     if (lenghtofArrays % inputsize != 0)
         return null;
     //we add each input one , after the other in a list of doubles till we reach the input size
     for (int i = 0; i < lenghtofArrays; i++)
     {
         for (int k = 0; k < firstinputt.Length; k++)
         {
             if (listused.Count < inputsize * firstinputt.Length)
             {
                 listused.Add(firstinputt[k][i]);
                 if (listused.Count == inputsize * firstinputt.Length)
                 {
                     FirstList.Add(listused.ToArray());
                     listused.Clear();
                 }
             }
         }
     }
     return (double[][])FirstList.ToArray(typeof(double[]));
 }
コード例 #35
0
ファイル: Encryption.cs プロジェクト: RobertUJ/App_Web_VM
        public static string Text_Decryption(string text, int bits, string encryption_key)
        {
            string result = String.Empty;
            ArrayList list = new ArrayList();

            try
            {
                RSACryptoServiceProvider rsacsp = new RSACryptoServiceProvider(bits);
                rsacsp.FromXmlString(encryption_key);
                int blockSizeBase64 = (bits / 8 % 3 != 0) ?  (((bits / 8) / 3) * 4) + 4 : ((bits / 8) / 3) * 4;
                int iterations = text.Length / blockSizeBase64;

                for (int i = 0; i < iterations; i++)
                {
                    Byte[] encrypted_bytes = Convert.FromBase64String(text.Substring(blockSizeBase64 * i, blockSizeBase64));
                    Array.Reverse(encrypted_bytes);
                    list.AddRange(rsacsp.Decrypt(encrypted_bytes, true));
                }

            }
            catch (Exception e)
            {
                result = "<Error>" + e.Message + "</Error>";
            }

            result = Encoding.UTF32.GetString((Byte[])list.ToArray(typeof(Byte)));

            return result;
        }
コード例 #36
0
        public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) {
            var result = fsResult.Success;

            // Verify that we actually have an List
            if ((result += CheckType(data, fsDataType.Array)).Failed) {
                return result;
            }

            Type elementType = storageType.GetElementType();

            var serializedList = data.AsList;
            var list = new ArrayList(serializedList.Count);
            int existingCount = list.Count;

            for (int i = 0; i < serializedList.Count; ++i) {
                var serializedItem = serializedList[i];
                object deserialized = null;
                if (i < existingCount) deserialized = list[i];

                var itemResult = Serializer.TryDeserialize(serializedItem, elementType, ref deserialized);
                result.AddMessages(itemResult);
                if (itemResult.Failed) continue;

                if (i < existingCount) list[i] = deserialized;
                else list.Add(deserialized);
            }

            instance = list.ToArray(elementType);
            return result;
        }
コード例 #37
0
ファイル: HtmlElement.cs プロジェクト: Skinny1001/PlayUO
 public static HtmlElement[] GetElements(string text)
 {
     ArrayList list = new ArrayList();
     int startIndex = 0;
     int index = 0;
     int num3 = 0;
     while (true)
     {
         num3 = index;
         startIndex = text.IndexOf('<', index);
         if (startIndex == -1)
         {
             list.Add(new HtmlElement(text.Substring(num3), ElementType.Text, null));
             break;
         }
         index = text.IndexOf('>', startIndex + 1);
         if (index == -1)
         {
             list.Add(new HtmlElement(text.Substring(num3), ElementType.Text, null));
             break;
         }
         if (startIndex != num3)
         {
             list.Add(new HtmlElement(text.Substring(num3, startIndex - num3), ElementType.Text, null));
         }
         index++;
         list.Add(Parse(text.Substring(startIndex, index - startIndex)));
     }
     return (HtmlElement[]) list.ToArray(typeof(HtmlElement));
 }
コード例 #38
0
        private void EnsureRelevantMethodsAreVirtual(Type service, Type implementation)
        {
            if (service.IsInterface) return;

            MethodInfo[] methods = implementation.GetMethods( 
                BindingFlags.Instance|BindingFlags.Public|BindingFlags.DeclaredOnly );

            ArrayList problematicMethods = new ArrayList();

            foreach( MethodInfo method in methods )
            {
                if (!method.IsVirtual && method.IsDefined( typeof(PermissionAttribute), true ))
                {
                    problematicMethods.Add( method.Name );
                }
            }
			
            if (problematicMethods.Count != 0)
            {
                String[] methodNames = (String[]) problematicMethods.ToArray( typeof(String) );

                String message = String.Format( "The class {0} wants to use security interception, " + 
                    "however the methods must be marked as virtual in order to do so. Please correct " + 
                    "the following methods: {1}", implementation.FullName, String.Join(", ", methodNames) );

                throw new FacilityException(message);
            }
        }
コード例 #39
0
        // Methods
        public new void Execute(CopyItemsArgs args)
        {
            Event.RaiseEvent("item:bucketing:cloning", args, this);
            Assert.ArgumentNotNull(args, "args");
            var items = GetItems(args);
            if (args.IsNotNull())
            {
                var itemId = args.Parameters["destination"];
                if (itemId.IsNotNull())
                {
                    var database = GetDatabase(args);
                    if (database.GetItem(itemId).IsBucketItemCheck())
                    {
                        var list = new ArrayList();
                        foreach (var item3 in from item2 in items
                                              where item2.IsNotNull()
                                              let item = BucketManager.CreateAndReturnDateFolderDestination(database.GetItem(itemId), item2)
                                              let copyOfName = ItemUtil.GetCopyOfName(item, item2.Name)
                                              select item2.CloneTo(item, copyOfName, true))
                        {
                            list.Add(item3);
                        }

                        args.Copies = list.ToArray(typeof(Item)) as Item[];
                        Event.RaiseEvent("item:bucketing:cloned", args, this);
                        args.AbortPipeline();
                    }
                }
            }
        }
コード例 #40
0
		//rewritten by Corillian so if it doesn't work you know who to yell at ;)
		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			byte grouped = (byte)packet.ReadByte();
			ArrayList list = new ArrayList();
			if (grouped != 0x00)
			{
				ArrayList groups = GroupMgr.ListGroupByStatus(0x00);
				if (groups != null)
				{
					foreach (Group group in groups)
						if (GameServer.ServerRules.IsAllowedToGroup(group.Leader, client.Player, true))
						{
							list.Add(group.Leader);
						}
				}
			}

			ArrayList Lfg = GroupMgr.LookingForGroupPlayers();

			if (Lfg != null)
			{
				foreach (GamePlayer player in Lfg)
				{
					if (player != client.Player && GameServer.ServerRules.IsAllowedToGroup(client.Player, player, true))
					{
						list.Add(player);
					}
				}
			}

			client.Out.SendFindGroupWindowUpdate((GamePlayer[])list.ToArray(typeof(GamePlayer)));
		}
コード例 #41
0
    public static Hashtable GetBulkInvoiceLinesByInvoiceID(Invoice[] invoices)
    {
        Hashtable hash = new Hashtable();

        int[] invoiceIDs = new int[invoices.Length];
        for (int i = 0; i < invoices.Length; i++)
        {
            invoiceIDs[i] = invoices[i].InvoiceID;
        }
        InvoiceLine[] allInvoiceLines = InvoiceLineDB.GetByInvoiceIDs(invoiceIDs);

        foreach (Invoice curInvoice in invoices)
        {
            System.Collections.ArrayList curInvoiceLines = new System.Collections.ArrayList();
            for (int i = 0; i < allInvoiceLines.Length; i++)
            {
                if (allInvoiceLines[i].InvoiceID == curInvoice.InvoiceID)
                {
                    curInvoiceLines.Add(allInvoiceLines[i]);
                }
            }

            hash[curInvoice.InvoiceID] = (InvoiceLine[])curInvoiceLines.ToArray(typeof(InvoiceLine));
        }

        return(hash);
    }
コード例 #42
0
		private void SelectLightmapUsers(object userData, string[] options, int selected)
		{
			int num = (int)userData;
			ArrayList arrayList = new ArrayList();
			MeshRenderer[] array = UnityEngine.Object.FindObjectsOfType(typeof(MeshRenderer)) as MeshRenderer[];
			MeshRenderer[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				MeshRenderer meshRenderer = array2[i];
				if (meshRenderer != null && meshRenderer.lightmapIndex == num)
				{
					arrayList.Add(meshRenderer.gameObject);
				}
			}
			Terrain[] array3 = UnityEngine.Object.FindObjectsOfType(typeof(Terrain)) as Terrain[];
			Terrain[] array4 = array3;
			for (int j = 0; j < array4.Length; j++)
			{
				Terrain terrain = array4[j];
				if (terrain != null && terrain.lightmapIndex == num)
				{
					arrayList.Add(terrain.gameObject);
				}
			}
			Selection.objects = (arrayList.ToArray(typeof(UnityEngine.Object)) as UnityEngine.Object[]);
		}
コード例 #43
0
        public System.Collections.DictionaryEntry[] GetAttributes()
        {
            string strDataLine   = null;
            int    intElementEnd = 0;

            string[] strAttributes = null;
            string[] strSplit      = null;
            string   strName       = null;
            string   strValue      = null;

            System.Collections.ArrayList objAttributes = new System.Collections.ArrayList();
            intElementEnd = mstrInput.Substring(mintCurrentPosition).IndexOfAny(new char[] { '>', '<', '/' });
            strDataLine   = mstrInput.Substring(mintCurrentPosition, intElementEnd);
            strAttributes = strDataLine.Split(' ');
            foreach (string strAttribute in strAttributes)
            {
                if (strAttribute != string.Empty)
                {
                    strSplit = strAttribute.Split('=');
                    if (strSplit.Length == 2)
                    {
                        strName  = strSplit[0];
                        strValue = strSplit[1];
                        // remove quotes
                        strValue.Trim('"');
                        objAttributes.Add(new System.Collections.DictionaryEntry(strName, strValue));
                    }
                }
            }
            return((System.Collections.DictionaryEntry[])objAttributes.ToArray(typeof(System.Collections.DictionaryEntry)));
        }
コード例 #44
0
        public string[] GetSelectableNames(string prefixText)
        {
            ArrayList items = new ArrayList();

            Encoding e = Encoding.GetEncoding("shift_jis");
            string str = HttpUtility.UrlEncode(prefixText, e);
            XmlDocument document = new XmlDocument();
            XmlReader reader = XmlReader.Create("http://api.kakaku.com/Ver1/ItemSearch.asp?Keyword=" + str + "&CategoryGroup=ALL&ResultSet=medium&SortOrder=popularityrank&PageNum=1");
            document.Load(reader);
            XmlNodeList nodeList = document.SelectNodes(@"/ProductInfo/Item");
            foreach (XmlNode node in nodeList)
            {
                ProductItem productItem = new ProductItem();
                foreach (XmlNode attrnode in node)
                {
                    switch (attrnode.Name)
                    {
                        case "ProductID":
                            productItem.ProductID = attrnode.InnerText;
                            break;
                        case "ProductName":
                            productItem.ProductName = attrnode.InnerText;
                            break;
                    }
                }

                items.Add(productItem.ProductID + ": " + productItem.ProductName);
            }

            return (String[])items.ToArray(typeof(String));
        }
コード例 #45
0
 /// <summary>
 /// ?????
 /// </summary>
 /// <param name="str">???????</param>
 /// <returns>???????</returns>
 public static string DecryptString(string str)
 {
     try
     {
         if ((str.Length % 4) != 0)
         {
             throw new ArgumentException("?????BASE64??,????", "str");
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(str, "^[A-Z0-9/+=]*$", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
         {
             throw new ArgumentException("??????BASE64??,????", "str");
         }
         string Base64Code = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";
         int    page       = str.Length / 4;
         System.Collections.ArrayList outMessage = new System.Collections.ArrayList(page * 3);
         char[] message = str.ToCharArray();
         for (int i = 0; i < page; i++)
         {
             byte[] instr = new byte[4];
             instr[0] = (byte)Base64Code.IndexOf(message[i * 4]);
             instr[1] = (byte)Base64Code.IndexOf(message[i * 4 + 1]);
             instr[2] = (byte)Base64Code.IndexOf(message[i * 4 + 2]);
             instr[3] = (byte)Base64Code.IndexOf(message[i * 4 + 3]);
             byte[] outstr = new byte[3];
             outstr[0] = (byte)((instr[0] << 2) ^ ((instr[1] & 0x30) >> 4));
             if (instr[2] != 64)
             {
                 outstr[1] = (byte)((instr[1] << 4) ^ ((instr[2] & 0x3c) >> 2));
             }
             else
             {
                 outstr[2] = 0;
             }
             if (instr[3] != 64)
             {
                 outstr[2] = (byte)((instr[2] << 6) ^ instr[3]);
             }
             else
             {
                 outstr[2] = 0;
             }
             outMessage.Add(outstr[0]);
             if (outstr[1] != 0)
             {
                 outMessage.Add(outstr[1]);
             }
             if (outstr[2] != 0)
             {
                 outMessage.Add(outstr[2]);
             }
         }
         byte[] outbyte = (byte[])outMessage.ToArray(Type.GetType("System.Byte"));
         return(System.Text.Encoding.Default.GetString(outbyte));
     }
     catch
     {
         return("");
     }
 }
コード例 #46
0
ファイル: clsPublic.cs プロジェクト: ewin66/HIS
        public long m_lngGetSampleCodes(string p_strCheckNO, out string[] p_strSampleCodeArr)
        {
            p_strSampleCodeArr = null;
            if (p_strCheckNO == null)
            {
                return(-1);
            }

            long lngRes = -1;

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

                    lngRes = 1;
                }
                catch (Exception ex)
                {
                    lngRes             = 0;
                    p_strSampleCodeArr = null;
                }
            }
            else
            {
                try
                {
                    int intCehckNOLength = p_strCheckNO.Length;
                    if (System.Math.IEEERemainder(intCehckNOLength, m_intSampleCodeLength) != 0)
                    {
                        return(-1);
                    }
                    int intCount = intCehckNOLength / m_intSampleCodeLength;
                    p_strSampleCodeArr = new string[intCount];
                    for (int i = 0; i < intCount; i++)
                    {
                        p_strSampleCodeArr[i] = p_strCheckNO.Substring(i * m_intSampleCodeLength, m_intSampleCodeLength);
                    }
                    lngRes = 1;
                }
                catch (Exception ex)
                {
                    lngRes             = 0;
                    p_strSampleCodeArr = null;
                }
            }
            return(lngRes);
        }
コード例 #47
0
        private static DayFolderNode[] GetDayFolderInformation(FileSystemInfo[] fia)
        {
            if (fia == null || fia.Length < 1)
            {
                return(null);
            }

            System.Collections.ArrayList ret = new System.Collections.ArrayList();

            DayFolderNode dfn;

            HourFolderNode[] hours = null;

            DateTime dt;

            foreach (FileSystemInfo fsi in fia)
            {
                //fill the info
                dfn = new DayFolderNode();

                dfn.folderName  = fsi.FullName;
                dfn.dayAsString = fsi.Name;


                if (!DirectoryStructure.TimeFromDayFolderName(fsi.Name, out dt))
                {
                    return(null);
                }

                dfn.startUnixTime = WocketsTimer.GetUnixTime(dt);
                dfn.endUnixTime   = dfn.startUnixTime + WocketsTimer.MilliInDay - 1;

                //Get the hour information
                hours = DirectoryStructure.GetHourFolderInformation(fsi.FullName, dfn.startUnixTime);
                if (hours == null || hours.Length < 1)
                {
                    continue;
                }

                dfn.hours = hours;

                //add to the list
                ret.Add(dfn);

                hours = null;
                dfn   = null;
            }

            if (ret.Count > 0)
            {
                //Create the array to return
                return((DayFolderNode[])ret.ToArray(typeof(DayFolderNode)));
            }
            else
            {
                return(null);
            }
        }
コード例 #48
0
 protected string[] concat_conditions()
 {
     System.Collections.ArrayList list = new System.Collections.ArrayList();
     foreach (List <string> s in filters.Values)
     {
         list.Add("(" + string.Join(" OR ", (string[])s.ToArray()) + ")");
     }
     return((string[])list.ToArray(typeof(String)));
 }
コード例 #49
0
ファイル: MainController.cs プロジェクト: wangkesen/cyberduck
        /// <summary>
        /// Runs this.MainForm in this application context. Converts the command
        /// line arguments correctly for the base this.Run method.
        /// </summary>
        /// <param name="commandLineArgs">Command line collection.</param>
        private void Run(ICollection commandLineArgs)
        {
            // convert the Collection<string> to string[], so that it can be used
            // in the Run method.
            ArrayList list = new ArrayList(commandLineArgs);

            string[] commandLine = (string[])list.ToArray(typeof(string));
            base.Run(commandLine);
        }
コード例 #50
0
        public TspLibDocument(string fileName)
        {
            //
            // Create the objective.
            //
            System.Collections.ArrayList cities2 = new System.Collections.ArrayList();
            System.IO.StreamReader       sr      = System.IO.File.OpenText(fileName);

            string s;
            bool   gotime = false;

            s = sr.ReadLine();
            while (s != null)
            {
                s.Trim();

                if (!gotime)
                {
                    if (s == "NODE_COORD_SECTION")
                    {
                        gotime = true;
                    }
                    s = sr.ReadLine();
                    continue;
                }
                if (s == "EOF")
                {
                    break;
                }

                string[] sa = s.Split(' ', '\t');
                if (sa.Length != 3)
                {
                    throw new Exception();
                }
                int city = Int32.Parse(sa[0]);
                int x    = Int32.Parse(sa[1]);
                int y    = Int32.Parse(sa[2]);

                cities2.Add(new Point(x, y));

                if (x > maxX)
                {
                    maxX = x;
                }
                if (y > maxY)
                {
                    maxY = y;
                }

                s = sr.ReadLine();
            }
            sr.Close();

            cities = (Point[])cities2.ToArray(typeof(Point));
        }
コード例 #51
0
 /// <summary>
 /// Gets float[] value from XML attribute
 /// </summary>
 /// <param name="name"></param>
 /// <param name="attrs"></param>
 /// <returns></returns>
 public static float[] GetFloatArray(string name, XmlAttributeCollection attrs)
 {
     string[] textArray = GetStringArray(name, attrs);
     System.Collections.ArrayList alist = new System.Collections.ArrayList();
     foreach (string t in textArray)
     {
         alist.Add((float)Convert.ToDouble(t));
     }
     return((float[])alist.ToArray(typeof(float)));
 }
コード例 #52
0
ファイル: DesigComents.cs プロジェクト: damoOnly/e-commerce
 private System.Data.DataTable ConvertListToDataTable <T>(System.Collections.Generic.IList <T> list, params string[] propertyName)
 {
     System.Collections.Generic.List <string> list2 = new System.Collections.Generic.List <string>();
     if (propertyName != null)
     {
         list2.AddRange(propertyName);
     }
     System.Data.DataTable dataTable = new System.Data.DataTable();
     if (list.Count > 0)
     {
         T t = list[0];
         System.Reflection.PropertyInfo[] properties = t.GetType().GetProperties();
         System.Reflection.PropertyInfo[] array      = properties;
         for (int i = 0; i < array.Length; i++)
         {
             System.Reflection.PropertyInfo propertyInfo = array[i];
             if (list2.Count == 0)
             {
                 dataTable.Columns.Add(propertyInfo.Name, propertyInfo.PropertyType);
             }
             else
             {
                 if (list2.Contains(propertyInfo.Name))
                 {
                     dataTable.Columns.Add(propertyInfo.Name, propertyInfo.PropertyType);
                 }
             }
         }
         for (int j = 0; j < list.Count; j++)
         {
             System.Collections.ArrayList     arrayList = new System.Collections.ArrayList();
             System.Reflection.PropertyInfo[] array2    = properties;
             for (int k = 0; k < array2.Length; k++)
             {
                 System.Reflection.PropertyInfo propertyInfo2 = array2[k];
                 if (list2.Count == 0)
                 {
                     object value = propertyInfo2.GetValue(list[j], null);
                     arrayList.Add(value);
                 }
                 else
                 {
                     if (list2.Contains(propertyInfo2.Name))
                     {
                         object value2 = propertyInfo2.GetValue(list[j], null);
                         arrayList.Add(value2);
                     }
                 }
             }
             object[] values = arrayList.ToArray();
             dataTable.LoadDataRow(values, true);
         }
     }
     return(dataTable);
 }
コード例 #53
0
 public static ContactAus[] RemoveInvalidPhoneNumbers(ContactAus[] inList)
 {
     System.Collections.ArrayList list = new System.Collections.ArrayList();
     for (int i = 0; i < inList.Length; i++)
     {
         if (Utilities.IsValidPhoneNumber(inList[i].AddrLine1))
         {
             list.Add(inList[i]);
         }
     }
     return((ContactAus[])list.ToArray(typeof(ContactAus)));
 }
コード例 #54
0
        /// <summary>
        /// Reads data from the provided data reader and returns
        /// an array of mapped objects.
        /// </summary>
        /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
        /// <param name="startIndex">The index of the first record to map.</param>
        /// <param name="length">The number of records to map.</param>
        /// <param name="totalRecordCount">A reference parameter that returns the total number
        /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
        /// <returns>An array of <see cref="EditionTypeRow"/> objects.</returns>
        protected virtual EditionTypeRow[] MapRecords(IDataReader reader,
                                                      int startIndex, int length, ref int totalRecordCount)
        {
            if (0 > startIndex)
            {
                throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero.");
            }
            if (0 > length)
            {
                throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero.");
            }

            int editionType_IDColumnIndex     = reader.GetOrdinal("EditionType_ID");
            int editionNameColumnIndex        = reader.GetOrdinal("EditionName");
            int editionDescriptionColumnIndex = reader.GetOrdinal("EditionDescription");
            int editionDisplayURLColumnIndex  = reader.GetOrdinal("EditionDisplayURL");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    EditionTypeRow record = new EditionTypeRow();
                    recordList.Add(record);

                    record.EditionType_ID = Convert.ToInt32(reader.GetValue(editionType_IDColumnIndex));
                    if (!reader.IsDBNull(editionNameColumnIndex))
                    {
                        record.EditionName = Convert.ToString(reader.GetValue(editionNameColumnIndex));
                    }
                    if (!reader.IsDBNull(editionDescriptionColumnIndex))
                    {
                        record.EditionDescription = Convert.ToString(reader.GetValue(editionDescriptionColumnIndex));
                    }
                    if (!reader.IsDBNull(editionDisplayURLColumnIndex))
                    {
                        record.EditionDisplayURL = Convert.ToString(reader.GetValue(editionDisplayURLColumnIndex));
                    }

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((EditionTypeRow[])(recordList.ToArray(typeof(EditionTypeRow))));
        }
コード例 #55
0
 Type[] FindTypes(TypeFilter filter, object filterCriteria)
 {
     System.Collections.ArrayList filtered = new System.Collections.ArrayList();
     Type[] types = GetTypes();
     foreach (Type t in types)
     {
         if (filter(t, filterCriteria))
         {
             filtered.Add(t);
         }
     }
     return((Type[])filtered.ToArray(typeof(Type)));
 }
コード例 #56
0
        protected TResult BindArrayKvpEntityProperties <TResult>(string propertyName, Type arrayType,
                                                                 IDictionary <string, EntityProperty> allValues,
                                                                 Func <object, TResult> onBound,
                                                                 Func <TResult> onFailedToBind)
        {
            var keyType   = arrayType.GenericTypeArguments[0];
            var valueType = arrayType.GenericTypeArguments[1];

            return(GetMemberValue(keyType.MakeArrayType(),
                                  $"{propertyName}__keys", allValues,
                                  keyValuesObj =>
            {
                var keyValues = keyValuesObj.ObjectToEnumerable();
                return GetMemberValue(valueType.MakeArrayType(),
                                      $"{propertyName}__values", allValues,
                                      valueValuesObj =>
                {
                    var propertyValues = valueValuesObj.ObjectToEnumerable();

                    var keyEnumerator = keyValues.GetEnumerator();
                    var propertyEnumerator = propertyValues.GetEnumerator();
                    var refOpt = new System.Collections.ArrayList();
                    while (keyEnumerator.MoveNext())
                    {
                        if (!propertyEnumerator.MoveNext())
                        {
                            return onBound(refOpt.ToArray().CastArray(arrayType));
                        }
                        var keyValue = keyEnumerator.Current;
                        var propertyValue = propertyEnumerator.Current;
                        var kvp = Activator.CreateInstance(arrayType, new object[] { keyValue, propertyValue });
                        refOpt.Add(kvp);
                    }
                    return onBound(refOpt.ToArray().CastArray(arrayType));
                },
                                      () => onBound(Array.CreateInstance(arrayType, 0)));
            },
                                  () => onBound(Array.CreateInstance(arrayType, 0))));
        }
コード例 #57
0
 public string[] ZIPContents(string SourceFile)
 {
     System.Collections.ArrayList        contents = new System.Collections.ArrayList();
     ICSharpCode.SharpZipLib.Zip.ZipFile zip      = new ICSharpCode.SharpZipLib.Zip.ZipFile(SourceFile);
     for (int i = 0; i < zip.Size; i++)
     {
         if (!zip[i].IsDirectory)
         {
             contents.Add(zip[i].Name);
         }
     }
     return((string[])contents.ToArray(Type.GetType("System.String")));
 }
コード例 #58
0
        private void RadRibbonFormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            ArrayList formn = new System.Collections.ArrayList(System.Windows.Forms.Application.OpenForms);

            var login = from log in formn.ToArray()
                        where ((Form)log).Name == "RadFormLogin"
                        select log;

            if (login.Count() > 0)
            {
                ((Form)login.First()).Close();
            }
        }
コード例 #59
0
        /// <summary>
        /// Returns all the Appenders that are currently configured
        /// </summary>
        /// <returns>An array containing all the currently configured appenders</returns>
        /// <remarks>
        /// <para>
        /// Returns all the <see cref="log4net.Appender.IAppender"/> instances that are currently configured.
        /// All the loggers are searched for appenders. The appenders may also be containers
        /// for appenders and these are also searched for additional loggers.
        /// </para>
        /// <para>
        /// The list returned is unordered but does not contain duplicates.
        /// </para>
        /// </remarks>
        override public Appender.IAppender[] GetAppenders()
        {
            System.Collections.ArrayList appenderList = new System.Collections.ArrayList();

            CollectAppenders(appenderList, Root);

            foreach (Logger logger in GetCurrentLoggers())
            {
                CollectAppenders(appenderList, logger);
            }

            return((Appender.IAppender[])appenderList.ToArray(typeof(Appender.IAppender)));
        }
コード例 #60
0
ファイル: MyClass_String.cs プロジェクト: shu77/c_sharp_test
        /// <summary>
        ///  remove duplicates from string Array
        /// </summary>
        /// <param name="myList"></param>
        /// <returns></returns>
        public static string[] RemoveDuplicates(string[] myList)
        {
            System.Collections.ArrayList newList = new System.Collections.ArrayList();

            foreach (string str in myList)
            {
                if (!newList.Contains(str))
                {
                    newList.Add(str);
                }
            }
            return((string[])newList.ToArray(typeof(string)));
        }