当前位置: 首页>>代码示例>>C#>>正文


C# IList.GetType方法代码示例

本文整理汇总了C#中IList.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IList.GetType方法的具体用法?C# IList.GetType怎么用?C# IList.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IList的用法示例。


在下文中一共展示了IList.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateTime

        public static void CalculateTime(IList list, int k)
        {
            // Add
            var startAdding = DateTime.Now;
            string test = "Test string";
            for (int i = 0; i < k; i++)
            {
                list.Add(test);
            }
            var finishAdding = DateTime.Now;
            Console.WriteLine("Addition time (" + k + " elements) : " + list.GetType() + "  " + (finishAdding - startAdding));
            // Search
            var startSearch = DateTime.Now;
            for (int i = 0; i < k; i++)
            {
                bool a = list.Contains(test);
            }
            var finishSearch = DateTime.Now;
            Console.WriteLine("Search time (" + k + " elements) : " + list.GetType() + "  " + (finishSearch - startSearch));

            // Remove
            k = 1000;
            var startRemoving = DateTime.Now;
            for (int i = 0; i < k; i++)
            {
                list.Remove(test);
            }
            var finishRemoving = DateTime.Now;
            Console.WriteLine("Removal time (" + k + " elements) : " + list.GetType() + "  " + (finishRemoving - startRemoving) + "\n");
        }
开发者ID:yuliapetrova,项目名称:CSharpTasks,代码行数:30,代码来源:Program.cs

示例2: OnItemsSourceChanged

        protected virtual void OnItemsSourceChanged(IList oldValue, IList newValue)
        {
            if (newValue == null)
                return;

            if (ItemsSourceType == null)
                ItemsSourceType = newValue.GetType();

            if (ItemType == null)
                ItemType = newValue.GetType().GetGenericArguments()[0];

            if (newValue.Count > 0)
                SetText(newValue);
        }
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:14,代码来源:PrimitiveTypeCollectionEditor.cs

示例3: IListTypeDefinitionFinder

        public IListTypeDefinitionFinder(IList list)
        {
            if (list == null) throw new ArgumentNullException("list");

            _listType = list.GetType();
            SetListTypeUnderlyingType();
        }
开发者ID:dibley1973,项目名称:StoredProcedureFramework,代码行数:7,代码来源:IListTypeDefinitionFinder.cs

示例4: ToJsonR

        public object ToJsonR(IList items, Style style = Style.Full)
        {
            var jsonR = new JsonR();

            Type itemType = GetListItemType(items.GetType());
            jsonR.Type    = itemType.Name;

            SplitKeyValues(items, jsonR.Keys, jsonR.Values);
            switch (style)
            {
                case Style.Keys:
                    return jsonR.Keys;

                case Style.Values:
                    return jsonR.Values;

                case Style.Type:
                    return jsonR.Type;

                case Style.Hint:
                    return new {jsonR.Type, jsonR.Values };
            }

            return jsonR;
        }
开发者ID:itechnology,项目名称:JsonRaw,代码行数:25,代码来源:Parser.cs

示例5: GetClipboardTextFromIList

 public static String GetClipboardTextFromIList(IList argList, CultureInfo argCultureInfo, Boolean argWithHeaders, String argCellSeparator)
 {
     // Create the StringBuilder
     StringBuilder finalBuilder = new StringBuilder();
     if (argWithHeaders)
     {
         foreach (PropertyInfo prop in argList.GetType().GetGenericArguments()[0].GetProperties())
         {
             finalBuilder.AppendFormat("{0}{1}", GetClipboardTextFromValueObject(prop.Name, argCultureInfo).Replace(argCellSeparator, String.Empty), argCellSeparator);
         }
         if (finalBuilder.Length > argCellSeparator.Length - 1)
         {
             finalBuilder.Length -= argCellSeparator.Length; //remove cell separator character
         }
         finalBuilder.Append("\r\n"); // add \r\n
     }
     foreach (Object item in argList)
     {
         finalBuilder.AppendFormat("{0}\r\n", GetClipboardTextFromObject(item, argCultureInfo, argCellSeparator)); // add \r\n
     }
     if (finalBuilder.Length > 1)
     {
         finalBuilder.Length -= 2; //remove \r\n character
     }
     return finalBuilder.ToString();
 }
开发者ID:Gpower2,项目名称:gSqlUtils,代码行数:26,代码来源:ClipboardHelper.cs

