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


C# IEnumerable.Union方法代码示例

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


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

示例1: TagAsync

        /// <summary>
        /// Set tags to the specified <paramref name="file"/>.
        /// </summary>
        /// <returns>The task to process it.</returns>
        /// <param name="file">File to tag.</param>
        /// <param name="tags">Tags to set.</param>
        /// <param name="clear">If set to <c>true</c> replace existing tags with ne <paramref name="tags"/>.</param>
        public Task TagAsync(FileInfo file, IEnumerable<string> tags, bool clear)
        {
            return Task.Factory.StartNew(() =>
            {
                ImageFile imagefile = ImageFile.FromFile(file.FullName);

                string tagsValue;
                if (clear)
                {
                    tagsValue = tags.Distinct(StringComparer.CurrentCultureIgnoreCase).Join(";");
                }
                else
                {
                    List<string> existingTags = new List<string>();
                    ExifProperty existingTagsValue;
                    if (imagefile.Properties.TryGetValue(ExifTag.WindowsKeywords, out existingTagsValue))
                        existingTags = existingTagsValue.Value.ToString().Split(';').ToList();
                    tagsValue = tags.Union(existingTags).Distinct(StringComparer.CurrentCultureIgnoreCase).Join(";");
                }

                imagefile.Properties.Set(ExifTag.WindowsKeywords, tagsValue);

                imagefile.Save(file.FullName);
            });
        }
开发者ID:crabouif,项目名称:Self-Media-Database,代码行数:32,代码来源:FileSystemImageManager.cs

示例2: HasRefactoring

        public bool HasRefactoring()
        {
            refactorings = Enumerable.Empty<IManualRefactoring>();

            SyntaxTree treeBefore = SyntaxTree.ParseCompilationUnit(before);
            SyntaxTree treeAfter = SyntaxTree.ParseCompilationUnit(after);

            // Get the classes in the code before and after.
            var classesBefore = treeBefore.GetRoot().DescendantNodes().Where(n => n.Kind == SyntaxKind.ClassDeclaration);
            var classesAfter = treeAfter.GetRoot().DescendantNodes().Where(n => n.Kind == SyntaxKind.ClassDeclaration);

            // Get the pairs of class declaration in the code before and after
            var paris = GetClassDeclarationPairs(classesBefore, classesAfter);
            foreach (var pair in paris)
            {
                var detector = new InClassExtractMethodDetector((ClassDeclarationSyntax)pair.Key, (ClassDeclarationSyntax)pair.Value);
                detector.SetSyntaxTreeBefore(treeBefore);
                detector.SetSyntaxTreeAfter(treeAfter);
                if(detector.HasRefactoring())
                {
                    refactorings = refactorings.Union(detector.GetRefactorings());
                    return true;
                }
            }
            return false;
        }
开发者ID:nkcsgexi,项目名称:ghostfactor1,代码行数:26,代码来源:ExtractMethodDetector.cs

示例3: VisualNetwork

 public VisualNetwork(GraphicsDevice graphicsDevice, IEnumerable<Neuron> sensoryNeurons, IEnumerable<Neuron> interNeurons, IEnumerable<Neuron> responsiveNeurons)
 {
     this.SensoryNeurons = sensoryNeurons;
     this.InterNeurons = interNeurons;
     this.ResponsiveNeurons = responsiveNeurons;
     this.Neurons = sensoryNeurons.Union(interNeurons).Union(responsiveNeurons).ToArray();
 }
开发者ID:odinhaus,项目名称:Genesis,代码行数:7,代码来源:VisualNetwork.cs

示例4: ContextConfiguration

        public ContextConfiguration()
        {
            //get all types that inheret from EntityTypeConfiguration or ComplexTypeConfiguration
            var maps = from t in Assembly.GetExecutingAssembly().GetTypes()
                       where t.BaseType != null && t.BaseType.IsGenericType
                       let baseDef = t.BaseType.GetGenericTypeDefinition()
                       where baseDef == typeof(EntityTypeConfiguration<>) ||
                             baseDef == typeof(ComplexTypeConfiguration<>)
                       select Activator.CreateInstance(t);

            configurations = maps;

            //get all types that inheret from EntityWithTypedId without entity itself
            dbsets = from t in Assembly.GetExecutingAssembly().GetTypes()
                     where t.BaseType != null && t.BaseType.IsGenericType && !t.IsAbstract
                     && t != typeof(Entity)
                     let baseDef = t.BaseType.GetGenericTypeDefinition()
                     where baseDef == typeof(EntityWithTypedId<>)
                     select t;

            //+get all types that inheret from Entity
            dbsets = dbsets.Union(
                from t in Assembly.GetExecutingAssembly().GetTypes()
                where t.IsSubclassOf(typeof(Entity)) && !t.IsAbstract
                select t
                );
        }
