System.Collections.ArrayList.ToArray(System.Type)

Here are the examples of the csharp api System.Collections.ArrayList.ToArray(System.Type) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

293 Examples 7

19 Source : FrmDoublePageReader.cs
with GNU General Public License v3.0
from 9vult

private void UpdateChapters()
        {
            cmboChapter.Items.Clear();
            Chapter[] cs = SortChapters((Chapter[])chapters.ToArray(typeof(Chapter)));
            foreach (Chapter c in cs)
            {
                cmboChapter.Items.Add(c.num);
            }
            cmboChapter.SelectedItem = curChapter.num;
        }

19 Source : FrmDoublePageReader.cs
with GNU General Public License v3.0
from 9vult

public void StartUp(Manga m, FrmStartPage startPage)
        {
            this.root = m.mangaDirectory;
            this.startPage = startPage;
            
            foreach (DirectoryInfo dir in root.GetDirectories("*", SearchOption.TopDirectoryOnly)) // chapters
            {
                FileInfo[] files = dir.GetFiles("*");
                ArrayList pages = new ArrayList();

                foreach (FileInfo fi in files) // pages
                {
                    string shortName = Path.GetFileNameWithoutExtension(fi.Name);
                    string num = Regex.Match(shortName, @"(\d+(\.\d+)?)|(\.\d+)").Value;
                    pages.Add(new Page(num, fi));
                }

                Chapter c = new Chapter(dir.Name, dir, SortPages((Page[])pages.ToArray(typeof(Page))));
                if (dir.Name == m.currentChapter)
                {
                    curChapter = c;
                } 
                chapters.Add(c);
            }

            UpdateChapters();
            UpdatePages(curChapter);
            cmboPage.SelectedItem = m.currentPage;
        }

19 Source : FileService.cs
with GNU General Public License v2.0
from afrantzis

private bool AskForSaveIfFilesChanged()
	{
		ArrayList list = new ArrayList();

		// create a list with the changed files
		int i = 0;
		foreach (DataViewDisplay dv in dataBook.Children) {
			ByteBuffer bb = dv.View.Buffer;
			if (bb.HasChanged)
				list.Add(new SaveFileItem(true, bb.Filename, i));
			i++;
		}

		if (list.Count == 0)
			return true;

		// special handling if only one file changed
		if (list.Count == 1) {
			int page = ((SaveFileItem)list[0]).Page;
			// make the page active
			dataBook.Page = page;

			DataView dv = ((DataViewDisplay)dataBook.GetNthPage(page)).View;
			return AskForSaveIfFileChanged(dv);
		}

		// show the confirmation alert
		SaveFileItem[] array = (SaveFileItem[])list.ToArray(typeof(SaveFileItem));

		SaveConfirmationMultiAlert sca = new SaveConfirmationMultiAlert(array, mainWindow);
		ResponseType res = (ResponseType)sca.Run();
		sca.Destroy();

		// handle responses
		if (res == ResponseType.Ok) {
			bool allSaved = true;

			// save the files the user specified
			foreach(SaveFileItem item in array) {
				if (item.Save == true) {
					DataView dv = ((DataViewDisplay)dataBook.GetNthPage(item.Page)).View;
					// make page active
					dataBook.Page = item.Page;
					// try to save the file
					if (SaveFile(dv, null, false, true) == false)
						allSaved = false;
					else {
						//UpdateTabLabel(dv);
						//UpdateWindowreplacedle(dv);
					}
				}
			}

			return allSaved;
		}
		else if (res == ResponseType.No){
			return true;
		}
		else /*if (res==ResponseType.Cancel)*/
			return false;
	}

19 Source : DataConverter.cs
with GNU General Public License v3.0
from aiportal

private static object ArrayFromString(string str, Type type)
		{
			Debug.replacedert(!string.IsNullOrEmpty(str));
			Debug.replacedert(type.IsArray);

			string[] vals = str.Split(new char[] { ArraySeparator });
			var list = new System.Collections.ArrayList(vals.Length);
			var t = type.GetElementType();
			for (int i = 0; i < vals.Length; ++i)
				list.Add(ObjectFromString(vals[i], t));
			return list.ToArray(t);
		}

19 Source : ArrayUtilities.cs
with Apache License 2.0
from aivclab

public static void Insert<T>(ref T[] array, int index, T item)
        {
            var a = new ArrayList();
            a.AddRange(c : array);
            a.Insert(index : index, value : item);
            array = a.ToArray(type : typeof(T)) as T[];
        }

19 Source : ProgramArguments.cs
with MIT License
from Alan-FGR

private bool LexFileArguments(string fileName, out string[] arguments)
		{
			string args = null;

			try
			{
				using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read))
				{
					args = (new StreamReader(file)).ReadToEnd();
				}
			}
			catch (Exception e)
			{
				this.reporter(string.Format("Error: Can't open command line argument file '{0}' : '{1}'", fileName, e.Message));
				arguments = null;
				return false;
			}

			bool hadError = false;
			ArrayList argArray = new ArrayList();
			StringBuilder currentArg = new StringBuilder();
			bool inQuotes = false;
			int index = 0;

			// while (index < args.Length)
			try
			{
				while (true)
				{
					// skip whitespace
					while (char.IsWhiteSpace(args[index]))
					{
						index += 1;
					}

					// # - comment to end of line
					if (args[index] == '#')
					{
						index += 1;
						while (args[index] != '\n')
						{
							index += 1;
						}
						continue;
					}

					// do one argument
					do
					{
						if (args[index] == '\\')
						{
							int cSlashes = 1;
							index += 1;
							while (index == args.Length && args[index] == '\\')
							{
								cSlashes += 1;
							}

							if (index == args.Length || args[index] != '"')
							{
								currentArg.Append('\\', cSlashes);
							}
							else
							{
								currentArg.Append('\\', (cSlashes >> 1));
								if (0 != (cSlashes & 1))
								{
									currentArg.Append('"');
								}
								else
								{
									inQuotes = !inQuotes;
								}
							}
						}
						else if (args[index] == '"')
						{
							inQuotes = !inQuotes;
							index += 1;
						}
						else
						{
							currentArg.Append(args[index]);
							index += 1;
						}
					} while (!char.IsWhiteSpace(args[index]) || inQuotes);
					argArray.Add(currentArg.ToString());
					currentArg.Length = 0;
				}
			}
			catch (System.IndexOutOfRangeException)
			{
				// got EOF 
				if (inQuotes)
				{
					this.reporter(string.Format("Error: Unbalanced '\"' in command line argument file '{0}'", fileName));
					hadError = true;
				}
				else if (currentArg.Length > 0)
				{
					// valid argument can be terminated by EOF
					argArray.Add(currentArg.ToString());
				}
			}

			arguments = (string[])argArray.ToArray(typeof(string));
			return hadError;
		}

19 Source : ProgramArguments.cs
with MIT License
from Alan-FGR

public bool Finish(object destination)
			{
				if (this.SeenValue)
				{
					if (this.IsCollection)
					{
						this.field.SetValue(destination, this.collectionValues.ToArray(this.elementType));
					}
				}
				else
				{
					if (this.HasDefaultValue)
					{
						this.field.SetValue(destination, this.DefaultValue);
					}
				}

				return ReportMissingRequiredArgument();
			}

19 Source : DirectoryDiffFileFilter.cs
with Apache License 2.0
from AmpScm