示例6: SerializeXml

        //ArrayList openElements = new ArrayList();
        public void SerializeXml(IList<StarSystem> starSystems)
        {
            MemoryStream memXmlStream = new MemoryStream();
            XmlSerializer serializer = new XmlSerializer(starSystems.GetType(), null, new Type[] { typeof(Planet), typeof(StarSystem) }, new XmlRootAttribute("Stars"), null, null);

            serializer.Serialize(memXmlStream, starSystems);

            XmlDocument xmlDoc = new XmlDocument();

            memXmlStream.Seek(0, SeekOrigin.Begin);
            xmlDoc.Load(memXmlStream);

            XmlProcessingInstruction newPI;
            String PItext = string.Format("type='text/xsl' href='{0}'", "system.xslt");
            newPI = xmlDoc.CreateProcessingInstruction("xml-stylesheet", PItext);

            xmlDoc.InsertAfter(newPI, xmlDoc.FirstChild);

            // Now write the document

            // out to the final output stream

            XmlTextWriter wr = new XmlTextWriter("system.xml", System.Text.Encoding.ASCII);
            wr.Formatting = Formatting.Indented;
            wr.IndentChar = '\t';
            wr.Indentation = 1;

            XmlWriterSettings settings = new XmlWriterSettings();
            XmlWriter writer = XmlWriter.Create(wr, settings);

            xmlDoc.WriteTo(writer);
            writer.Flush();
            //Console.Write(xmlDoc.InnerXml);
        }
开发者ID:sveco,项目名称:AccreteSharp,代码行数:35,代码来源:SystemDisplayXml.cs

示例7: FindNew

        public static IList<IDatabaseObject> FindNew(IList<IDatabaseObject> oldsource, IList<IDatabaseObject> newsource)
        {
            if (oldsource.GetType() != newsource.GetType())
                throw new Exception("Die Datentypen müssen für einen Vergleich gleich sein.");

            if (oldsource.Count < 1) return newsource;

            List<IDatabaseObject> result = new List<IDatabaseObject>();
            Type t = oldsource[0].GetType();
            PropertyInfo i = t.GetProperty("ObjectID");

            
            
            if(i != null)
                foreach (IDatabaseObject a in newsource)
                {
                    bool isContained = false;
                    foreach (IDatabaseObject b in oldsource)
                    {
                        int id1 = (int)i.GetValue(a, null);
                        int id2 = (int)i.GetValue(b, null);
                        if (id1 == id2)
                        {
                            isContained = true;
                            break;
                        }
                    }


                    if (!isContained) result.Add(a);
                }

            return result;
        }
开发者ID:fhoner,项目名称:Kasse,代码行数:34,代码来源:RefreshHelper.cs

示例8: List2XML

        /// <summary>
        /// Metodo para serializar una Lista de objetos en un XML simple
        /// </summary>
        /// <param name="thelist"> la lista de tipo List<T> </param>
        /// <returns></returns>
        public static string List2XML(IList thelist)
        {
            string xml = "";

            try
            {


                XmlSerializer xmlSer = new XmlSerializer(thelist.GetType());
                StringWriterWithEncoding sWriter = new StringWriterWithEncoding(Encoding.UTF8);

                XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
                xsn.Add(String.Empty, "");

                xmlSer.Serialize(sWriter, thelist, xsn);

                xml = sWriter.ToString();

              



            }
            catch (Exception e)
            {
               
            }

            return xml;
        }
开发者ID:julianobarbosa,项目名称:integradesigner,代码行数:35,代码来源:XMLObjectConverter.cs

示例9: Apply

        public static void Apply(this FilterScheme filterScheme, IEnumerable rawCollection, IList filteredCollection)
        {
            Argument.IsNotNull("filterScheme", filterScheme);
            Argument.IsNotNull("rawCollection", rawCollection);
            Argument.IsNotNull("filteredCollection", filteredCollection);

            IDisposable suspendToken = null;
            var filteredCollectionType = filteredCollection.GetType();
            if (filteredCollectionType.IsGenericTypeEx() && filteredCollectionType.GetGenericTypeDefinitionEx() == typeof(FastObservableCollection<>))
            {
                suspendToken = (IDisposable)filteredCollectionType.GetMethodEx("SuspendChangeNotifications").Invoke(filteredCollection, null);
            }

            filteredCollection.Clear();

            foreach (object item in rawCollection)
            {
                if (filterScheme.CalculateResult(item))
                {
                    filteredCollection.Add(item);
                }
            }

            if (suspendToken != null)
            {
                suspendToken.Dispose();
            }
        }
