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


C# HashSet.SymmetricExceptWith方法代码示例

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


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

示例1: Main

 static void Main(string[] args)
 {
     var letters = new HashSet<char>("the quick brown fox");
     Console.WriteLine(letters.Contains('t')); // true
     Console.WriteLine(letters.Contains('j')); // false
     foreach (char c in letters)
     {
         Console.Write(c); // the quickbrownfx
     }
     letters.IntersectWith("aeiou");
     foreach (char c in letters)
     {
         Console.Write(c); // euio
     }
     var letters2 = new HashSet<char>("the quick brown fox");
     letters2.ExceptWith("aeiou");
     foreach (char c in letters2)
     {
         Console.Write(c); // th qckbrwnfx
     }
     var letters3 = new HashSet<char>("the quick brown fox");
     letters3.SymmetricExceptWith("the lazy brown fox");
     foreach (char c in letters3)
     {
         Console.Write(c); // quicklazy
     }
 }
开发者ID:PhilTheAir,项目名称:CSharp,代码行数:27,代码来源:HashSetContainer.cs

示例2: OnCycle

        internal override void OnCycle()
        {
            ad++;
            if (ad == 10)
            {
                if (_currentCustomer == null)
                    _unit.MoveTo(_unit.GetRoom().GetGameMap().getRandomWalkableSquare());
                ad = 0;
            }
            if (_currentCustomer != null && _unit.Coordinate == _currentCustomer.SquareInFront)
            {
                _unit.Chat("Don't drink it all in one go, savour the flavor!", true);
                _currentCustomer = null;
            }

            RoomUnitManager unitManager = _unit.GetRoom().GetRoomUserManager();
            List<Point> area = GetCustomerArea();
            List<int> currentCustomers = new List<int>();

            foreach (Point p in area)
            {
                RoomUser customer = unitManager.GetUnitForSquare(p.X, p.Y) as RoomUser;
                if (customer == null)
                    continue;
                currentCustomers.Add(customer.VirtualID);

                if (!_customers.Contains(customer.VirtualID)) // New customer
                {
                    _customers.Add(customer.VirtualID);
                    _unit.Chat(string.Format("Hello, {0}", customer.Name), true);
                }
            }

            var test = new HashSet<int>(_customers);
            test.SymmetricExceptWith(currentCustomers);
            List<int> toRemove = new List<int>();
            foreach (int customerID in test)
            {
                if (!currentCustomers.Contains(customerID)) // A customer left
                {
                    _customers.Remove(customerID);
                    //toRemove.Add(customerID);
                    _unit.Chat(string.Format("Bye, {0}", unitManager.GetRoomUnitByVirtualId(customerID).Name), true);
                }
            }

            // Remove old customers
            //foreach (int customerID in toRemove)
            //    _customers.Remove(customerID);
        }
开发者ID:Kristopher-RZ,项目名称:Firewind,代码行数:50,代码来源:BartenderAI.cs

示例3: SymmetricExceptWithTest

 public void SymmetricExceptWithTest()
 {
     var set=new HashSet<int>();
     var arr = new int[100];
     for (int i = 0; i < 100; i++)
     {
         set.Add(i);
         arr[i] = i + 50;
     }
     set.SymmetricExceptWith(arr);
     Assert.AreEqual(set.Count, 100);
     for (int i = 0,j=100; i < 50 && j<150; i++,j++)
     {
         Assert.IsTrue(set.Contains(i) && set.Contains(j));
     }
 }
开发者ID:Confirmit,项目名称:Students,代码行数:16,代码来源:HashSetUnitTest.cs

示例4: btnHashSet_Click

        private void btnHashSet_Click(object sender, EventArgs e)
        {
            clearList();

            var letters = new HashSet<char>("teerapong");
            string result = "";

            foreach (char c in letters) result += c;
            lsvResult.Items.Add(result); result = "";

            lsvResult.Items.Add(letters.Contains('t'));
            lsvResult.Items.Add(letters.Contains('z'));

            letters = new HashSet<char>("teerapong");
            letters.IntersectWith("aeiou");
            foreach (char c in letters) result += c;
            lsvResult.Items.Add(result); result = "";

            letters = new HashSet<char>("teerapong");
            letters.ExceptWith("aeiou");
            foreach (char c in letters) result += c;
            lsvResult.Items.Add(result); result = "";

            letters = new HashSet<char>("teerapong");
            letters.SymmetricExceptWith("teerapongs" );
            foreach (char c in letters) result += c;
            lsvResult.Items.Add(result); result = "";

            HashSet<int> first = new HashSet<int>();
            HashSet<int> second = new HashSet<int>();
            for (var i = 1; i <= 5; i++)
            {
                first.Add(5 * i);
            }
            for (var j = 1; j <= 5; j++)
            {
                second.Add(10 * j);
            }
            lsvResult.Items.Add("The table of 5 is:");
            foreach (var n in first)
            {
                lsvResult.Items.Add(n);
            }
            lsvResult.Items.Add("The table of 10 is:");
            foreach (var n in second)
            {
                lsvResult.Items.Add(n);
            }
        }