开发者ID:schreys,项目名称:MultiSafepayTest,代码行数:27,代码来源:ContextConfiguration.cs

示例5: SendMailAsync

        public async static Task SendMailAsync(string from, IEnumerable<string> mailto, string subject, string message, string attachFile = null)
        {
            using (var mail = new MailMessage {From = new MailAddress(from)})
            using (var client = new SmtpClient { DeliveryFormat = SmtpDeliveryFormat.International })
            {
                client.Host = ConfigurationManager.AppSettings.Get("smtp.host") ?? client.Host;
                client.Port = Convert.ToInt32(ConfigurationManager.AppSettings.Get("smtp.port") ?? client.Port.ToString());
                client.Timeout = Convert.ToInt32(ConfigurationManager.AppSettings.Get("smtp.timeout") ?? client.Timeout.ToString());

                var enableSsl = ConfigurationManager.AppSettings.Get("smtp.enableSSL");
                if (enableSsl.IsNotEmpty())
                    client.EnableSsl = enableSsl.ToLower() == "true" || enableSsl == "1";
                var smtpUser = ConfigurationManager.AppSettings.Get("smtp.userName");
                var smtpPassword = ConfigurationManager.AppSettings.Get("smtp.password");
                if (smtpUser != null && smtpPassword != null)
                    client.Credentials = new NetworkCredential(smtpUser, smtpPassword);

                foreach (var email in mailto.Union(new[] { ConfigurationManager.AppSettings.Get("smtp.administrator") }).Where(x => x.IsNotEmpty()))
                {
                    if (mail.To.Count == 0)
                        mail.To.Add(new MailAddress(email));
                    mail.Bcc.Add(new MailAddress(email));
                }
                mail.Subject = subject;
                mail.Body = message;
                mail.SubjectEncoding = Encoding.UTF8;
                mail.BodyEncoding = Encoding.UTF8;
                if (!string.IsNullOrEmpty(attachFile))
                    mail.Attachments.Add(new Attachment(attachFile));
                await client.SendMailAsync(mail);
            }
        }
开发者ID:ComposITDevelop,项目名称:SAM,代码行数:32,代码来源:MailService.cs