public FileInfo[] Filter(DirectoryInfo Dir)
        {
            //Get all the files that match the filters
            ArrayList arFiles = new ArrayList();
            foreach (string strFilter in m_arFilters)
            {
                FileInfo[] arFilterFiles = Dir.GetFiles(strFilter);
                arFiles.AddRange(arFilterFiles);
            }

            //Sort them
            arFiles.Sort(FileSystemInfoComparer.Comparer);

            //Throw out duplicates
            FileInfo PreviousFile = null;
            for (int i = 0; i < arFiles.Count; /*Incremented in the loop*/)
            {
                FileInfo CurrentFile = (FileInfo)arFiles[i];
                if (PreviousFile != null && FileSystemInfoComparer.Comparer.Compare(CurrentFile, PreviousFile) == 0)
                {
                    arFiles.RemoveAt(i);
                    //Don't increment i;
                }
                else
                {
                    PreviousFile = CurrentFile;
                    i++;
                }
            }

            //Exclude these files if necessary
            if (m_bInclude)
            {
                return (FileInfo[])arFiles.ToArray(typeof(FileInfo));
            }
            else
            {
                FileInfo[] arAllFiles = Dir.GetFiles();
                Array.Sort(arAllFiles, FileSystemInfoComparer.Comparer);

                ArrayList arFilesToInclude = new ArrayList();
                int iNumExcludes = arFiles.Count;
                int iNumTotal = arAllFiles.Length;
                int e = 0;
                for (int a = 0; a < iNumTotal; a++)
                {
                    int iCompareResult = -1;
                    FileInfo A = arAllFiles[a];
                    if (e < iNumExcludes)
                    {
                        FileInfo E = (FileInfo)arFiles[e];
                        iCompareResult = FileSystemInfoComparer.Comparer.Compare(A, E);
                    }

                    if (iCompareResult == 0)
                    {
                        //Don't put this match in the results.
                        e++;
                    }
                    else
                    {
                        arFilesToInclude.Add(A);
                    }
                }

                return (FileInfo[])arFilesToInclude.ToArray(typeof(FileInfo));
            }
        }

19 Source : MyersDiff.cs
with Apache License 2.0
from AmpScm

public int[] GetLCS()
        {
            ArrayList Output = new ArrayList();

            GetLCS(new SubArray(m_arA), new SubArray(m_arB), Output);

            return (int[])Output.ToArray(typeof(int));
        }

19 Source : AnkhEditorFactory.cs
with Apache License 2.0
from AmpScm

public virtual string[] GetExtensions()
        {
            ArrayList list = new ArrayList(this.GetEditorExtensions().Keys);
            return (string[])list.ToArray(typeof(string));
        }

19 Source : ExceptionSupport.cs
with Apache License 2.0
from apache

private static FieldInfo[] GetConstants(Type type)
        {
            ArrayList list = new ArrayList();
            FieldInfo[] fields = type.GetFields(
                BindingFlags.Static | 
                BindingFlags.Public | 
                BindingFlags.FlattenHierarchy
                );
            foreach (FieldInfo field in fields)
            {
                if (field.IsLiteral && !field.IsInitOnly)
                    list.Add(field);
            }
            return (FieldInfo[])list.ToArray(typeof(FieldInfo));
        }

19 Source : ExceptionSupport.cs
with Apache License 2.0
from apache

private static string[] GetStringConstants(Type type)
        {
            FieldInfo[] fields = GetConstants(type);
            ArrayList list = new ArrayList(fields.Length);
            foreach(FieldInfo fi in fields)
            {
                if (fi.FieldType.Equals(typeof(string)))
                {
                    list.Add(fi.GetValue(null));
                }
            }
            return (string[])list.ToArray(typeof(string));
        }

19 Source : NMSConnectionFactory.cs
with Apache License 2.0
from apache

private static string[] GetConfigSearchPaths()
        {
            ArrayList pathList = new ArrayList();

            // Check the current folder first.
            pathList.Add("");
#if !NETCF
            try
            {
                AppDomain currentDomain = AppDomain.CurrentDomain;

                // Check the folder the replacedembly is located in.
                replacedembly executingreplacedembly = replacedembly.GetExecutingreplacedembly();
                try
                {
                    pathList.Add(Path.GetDirectoryName(executingreplacedembly.Location));
                }
                catch (Exception ex)
                {
                    Tracer.DebugFormat("Error parsing executing replacedembly location: {0} : {1}",
                        executingreplacedembly.Location, ex.Message);
                }

                if (null != currentDomain.BaseDirectory)
                {
                    pathList.Add(currentDomain.BaseDirectory);
                }

                if (null != currentDomain.RelativeSearchPath)
                {
                    pathList.Add(currentDomain.RelativeSearchPath);
                }
            }
            catch (Exception ex)
            {
                Tracer.DebugFormat("Error configuring search paths: {0}", ex.Message);
            }
#endif

            return (string[]) pathList.ToArray(typeof(string));
        }

19 Source : NMSTestSupport.cs
with Apache License 2.0
from apache

private static string[] GetConfigSearchPaths()
        {
            ArrayList pathList = new ArrayList();

            // Check the current folder first.
            pathList.Add("");
#if !NETCF
            AppDomain currentDomain = AppDomain.CurrentDomain;

            // Check the folder the replacedembly is located in.
            pathList.Add(Path.GetDirectoryName(replacedembly.GetExecutingreplacedembly().Location));
            if (null != currentDomain.BaseDirectory)
            {
                pathList.Add(currentDomain.BaseDirectory);
            }

            if (null != currentDomain.RelativeSearchPath)
            {
                pathList.Add(currentDomain.RelativeSearchPath);
            }
#endif

            return (string[]) pathList.ToArray(typeof(string));
        }

19 Source : AppenderSkeleton.cs
with Apache License 2.0
from apache

public void DoAppend(LoggingEvent[] loggingEvents) 
		{
			// This lock is absolutely critical for correct formatting
			// of the message in a multi-threaded environment.  Without
			// this, the message may be broken up into elements from
			// multiple thread contexts (like get the wrong thread ID).

			lock(this)
			{
				if (m_closed)
				{
					ErrorHandler.Error("Attempted to append to closed appender named ["+m_name+"].");
					return;
				}

				// prevent re-entry
				if (m_recursiveGuard)
				{
					return;
				}

				try
				{
					m_recursiveGuard = true;

					ArrayList filteredEvents = new ArrayList(loggingEvents.Length);

					foreach(LoggingEvent loggingEvent in loggingEvents)
					{
						if (FilterEvent(loggingEvent))
						{
							filteredEvents.Add(loggingEvent);
						}
					}

					if (filteredEvents.Count > 0 && PreAppendCheck())
					{
						this.Append((LoggingEvent[])filteredEvents.ToArray(typeof(LoggingEvent)));
					}
				}
				catch(Exception ex)
				{
					ErrorHandler.Error("Failed in Bulk DoAppend", ex);
				}
#if !MONO && !NET_2_0 && !NETSTANDARD
				// on .NET 2.0 (and higher) and Mono (all profiles), 
				// exceptions that do not derive from System.Exception will be
				// wrapped in a RuntimeWrappedException by the runtime, and as
				// such will be catched by the catch clause above
				catch
				{
					// Catch handler for non System.Exception types
					ErrorHandler.Error("Failed in Bulk DoAppend (unknown exception)");
				}
#endif
				finally
				{
					m_recursiveGuard = false;
				}
			}
		}

19 Source : BufferingAppenderSkeleton.cs
with Apache License 2.0
from apache