开发者ID:TeerapongSSD,项目名称:Training_C_Sharp,代码行数:49,代码来源:Form1.cs

示例5: GetMemberResults

        internal IEnumerable<MemberResult> GetMemberResults(IEnumerable<Namespace> vars, bool intersectMultipleResults = true)
        {
            IList<Namespace> namespaces = new List<Namespace>();
            foreach (var ns in vars) {
                if (ns != null) {
                    namespaces.Add(ns);
                }
            }

            if (namespaces.Count == 1) {
                // optimize for the common case of only a single namespace
                var newMembers = namespaces[0].GetAllMembers(GlobalScope.ShowClr);
                if (newMembers == null || newMembers.Count == 0) {
                    return new MemberResult[0];
                }

                return SingleMemberResult(newMembers);
            }

            Dictionary<string, List<Namespace>> memberDict = null;
            HashSet<string> memberSet = null;
            foreach (Namespace ns in namespaces) {
                if (ProjectState._noneInst   == ns) {
                    continue;
                }

                var newMembers = ns.GetAllMembers(GlobalScope.ShowClr);
                // IntersectMembers(members, memberSet, memberDict);
                if (newMembers == null || newMembers.Count == 0) {
                    continue;
                }

                if (memberSet == null) {
                    // first namespace, add everything
                    memberSet = new HashSet<string>(newMembers.Keys);
                    memberDict = new Dictionary<string, List<Namespace>>();
                    foreach (var kvp in newMembers) {
                        var tmp = new List<Namespace>(kvp.Value);
                        memberDict[kvp.Key] = tmp;
                    }
                } else {
                    // 2nd or nth namespace, union or intersect
                    HashSet<string> toRemove;
                    IEnumerable<string> adding;

                    if (intersectMultipleResults) {
                        adding = new HashSet<string>(newMembers.Keys);
                        // Find the things only in memberSet that we need to remove from memberDict
                        // toRemove = (memberSet ^ adding) & memberSet

                        toRemove = new HashSet<string>(memberSet);
                        toRemove.SymmetricExceptWith(adding);
                        toRemove.IntersectWith(memberSet);

                        // intersect memberSet with what we're adding
                        memberSet.IntersectWith(adding);

                        // we're only adding things they both had
                        adding = memberSet;
                    } else {
                        // we're adding all of newMembers keys
                        adding = newMembers.Keys;
                        toRemove = null;
                    }

                    // update memberDict
                    foreach (var name in adding) {
                        List<Namespace> values;
                        if (!memberDict.TryGetValue(name, out values)) {
                            memberDict[name] = values = new List<Namespace>();
                        }
                        values.AddRange(newMembers[name]);
                    }

                    if (toRemove != null) {
                        foreach (var name in toRemove) {
                            memberDict.Remove(name);
                        }
                    }
                }
            }

            if (memberDict == null) {
                return new MemberResult[0];
            }
            return MemberDictToResultList(memberDict);
        }
开发者ID:TerabyteX,项目名称:main,代码行数:87,代码来源:ModuleAnalysis.cs

