/// <summary> /// Extracts the inner list from the System.Collections.CollectionBase. /// </summary> /// <param name="collection">The collection base to extract from.</param> /// <returns>An array list that is the inner list for a collection base object.</returns> public static System.Collections.ArrayList GetInnerList(System.Collections.CollectionBase collection) { // check to see if collection object is null if (collection == null) { throw new ArgumentNullException("collection", "Unable to extract the inner list for a null collection."); } // declare the property member array PropertyInfo[] proparray; // get the object type Type objtype = collection.GetType(); // Get the properties of the collection proparray = objtype.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance); // create a return variable for the inner list. System.Collections.ArrayList innerlist = null; // get the inner list for (int i = 0; i < proparray.Length; i++) { if (proparray[i].Name == "InnerList") { innerlist = proparray[i].GetValue(collection, null) as System.Collections.ArrayList; break; } } // return the inner list return(innerlist); }
private void Button_Click(object sender, RoutedEventArgs e) { string output = ""; PSMemberInfoCollection <PSPropertyInfo> props = adUser.Properties; PSPropertyInfo propMem = props["MemberOf"]; object propMemVal = propMem.Value; //ADPropertyValueCollection System.Collections.CollectionBase x = propMemVal as System.Collections.CollectionBase; //Type t = propMemVal.GetType(); //MessageBoxResult messageBoxResult1 = System.Windows.MessageBox.Show(this, t.ToString(), "Member Groups", System.Windows.MessageBoxButton.OK); //Array x = propMemVal as Array; foreach (var memberGroup in x) { string memberString = memberGroup as string; string memberStringReduced = memberString.Substring(memberString.IndexOf('=') + 1, memberString.IndexOf(',') - 3); output += memberStringReduced + "\n"; } MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(this, output, "Member Groups", System.Windows.MessageBoxButton.OK); }
public CompileException(System.Collections.CollectionBase errors) : base("Compile Error") { this.Errors = Enumerable.Cast <CompilerError>(errors); }