public virtual void Flush(bool flushLossyBuffer)
		{
			// This method will be called outside of the AppenderSkeleton DoAppend() method
			// therefore it needs to be protected by its own lock. This will block any
			// Appends while the buffer is flushed.
			lock(this)
			{
				if (m_cb != null && m_cb.Length > 0)
				{
					if (m_lossy)
					{
						// If we are allowed to eagerly flush from the lossy buffer
						if (flushLossyBuffer)
						{
							if (m_lossyEvaluator != null)
							{
								// Test the contents of the buffer against the lossy evaluator
								LoggingEvent[] bufferedEvents = m_cb.PopAll();
								ArrayList filteredEvents = new ArrayList(bufferedEvents.Length);

								foreach(LoggingEvent loggingEvent in bufferedEvents)
								{
									if (m_lossyEvaluator.IsTriggeringEvent(loggingEvent))
									{
										filteredEvents.Add(loggingEvent);
									}
								}

								// Send the events that meet the lossy evaluator criteria
								if (filteredEvents.Count > 0)
								{
									SendBuffer((LoggingEvent[])filteredEvents.ToArray(typeof(LoggingEvent)));
								}
							}
							else
							{
								// No lossy evaluator, all buffered events are discarded
								m_cb.Clear();
							}
						}
					}
					else
					{
						// Not lossy, send whole buffer
						SendFromBuffer(null, m_cb);
					}
				}
			}
		}

19 Source : MemoryAppender.cs
with Apache License 2.0
from apache

public virtual LoggingEvent[] GetEvents()
		{
            lock (m_eventsList.SyncRoot)
            {
                return (LoggingEvent[]) m_eventsList.ToArray(typeof(LoggingEvent));
            }
		}

19 Source : MemoryAppender.cs
with Apache License 2.0
from apache

public virtual LoggingEvent[] PopAllEvents()
        {
            lock (m_eventsList.SyncRoot)
            {
                LoggingEvent[] tmp = (LoggingEvent[]) m_eventsList.ToArray(typeof (LoggingEvent));
                m_eventsList.Clear();
                return tmp;
            }
        }

19 Source : MethodItem.cs
with Apache License 2.0
from apache

private static string[] GetMethodParameterNames(System.Reflection.MethodBase methodBase)
		{
			ArrayList methodParameterNames = new ArrayList();
			try
			{
				System.Reflection.ParameterInfo[] methodBaseGetParameters = methodBase.GetParameters();

				int methodBaseGetParametersCount = methodBaseGetParameters.GetUpperBound(0);

				for (int i = 0; i <= methodBaseGetParametersCount; i++)
				{
					methodParameterNames.Add(methodBaseGetParameters[i].ParameterType + " " + methodBaseGetParameters[i].Name);
				}
			}
			catch (Exception ex)
			{
				LogLog.Error(declaringType, "An exception ocurred while retreiving method parameters.", ex);
			}

			return (string[])methodParameterNames.ToArray(typeof(string));
		}

19 Source : Hierarchy.cs
with Apache License 2.0
from apache

public override 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));
		}

19 Source : Hierarchy.cs
with Apache License 2.0
from apache

public override ILogger[] GetCurrentLoggers() 
		{
			// The acreplacedulation in loggers is necessary because not all elements in
			// ht are Logger objects as there might be some ProvisionNodes
			// as well.
			lock(m_ht) 
			{
				System.Collections.ArrayList loggers = new System.Collections.ArrayList(m_ht.Count);
	
				// Iterate through m_ht values
				foreach(object node in m_ht.Values)
				{
					if (node is Logger) 
					{
						loggers.Add(node);
					}
				}
				return (Logger[])loggers.ToArray(typeof(Logger));
			}
		}

19 Source : PropertySorter.cs
with GNU General Public License v3.0
from audiamus

public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) {
      //
      // This override returns a list of properties in order
      //
      PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(value, attributes);
      ArrayList orderedProperties = new ArrayList();
      foreach (PropertyDescriptor pd in pdc) {
        Attribute attribute = pd.Attributes[typeof(PropertyOrderAttribute)];
        if (attribute != null) {
          //
          // If the attribute is found, then create an pair object to hold it
          //
          PropertyOrderAttribute poa = (PropertyOrderAttribute)attribute;
          orderedProperties.Add(new PropertyOrderPair(pd.Name, poa.Order));
        } else {
          //
          // If no order attribute is specifed then given it an order of 0
          //
          orderedProperties.Add(new PropertyOrderPair(pd.Name, 0));
        }
      }
      //
      // Perform the actual order using the value PropertyOrderPair clreplacedes
      // implementation of IComparable to sort
      //
      orderedProperties.Sort();
      //
      // Build a string list of the ordered names
      //
      ArrayList propertyNames = new ArrayList();
      foreach (PropertyOrderPair pop in orderedProperties) {
        propertyNames.Add(pop.Name);
      }
      //
      // Preplaced in the ordered list for the PropertyDescriptorCollection to sort by
      //
      return pdc.Sort((string[])propertyNames.ToArray(typeof(string)));
    }

19 Source : NameFilter.cs
with MIT License
from ay2015

public static string[] SplitQuoted(string original)
		{
			char escape = '\\';
			char[] separators = { ';' };

			ArrayList result = new ArrayList();

			if ((original != null) && (original.Length > 0)) {
				int endIndex = -1;
				StringBuilder b = new StringBuilder();

				while (endIndex < original.Length) {
					endIndex += 1;
					if (endIndex >= original.Length) {
						result.Add(b.ToString());
					}
					else if (original[endIndex] == escape) {
						endIndex += 1;
						if (endIndex >= original.Length) {
#if NETCF_1_0
							throw new ArgumentException("Missing terminating escape character");
#else
							throw new ArgumentException("Missing terminating escape character", "original");
#endif
						}
						// include escape if this is not an escaped separator
						if (Array.IndexOf(separators, original[endIndex]) < 0)
							b.Append(escape);

						b.Append(original[endIndex]);
					}
					else {
						if (Array.IndexOf(separators, original[endIndex]) >= 0) {
							result.Add(b.ToString());
							b.Length = 0;
						}
						else {
							b.Append(original[endIndex]);
						}
					}
				}
			}

			return (string[])result.ToArray(typeof(string));
		}

19 Source : AyFuncSystem.cs
with MIT License
from ay2015

public virtual string[] GetDotNetVersions()
        {
            DirectoryInfo[] directories = new DirectoryInfo(Environment.SystemDirectory + @"\..\Microsoft.NET\Framework").GetDirectories("v?.?.*");
            System.Collections.ArrayList list = new System.Collections.ArrayList();
            foreach (DirectoryInfo info2 in directories)
            {
                list.Add(info2.Name.Substring(1));
            }
            return (list.ToArray(typeof(string)) as string[]);
        }

19 Source : AyCommon.cs
with MIT License
from ay2015

public static int[] ToIntArray(this string[] region)
    {
        ArrayList aList = new ArrayList();
        foreach (string i in region)
            aList.Add(i.ToInt());
        return (int[])aList.ToArray(typeof(int));
    }

19 Source : LogAnalyticsClientBase.cs
with MIT License
from Azure

private DataTable ResultAsDataTable(QueryResults results)
        {
            DataTable dataTable = new DataTable("results");
            dataTable.Clear();

            dataTable.Columns.AddRange(results.Tables[0].Columns.Select(s => new DataColumn(s.Name, TypeConverter.StringToType(s.Type))).ToArray());
            var rows = results.Tables[0].Rows.Select(s => dataTable.NewRow().ItemArray = s.ToArray());
            foreach (var i in rows) 
            {
                dataTable.Rows.Add(MakeRow(i, dataTable).ToArray());
            }

            return dataTable;
        }

19 Source : FileCompiler.cs
with Apache License 2.0
from beetlex-io

