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


C# OrderedDictionary.Contains方法代码示例

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


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

示例1: GetSelectedRowData

 public IOrderedDictionary GetSelectedRowData()
 {
     IOrderedDictionary result;
     if (null == this.SelectedRow)
     {
         result = null;
     }
     else
     {
         OrderedDictionary fieldValues = new OrderedDictionary();
         foreach (object field in this.CreateColumns(null, false))
         {
             if (field is BoundField && !fieldValues.Contains(((BoundField)field).DataField))
             {
                 fieldValues.Add(((BoundField)field).DataField, null);
             }
         }
         string[] dataKeyNames = this.DataKeyNames;
         for (int i = 0; i < dataKeyNames.Length; i++)
         {
             string key = dataKeyNames[i];
             if (!fieldValues.Contains(key))
             {
                 fieldValues.Add(key, null);
             }
         }
         this.ExtractRowValues(fieldValues, this.SelectedRow, true, true);
         result = fieldValues;
     }
     return result;
 }
开发者ID:t1b1c,项目名称:lwas,代码行数:31,代码来源:DataGridView.cs

示例2: GetQuery

 /// <summary>
 /// All shared queries must go here.
 /// </summary>
 /// <param name="queryName"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public static IQueryable<User> GetQuery(string queryName, OrderedDictionary parameters)
 {
     // Get parameters.
     string[] qa = queryName.Split('/');
     string p0 = qa[0];
     string p1 = (qa.Length > 1) ? qa[1] : string.Empty;
     string p2 = (qa.Length > 2) ? qa[2] : string.Empty;
     // Set predefined query.
     IQueryable<User> query = null;
     Guid userId = parameters.Contains("UserId") ? (Guid)parameters["UserId"] : Guid.Empty;
     var db = SecurityEntities.Current;
     UserQueryName qne = GuidEnum.TryParse<UserQueryName>(p0, UserQueryName.None, true);
     switch (qne)
     {
         case UserQueryName.All:
             query = from row in db.Users select row;
             break;
         default:
             throw new NotImplementedException(string.Format("{0} QueryName not supported", queryName));
         //break;
     }
     // Add search condition.
     if (parameters != null)
     {
         // Apply search filter.
         string searchValue;
         searchValue = parameters.Contains("SearchName") ? (string)parameters["SearchName"] : string.Empty;
         if (!string.IsNullOrEmpty(searchValue))
         {
             searchValue = searchValue.Trim();
             Guid uid;
             if (Guid.TryParse(searchValue, out uid))
             {
                 query = query.Where(x => x.UserId == uid);
             }
             else
             {
                 // we cant use FullText index inside linq so just extend command timout in order for 
                 // search not to fail.
                 if (db.CommandTimeout < 120) db.CommandTimeout = 120;
                 query = query.Where(x =>
                     x.UserName == searchValue);
             }
         }
     }
     return query;
 }
开发者ID:vcompestine,项目名称:x360ce,代码行数:53,代码来源:User.cs

