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


C# IEnumerable.ToDictionary方法代码示例

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


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

示例1: CreateNewExpression

        public static Expression CreateNewExpression(Expression currentContext, IEnumerable<DataApiNode> fieldExpressions, ISchemaProvider schemaProvider, out Type dynamicType)
        {
            var fieldExpressionsByName = fieldExpressions.ToDictionary(f => f.Name, f => f.Expression);
            dynamicType = LinqRuntimeTypeBuilder.GetDynamicType(fieldExpressions.ToDictionary(f => f.Name, f => f.Expression.Type));

            var bindings = dynamicType.GetFields().Select(p => Expression.Bind(p, fieldExpressionsByName[p.Name])).OfType<MemberBinding>();
            var newExp = Expression.New(dynamicType.GetConstructor(Type.EmptyTypes));
            var mi = Expression.MemberInit(newExp, bindings);
            return mi;
        }
开发者ID:lukemurray,项目名称:EntityQueryLanguage,代码行数:10,代码来源:DataApiExpressionUtil.cs

示例2: EpicsOverviewViewModel

 public EpicsOverviewViewModel(IEnumerable<JiraIssue> issues, IEnumerable<RawAgileEpic> epics, IMessenger messenger)
 {
    _issues = issues;
    _messenger = messenger;
    _epicKeyToIgnoreStatus = epics.ToDictionary(e => e.Key, e => e.Done);
    _epicKeyToIgnoreStatus[""] = false;
    _epicKeyToName = epics.ToDictionary(e => e.Key, e => e.Name);
    _epicKeyToName[""] = "(No epic)";
    EpicsStatistics = new ObservableCollection<EpicShare>();
    
    GenerateData();
 }
开发者ID:sceeter89,项目名称:jira-client,代码行数:12,代码来源:EpicsOverviewViewModel.cs

示例3: AudioScan

        internal AudioScan(DirectoryInfo directory, SearchOption searchoption,
                           bool parseAdd, bool parseUpdate, bool removeDeadFiles,
                           string[] extensions, IEnumerable<RawTrack> existingFiles, IEnumerable<string> ignoredFiles,
                           ScanFileEventHandler parsed,
                           ScanCompletedEventHandler done)
        {
            var thread = new Thread(Run);

            _directory = directory;
            _searchoption = searchoption;

            _parseAdd = parseAdd;
            _parseUpdate = parseUpdate;
            _removeDeadFiles = removeDeadFiles;

            _parser = new MediaParser();

            _extensions = extensions;
            _existingFiles = existingFiles.ToDictionary(rt => rt.File);

            _ignoredFiles = (from s in ignoredFiles select new FileInfo(s)).ToArray();

            Parsed = parsed;
            Done = done;

            _state = ScannerState.NotRunning;

            _added = _updated = _skipped = _error = _removed = _total = 0;

            thread.Start();
        }
开发者ID:gfdittmer,项目名称:MiSharp,代码行数:31,代码来源:AudioScan.cs

示例4: SyndicationService

 public SyndicationService(string title, IEnumerable<IResourceCollection> collections)
 {
     Title = title;
     this.collections = collections.ToDictionary(
         x => x.Info.Title.Text,
         StringComparer.OrdinalIgnoreCase);
 }
开发者ID:shishkin,项目名称:MyBlog,代码行数:7,代码来源:SyndicationService.cs

示例5: ExecuteMarginCall

        /// <summary>
        /// Executes synchronous orders to bring the account within margin requirements.
        /// </summary>
        /// <param name="generatedMarginCallOrders">These are the margin call orders that were generated
        /// by individual security margin models.</param>
        /// <returns>The list of orders that were actually executed</returns>
        public virtual List<Order> ExecuteMarginCall(IEnumerable<Order> generatedMarginCallOrders)
        {
            // if our margin used is back under the portfolio value then we can stop liquidating
            if (Portfolio.MarginRemaining >= 0)
            {
                return new List<Order>();
            }

            // order by losers first
            var executedOrders = new List<Order>();
            var ordersWithSecurities = generatedMarginCallOrders.ToDictionary(x => x, x => Portfolio[x.Symbol]);
            var orderedByLosers = ordersWithSecurities.OrderBy(x => x.Value.UnrealizedProfit).Select(x => x.Key);
            foreach (var order in orderedByLosers)
            {
                Portfolio.Transactions.AddOrder(order);
                Portfolio.Transactions.WaitForOrder(order.Id);
                executedOrders.Add(order);

                // if our margin used is back under the portfolio value then we can stop liquidating
                if (Portfolio.MarginRemaining >= 0)
                {
                    break;
                }
            }
            return executedOrders;
        }
开发者ID:reddream,项目名称:Lean,代码行数:32,代码来源:MarginCallModel.cs