public replacedembly Createreplacedembly(IList filenames, IList references)
		{
			string fileType = null;
			foreach (string filename in filenames)
			{
				string extension = Path.GetExtension(filename);
				if (fileType == null)
				{
					fileType = extension;
				}
				else if (fileType != extension)
				{
					throw new ArgumentException("All files in the file list must be of the same type.");
				}
			}


			compilerErrors = null;


			CodeDomProvider codeProvider = null;
			switch (fileType)
			{
				case ".cs":
					codeProvider = new Microsoft.CSharp.CSharpCodeProvider();
					break;
				case ".vb":
					codeProvider = new Microsoft.CSharp.CSharpCodeProvider();
					break;
				default:
					throw new InvalidOperationException("Script files must have a .cs, .vb, or .js extension, for C#, Visual Basic.NET, or JScript respectively.");
			}



			CompilerParameters compilerParams = new CompilerParameters();
			compilerParams.CompilerOptions = "/target:library /optimize";
			compilerParams.GenerateExecutable = false;
			compilerParams.GenerateInMemory = true;
			compilerParams.IncludeDebugInformation = false;
			compilerParams.Referencedreplacedemblies.Add("mscorlib.dll");
			compilerParams.Referencedreplacedemblies.Add("System.dll");


			foreach (string reference in references)
			{
				if (!compilerParams.Referencedreplacedemblies.Contains(reference))
				{
					compilerParams.Referencedreplacedemblies.Add(reference);
				}
			}


			CompilerResults results = codeProvider.CompilereplacedemblyFromFile(
				compilerParams, (string[])ArrayList.Adapter(filenames).ToArray(typeof(string)));


			if (results.Errors.Count > 0)
			{
				StringBuilder sb = new StringBuilder();
				foreach (CompilerError item in results.Errors)
				{
					sb.AppendFormat("{0} line:{1}   {2}\r\n", item.FileName, item.Line, item.ErrorText);
				}
				compilerErrors = results.Errors;
				throw new Exception(
					"Compiler error(s)\r\n" + sb.ToString());
			}

			replacedembly createdreplacedembly = results.Compiledreplacedembly;
			return createdreplacedembly;
		}

19 Source : ListParser.cs
with MIT License
from bilal-fazlani

public object? Parse(IArgument argument, IEnumerable<string> values)
        {
            // TODO: when _type & values is IEnumerable but not ICollection
            //       DO NOT enumerate values here as it could be a stream.
            var listInstance = _type.IsArray
                ? new ArrayList()
                : _type.IsCollection()
                    ? CreateGenericList()
                    : null;

            if (listInstance == null)
            {
                return values;
            }

            foreach (string stringValue in values)
            {
                listInstance.Add(_argumentTypeDescriptor.ParseString(argument, stringValue));
            }

            return _type.IsArray 
                ? ((ArrayList)listInstance).ToArray(_underlyingType)
                : listInstance;
        }

19 Source : DelegateServiceProvdier.cs
with GNU General Public License v3.0
from blqw

private IEnumerable ConvertDelegates(Type delegateType, IEnumerable enumerable)
        {
            var newServices = new ArrayList();
            var delegateMethod = delegateType.GetMethod("Invoke");
            foreach (var item in enumerable)
            {
                if (delegateType.IsInstanceOfType(item))
                {
                    newServices.Add(item);
                    continue;
                }
                var method = (item as Delegate)?.Method ?? item as MethodInfo;
                if (CompareMethodSignature(delegateMethod, method))
                {
                    newServices.Add(method.CreateDelegate(delegateType, null));
                }
            }
            return newServices.ToArray(delegateType);
        }

19 Source : JSON.cs
with GNU General Public License v3.0
from bonarr

private object CreateArray(ArrayList data, Type pt, Type bt, Dictionary<string, object> globalTypes)
        {
            ArrayList col = new ArrayList();
            // create an array of objects
            foreach (var ob in data)
            {
                if (ob is IDictionary)
                    col.Add(ParseDictionary((Dictionary<string, object>)ob, globalTypes, bt));
                else
                    col.Add(ChangeType(ob, bt));
            }
            return col.ToArray(bt);
        }

19 Source : Plugins.cs
with GNU General Public License v3.0
from brhinescot

private string[] DiscoverPluginreplacedembliesHelper()
        {
            ArrayList replacedemblies = new ArrayList();
            foreach (string pluginPath in ParsePluginDirectory())
                try
                {
                    replacedembly replacedembly = replacedembly.LoadFile(pluginPath);
                    //Enumerate through the replacedembly object
                    //
                    foreach (Type type in replacedembly.GetTypes())
                        //Look for public types and ignore abstract clreplacedes
                        //
                        if (type.IsPublic && type.Attributes != TypeAttributes.Abstract)
                            if (type.GetInterface(PluginInterfaceName, false) != null)
                                replacedemblies.Add(pluginPath);
                }
                catch (ReflectionTypeLoadException) { }
                catch (FileLoadException) { }

            return (string[]) replacedemblies.ToArray(typeof(string));
        }

19 Source : LumiProbesScript.cs
with MIT License
from cgaueb

public void populateGUI_LightProbes() {
        sceneVolumeLP = EditorGUILayout.ObjectField("LP Volume:", sceneVolumeLP, typeof(GameObject), true) as GameObject;

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel(new GUIContent("Placement Type:", "The LP placement method"));
        string[] options = (string[])populatePlacementPopup().ToArray(typeof(string));
        PlacementType newLightProbesPlaceType = (PlacementType)EditorGUILayout.Popup((int)LightProbesPlaceType, options, CustomStyles.defaultGUILayoutOption);
        EditorGUILayout.EndHorizontal();

        //LightProbesPlaceType = (LumiProbesScript.PlacementType)EditorGUILayout.EnumPopup(new GUIContent("Placement Type:", "The LP placement method"), LightProbesPlaceType);
        currentLightProbesGenerator = generatorListLightProbes[newLightProbesPlaceType];
        currentLightProbesGenerator.populateGUI_Initialization();

        if (LightProbesPlaceType != newLightProbesPlaceType) {
            LightProbeGroup.probePositions = currentLightProbesGenerator.Positions.ToArray();
            LightProbesPlaceType = newLightProbesPlaceType;
        }
    }

19 Source : LumiProbesScript.cs
with MIT License
from cgaueb

public void populateGUI_EvaluationPoints() {
        sceneVolumeEP = EditorGUILayout.ObjectField("EP Volume:", sceneVolumeEP, typeof(GameObject), true) as GameObject;

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel(new GUIContent("Placement Type:", "The EP placement method"));
        string[] options = (string[])populatePlacementPopup().ToArray(typeof(string));
        PlacementType newEvaluationPositionsPlaceType = (PlacementType)EditorGUILayout.Popup((int)EvaluationPositionsPlaceType, options, CustomStyles.defaultGUILayoutOption);
        EditorGUILayout.EndHorizontal();

        //EvaluationPositionsPlaceType = (LumiProbesScript.PlacementType)EditorGUILayout.EnumPopup(new GUIContent("Placement Type:", "The EP placement method"), EvaluationPositionsPlaceType);
        currentEvaluationPointsGenerator = generatorListEvaluationPoints[EvaluationPositionsPlaceType];
        currentEvaluationPointsGenerator.populateGUI_Initialization();

        if (EvaluationPositionsPlaceType != newEvaluationPositionsPlaceType) {
            EvaluationPositionsPlaceType = newEvaluationPositionsPlaceType;
            foreach (PlacementType type in Enum.GetValues(typeof(PlacementType))) {
                GameObject evaluationObjectParent = GameObject.Find("EvaluationGroup_" + type.ToString());
                if (evaluationObjectParent == null) {
                    continue;
                }
                if (type == newEvaluationPositionsPlaceType) {
                    evaluationObjectParent.transform.localScale = new Vector3(1, 1, 1);
                } else {
                    evaluationObjectParent.transform.localScale = new Vector3(0, 0, 0);
                }
            }
        }
    }