示例6: CanCreateAndRunFromView

        public void CanCreateAndRunFromView(ViewDefinition vd)
        {
            var snapshotManager = Context.MarketDataSnapshotManager;
            using (var proc = snapshotManager.CreateFromViewDefinition(vd.Name))
            {
                proc.Snapshot.Name = TestUtils.GetUniqueName();
                var uid = Context.MarketDataSnapshotMaster.Add(new MarketDataSnapshotDocument(null, proc.Snapshot)).UniqueId;

                try
                {
                    var snapOptions = ExecutionOptions.Snapshot(proc.Snapshot.UniqueId);
                    var withSnapshot = GetFirstResult(snapOptions, vd.Name);

                    var options = ExecutionOptions.SingleCycle;
                    IViewComputationResultModel withoutSnapshot = GetFirstResult(options, vd.Name);

                    var withoutCount = CountResults(withoutSnapshot);
                    var withCount = CountResults(withSnapshot);
                    if (withoutCount != withCount)
                    {
                        var withSpecs = new HashSet<ValueSpecification>(withSnapshot.AllResults.Select(r => r.ComputedValue.Specification));
                        var withoutSpecs = new HashSet<ValueSpecification>(withoutSnapshot.AllResults.Select(r => r.ComputedValue.Specification));
                        withoutSpecs.SymmetricExceptWith(withSpecs);
                        Assert.True(false, string.Format("Running snapshot of {0} only had {1}, live had {2}", vd.Name, withCount, withoutCount));
                    }

                    Assert.Equal(withoutCount, withCount);
                }
                finally
                {
                    Context.MarketDataSnapshotMaster.Remove(uid);
                }
            }
        }
开发者ID:BietteMaxime,项目名称:OG-DotNet,代码行数:34,代码来源:MarketDataSnapshotManagerTests.cs

示例7: Execute

    public override System.Collections.IEnumerator Execute(UTContext context)
    {
        var theFirstListProperty = firstListProperty.EvaluateIn (context);
        if (string.IsNullOrEmpty (theFirstListProperty)) {
            throw new UTFailBuildException ("You must specify the property holding the first list.", this);
        }

        var theSecondListProperty = secondListProperty.EvaluateIn (context);
        if (string.IsNullOrEmpty (theFirstListProperty)) {
            throw new UTFailBuildException ("You must specify the property holding the second list.", this);
        }

        var theOutputProperty = outputProperty.EvaluateIn (context);
        if (string.IsNullOrEmpty (theFirstListProperty)) {
            throw new UTFailBuildException ("You must specify the output property.", this);
        }

        var firstEnumerable = context [theFirstListProperty];
        if (!(firstEnumerable is IEnumerable)) {
            if (firstEnumerable == null) {
                throw new UTFailBuildException ("Property '" + theFirstListProperty + "' has a null value. Cannot combine this.", this);
            }
            throw new UTFailBuildException ("Property '" + theFirstListProperty + "' is of type '" + firstEnumerable.GetType () + "'. Cannot combine this.", this);
        }

        var secondEnumerable = context [theSecondListProperty];
        if (!(secondEnumerable is IEnumerable)) {
            if (secondEnumerable == null) {
                throw new UTFailBuildException ("Property '" + theSecondListProperty + "' has a null value. Cannot combine this.", this);
            }
            throw new UTFailBuildException ("Property '" + theSecondListProperty + "' is of type '" + secondEnumerable.GetType () + "'. Cannot combine this.", this);
        }

        var firstListAsSet = new HashSet<object> ();
        foreach (var obj in (IEnumerable)firstEnumerable) {
            firstListAsSet.Add (obj);
        }

        var secondListAsSet = new HashSet<object> ();
        foreach (var obj in (IEnumerable)secondEnumerable) {
            secondListAsSet.Add (obj);
        }

        var theListOperationType = listOperationType.EvaluateIn (context);
        switch (theListOperationType) {
        case UTCombineListOperation.Union:
            firstListAsSet.UnionWith (secondListAsSet);
            break;
        case UTCombineListOperation.Intersect:
            firstListAsSet.IntersectWith (secondListAsSet);
            break;
        case UTCombineListOperation.Subtract:
            firstListAsSet.ExceptWith (secondListAsSet);
            break;
        case UTCombineListOperation.ExclusiveOr:
            firstListAsSet.SymmetricExceptWith (secondListAsSet);
            break;
        }

        context [theOutputProperty] = firstListAsSet;

        yield return "";
    }
开发者ID:realshyfox,项目名称:PlayMakerCustomActions_U3,代码行数:63,代码来源:UTCombineListsAction.cs