示例3: PassingEqualityComparers

        public void PassingEqualityComparers()
        {
            var eqComp = new CaseInsensitiveEqualityComparer();
            var d1 = new OrderedDictionary(eqComp);
            d1.Add("foo", "bar");
            Assert.Throws<ArgumentException>(() => d1.Add("FOO", "bar"));

            // The equality comparer should also test for a non-existent key 
            d1.Remove("foofoo");
            Assert.True(d1.Contains("foo"));

            // Make sure we can change an existent key that passes the equality comparer
            d1["FOO"] = "barbar";
            Assert.Equal("barbar", d1["foo"]);

            d1.Remove("FOO");
            Assert.False(d1.Contains("foo"));
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:18,代码来源:OrderedDictionaryTests.cs

示例4: Common

		private void Common (OrderedDictionary od)
		{
			Assert.IsNotNull (od.GetEnumerator (), "GetEnumerator");
			Assert.AreEqual (0, od.Count, "Count-0");
			Assert.IsFalse (od.IsReadOnly, "IsReadOnly");
			od.Add ("a", "1");
			Assert.AreEqual (1, od.Count, "Count-1");
			od["a"] = "11";
			Assert.AreEqual ("11", od["a"], "this[string]");
			od[0] = "111";
			Assert.AreEqual ("111", od[0], "this[int]");

			DictionaryEntry[] array = new DictionaryEntry[2];
			od.CopyTo (array, 1);

			Assert.AreEqual ("111", ((DictionaryEntry)array[1]).Value, "CopyTo");
			Assert.AreEqual (1, od.Keys.Count, "Keys");
			Assert.AreEqual (1, od.Values.Count, "Values");
			Assert.IsTrue (od.Contains ("a"), "Contains(a)");
			Assert.IsFalse (od.Contains ("111"), "Contains(111)");

			od.Insert (0, "b", "2");
			Assert.AreEqual (2, od.Count, "Count-2");
			od.Add ("c", "3");
			Assert.AreEqual (3, od.Count, "Count-3");

			OrderedDictionary ro = od.AsReadOnly ();

			od.RemoveAt (2);
			Assert.AreEqual (2, od.Count, "Count-4");
			Assert.IsFalse (od.Contains ("c"), "Contains(c)");

			od.Remove ("b");
			Assert.AreEqual (1, od.Count, "Count-5");
			Assert.IsFalse (od.Contains ("b"), "Contains(b)");

			od.Clear ();
			Assert.AreEqual (0, od.Count, "Count-6");

			Assert.IsTrue (ro.IsReadOnly, "IsReadOnly-2");
			// it's a read-only reference
			Assert.AreEqual (0, od.Count, "Count-7");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:43,代码来源:OrderedDictionaryTest.cs

示例5: ExpandDependencies

 protected virtual void ExpandDependencies(ResourceDefinition resource, RequireSettings settings, OrderedDictionary allResources) {
     if (resource == null) {
         return;
     }
     // Settings is given so they can cascade down into dependencies. For example, if Foo depends on Bar, and Foo's required
     // location is Head, so too should Bar's location.
     // forge the effective require settings for this resource
     // (1) If a require exists for the resource, combine with it. Last settings in gets preference for its specified values.
     // (2) If no require already exists, form a new settings object based on the given one but with its own type/name.
     settings = allResources.Contains(resource)
         ? ((RequireSettings)allResources[resource]).Combine(settings)
         : new RequireSettings { Type = resource.Type, Name = resource.Name }.Combine(settings);
     if (resource.Dependencies != null) {
         var dependencies = from d in resource.Dependencies
                            select FindResource(new RequireSettings { Type = resource.Type, Name = d });
         foreach (var dependency in dependencies) {
             if (dependency == null) {
                 continue;
             }
             ExpandDependencies(dependency, settings, allResources);
         }
     }
     allResources[resource] = settings;
 }
开发者ID:wezmag,项目名称:Coevery,代码行数:24,代码来源:ResourceManager.cs

示例6: HandleCommand

        private bool HandleCommand(string commandName) {
            DataSourceView view = null;

            if (IsDataBindingAutomatic) {
                view = GetData();
                if (view == null) {
                    throw new HttpException(SR.GetString(SR.View_DataSourceReturnedNullView, ID));
                }
            }
            else {
                return false;
            }

            if (!view.CanExecute(commandName)) {
                return false;
            }
            
            OrderedDictionary values = new OrderedDictionary();
            OrderedDictionary keys = new OrderedDictionary();

            ExtractRowValues(values, true /*includeReadOnlyFields*/, false /*includePrimaryKey*/);
            foreach (DictionaryEntry entry in DataKey.Values) {
                keys.Add(entry.Key, entry.Value);
                if (values.Contains(entry.Key)) {
                    values.Remove(entry.Key);
                }
            }

            view.ExecuteCommand(commandName, keys, values, HandleCommandCallback);
            return true;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:31,代码来源:DetailsView.cs

示例7: ExportGradeSheet

        protected void ExportGradeSheet(object sender, EventArgs e)
        {
            DataHandler db = new DataHandler();

            using (db.Connect())
            {
                db.Command("ListAllCourseAndGradesForInstructor", true);
                db.Add("@instructor_id", SessionManager.Instructor.ID);

                db.Start();
                SqlDataReader reader = db.Exec();

                SpreadSheetExport excelExport = new SpreadSheetExport();
                excelExport.CreateSpreadSheet();

                //These values will keep track of the utilized Assignments and Students
                string prevCourse = "";
                string prevAssignment = "";
                string prevStudent = "";

                //Will use these values to keep track of where I'm placing values
                string student_column = "A";        //This shouldn't change
                uint student_row_value = 2;

                string assign_column = "B";
                uint assgn_row_value = 1;           //This shouldn't change.
                //I will only increment student_row_value and assign_column when new fields are added
                //----------------------------------------------------------------

                OrderedDictionary trackedReferences = new OrderedDictionary();
                //My current strategy to solve the issue of keeping track which Student and Assignment is what and where to place
                //the associated grade is to keep track of said Student and Assignment in an associative array. As I come across each
                //Student or assignment I will store thier col and row values in the array. Once I come across said Student or Assignment
                //Again I will reference it and use that value to put them in their rightful place.
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        string currentCourse = reader["course_name"].ToString();
                        string currentStudent = reader["student_name"].ToString();
                        string currentAssignment = reader["assignment_name"].ToString();
                        string currentAssignmentGrade = reader["assignment_grade"].ToString();

                        //This section determines whether we have a new Course to add or not
                        if (!prevCourse.Equals(currentCourse) && !prevCourse.Equals(""))      //We found a new Course name and it's not the first sheet
                        {
                            excelExport.AddWorkSheet(currentCourse);
                            student_row_value = 2;
                            assign_column = "B";
                            //Reset these values back to thier defaults since we're going to be using a new sheet
                        }
                        else if (prevCourse.Equals(""))     //This means our first runthrough. We're going to need the name of this course now
                        {
                            prevCourse = currentCourse;
                            excelExport.AddWorkSheet(currentCourse);
                        }

                        //We've come across a different assignment but we've seen it before AND not a new student
                        //if (!prevAssignment.Equals(reader["assignment_name"].ToString()) &&
                        //    (trackedReferences.Contains(reader["assignment_name"].ToString()) && trackedReferences.Contains(reader["student_name"].ToString())))
                        if (trackedReferences.Contains(currentStudent) && trackedReferences.Contains(currentAssignment))
                        {
                            excelExport.InsertTextInCell(currentAssignmentGrade, trackedReferences[currentAssignment].ToString(), (uint)trackedReferences[currentStudent], currentCourse);

                        } //New assignment and haven't added it before and existing student
                        else if ((!prevAssignment.Equals(currentAssignment) &&
                                 !trackedReferences.Contains(currentAssignment)) && trackedReferences.Contains(currentStudent))
                        {
                            excelExport.InsertTextInCell(currentAssignment, assign_column, assgn_row_value, currentCourse);
                            trackedReferences.Add(currentAssignment, assign_column);

                            excelExport.InsertTextInCell(currentAssignmentGrade, assign_column, (uint)trackedReferences[currentStudent], currentCourse);

                            assign_column = excelExport.IncrementColRef(assign_column);

                        } //New student found but not assignment
                        else if ((!prevStudent.Equals(currentStudent) && !trackedReferences.Contains(currentStudent)) && trackedReferences.Contains(currentAssignment))
                        {
                            excelExport.InsertTextInCell(currentStudent, student_column, student_row_value, currentCourse);
                            trackedReferences.Add(currentStudent, student_row_value);

                            excelExport.InsertTextInCell(currentAssignmentGrade, trackedReferences[currentAssignment].ToString(), student_row_value, currentCourse);
                            student_row_value++;
                        }
                        else if((!trackedReferences.Contains(currentStudent) && !trackedReferences.Contains(currentAssignment)) || (prevAssignment.Equals("") && prevStudent.Equals("")))  //This appears to be a new student and assignment. Add it and place in dictionary
                        {
                            excelExport.InsertTextInCell(currentStudent, student_column, student_row_value, currentCourse);
                            trackedReferences.Add(currentStudent, student_row_value);

                            excelExport.InsertTextInCell(currentAssignment, assign_column, assgn_row_value, currentCourse);
                            trackedReferences.Add(currentAssignment, assign_column);

                            excelExport.InsertTextInCell(currentAssignmentGrade, assign_column, student_row_value, currentCourse);

                            student_row_value++;
                            assign_column = excelExport.IncrementColRef(assign_column);
                        }

                        //This may look weird, but I'm doing this to capture the previous value in this variable because on next iration the real current values will be captured
                        prevCourse = currentCourse;
//.........这里部分代码省略.........
开发者ID:ke5vmj,项目名称:GradeBookNET,代码行数:101,代码来源:Report.aspx.cs

示例8: HandleCommand

 private bool HandleCommand(string commandName)
 {
     DataSourceView data = null;
     if (base.IsBoundUsingDataSourceID)
     {
         data = this.GetData();
         if (data == null)
         {
             throw new HttpException(System.Web.SR.GetString("View_DataSourceReturnedNullView", new object[] { this.ID }));
         }
     }
     else
     {
         return false;
     }
     if (!data.CanExecute(commandName))
     {
         return false;
     }
     OrderedDictionary fieldValues = new OrderedDictionary();
     OrderedDictionary keys = new OrderedDictionary();
     this.ExtractRowValues(fieldValues, true, false);
     foreach (DictionaryEntry entry in this.DataKey.Values)
     {
         keys.Add(entry.Key, entry.Value);
         if (fieldValues.Contains(entry.Key))
         {
             fieldValues.Remove(entry.Key);
         }
     }
     data.ExecuteCommand(commandName, keys, fieldValues, new DataSourceViewOperationCallback(this.HandleCommandCallback));
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:DetailsView.cs

示例9: HandleCommand

        private bool HandleCommand(ListViewItem item, int itemIndex, string commandName) {
            DataSourceView view = null;

            if (IsDataBindingAutomatic) {
                view = GetData();
                if (view == null) {
                    throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, AtlasWeb.ListView_NullView, ID));
                }
            }
            else {
                return false;
            }

            if (!view.CanExecute(commandName)) {
                return false;
            }

            ListViewDataItem dataItem = item as ListViewDataItem;
            if (itemIndex < 0 && dataItem == null) {
                throw new InvalidOperationException(AtlasWeb.ListView_InvalidCommand);
            }

            OrderedDictionary values = new OrderedDictionary();
            OrderedDictionary keys = new OrderedDictionary();
            if (item != null) {
                ExtractItemValues(values, item, false /*includePrimaryKey*/);
            }

            if (DataKeys.Count > itemIndex) {
                foreach (DictionaryEntry entry in DataKeys[itemIndex].Values) {
                    keys.Add(entry.Key, entry.Value);
                    if (values.Contains(entry.Key)) {
                        values.Remove(entry.Key);
                    }
                }
            }
            
            view.ExecuteCommand(commandName, keys, values, HandleCommandCallback);
            return true;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:40,代码来源:ListView.cs

示例10: CopyToTests

        public void CopyToTests()
        {
            var d = new OrderedDictionary();
            d["foo"] = "bar";
            d["   "] = "asd";

            DictionaryEntry[] arr = new DictionaryEntry[3];

            Assert.Throws<ArgumentNullException>(() => d.CopyTo(null, 0));
            Assert.Throws<ArgumentOutOfRangeException>(() => d.CopyTo(arr, -1));
            Assert.Throws<ArgumentException>(() => d.CopyTo(arr, 3));

            d.CopyTo(arr, 0);
            for (int i = 0; i < 2; i++)
            {
                Assert.True(d.Contains(arr[i].Key));
                Assert.Equal(d[arr[i].Key], arr[i].Value);
            }
            Assert.NotEqual(arr[0].Key, arr[1].Key);

            d.CopyTo(arr, 1);
            for (int i = 1; i < 3; i++)
            {
                Assert.True(d.Contains(arr[i].Key));
                Assert.Equal(d[arr[i].Key], arr[i].Value);
            }
            Assert.NotEqual(arr[1].Key, arr[2].Key);
        }
开发者ID:rajeevkb,项目名称:corefx,代码行数:28,代码来源:OrderedDictionaryTests.cs

示例11: GetValues

		public IOrderedDictionary GetValues (HttpContext context, Control control)
		{
			OrderedDictionary values = new OrderedDictionary ();
			foreach (Parameter param in this)
			{
				string name = param.Name;
				for (int i = 1; values.Contains (name); i++)
					name = param.Name + i.ToString ();
				values.Add (name, param.GetValue (context, control));
			}
			return values;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:12,代码来源:ParameterCollection.cs

示例12: MergeParameterValues

		IOrderedDictionary MergeParameterValues (ParameterCollection viewParams, IDictionary values, IDictionary oldValues, bool allwaysAddNewValues)
		{
			OrderedDictionary mergedValues = new OrderedDictionary ();
			foreach (Parameter p in viewParams) {
				bool oldAdded = false;
				if (oldValues != null && oldValues.Contains (p.Name)) {
					object val = Convert.ChangeType (oldValues [p.Name], p.Type);
					mergedValues [FormatOldParameter (p.Name)] = val;
					oldAdded = true;
				}
				
				if (values != null && values.Contains (p.Name)) {
					object val = Convert.ChangeType (values [p.Name], p.Type);
					mergedValues [p.Name] = val;
				} else if (!oldAdded || allwaysAddNewValues) {
					object val = p.GetValue (context, owner);
					mergedValues [p.Name] = val;
				}
			}
			
			if (values != null) {
				foreach (DictionaryEntry de in values)
					if (!mergedValues.Contains (de.Key))
						mergedValues [de.Key] = de.Value;
			}
			
			if (oldValues != null) {
				foreach (DictionaryEntry de in oldValues)
					if (!mergedValues.Contains (FormatOldParameter ((string)de.Key)))
						mergedValues [FormatOldParameter ((string)de.Key)] = de.Value;
			}
			
			return mergedValues;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:34,代码来源:ObjectDataSourceView.cs

示例13: GetValues

 public IOrderedDictionary GetValues(HttpContext context, Control control)
 {
     this.UpdateValues(context, control);
     IOrderedDictionary dictionary = new OrderedDictionary();
     foreach (Parameter parameter in this)
     {
         string name = parameter.Name;
         for (int i = 1; dictionary.Contains(name); i++)
         {
             name = parameter.Name + i.ToString(CultureInfo.InvariantCulture);
         }
         dictionary.Add(name, parameter.ParameterValue);
     }
     return dictionary;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:ParameterCollection.cs

示例14: playQueueContents

        private void playQueueContents(OrderedDictionary queueToPlay, Boolean isImmediateMessages)
        {
            long milliseconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            List<String> keysToPlay = new List<String>();
            List<String> soundsProcessed = new List<String>();

            Boolean oneOrMoreEventsEnabled = false;
            if (queueToPlay.Count > 0)
            {
                Console.WriteLine("Processing queue of " + queueToPlay.Count + " event(s)");
            }
            lock (queueToPlay)
            {
                foreach (String key in queueToPlay.Keys)
                {
                    QueuedMessage queuedMessage = (QueuedMessage)queueToPlay[key];
                    if (isImmediateMessages || queuedMessage.dueTime <= milliseconds)
                    {
                        if ((isImmediateMessages || !keepQuiet) &&
                            (queuedMessage.abstractEvent == null || queuedMessage.abstractEvent.isClipStillValid(key)) &&
                            !keysToPlay.Contains(key) && (!queuedMessage.gapFiller || playGapFillerMessage(queueToPlay)) &&
                            (queuedMessage.expiryTime == 0 || queuedMessage.expiryTime > milliseconds))
                        {
                            keysToPlay.Add(key);
                        }
                        else
                        {
                            Console.WriteLine("Clip " + key + " is not valid");
                            soundsProcessed.Add(key);
                        }
                    }
                }
                if (keysToPlay.Count > 0)
                {
                    if (keysToPlay.Count == 1 && clipIsPearlOfWisdom(keysToPlay[0]) && hasPearlJustBeenPlayed())
                    {
                        Console.WriteLine("Rejecting pearl of wisdom " + keysToPlay[0] +
                            " because one has been played in the last " + minTimeBetweenPearlsOfWisdom + " seconds");
                        soundsProcessed.Add(keysToPlay[0]);
                    }
                    else
                    {
                        foreach (String eventName in keysToPlay)
                        {
                            if ((eventName.StartsWith(QueuedMessage.compoundMessageIdentifier) &&
                                ((QueuedMessage)queueToPlay[eventName]).isValid) || enabledSounds.Contains(eventName))
                            {
                                oneOrMoreEventsEnabled = true;
                            }
                        }
                    }
                }
                if (queueToPlay.Count > 0 && keysToPlay.Count == 0)
                {
                    Console.WriteLine("None of the " + queueToPlay.Count + " message(s) in this queue is due or valid");
                }
            }
            Boolean wasInterrupted = false;
            if (oneOrMoreEventsEnabled)
            {
                // block for immediate messages...
                if (isImmediateMessages)
                {
                    lock (queueToPlay)
                    {
                        openRadioChannelInternal();
                        soundsProcessed.AddRange(playSounds(keysToPlay, isImmediateMessages, out wasInterrupted));
                    }
                }
                else
                {
                    // for queued messages, allow other messages to be inserted into the queue while these are being read
                    openRadioChannelInternal();
                    soundsProcessed.AddRange(playSounds(keysToPlay, isImmediateMessages, out wasInterrupted));
                }
            }
            else
            {
                soundsProcessed.AddRange(keysToPlay);
            }
            if (soundsProcessed.Count > 0)
            {
                lock (queueToPlay)
                {
                    foreach (String key in soundsProcessed)
                    {
                        if (queueToPlay.Contains(key))
                        {
                            queueToPlay.Remove(key);
                        }
                    }
                }
            }
            if (queueHasDueMessages(queueToPlay, isImmediateMessages) && !wasInterrupted && !isImmediateMessages)
            {
                Console.WriteLine("There are " + queueToPlay.Count + " more events in the queue, playing them...");
                playQueueContents(queueToPlay, isImmediateMessages);
            }
        }
开发者ID:mrbelowski,项目名称:r3e_crewchief_v2,代码行数:99,代码来源:AudioPlayer.cs

示例15: ToDictionary

 private OrderedDictionary ToDictionary(IEnumerable<string> keywords)
 {
     var od = new OrderedDictionary();
     foreach (var k in keywords)
     {
         if (!od.Contains(k))
         {
             od.Add(k, null);
         }
     }
     return od;
 }
开发者ID:kevintavog,项目名称:MapThis,代码行数:12,代码来源:FileKeywords.cs


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