19 Source : NetServices.cs
with MIT License
from chatop2020

public static IPAddress GetDefaultIPAddress(IPAddress defaultGateway)
        {
            try
            {
                string[] gatewayOctets = Regex.Split(defaultGateway.ToString(), @"\.");

                IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());

                ArrayList possibleMatches = new ArrayList();
                foreach (IPAddress localAddress in hostEntry.AddressList)
                {
                    possibleMatches.Add(localAddress);
                }

                for (int octetIndex = 0; octetIndex < 4; octetIndex++)
                {
                    IPAddress[] testAddresses = (IPAddress[]) possibleMatches.ToArray(typeof(IPAddress));
                    foreach (IPAddress localAddress in testAddresses)
                    {
                        string[] localOctets = Regex.Split(localAddress.ToString(), @"\.");
                        if (gatewayOctets[octetIndex] != localOctets[octetIndex])
                        {
                            possibleMatches.Remove(localAddress);
                        }

                        if (possibleMatches.Count == 1)
                        {
                            return (IPAddress) possibleMatches[0];
                        }
                    }
                }

                return null;
            }
            catch
            {
                return null;
            }
        }

19 Source : MailClient.cs
with Apache License 2.0
from chenxuuu

public IMailFolder[] GetFolders(string path = "")
        {
            ArrayList folders = new ArrayList();
            
            var personal = client.GetFolder(path);

            foreach (var folder in personal.GetSubfolders(false))
            {
                if (folder.GetSubfolders(false).Count > 0)
                {
#if DEBUG
                    Console.WriteLine($"[folder open] {path + folder.Name}");
#endif
                    folders.AddRange(GetFolders(folder.FullName));
                }
                else
                {
                    folders.Add(folder);
#if DEBUG
                    Console.WriteLine($"[folder get] {folder.FullName}");
#endif
                }
            }
            return (IMailFolder[])folders.ToArray(typeof(IMailFolder));
        }

19 Source : VisualDisk.cs
with Apache License 2.0
from chenxuuu

public string[] GetFileList(string folderPath, bool deleteMissing = false)
        {
            ArrayList mails = new ArrayList();
            var client = GetImapClient();
            var folder = client.GetFolder(folderPath);
            folder.Open(FolderAccess.ReadWrite);
            Console.WriteLine($"find {folder.Count} mails in this folder");
            for(int i = 0;i < folder.Count; i += 100)
            {
                Console.WriteLine($"fatching mails {i}/{folder.Count}");
                int max = i + 100;
                if (max >= folder.Count)
                    max = folder.Count - 1;
                foreach (var m in folder.Fetch(i, max, MessageSummaryItems.Full | MessageSummaryItems.UniqueId))
                {
                    if(m.Envelope.Subject.IndexOf("[mailDisk]") == 0)
                        mails.Add(m.Envelope.Subject.Substring("[mailDisk]".Length));
                }
                if (max == folder.Count)
                    break;
            }
            Console.WriteLine($"mails in {folder.Count} fatched ok.");

            ArrayList files = new ArrayList();
            foreach(string f in mails)
            {
                if (f.IndexOf("<")>=0)
                {
                    MatchCollection mc = Regex.Matches(f, @"(.+?)<1/(\d+?)>");
                    if (mc.Count > 0 && mc[0].Groups.Count == 3)
                    {
                        Console.WriteLine($"find file {mc[0].Groups[1]} with {mc[0].Groups[2]} parts,checking...");
                        bool result = true;//check is it have all files
                        int sum = int.Parse(mc[0].Groups[2].ToString());
                        for(int i=1;i<=sum;i++)
                        {
                            if(!mails.Contains($"{mc[0].Groups[1]}<{i}/{sum}>"))
                            {
                                result = false;
                                break;
                            }
                        }
                        if(result)
                        {
                            files.Add(mc[0].Groups[1].ToString());
                            Console.WriteLine($"file {mc[0].Groups[1]} check ok");
                        }
                        else
                            Console.WriteLine($"file {mc[0].Groups[1]}'s parts are missing");
                    }
                        
                }
                else
                {
                    files.Add(f);
                }
            }
            if(deleteMissing)
            {
                Console.WriteLine("start cleaning all missing mails");
                for (int i = 0; i < folder.Count; i += 100)
                {
                    Console.WriteLine($"fatching mails {i}/{folder.Count}");
                    int max = i + 100;
                    if (max >= folder.Count)
                        max = folder.Count - 1;
                    foreach (var m in folder.Fetch(i, max, MessageSummaryItems.Full | MessageSummaryItems.UniqueId))
                    {
                        if (m.Envelope.Subject.IndexOf("[mailDisk]") == 0)
                        {
                            string name = m.Envelope.Subject.Substring("[mailDisk]".Length);
                            Console.WriteLine($"checking file {name}");
                            MatchCollection mc = Regex.Matches(name, @"(.+?)<(\d+?)/(\d+?)>");
                            if (mc.Count > 0 && mc[0].Groups.Count == 4)
                                name = mc[0].Groups[1].ToString();
                            if (!files.Contains(name))
                            {
                                Console.WriteLine($"file {name} is not right, mark as deleted");
                                folder.AddFlags(m.UniqueId, MessageFlags.Deleted, true);
                            }
                        }
                    }
                    if (max == folder.Count)
                        break;
                }
                folder.Expunge();
            }
            client.Disconnect(true);
            return (string[])files.ToArray(typeof(string));
        }

19 Source : T4MExtendsSC.cs
with Apache License 2.0
from chenyong2github

void SaveInPlayingMode(){
		
		string[] F = onPlayModeInstanceFolder.ToArray(typeof(string)) as string[];
		string[] G = onPlayModeInstanceGroup.ToArray(typeof(string)) as string[];
		Vector3[] P = onPlayModeInstancePos.ToArray(typeof(Vector3)) as Vector3[];
		Quaternion[]R = onPlayModeInstanceRot.ToArray(typeof(Quaternion)) as Quaternion[];
		Vector3[] S = onPlayModeInstanceSize.ToArray(typeof(Vector3)) as Vector3[];
		Vector3[] D = onPlayModeDestroyed.ToArray(typeof(Vector3)) as Vector3[];
		
		for (int i=0;i<F.Length;i++){
			GameObject test = PrefabUtility.InstantiatePrefab((GameObject)replacedetDatabase.LoadreplacedetAtPath(F[i], typeof(GameObject))) as GameObject;
			test.transform.position = P[i];
			test.transform.rotation = R[i];
			test.transform.localScale = S[i];
			if (!test.GetComponent<T4MPlantObjSC>())
					test.AddComponent <T4MPlantObjSC>();
			GameObject Group = GameObject.Find(G[i]);
			if (!Group){
				Group = new GameObject (G[i]);
			}
			test.transform.parent = Group.transform;
		}
		T4MPlantObjSC[] T4MPlantToErase =  GameObject.FindObjectsOfType(typeof(T4MPlantObjSC)) as T4MPlantObjSC[];
		for (int j=0;j<D.Length;j++){
			for (int k=0;k<T4MPlantToErase.Length;k++){
				if (T4MPlantToErase[k].gameObject.transform.position == D[j])
					DestroyImmediate(T4MPlantToErase[k].gameObject);
					T4MPlantToErase =  GameObject.FindObjectsOfType(typeof(T4MPlantObjSC)) as T4MPlantObjSC[];
					
			}
		}
			onPlayModeInstanceFolder = new ArrayList();
			onPlayModeInstanceGroup = new ArrayList();
			onPlayModeInstancePos = new ArrayList();
			onPlayModeInstanceRot = new ArrayList();
			onPlayModeInstanceSize = new ArrayList();
			onPlayModeDestroyed = new ArrayList();
	}