示例8: Main

    static void Main(string[] args)
    {
      Console.WriteLine("Combining two collections with no duplicates:");
      List<string> colors = new List<string> { "red", "orange", "yellow" };
      string[] moreColors = { "orange", "yellow", "green", "blue", "violet" };
      // Want to combine but without any duplicates.
      // Following is just the first stage ...
      HashSet<string> combined = new HashSet<string>(colors);
      // ... now for the second stage.
      // UnionWith() collects items in both lists that aren't duplicated,
      // resulting in a combined collection whose members are all unique.
      combined.UnionWith(moreColors);
      foreach (string color in combined)
      {
        Console.WriteLine(color);
      }
      Console.WriteLine("\nConverting the combined set to a list:");
      // Initialize a new List from combined.
      List<string> spectrum = new List<string>(combined);
      foreach(string color in spectrum)
      {
        Console.WriteLine("{0}", color);
      }

      Console.WriteLine("\nFinding the overlap in two lists:");
      List<string> presidentialCandidates = 
        new List<string> { "Clinton", "Edwards", "Giuliani", 
          "McCain", "Obama", "Romney" };
      List<string> senators = new List<string> { "Alexander", "Boxer", 
        "Clinton", "McCain", "Obama", "Snowe" };
      // Following set hasn't yet weeded out non-Senators ...
      HashSet<string> senatorsRunning = 
        new HashSet<string>(presidentialCandidates);
      // ... but IntersectWith() collects items that appear only in both lists,
      // effectively eliminating the non-Senators.
      senatorsRunning.IntersectWith(senators);
      foreach (string senator in senatorsRunning)
      {
        Console.WriteLine(senator);
      }

      Console.WriteLine("\nExcluding items from a list:");
      // Initialize a Queue from an array.
      Queue<int> queue = 
        new Queue<int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17 });
      // Create a set containing small prime numbers. This is stage 1 of 2.
      HashSet<int> unique = 
        new HashSet<int> { 1, 3, 5, 7, 9, 11, 13, 15 };
      // ExceptWith() removes any items in remainder that are 
      // also in queue: 1, 3, 5, 7,
      // leaving remainder with 9, 11, 13, 15. Stage 2 of 2.
      unique.ExceptWith(queue);
      foreach (int n in unique)
      {
        Console.WriteLine(n.ToString());
      }

      Console.WriteLine("\nFinding just the non-overlapping items in two lists:");
      Stack<int> stackOne = new Stack<int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8 });
      Stack<int> stackTwo = new Stack<int>(new int[] { 2, 4, 6, 7, 8, 10, 12 });
      HashSet<int> nonoverlapping = new HashSet<int>(stackOne);
      // SymmetricExceptWith() collects items that are in one collection but not
      // the other: the items that don't overlap.
      nonoverlapping.SymmetricExceptWith(stackTwo);
      foreach(int n in nonoverlapping)
      {
        Console.WriteLine(n.ToString());
      }

      Console.WriteLine("Press Enter to terminate...");
      Console.Read();
    }
开发者ID:hbumadian,项目名称:CSharpForDummies,代码行数:72,代码来源:Program.cs