示例6: Reconcile

    public override Control Reconcile(IEnumerable<PricingItem> mlpSource_, IEnumerable<PricingItem> dsSource_)
    {
      var allCodes = mlpSource_.Union(dsSource_).Select(x => x.SymmetryCode).Distinct();

      var lines = new System.ComponentModel.BindingList<CloseItem>();

      foreach (var symcode in allCodes)
      {

        var line = new CloseItem();
        line.SymmetryCode = symcode;

        {
          var mlpitem = mlpSource_.Where(x => x.SymmetryCode.Equals(symcode)).FirstOrDefault();
          if (mlpitem != null) line.MLPPrice = mlpitem.Value;
        }

        {
          var dsItem = dsSource_.Where(x => x.SymmetryCode.Equals(symcode)).FirstOrDefault();
          if (dsItem != null) line.DSPrice = dsItem.Value;
        }

        lines.Add(line);
      }

      var grid = lines.DisplayInGrid(m_name,displayInShowForm_:false);
      grid.SetHeaderClickSort();
      return grid;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:29,代码来源:CloseReconciler.cs

示例7: AggregateValidationResult

 public AggregateValidationResult(IEnumerable<ValidationResult> validationResults, params IEnumerable<ValidationResult>[] additionalValidationResults)
 {
     _validationResults = validationResults
         .Union(additionalValidationResults
         .SelectMany(x => x));
     FailedValidators = _validationResults.Where(x => !x.IsValid());
 }
开发者ID:SeregaZH,项目名称:FluentValidationFramework,代码行数:7,代码来源:AggregateValidationResult.cs

示例8: AppendChildren

        public override IEnumerable<ContentItem> AppendChildren(IEnumerable<ContentItem> previousChildren, Query query)
        {
            if(query.Interface != Interfaces.Managing)
                return previousChildren;

            return previousChildren.Union(nodes.GetChildren(query.Parent.Path));
        }
开发者ID:GrimaceOfDespair,项目名称:n2cms,代码行数:7,代码来源:FileSystemSource.cs

示例9: TryToComposeLine

        private static int TryToComposeLine(IEnumerable<int>[] numbersArray, int level,
                                            IEnumerable<int> restrictedArrays, IEnumerable<int> restrictedNumbers, int mustStartWith)
        {
            if (level == 0)
            {
                for (int i = 0; i < numbersArray.Length; ++i )
                {
                    foreach (var number in numbersArray[i])
                    {
                        var result = TryToComposeLine(numbersArray, 1, new[] { i }, new[] { number }, number % 100);
                        if (result > 0)
                            return result;
                    }
                }
            }

            for (int i = 0; i < numbersArray.Length; ++i)
            {
                if (restrictedArrays.Contains(i))
                    continue;

                foreach (var number in numbersArray[i])
                {
                    if (restrictedNumbers.Contains(number) || number / 100 != mustStartWith)
                        continue;

                    var result = TryToComposeLine(numbersArray, level + 1, restrictedArrays.Union(new[] {i}),
                                                  restrictedNumbers.Union(new[] {number}),
                                                  number % 100);
                    if (result > 0)
                        return result;
                }
            }

            int count = 0;
            int[] ar = restrictedArrays.ToArray();
            foreach (var restrictedNumber in restrictedNumbers)
            {
                Console.Write(ar[count] + ":" + restrictedNumber + "=>");
                ++count;
            }

            if (level > 5)
            {
                // Check.
                var a = restrictedNumbers.ToArray();
                if (a[0] / 100 != a[5] % 100)
                {
                    Console.WriteLine("EPIC FAIL");
                    return -1;
                }

                Console.WriteLine();
                return restrictedNumbers.Sum();
            }

            Console.WriteLine("FAIL");

            return -1;
        }
开发者ID:VitalyKalinkin,项目名称:ProjectEuler,代码行数:60,代码来源:Program.cs

示例10: Execute

        public ScriptResult Execute(string code, string[] scriptArgs, AssemblyReferences references, IEnumerable<string> namespaces,
            ScriptPackSession scriptPackSession)
        {
            Guard.AgainstNullArgument("references", references);
            Guard.AgainstNullArgument("scriptPackSession", scriptPackSession);

            references.PathReferences.UnionWith(scriptPackSession.References);

            SessionState<Evaluator> sessionState;
            if (!scriptPackSession.State.ContainsKey(SessionKey))
            {
                Logger.Debug("Creating session");
                var context = new CompilerContext(new CompilerSettings
                {
                    AssemblyReferences = references.PathReferences.ToList()
                }, new ConsoleReportPrinter());

                var evaluator = new Evaluator(context);
                var allNamespaces = namespaces.Union(scriptPackSession.Namespaces).Distinct();

                var host = _scriptHostFactory.CreateScriptHost(new ScriptPackManager(scriptPackSession.Contexts), scriptArgs);
                MonoHost.SetHost((ScriptHost)host);

                evaluator.ReferenceAssembly(typeof(MonoHost).Assembly);
                evaluator.InteractiveBaseClass = typeof(MonoHost);

                sessionState = new SessionState<Evaluator>
                {
                    References = new AssemblyReferences(references.PathReferences, references.Assemblies),
                    Namespaces = new HashSet<string>(),
                    Session = evaluator
                };

                ImportNamespaces(allNamespaces, sessionState);

                scriptPackSession.State[SessionKey] = sessionState;
            }
            else
            {
                Logger.Debug("Reusing existing session");
                sessionState = (SessionState<Evaluator>)scriptPackSession.State[SessionKey];

                var newReferences = sessionState.References == null ? references : references.Except(sessionState.References);
                foreach (var reference in newReferences.PathReferences)
                {
                    Logger.DebugFormat("Adding reference to {0}", reference);
                    sessionState.Session.LoadAssembly(reference);
                }

                sessionState.References = new AssemblyReferences(references.PathReferences, references.Assemblies);

                var newNamespaces = sessionState.Namespaces == null ? namespaces : namespaces.Except(sessionState.Namespaces);
                ImportNamespaces(newNamespaces, sessionState);
            }

            Logger.Debug("Starting execution");
            var result = Execute(code, sessionState.Session);
            Logger.Debug("Finished execution");
            return result;
        }
开发者ID:selony,项目名称:scriptcs,代码行数:60,代码来源:MonoScriptEngine.cs

示例11: CompileDynamicLibrary

	public override void CompileDynamicLibrary(string outputFile, IEnumerable<string> sources, IEnumerable<string> includePaths, IEnumerable<string> libraries, IEnumerable<string> libraryPaths)
	{
		string[] array = sources.ToArray<string>();
		string text = NativeCompiler.Aggregate(array.Select(new Func<string, string>(base.ObjectFileFor)), " ", " " + Environment.NewLine);
		string includePathsString = NativeCompiler.Aggregate(includePaths.Union(this.m_IncludePaths), "/I \"", "\" ");
		string text2 = NativeCompiler.Aggregate(libraries.Union(this.m_Libraries), " ", " ");
		string text3 = NativeCompiler.Aggregate(libraryPaths.Union(this.m_Settings.LibPaths), "/LIBPATH:\"", "\" ");
		this.GenerateEmptyPdbFile(outputFile);
		NativeCompiler.ParallelFor<string>(array, delegate(string file)
		{
			this.Compile(file, includePathsString);
		});
		string contents = string.Format(" {0} {1} {2} /DEBUG /INCREMENTAL:NO /MACHINE:{4} /DLL /out:\"{3}\" /DEF:\"{5}\" ", new object[]
		{
			text,
			text2,
			text3,
			outputFile,
			this.m_Settings.MachineSpecification,
			this.m_DefFile
		});
		string tempFileName = Path.GetTempFileName();
		File.WriteAllText(tempFileName, contents);
		base.Execute(string.Format("@{0}", tempFileName), "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\bin\\link.exe");
	}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:25,代码来源:MSVCCompiler.cs

示例12: RazorDocumentManager

        public RazorDocumentManager([ImportMany]params IRazorDocumentSource[] documentSources)
        {
            _documentSources = (documentSources ?? Enumerable.Empty<IRazorDocumentSource>());

            // Always add the plain Razor Template file source at the end of the list
            _documentSources = _documentSources.Union(new [] { new RazorTemplateFileSource() });

            Encoding = Encoding.UTF8;
        }
开发者ID:RazorPad,项目名称:RazorPad,代码行数:9,代码来源:RazorDocumentManager.cs

示例13: LoadConversation

 public void LoadConversation(User contact, IEnumerable<Message> conversation)
 {
     ChatSessionViewModel chatSession;
     if(_chatSessions.TryGetValue(contact.Name, out chatSession))
     {
         var union = conversation.Union(chatSession.Conversation);
         chatSession.Conversation = new ObservableCollection<Message>(union);
     }
 }
开发者ID:xiurui12345,项目名称:MessengR,代码行数:9,代码来源:ChatSessionsViewModel.cs

示例14: GenerateWith

        public IEnumerable<Feat> GenerateWith(CharacterClass characterClass, Race race, Dictionary<string, Stat> stats,
            Dictionary<string, Skill> skills, BaseAttack baseAttack, IEnumerable<Feat> preselectedFeats)
        {
            var additionalFeats = GetAdditionalFeats(characterClass, race, stats, skills, baseAttack, preselectedFeats);
            var allButBonusFeats = preselectedFeats.Union(additionalFeats);
            var bonusFeats = GetBonusFeats(characterClass, race, stats, skills, baseAttack, allButBonusFeats);

            return additionalFeats.Union(bonusFeats);
        }
开发者ID:DnDGen,项目名称:CharacterGen,代码行数:9,代码来源:AdditionalFeatsGenerator.cs

示例15: GroupEqualObjects

 protected override IEnumerable<Tuple<object, object>> GroupEqualObjects(IEnumerable<object> newArray, IEnumerable<object> oldArray)
 {
     return newArray.Union(oldArray).Distinct(_sameObjectComparer)
         .Select(elem => new
         {
             newItem = newArray.FirstOrDefault(x => _sameObjectComparer.Equals(x, elem)),
             oldItem = oldArray.FirstOrDefault(x => _sameObjectComparer.Equals(x, elem))
         })
         .Select(x => new Tuple<object, object>(x.newItem, x.oldItem));
 }
开发者ID:sportingsolutions,项目名称:ObjectDiffer,代码行数:10,代码来源:ObjectEqualityEnumerableDiffer.cs


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