19 Source : VisualDisk.cs
with Apache License 2.0
from chenxuuu

public IMailFolder[] GetFolders(string path = "")
        {
            ArrayList folders = new ArrayList();

            var personal = GetImapClient().GetFolder(path);

            foreach (var folder in personal.GetSubfolders(false))
            {
                if (folder.GetSubfolders(false).Count > 0)
                {
                    folders.Add(folder);
                    folders.AddRange(GetFolders(folder.FullName));
                }
                else
                {
                    folders.Add(folder);
                }
            }
            return (IMailFolder[])folders.ToArray(typeof(IMailFolder));
        }

19 Source : CollectionUtility.cs
with MIT License
from codewitch-honey-crisis

public static Array ToArray(this ICollection source, Type elementType)
		{
			var al = new ArrayList(source);
			return al.ToArray(elementType);
		}

19 Source : CollectionUtility.cs
with MIT License
from codewitch-honey-crisis

public static Array ToArray(this IEnumerable source, Type elementType)
		{
			var al = new ArrayList();
			foreach (object o in source)
				al.Add(o);
			return al.ToArray(elementType);
		}

19 Source : classmanager.cs
with MIT License
from CoFlows

private static ClreplacedInfo GetClreplacedInfo(Type type)
        {
            var ci = new ClreplacedInfo(type);
            var methods = new Hashtable();
            ArrayList list;
            MethodInfo meth;
            ManagedType ob;
            string name;
            object item;
            Type tp;
            int i, n;

            // This is complicated because inheritance in Python is name
            // based. We can't just find DeclaredOnly members, because we
            // could have a base clreplaced A that defines two overloads of a
            // method and a clreplaced B that defines two more. The name-based
            // descriptor Python will find needs to know about inherited
            // overloads as well as those declared on the sub clreplaced.
            BindingFlags flags = BindingFlags.Static |
                                 BindingFlags.Instance |
                                 BindingFlags.Public |
                                 BindingFlags.NonPublic;

            MemberInfo[] info = type.GetMembers(flags);
            var local = new Hashtable();
            var items = new ArrayList();
            MemberInfo m;

            // Loop through once to find out which names are declared
            for (i = 0; i < info.Length; i++)
            {
                m = info[i];
                if (m.DeclaringType == type)
                {
                    local[m.Name] = 1;
                }
            }

            // Now again to filter w/o losing overloaded member info
            for (i = 0; i < info.Length; i++)
            {
                m = info[i];
                if (local[m.Name] != null)
                {
                    items.Add(m);
                }
            }

            if (type.IsInterface)
            {
                // Interface inheritance seems to be a different animal:
                // more contractual, less structural.  Thus, a Type that
                // represents an interface that inherits from another
                // interface does not return the inherited interface's
                // methods in GetMembers. For example ICollection inherits
                // from IEnumerable, but ICollection's GetMemebers does not
                // return GetEnumerator.
                //
                // Not sure if this is the correct way to fix this, but it
                // seems to work. Thanks to Bruce Dodson for the fix.

                Type[] inheritedInterfaces = type.GetInterfaces();

                for (i = 0; i < inheritedInterfaces.Length; ++i)
                {
                    Type inheritedType = inheritedInterfaces[i];
                    MemberInfo[] imembers = inheritedType.GetMembers(flags);
                    for (n = 0; n < imembers.Length; n++)
                    {
                        m = imembers[n];
                        if (local[m.Name] == null)
                        {
                            items.Add(m);
                        }
                    }
                }
            }

            for (i = 0; i < items.Count; i++)
            {
                var mi = (MemberInfo)items[i];

                switch (mi.MemberType)
                {
                    case MemberTypes.Method:
                        meth = (MethodInfo)mi;
                        if (!(meth.IsPublic || meth.IsFamily ||
                              meth.IsFamilyOrreplacedembly))
                        {
                            continue;
                        }
                        name = meth.Name;
                        item = methods[name];
                        if (item == null)
                        {
                            item = methods[name] = new ArrayList();
                        }
                        list = (ArrayList)item;
                        list.Add(meth);
                        continue;

                    case MemberTypes.Property:
                        var pi = (PropertyInfo)mi;

                        MethodInfo mm = null;
                        try
                        {
                            mm = pi.GetGetMethod(true);
                            if (mm == null)
                            {
                                mm = pi.GetSetMethod(true);
                            }
                        }
                        catch (SecurityException)
                        {
                            // GetGetMethod may try to get a method protected by
                            // StrongNameIdenreplacedyPermission - effectively private.
                            continue;
                        }

                        if (mm == null)
                        {
                            continue;
                        }

                        if (!(mm.IsPublic || mm.IsFamily || mm.IsFamilyOrreplacedembly))
                        {
                            continue;
                        }

                        // Check for indexer
                        ParameterInfo[] args = pi.GetIndexParameters();
                        if (args.GetLength(0) > 0)
                        {
                            Indexer idx = ci.indexer;
                            if (idx == null)
                            {
                                ci.indexer = new Indexer();
                                idx = ci.indexer;
                            }
                            idx.AddProperty(pi);
                            continue;
                        }

                        ob = new PropertyObject(pi);
                        ci.members[pi.Name] = ob;
                        continue;

                    case MemberTypes.Field:
                        var fi = (FieldInfo)mi;
                        if (!(fi.IsPublic || fi.IsFamily || fi.IsFamilyOrreplacedembly))
                        {
                            continue;
                        }
                        ob = new FieldObject(fi);
                        ci.members[mi.Name] = ob;
                        continue;

                    case MemberTypes.Event:
                        var ei = (EventInfo)mi;
                        MethodInfo me = ei.GetAddMethod(true);
                        if (!(me.IsPublic || me.IsFamily || me.IsFamilyOrreplacedembly))
                        {
                            continue;
                        }
                        ob = new EventObject(ei);
                        ci.members[ei.Name] = ob;
                        continue;

                    case MemberTypes.NestedType:
                        tp = (Type)mi;
                        if (!(tp.IsNestedPublic || tp.IsNestedFamily ||
                              tp.IsNestedFamORreplacedem))
                        {
                            continue;
                        }
                        // Note the given instance might be uninitialized
                        ob = GetClreplaced(tp);
                        ci.members[mi.Name] = ob;
                        continue;
                }
            }

            IDictionaryEnumerator iter = methods.GetEnumerator();

            while (iter.MoveNext())
            {
                name = (string)iter.Key;
                list = (ArrayList)iter.Value;

                var mlist = (MethodInfo[])list.ToArray(typeof(MethodInfo));

                ob = new MethodObject(type, name, mlist);
                ci.members[name] = ob;
            }

            return ci;
        }

19 Source : methodbinder.cs
with MIT License
from CoFlows

internal MethodBase[] GetMethods()
        {
            if (!init)
            {
                // I'm sure this could be made more efficient.
                list.Sort(new MethodSorter());
                methods = (MethodBase[])list.ToArray(typeof(MethodBase));
                init = true;
            }
            return methods;
        }

19 Source : Functions.cs
with MIT License
from CoreOpenMMO