示例9: HandleSelectionChange

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Selections the changed.
		/// </summary>
		/// <param name="prootb">The prootb.</param>
		/// <param name="sel">The sel.</param>
		/// ------------------------------------------------------------------------------------
		protected override void HandleSelectionChange(IVwRootBox prootb, IVwSelection sel)
		{
			CheckDisposed();

			if (m_fInChangeSelectedObjects)
				return;
			m_fInChangeSelectedObjects = true;
			try
			{
				int cvsli = 0;

				// Out variables for AllTextSelInfo.
				int ihvoRoot = 0;
				int tagTextProp = 0;
				int cpropPrevious = 0;
				int ichAnchor = 0;
				int ichEnd = 0;
				int ws = 0;
				bool fAssocPrev = false;
				int ihvoEnd = 0;
				ITsTextProps ttpBogus = null;
				SelLevInfo[] rgvsli = new SelLevInfo[0];

				List<int> newSelectedObjects = new List<int>(4);
				newSelectedObjects.Add(XmlVc.FocusHvo);
				if (sel != null)
				{
					cvsli = sel.CLevels(false) - 1;
					// Main array of information retrived from sel that made combo.
					rgvsli = SelLevInfo.AllTextSelInfo(sel, cvsli,
						out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
						out ws, out fAssocPrev, out ihvoEnd, out ttpBogus);
					for (int i = 0; i < cvsli; i++)
					{
						newSelectedObjects.Add(rgvsli[i].hvo);
					}
				}
				var changed = new HashSet<int>(m_xmlVc.SelectedObjects);
				changed.SymmetricExceptWith(newSelectedObjects);
				if (changed.Count != 0)
				{
					m_xmlVc.SelectedObjects = newSelectedObjects;
					// Generate propChanged calls that force the relevant parts of the view to redraw
					// to indicate which command icons should be visible.
					foreach (int hvo in changed)
						m_rootb.PropChanged(hvo, XmlVc.IsObjectSelectedTag, 0, 1, 1);
					if (sel != null && !sel.IsValid)
					{
						// we wiped it out by regenerating parts of the display in our PropChanged calls! Restore it if we can.
						sel = m_rootb.MakeTextSelection(ihvoRoot, cvsli, rgvsli, tagTextProp,
							cpropPrevious, ichAnchor, ichEnd, ws, fAssocPrev, ihvoEnd, ttpBogus, true);
					}
				}
			}

			finally
			{
				m_fInChangeSelectedObjects = false;
			}
			base.HandleSelectionChange(prootb, sel);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:68,代码来源:XmlView.cs

示例10: AppendDifferential

 public void AppendDifferential(Differential differential, DocumentState originatingState)
 {
     var contextChangeIndices = new HashSet<int>(_activeDifferentialIndices);
     contextChangeIndices.SymmetricExceptWith(originatingState.ActiveDifferentialIndices);
 }
开发者ID:coder0xff,项目名称:Alterity,代码行数:5,代码来源:Document.cs

示例11: BuildersAreSymmetric

        public void BuildersAreSymmetric(TypeDefinition type)
        {
            if (type.Name == "ValuePropertiesBuilder")
            {
                //This builder is too clever for its own good
                return;
            }
            if (type.BaseType != null && type.BaseType.Name.StartsWith("BuilderBase"))
            {
                var methods = type.Methods.Cast<MethodDefinition>();
                Assert.NotEmpty(methods);

                var serialize = methods.SingleOrDefault(m => m.Name == "SerializeImpl");
                var deserialize = methods.SingleOrDefault(m => m.Name == "DeserializeImpl");
                Assert.NotNull(deserialize);
                if (IsUseful(deserialize) && IsUseful(serialize))
                {
                    var deserializeStrings = new HashSet<string>(GetStaticStrings(deserialize));
                    var serializeStrings = new HashSet<string>(GetStaticStrings(serialize));
                    if (! deserializeStrings.SetEquals(serializeStrings))
                    {
                        deserializeStrings.SymmetricExceptWith(serializeStrings);
                        throw new Exception(string.Format("Mismatched strings: {0}", string.Join(",", deserializeStrings)));
                    }
                }
            }
        }
开发者ID:BietteMaxime,项目名称:OG-DotNet,代码行数:27,代码来源:StaticAnalysisTests.cs

示例12: Main

        static void Main(string[] args)
        {
            var set=new MySet.HashSet<int>();
            var micrset=new HashSet<int>();

            var watch = new Stopwatch();
            var rnd = new Random();

            watch.Start();
            for (int i = 0; i < 100000; i++)
            {
                set.Add(rnd.Next(0, 100000));
            }

            watch.Stop();
            Console.WriteLine(watch.Elapsed);
            watch.Reset();

            watch.Start();
            for (int i = 0; i < 100000; i++)
            {
                micrset.Add(rnd.Next(50000, 150000));
            }
            watch.Stop();
            Console.WriteLine(watch.Elapsed);

            watch.Reset();
            watch.Start();
               micrset.SymmetricExceptWith(set);
            watch.Stop();
            Console.WriteLine("\n\n"+watch.Elapsed+"\n\n");
            watch.Reset();
            var words = GetWords();

            watch.Restart();
            var my = GetTable(words);
            watch.Stop();
            Console.WriteLine(watch.Elapsed);

            watch.Restart();

            var notmy = GetDictionary(words);
            watch.Stop();
            Console.WriteLine(watch.Elapsed);

            Console.WriteLine();
            var notnot=new HashSet<int>();
            Console.ReadKey();
        }
开发者ID:Confirmit,项目名称:Students,代码行数:49,代码来源:Program.cs

示例13: SymmetricExceptWith

        public void SymmetricExceptWith()
        {
            var set = new HashSet<int>();

              Assert.That(() => set.SymmetricExceptWith(null), Throws.TypeOf(typeof(ArgumentNullException)));

              set.SymmetricExceptWith(new[] { 3, 9, 11 });
              Assert.IsTrue(set.SetEquals(new[] { 3, 9, 11 }));

              set.SymmetricExceptWith(Enumerable.Range(0, 10));
              Assert.IsTrue(set.SetEquals(new[] { 0, 1, 2, 4, 5, 6, 7, 8, 11 }));

              set.SymmetricExceptWith(set);
              Assert.IsTrue(set.SetEquals(new int[0]));
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:15,代码来源:HashSetTest.cs

示例14: CanCombineSnapshots

        public void CanCombineSnapshots()
        {
            ViewDefinition vd = Context.ViewProcessor.ViewDefinitionRepository.GetViewDefinition(@"Demo Equity Option Test View");
            var snapshotManager = Context.MarketDataSnapshotManager;
            Tuple<ManageableMarketDataSnapshot, ManageableMarketDataSnapshot> snaps;
            using (var proc = snapshotManager.CreateFromViewDefinition(vd.Name))
            {
                var snapshot = proc.Snapshot;
                snaps = Halve(snapshot);

                snaps.Item1.Name = TestUtils.GetUniqueName();
                snaps.Item2.Name = TestUtils.GetUniqueName();

                Context.MarketDataSnapshotMaster.Add(new MarketDataSnapshotDocument(null, snaps.Item1));
                Context.MarketDataSnapshotMaster.Add(new MarketDataSnapshotDocument(null, snaps.Item2));
            }

            try
            {
                var snapOptions = ExecutionOptions.GetSingleCycle(new CombinedMarketDataSpecification(new UserMarketDataSpecification(snaps.Item2.UniqueId), new UserMarketDataSpecification(snaps.Item1.UniqueId)));
                var withSnapshot = GetFirstResult(snapOptions, vd.Name);

                var options = ExecutionOptions.SingleCycle;
                IViewComputationResultModel withoutSnapshot = GetFirstResult(options, vd.Name);

                var withoutCount = CountResults(withoutSnapshot);
                var withCount = CountResults(withSnapshot);
                if (withoutCount != withCount)
                {
                    var withSpecs = new HashSet<ValueSpecification>(withSnapshot.AllResults.Select(r => r.ComputedValue.Specification));
                    var withoutSpecs = new HashSet<ValueSpecification>(withoutSnapshot.AllResults.Select(r => r.ComputedValue.Specification));
                    withoutSpecs.SymmetricExceptWith(withSpecs);
                    Assert.True(false, string.Format("Running snapshot of {0} only had {1}, live had {2}", vd.Name, withCount, withoutCount));
                }

                Assert.Equal(withoutCount, withCount);
            }
            finally
            {
                Context.MarketDataSnapshotMaster.Remove(snaps.Item1.UniqueId);
                Context.MarketDataSnapshotMaster.Remove(snaps.Item2.UniqueId);
            }
        }
开发者ID:BietteMaxime,项目名称:OG-DotNet,代码行数:43,代码来源:MarketDataSnapshotManagerTests.cs

示例15: CheckSyntax

        internal override void CheckSyntax()
        {
            if (GroupByClause != null)
            {
                if (!Columns.Aggregates.Any())
                    throw new SqlException("At least one aggregate function must be present along with a GROUP BY clause.\n");

                var groupByKeys = GroupByClause.GroupByItems.Select(g => g.Id.LookupId);
                var nonAggregateSelectKeys = Columns.ColumnSources.Where(c => !(c is AggregateNode)).Select(c => c.Id.LookupId);

                var difference = new HashSet<string>(groupByKeys, StringComparer.OrdinalIgnoreCase);
                difference.SymmetricExceptWith(nonAggregateSelectKeys);
                if (difference.Count > 0)
                    throw new SqlException(string.Format("The query contains the field '{0}' that is not matched between the select list and group by clause.", difference.First()));
            }
            else if (Columns.Aggregates.Any() && !Columns.IsAggregateOnlyQuery)
                throw new SqlException("Your query contains fields and aggregates but no GROUP BY clause.\n");

            if ((Columns.Distinct || GroupByClause != null) && OrderByClause != null)
            {
                var selectFields = Columns.FieldList;
                foreach (OrderByItem item in OrderByClause.OrderByItems)
                {
                    if (!selectFields.Contains(item.Id.LookupId, StringComparer.OrdinalIgnoreCase))
                        throw new SqlException(string.Format("The query specifies DISTINCT or GROUP BY but contains an ORDER BY field '{0}' that is not included in the result list.", item.Id.LookupId));
                }
            }

            base.CheckSyntax();
        }
开发者ID:purnachandrapilla,项目名称:SqlLinq,代码行数:30,代码来源:SelectNode.cs


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