示例6: XmlTestResultParser

 public XmlTestResultParser(IEnumerable<TestCase> testCasesRun, string xmlResultFile, TestEnvironment testEnvironment, string baseDir)
 {
     _testEnvironment = testEnvironment;
     _baseDir = baseDir;
     _xmlResultFile = xmlResultFile;
     _testCasesMap = testCasesRun.ToDictionary(tc => tc.FullyQualifiedName, tc => tc);
 }
开发者ID:csoltenborn,项目名称:GoogleTestAdapter,代码行数:7,代码来源:XmlTestResultParser.cs

示例7: Get

        /// <summary>
        ///     Gets the <see cref="Type" /> matching the provided members.
        /// </summary>
        /// <param name="sourceType">The <see cref="Type" /> to generate the runtime type from.</param>
        /// <param name="properties">The <see cref="MemberInfo" /> to use to generate properties.</param>
        /// <returns>A <see cref="Type" /> mathing the provided properties.</returns>
        public Type Get(Type sourceType, IEnumerable<MemberInfo> properties)
        {
            properties = properties.ToArray();
            if (!properties.Any())
            {
                throw new ArgumentOutOfRangeException("properties",
                    "properties must have at least 1 property definition");
            }

            var dictionary = properties.ToDictionary(f => _nameResolver.ResolveName(f), memberInfo => memberInfo);

            var className = GetTypeKey(sourceType, dictionary);
            return BuiltTypes.GetOrAdd(
                className,
                s =>
                {
                    var typeBuilder = ModuleBuilder.DefineType(
                        className,
                        TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Serializable);

                    Contract.Assume(typeBuilder != null);

                    SetAttributes(typeBuilder, sourceType);

                    foreach (var field in dictionary)
                    {
                        CreateProperty(typeBuilder, field);
                    }

                    return typeBuilder.CreateType();
                });
        }
开发者ID:calebjenkins,项目名称:Highway.Data,代码行数:38,代码来源:RuntimeTypeProvider.cs

示例8: RedirectFromLogin

        public static void RedirectFromLogin(string login, IEnumerable<RestResponseCookie> cookies)
        {
            if (cookies == null)
                throw new ArgumentNullException("cookies");

            cookies = cookies.ToArray();

            var data = JsonConvert.SerializeObject(cookies.ToDictionary(c => c.Name, c => c.Value));

            var cookie = FormsAuthentication.GetAuthCookie(login, false);

            var sourceTicket = FormsAuthentication.Decrypt(cookie.Value);

            if (sourceTicket == null)
                throw new ApplicationException("Unable to decrypt authentication");

            var expiration = cookies.Select(c => c.Expires)
                                    .Where(exp => exp > DateTime.Today.AddYears(-1) && exp < DateTime.Today.AddYears(1))
                                    .Concat(new[] {sourceTicket.Expiration})
                                    .Min();

            var ticket = new FormsAuthenticationTicket(
                sourceTicket.Version, sourceTicket.Name, sourceTicket.IssueDate,
                expiration, false, data);

            cookie.Value = FormsAuthentication.Encrypt(ticket);

            Response.SetCookie(cookie);
            var redirectUrl = FormsAuthentication.GetRedirectUrl(login, sourceTicket.IsPersistent);
            Response.Redirect(redirectUrl);
        }
开发者ID:rhartzog,项目名称:YouTrackBurnDown,代码行数:31,代码来源:CookieAuthenticator.cs

示例9: CryptographyManagerImpl

 /// <summary>
 /// Initializes a new instance of the class <see cref="CryptographyManagerImpl"/> given a collection of <see cref="IHashProvider"/> and a
 /// collection of <see cref="ISymmetricCryptoProvider"/>.
 /// </summary>
 /// <param name="hashProviderNames">Sequence of names of the hash providers as defined in configuration.</param>
 /// <param name="hashProviders">The hash providers corresponding to the names in <paramref name="hashProviderNames"/> at the same index.</param>
 /// <param name="cryptoProviderNames">Sequence of names of the cryptography providers as defined in configuration.</param>
 /// <param name="symmetricCryptoProviders">The symmetric cryptography providers corresponding to the names give in <paramref name="cryptoProviderNames"/>
 /// <param name="instrumentationProvider">The instrumentation provider used to report errors.</param>
 /// at the same index.</param>
 public CryptographyManagerImpl(IEnumerable<string> hashProviderNames, IEnumerable<IHashProvider> hashProviders,
     IEnumerable<string> cryptoProviderNames, IEnumerable<ISymmetricCryptoProvider> symmetricCryptoProviders,
     IDefaultCryptographyInstrumentationProvider instrumentationProvider)
     : this(hashProviderNames.ToDictionary(hashProviders), cryptoProviderNames.ToDictionary(symmetricCryptoProviders), instrumentationProvider)
 {
     
 }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:17,代码来源:CryptographyManagerImpl.cs