private static object ConvertStringToNewNonNullableType(string value, Type newType)
        {
            // Do conversion form string to array - not sure how array will be stored in string
            if (newType.IsArray)
            {
                // For comma separated list
                var singleItemType = newType.GetElementType();

                var elements = new ArrayList();
                foreach (var element in value.Split(','))
                {
                    var convertedSingleItem = ConvertSingleItem(element, singleItemType);
                    elements.Add(convertedSingleItem);
                }

                return elements.ToArray(singleItemType);
            }

            return ConvertSingleItem(value, newType);
        }

19 Source : DataContractSerializerOperationFormatter.cs
with MIT License
from CoreWCF

protected override void GetHeadersFromMessage(Message message, MessageDescription messageDescription, object[] parameters, bool isRequest)
        {
            MessageInfo messageInfo = isRequest ? requestMessageInfo : replyMessageInfo;
            if (!messageInfo.AnyHeaders)
            {
                return;
            }

            MessageHeaders headers = message.Headers;
            KeyValuePair<Type, ArrayList>[] multipleHeaderValues = null;
            ArrayList elementList = null;
            if (messageInfo.UnknownHeaderDescription != null)
            {
                elementList = new ArrayList();
            }

            for (int i = 0; i < headers.Count; i++)
            {
                MessageHeaderInfo header = headers[i];
                MessageHeaderDescription headerDescription = messageInfo.HeaderDescriptionTable.Get(header.Name, header.Namespace);
                if (headerDescription != null)
                {
                    if (header.MustUnderstand)
                    {
                        headers.UnderstoodHeaders.Add(header);
                    }

                    object item = null;
                    XmlDictionaryReader headerReader = headers.GetReaderAtHeader(i);
                    try
                    {
                        object dataValue = DeserializeHeaderContents(headerReader, messageDescription, headerDescription);
                        if (headerDescription.TypedHeader)
                        {
                            item = TypedHeaderManager.Create(headerDescription.Type, dataValue, headers[i].MustUnderstand, headers[i].Relay, headers[i].Actor);
                        }
                        else
                        {
                            item = dataValue;
                        }
                    }
                    finally
                    {
                        headerReader.Dispose();
                    }

                    if (headerDescription.Multiple)
                    {
                        if (multipleHeaderValues == null)
                        {
                            multipleHeaderValues = new KeyValuePair<Type, ArrayList>[parameters.Length];
                        }

                        if (multipleHeaderValues[headerDescription.Index].Key == null)
                        {
                            multipleHeaderValues[headerDescription.Index] = new KeyValuePair<System.Type, System.Collections.ArrayList>(headerDescription.TypedHeader ? TypedHeaderManager.GetMessageHeaderType(headerDescription.Type) : headerDescription.Type, new ArrayList());
                        }
                        multipleHeaderValues[headerDescription.Index].Value.Add(item);
                    }
                    else
                    {
                        parameters[headerDescription.Index] = item;
                    }
                }
                else if (messageInfo.UnknownHeaderDescription != null)
                {
                    MessageHeaderDescription unknownHeaderDescription = messageInfo.UnknownHeaderDescription;
                    XmlDictionaryReader headerReader = headers.GetReaderAtHeader(i);
                    try
                    {
                        XmlDoreplacedent doc = new XmlDoreplacedent();
                        object dataValue = doc.ReadNode(headerReader);
                        if (dataValue != null && unknownHeaderDescription.TypedHeader)
                        {
                            dataValue = TypedHeaderManager.Create(unknownHeaderDescription.Type, dataValue, headers[i].MustUnderstand, headers[i].Relay, headers[i].Actor);
                        }

                        elementList.Add(dataValue);
                    }
                    finally
                    {
                        headerReader.Dispose();
                    }
                }
            }
            if (multipleHeaderValues != null)
            {
                for (int i = 0; i < parameters.Length; i++)
                {
                    if (multipleHeaderValues[i].Key != null)
                    {
                        parameters[i] = multipleHeaderValues[i].Value.ToArray(multipleHeaderValues[i].Key);
                    }
                }
            }
            if (messageInfo.UnknownHeaderDescription != null)
            {
                parameters[messageInfo.UnknownHeaderDescription.Index] = elementList.ToArray(messageInfo.UnknownHeaderDescription.TypedHeader ? typeof(MessageHeader<XmlElement>) : typeof(XmlElement));
            }
        }

19 Source : DataContractSerializerOperationFormatter.cs
with MIT License
from CoreWCF

private object DeserializeParameter(XmlDictionaryReader reader, PartInfo part, bool isRequest)
        {
            if (part.Description.Multiple)
            {
                ArrayList items = new ArrayList();
                while (part.Serializer.IsStartObject(reader))
                {
                    items.Add(DeserializeParameterPart(reader, part, isRequest));
                }

                return items.ToArray(part.Description.Type);
            }
            return DeserializeParameterPart(reader, part, isRequest);
        }

19 Source : XmlSerializerOperationFormatter.cs
with MIT License
from CoreWCF