开发者ID:csuffyy,项目名称:Orc.FilterBuilder,代码行数:28,代码来源:FilterSchemeExtensions.cs

示例10: ListSource

		public ListSource(DialogViewController controller, IList list, IEnumerable<Type> viewTypes) : base(controller)
		{	
			Sections = new Dictionary<int, Section>();
			var section = new Section(controller) { DataContext = list };

			IList<Type> viewTypesList = null;
			if (viewTypes != null)
				viewTypesList = viewTypes.ToList();

			var genericType = list.GetType().GetGenericArguments().FirstOrDefault();
			CellId = new NSString(genericType.ToString());

			section.ViewTypes.Add(CellId, viewTypesList);
			
			Sections.Add(0, section);

			SelectedItems = list.GetType().CreateGenericListFromEnumerable(null);

			CellFactory = new TableCellFactory<UITableViewCell>(CellId);

//SelectionDisplayMode = SelectionDisplayMode.Collapsed;
//CollapsedList = new List<object>();
//			foreach(var item in Sections[0].DataContext)
//			{
//				CollapsedList.Add(item);
//			}
//			Sections[0].DataContext.Clear();
//
//IsCollapsed = true;
		}
开发者ID:drony,项目名称:MonoMobile.Views,代码行数:30,代码来源:ListSource.cs

示例11: ArrayAdapter

 public ArrayAdapter(IValue array)
 {
     _array = array;
     _list = array.ActualType.CreateGenericListInstance().As<IList>();
     _listType = _list.GetType().ToCachedType();
     _listType.InvokeAction("AddRange", _list, array.Instance);
 }
开发者ID:carl-berg,项目名称:Bender,代码行数:7,代码来源:ArrayAdapter.cs

示例12: CloneList

        /// <summary>
        /// Clones an IList object and returns a list with the same type as the original list.
        /// </summary>
        public static IList CloneList(IList list)
        {
            if (list == null)
                return null;

            var newList = Activator.CreateInstance(list.GetType()) as IList;
            foreach (var item in list)
                newList.Add(item);

            return newList;
        }
开发者ID:pedone,项目名称:DockingLibrary,代码行数:14,代码来源:ListHelper.cs

示例13: GetListElementsType

 public static Type GetListElementsType(IList Collection)
 {
     if (Collection == null)
     {
         return null;
     }
     else
     {
         return Collection.GetType().GenericTypeArguments.Single();
     }
 }
开发者ID:pgemeo,项目名称:WZNT,代码行数:11,代码来源:GlobalFunctions.cs

示例14: SelectedItemsReflector

            public SelectedItemsReflector(ListBox target, IList mirror)
            {
                if ((_target = target) == null) throw new ArgumentNullException("'target' cannot be null");
                if ((_mirror = mirror) == null) throw new ArgumentNullException("'mirror' cannot be null");

                var observable = _mirror as INotifyCollectionChanged;
                if (observable == null) throw new ArgumentException(String.Format("'mirror' has to be an instance of {0}, but {1}", typeof(INotifyCollectionChanged), _mirror.GetType()));

                _target.SelectionChanged -= SelectionChangedEventHandler;

                _target.SelectedItems.Clear();
                foreach (var item in _mirror) _target.SelectedItems.Add(item);

                _target.SelectionChanged += SelectionChangedEventHandler;
                observable.CollectionChanged += CollectionChangedEventHandler;
            }
开发者ID:vrishe,项目名称:watch-assistant,代码行数:16,代码来源:ListBoxHelper.cs

示例15: ListaDinamica

        public static MvcHtmlString ListaDinamica(this HtmlHelper html, string id, IList lista)
        {
            string strLink = String.Format("<ul data-role=\"listview\" data-filter=\"true\" data-filter-placeholder=\"Buscar...\" data-inset=\"true\">");

            PropertyInfo[] properties = lista.GetType().GetProperties();
            foreach (PropertyInfo property in properties)
            {
                if (property.PropertyType.Name == "Categoria")
                {
                    foreach (Entities.Categoria categoria in lista)
                    {
                        strLink += ("<li><a href=\"../Categoria/Editar/"+ categoria.Id.ToString() +"\">" + categoria.Nome.ToString() + "</a></li>");
                    }
                }
            }
            strLink += ("</ul>");
            return new MvcHtmlString(strLink);
        }
开发者ID:Josimar,项目名称:UpperCash,代码行数:18,代码来源:ListaDinamica.cs


注:本文中的IList.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。