示例10: StepDirectory

        public StepDirectory(string path, ScriptEngine pythonEngine)
        {
            _path = path;
            _pythonEngine = pythonEngine;
            _logger = LogManager.GetLogger("steps");

            var stepTypes = this.GetType().Assembly.GetTypes()
                .Where(t => !t.IsAbstract)
                .Where(t => t.IsSubclassOf(typeof (Step)))
                .Select(t => new
                                 {
                                     Type = t,
                                     Extensions = t.GetCustomAttributes(typeof (HandlesAttribute), true)
                                 .Cast<HandlesAttribute>()
                                 .SelectMany(h => h.Extensions)
                                 });

            _extensions = stepTypes.SelectMany(t => t.Extensions);
            _typesByExtension = _extensions.ToDictionary(ext => ext.ToLowerInvariant(),
                                                        ext => stepTypes.Single(s => s.Extensions.Contains(ext)).Type);

            LoadStepsAndMetadata();

            InitializeFileWatcher();
        }
开发者ID:brunomlopes,项目名称:techdays2010pt-ironpython,代码行数:25,代码来源:StepDirectory.cs

示例11: ResolveDependencies

        public static void ResolveDependencies(IEnumerable<ClassNode> allClasses)
        {
            var allClassesBySymbol = allClasses.ToDictionary(x => x.Symbol, x => x);

            foreach (var dependor in allClassesBySymbol.Values)
            {
                foreach (var dependency in dependor.SymbolDependencies)
                {
                    if (allClassesBySymbol.ContainsKey(dependency))
                    {
                        CreateDependency(allClassesBySymbol[dependency], dependor);
                    }
                    else
                    {
                        var matchingSymbols = allClassesBySymbol.Keys.Where(x => SymbolsMatch(x, dependency)).ToList();
                        if (matchingSymbols.Count == 1)
                        {
                            CreateDependency(allClassesBySymbol[matchingSymbols.First()], dependor);
                        }
                        if (matchingSymbols.Count > 1)
                            throw new NotImplementedException();
                    }
                }
            }
        }
开发者ID:davidkron,项目名称:DevArch,代码行数:25,代码来源:DependencyResolver.cs

示例12: _Schedule

            /// <summary>
            /// Erzeugt eine neue Verwaltung.
            /// </summary>
            /// <param name="definition">Die Definition der Aufzeichnung.</param>
            /// <param name="exceptions">Alle Ausnahmen zur Aufzeichnung.</param>
            /// <exception cref="ArgumentNullException">Es wurde keine Aufzeichnung angegeben.</exception>
            public _Schedule( IScheduleDefinition definition, IEnumerable<PlanException> exceptions = null )
            {
                // Validate
                if (definition == null)
                    throw new ArgumentNullException( "plan" );

                // Remember
                Definition = definition;

                // Default
                if (exceptions == null)
                    exceptions = Enumerable.Empty<PlanException>();

                // Validate exceptions
                foreach (var exception in exceptions)
                    if (exception.ExceptionDate.TimeOfDay != TimeSpan.Zero)
                        throw new ArgumentException( string.Format( Properties.SchedulerResources.Exception_NotAPureDate, exception.ExceptionDate ), "exceptions" );

                // Cross validate
                foreach (var exception in exceptions.GroupBy( e => e.ExceptionDate ))
                    if (exception.Count() > 1)
                        throw new ArgumentException( string.Format( Properties.SchedulerResources.Exception_DuplicateDate, exception.Key ), "exceptions" );

                // Order plan
                m_Exceptions = exceptions.ToDictionary( e => e.ExceptionDate );
            }
开发者ID:davinx,项目名称:DVB.NET---VCR.NET,代码行数:32,代码来源:RecordingScheduler.Recording.cs

示例13: EntityType

 internal EntityType(string schema, string name, IEnumerable<EntityField> fields)
 {
     _schema = schema;
     _name = name;
     _tableName = String.Format("{0}_{1}", _schema, _name);
     _fields = fields.ToDictionary(val => val.Name);
 }
开发者ID:Fedorm,项目名称:core-master,代码行数:7,代码来源:EntityType.cs

示例14: TaskList

 public TaskList(IEnumerable<TaskTable> tasks, IEnumerable<CategoryTable> categories, int currentPosition = 0)
 {
     _tasks = tasks.ToList();
     _taskDictionary = _tasks.ToDictionary(task => task.Id);
     _category = categories.ToDictionary(cat => cat.Id);
     _enumerator = new TaskEnumerator(this) { CurrentPosition = currentPosition };
 }
开发者ID:okrotowa,项目名称:Mosigra.Yorsh,代码行数:7,代码来源:TaskList.cs

示例15: AddSerializers

        public void AddSerializers(IEnumerable<Type> list)
        {
            var dictionary = list.ToDictionary(type => type.BaseType.GenericTypeArguments[0], type => (ISerializer)Activator.CreateInstance(type));

            foreach (var serializer in dictionary)
                serializers.Add(serializer.Key, serializer.Value);
        }
开发者ID:ryudice,项目名称:WebApiSerializers,代码行数:7,代码来源:SerializersCache.cs


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