protected override void GetHeadersFromMessage(Message message, MessageDescription messageDescription, object[] parameters, bool isRequest)
        {
            try
            {
                XmlSerializer serializer;
                MessageHeaderDescriptionTable headerDescriptionTable;
                MessageHeaderDescription unknownHeaderDescription;
                if (isRequest)
                {
                    serializer = _requestMessageInfo.HeaderSerializer;
                    headerDescriptionTable = _requestMessageInfo.HeaderDescriptionTable;
                    unknownHeaderDescription = _requestMessageInfo.UnknownHeaderDescription;
                }
                else
                {
                    serializer = _replyMessageInfo.HeaderSerializer;
                    headerDescriptionTable = _replyMessageInfo.HeaderDescriptionTable;
                    unknownHeaderDescription = _replyMessageInfo.UnknownHeaderDescription;
                }
                MessageHeaders headers = message.Headers;
                ArrayList unknownHeaders = null;
                XmlDoreplacedent xmlDoc = null;
                if (unknownHeaderDescription != null)
                {
                    unknownHeaders = new ArrayList();
                    xmlDoc = new XmlDoreplacedent();
                }
                if (serializer == null)
                {
                    if (unknownHeaderDescription != null)
                    {
                        for (int headerIndex = 0; headerIndex < headers.Count; headerIndex++)
                        {
                            AddUnknownHeader(unknownHeaderDescription, unknownHeaders, xmlDoc, null/*bufferWriter*/, headers[headerIndex], headers.GetReaderAtHeader(headerIndex));
                        }

                        parameters[unknownHeaderDescription.Index] = unknownHeaders.ToArray(unknownHeaderDescription.TypedHeader ? typeof(MessageHeader<XmlElement>) : typeof(XmlElement));
                    }
                    return;
                }


                MemoryStream memoryStream = new MemoryStream();
                XmlDictionaryWriter bufferWriter = XmlDictionaryWriter.CreateTextWriter(memoryStream);
                message.WriteStartEnvelope(bufferWriter);
                message.WriteStartHeaders(bufferWriter);
                MessageHeaderOfTHelper messageHeaderOfTHelper = null;
                for (int headerIndex = 0; headerIndex < headers.Count; headerIndex++)
                {
                    MessageHeaderInfo header = headers[headerIndex];
                    XmlDictionaryReader headerReader = headers.GetReaderAtHeader(headerIndex);
                    MessageHeaderDescription matchingHeaderDescription = headerDescriptionTable.Get(header.Name, header.Namespace);
                    if (matchingHeaderDescription != null)
                    {
                        if (header.MustUnderstand)
                        {
                            headers.UnderstoodHeaders.Add(header);
                        }

                        if (matchingHeaderDescription.TypedHeader)
                        {
                            if (messageHeaderOfTHelper == null)
                            {
                                messageHeaderOfTHelper = new MessageHeaderOfTHelper(parameters.Length);
                            }

                            messageHeaderOfTHelper.SetHeaderAttributes(matchingHeaderDescription, header.MustUnderstand, header.Relay, header.Actor);
                        }
                    }
                    if (matchingHeaderDescription == null && unknownHeaderDescription != null)
                    {
                        AddUnknownHeader(unknownHeaderDescription, unknownHeaders, xmlDoc, bufferWriter, header, headerReader);
                    }
                    else
                    {
                        bufferWriter.WriteNode(headerReader, false);
                    }

                    headerReader.Dispose();
                }
                bufferWriter.WriteEndElement();
                bufferWriter.WriteEndElement();
                bufferWriter.Flush();

                /*
                XmlDoreplacedent doc = new XmlDoreplacedent();
                memoryStream.Position = 0;
                doc.Load(memoryStream);
                doc.Save(Console.Out);
                */

                memoryStream.Position = 0;
                memoryStream.TryGetBuffer(out ArraySegment<byte> memoryBuffer);
                XmlDictionaryReader bufferReader = XmlDictionaryReader.CreateTextReader(memoryBuffer.Array, 0, (int)memoryStream.Length, XmlDictionaryReaderQuotas.Max);

                bufferReader.ReadStartElement();
                bufferReader.MoveToContent();
                if (!bufferReader.IsEmptyElement)
                {
                    bufferReader.ReadStartElement();
                    object[] headerValues = (object[])serializer.Deserialize(bufferReader, _isEncoded ? GetEncoding(message.Version.Envelope) : null);
                    int headerIndex = 0;
                    foreach (MessageHeaderDescription headerDescription in messageDescription.Headers)
                    {
                        if (!headerDescription.IsUnknownHeaderCollection)
                        {
                            object parameterValue = headerValues[headerIndex++];
                            if (headerDescription.TypedHeader && parameterValue != null)
                            {
                                parameterValue = messageHeaderOfTHelper.CreateMessageHeader(headerDescription, parameterValue);
                            }

                            parameters[headerDescription.Index] = parameterValue;
                        }
                    }
                    bufferReader.Dispose();
                }
                if (unknownHeaderDescription != null)
                {
                    parameters[unknownHeaderDescription.Index] = unknownHeaders.ToArray(unknownHeaderDescription.TypedHeader ? typeof(MessageHeader<XmlElement>) : typeof(XmlElement));
                }
            }
            catch (InvalidOperationException e)
            {
                // all exceptions from XmlSerializer get wrapped in InvalidOperationException,
                // so we must be conservative and never turn this into a fault
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                    SR.Format(SR.SFxErrorDeserializingHeader, messageDescription.MessageName), e));
            }
        }

19 Source : JSON.cs
with MIT License
from CreateBrowser

private object CreateArray(ArrayList data, Type pt, Type bt, Dictionary<string, object> globalTypes)
	{
		ArrayList col = new ArrayList();
		// create an array of objects
		foreach (object ob in data)
		{
			if (ob is IDictionary)
				col.Add(ParseDictionary((Dictionary<string, object>)ob, globalTypes, bt, null));
			else
				col.Add(ChangeType(ob, bt));
		}
		return col.ToArray(bt);
	}

19 Source : AssociativeEntityPropertyBag.cs
with MIT License
from CslaGenFork

public PropertySpec[] ToArray()
            {
                return (PropertySpec[]) _innerArray.ToArray(typeof (PropertySpec));
            }

19 Source : AssociativeEntityPropertyBag.cs
with MIT License
from CslaGenFork

PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
        {
            // Rather than preplaceding this function on to the default TypeDescriptor,
            // which would return the actual properties of replacedociativeEnreplacedyPropertyBag, I construct
            // a list here that contains property descriptors for the elements of the
            // Properties list in the bag.

            var props = new ArrayList();

            foreach (PropertySpec property in _properties)
            {
                var attrs = new ArrayList();

                // If a category, description, editor, or type converter are specified
                // in the PropertySpec, create attributes to define that relationship.
                if (property.Category != null)
                    attrs.Add(new CategoryAttribute(property.Category));

                if (property.Description != null)
                    attrs.Add(new DescriptionAttribute(property.Description));

                if (property.EditorTypeName != null)
                    attrs.Add(new EditorAttribute(property.EditorTypeName, typeof (UITypeEditor)));

                if (property.ConverterTypeName != null)
                    attrs.Add(new TypeConverterAttribute(property.ConverterTypeName));

                // Additionally, append the custom attributes replacedociated with the
                // PropertySpec, if any.
                if (property.Attributes != null)
                    attrs.AddRange(property.Attributes);

                if (property.DefaultValue != null)
                    attrs.Add(new DefaultValueAttribute(property.DefaultValue));

                attrs.Add(new BrowsableAttribute(property.Browsable));
                attrs.Add(new ReadOnlyAttribute(property.ReadOnly));
                attrs.Add(new BindableAttribute(property.Bindable));

                var attrArray = (Attribute[]) attrs.ToArray(typeof (Attribute));

                // Create a new property descriptor for the property item, and add
                // it to the list.
                var pd = new PropertySpecDescriptor(property,
                                                    this, property.Name, attrArray);
                props.Add(pd);
            }

            // Convert the list of PropertyDescriptors to a collection that the
            // ICustomTypeDescriptor can use, and return it.
            var propArray = (PropertyDescriptor[]) props.ToArray(
                typeof (PropertyDescriptor));
            return new PropertyDescriptorCollection(propArray);
        }

19 Source : AuthorizationRuleBag.cs
with MIT License
from CslaGenFork

PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
        {
            // Rather than preplaceding this function on to the default TypeDescriptor,
            // which would return the actual properties of AuthorizationRuleBag, I construct
            // a list here that contains property descriptors for the elements of the
            // Properties list in the bag.

            var props = new ArrayList();

            foreach (PropertySpec property in _properties)
            {
                var attrs = new ArrayList();

                // If a category, description, editor, or type converter are specified
                // in the PropertySpec, create attributes to define that relationship.
                if (property.Category != null)
                    attrs.Add(new CategoryAttribute(property.Category));

                if (property.Description != null)
                    attrs.Add(new DescriptionAttribute(property.Description));

                if (property.EditorTypeName != null)
                    attrs.Add(new EditorAttribute(property.EditorTypeName, typeof (UITypeEditor)));

                if (property.ConverterTypeName != null)
                    attrs.Add(new TypeConverterAttribute(property.ConverterTypeName));

                // Additionally, append the custom attributes replacedociated with the
                // PropertySpec, if any.
                if (property.Attributes != null)
                    attrs.AddRange(property.Attributes);

                if (property.DefaultValue != null)
                    attrs.Add(new DefaultValueAttribute(property.DefaultValue));

                attrs.Add(new BrowsableAttribute(property.Browsable));
                attrs.Add(new ReadOnlyAttribute(property.ReadOnly));
                attrs.Add(new BindableAttribute(property.Bindable));

                var attrArray = (Attribute[]) attrs.ToArray(typeof (Attribute));

                // Create a new property descriptor for the property item, and add
                // it to the list.
                var pd = new PropertySpecDescriptor(property, this, property.Name, attrArray);
                props.Add(pd);
            }

            // Convert the list of PropertyDescriptors to a collection that the
            // ICustomTypeDescriptor can use, and return it.
            var propArray = (PropertyDescriptor[]) props.ToArray(
                typeof (PropertyDescriptor));
            return new PropertyDescriptorCollection(propArray);
        }

See More Examples