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


C# Dictionary.ToDictionary方法代码示例

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


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

示例1: Serialize

 public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer) {
     var values = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
     
     // Get the value for each member in the dynamic object
     var clay = obj as IClayBehaviorProvider;
     clay.Behavior.GetMembers(() => null, clay, values);
     return values.ToDictionary(kv => kv.Key, kv => (object)((dynamic)kv.Value).Get());
 }
开发者ID:akhurst,项目名称:ricealumni,代码行数:8,代码来源:ClayJavaScriptConverter.cs

示例2: ExecuteInsertCommand

        private IDictionary<string, object> ExecuteInsertCommand(IDbCommand command, Dictionary<string, FbParameter> columnParameters, bool resultRequired)
        {
            command.ExecuteNonQuery();

            if (resultRequired)
            {
                return columnParameters.ToDictionary(p => p.Key, p => p.Value.Value is DBNull ? null : p.Value.Value);
            }

            return null;
        }
开发者ID:rafsawicki,项目名称:Simple.Data.Firebird,代码行数:11,代码来源:FbInserter.cs

示例3: frmProject

        public frmProject(SPWrapper sp)
        {
            Check.ArgNull (sp, "sp");
            this.sp = sp;
            InitializeComponent();

            configToFields = new Dictionary<string, Setting> {
                //BOTH
                {"id",					new TextSetting (inID)},
                {"display_name",		new TextSetting (inDisplayName)},
                {"authorization_key",	new TextSetting (inAuthKey)},
                {"version",				new TextSetting (inVersion)},
                {"loading_screen_file", new TextSetting (inLoading)},
                {"url_schemes",			new TextSetting (inURLSchemes)},
                {"orientations",		new ComboSetting<Orientation> (cmbOrientation,
                    OrientationSerialize.fromOrientation,
                    OrientationSerialize.toOrientation)},
                // IOS
                //{"ios_device_families",	new ComboSetting (cmbDeviceFamily)},
                {"ios_resources",		new FileSetting (fileResourcesiOS)},
                {"ios_dev_identity",	new FileSetting (fileIdentity)},
                {"ios_add_icon_gloss",	new BoolSetting (inGlassEffect)},
                {"ios_dev_mobile_provision_file", new FileSetting (fileProvision)},
                {"ios_app_runs_in_background", new BoolSetting  (inBackground)},
                {"ios_device_families", new ComboSetting<DeviceFamily> (cmbFamiliesiOS,
                    FamilySerialize.fromFamily,
                    FamilySerialize.toFamily)},
                // ANDROID
                {"version_code",		new TextSetting (inVersionAndroid)},
                {"keystore_file",		new FileSetting (fileKeystore)},
                {"keystore_password_file",new FileSetting (fileKeystorePassword)},
                {"key_password_file",	new FileSetting (fileKeyPassword)},
                {"android_resources", new FileSetting (fileResourcesAndroid)}
            };
            fieldsToConfig = configToFields.ToDictionary (p => p.Value, p => p.Key);
        }
开发者ID:NullSoldier,项目名称:Launchpad,代码行数:36,代码来源:frmProject.cs

示例4: Register

        public static void Register(Type[] regTypes)
        {
            if (!s_initialized)
                throw new InvalidOperationException("NetSerializer not initialized");

            var ctypes = CollectTypes(regTypes);
            var types = ctypes.Select(v => v).Where(v => !s_typeMap.ContainsKey(v)).ToArray<Type>();

            #if GENERATE_DEBUGGING_ASSEMBLY
            GenerateAssembly(types, s_typeMap);
            #endif
            s_typeMap = GenerateDynamic(types, s_typeMap);
            s_typeID_TypeData = s_typeMap.ToDictionary(kvp => kvp.Value.TypeID, kvp => kvp.Value);
            #if GENERATE_SWITCH
            s_Type_caseIDtypeIDMap = s_typeMap.ToDictionary(kvp => kvp.Key, kvp => (uint)(kvp.Value.TypeID | (kvp.Value.CaseID << 16)));
            s_caseID_typeIDMap = s_typeMap.ToDictionary(kvp => kvp.Value.TypeID, kvp => kvp.Value.CaseID);
            #endif
        }
开发者ID:smalinin,项目名称:netserializer,代码行数:18,代码来源:Main.cs

示例5: Initialize

        public static void Initialize(Type[] rootTypes)
        {
            if (s_initialized)
                throw new InvalidOperationException("NetSerializer already initialized");

            var types = CollectTypes(rootTypes);

            #if GENERATE_DEBUGGING_ASSEMBLY
            GenerateAssembly(types, s_typeMap);
            #endif
            s_typeMap = GenerateDynamic(types, s_typeMap);
            s_typeID_TypeData = s_typeMap.ToDictionary(kvp => kvp.Value.TypeID, kvp => kvp.Value);

            #if GENERATE_SWITCH
            s_Type_caseIDtypeIDMap = s_typeMap.ToDictionary(kvp => kvp.Key, kvp => (uint)(kvp.Value.TypeID | (kvp.Value.CaseID << 16)));
            s_caseID_typeIDMap = s_typeMap.ToDictionary(kvp => kvp.Value.TypeID, kvp => kvp.Value.CaseID);
            #endif
                s_initialized = true;
        }
开发者ID:smalinin,项目名称:netserializer,代码行数:19,代码来源:Main.cs

示例6: ButtonConsolidateOutputFiles_Click


//.........这里部分代码省略.........

                foreach (var userScore in usersScores)
                {
                    foreach (var scoreList in userScore.Value)
                    {
                        foreach (var score in scoreList.Value)
                        {
                            if (score < min) min = score;
                            if (score > max) max = score;
                        }
                    }
                }

                double range;
                double topUp;

                if (Math.Sign(max) == Math.Sign(min))
                {
                    range = Math.Abs(max) - Math.Abs(min);
                    topUp = - Math.Abs(min);
                }
                else
                {
                    range = Math.Abs(max) + Math.Abs(min);
                    topUp = Math.Abs(min);
                }

                Write("Max: " + max);
                Write("Min: " + min);
                Write("Range: " + range);
                Write("Topup: " + topUp);

                foreach (var userScore in usersScores)
                {
                    if (writeEachConceptFeature)
                    {
                        foreach (var scoreList in userScore.Value)
                        {
                            var conceptFeaturesDoc = new BsonDocument
                            {
                                {"_id", scoreList.Key},
                                {"concepts", new BsonArray(scoreList.Value)}
                            };

                            conceptFeaturesOutputTable.Insert(conceptFeaturesDoc);
                        }
                    }
                    else
                    {
                        if (conceptFeaturesOutputTable.FindOne(Query.EQ("_id", userScore.Key)) != null) continue;

                        var probabilities = new Dictionary<int, double>();
                        var numberOfPicturesTaken = userScore.Value.Count;

                        var conceptFeaturesDoc = new BsonDocument
                        {
                            {"_id", userScore.Key},
                            {"numberOfImages", numberOfPicturesTaken}
                        };

                        foreach (var scoreList in userScore.Value)
                        {
                            var counter = 0;

                            foreach (var score in scoreList.Value)
                            {
                                counter++;
                                var probability = (score + topUp)/range;

                                if (!probabilities.ContainsKey(counter))
                                {
                                    probabilities.Add(counter, 0);
                                }

                                if (binaryFeatures)
                                {
                                    probabilities[counter] += probability > treshhold ? 1 : 0;
                                }
                                else
                                {
                                    probabilities[counter] += probability;
                                }
                            }
                        }

                        if (!normaliseFeatures)
                        {
                            numberOfPicturesTaken = 1;
                        }

                        var record =
                            probabilities.ToDictionary(probability => probability.Key.ToString(CultureInfo.InvariantCulture),
                                probability => probability.Value/numberOfPicturesTaken);

                        conceptFeaturesDoc.AddRange(record);
                        conceptFeaturesOutputTable.Insert(conceptFeaturesDoc);
                    }
                }
            });
        }
开发者ID:farseev,项目名称:mobility,代码行数:101,代码来源:MainWindow.xaml.cs

示例7: Write

        /// <summary>
        /// Save pre-selection forest.
        /// </summary>
        /// <param name="decisionForest">The forest with each tree corresponding to a unit.</param>
        /// <param name="candidateGroups">The candidate group collection.</param>
        /// <param name="unitCandidateNameIds">Given candidate idx.</param>
        /// <param name="customFeatures">Cusotmized linguistic feature list.</param>
        /// <param name="outputPath">The output path.</param>
        public void Write(DecisionForest decisionForest,
            ICollection<CandidateGroup> candidateGroups, 
            IDictionary<string, int> unitCandidateNameIds,
            HashSet<string> customFeatures,
            string outputPath)
        {
            foreach (Question question in decisionForest.QuestionList)
            {
                question.Language = _phoneSet.Language;
                question.ValueSetToCodeValueSet(_posSet, _phoneSet, customFeatures);
            }

            FileStream file = new FileStream(outputPath, FileMode.Create);
            try
            {
                using (DataWriter writer = new DataWriter(file))
                {
                    file = null;
                    uint position = 0;

                    // Write header section place holder
                    PreselectionFileHeader header = new PreselectionFileHeader();
                    position += (uint)header.Write(writer);

                    HtsFontSerializer serializer = new HtsFontSerializer();

                    // Write feature, question and prepare string pool
                    HtsQuestionSet questionSet = new HtsQuestionSet
                    {
                        Items = decisionForest.QuestionList,
                        Header = new HtsQuestionSetHeader { HasQuestionName = false },
                        CustomFeatures = customFeatures,
                    };

                    using (StringPool stringPool = new StringPool())
                    {
                        Dictionary<string, uint> questionIndexes = new Dictionary<string, uint>();

                        header.QuestionOffset = position;
                        header.QuestionSize = serializer.Write(
                            questionSet, writer, stringPool, questionIndexes, customFeatures);
                        position += header.QuestionSize;

                        // Write leaf referenced data to buffer
                        IEnumerable<INodeData> dataNodes = GetCandidateNodes(candidateGroups);
                        using (MemoryStream candidateSetBuffer = new MemoryStream())
                        {
                            Dictionary<string, int> namedSetOffset = new Dictionary<string, int>();

                            int candidateSetSize = HtsFontSerializer.Write(
                                dataNodes, new DataWriter(candidateSetBuffer), namedSetOffset);

                            // Write decision forest
                            Dictionary<string, uint[]> namedOffsets =
                                namedSetOffset.ToDictionary(p => p.Key, p => new[] { (uint)p.Value });

                            header.DecisionTreeSectionOffset = position;

                            header.DecisionTreeSectionSize = (uint)Write(decisionForest, unitCandidateNameIds,
                                questionIndexes, questionSet, namedOffsets, new DecisionForestSerializer(), writer);
                            position += header.DecisionTreeSectionSize;

                            // Write string pool
                            header.StringPoolOffset = position;
                            header.StringPoolSize = HtsFontSerializer.Write(stringPool, writer);
                            position += header.StringPoolSize;

                            // Write leaf referenced data
                            header.CandidateSetSectionOffset = position;
                            header.CandidateSetSectionSize = writer.Write(candidateSetBuffer.ToArray());
                            position += header.CandidateSetSectionSize;
                        }

                        // Write header section place holder
                        using (PositionRecover recover = new PositionRecover(writer, 0))
                        {
                            header.Write(writer);
                        }
                    }              
                }
            }
            finally
            {
                if (null != file)
                {
                    file.Dispose();
                }
            }
        }
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:97,代码来源:PreselectionDataWriter.cs

示例8: ParamPack

 private ParamPack(string name, Dictionary<string, string> parameters)
 {
     Name = name;
     _parameters = parameters.ToDictionary(kv => kv.Key, kv => kv.Value);
 }
开发者ID:GrafGenerator,项目名称:ssrs-report-metrics,代码行数:5,代码来源:ParamPack.cs

示例9: LoadMesh


//.........这里部分代码省略.........
                            for (int i = 0; i < verticesNum; i++)
                            {
                                vertices[i] = new MyVertexFormatPositionH4(positions[i]);
                            }
                            meshVertexInput = meshVertexInput.Append(MyVertexInputComponentType.POSITION_PACKED);

                            result.VertexPositions = vertices;

                            fixed (MyVertexFormatPositionH4* V = vertices)
                            {
                                vertexBuffers.Add(
                                    MyManagers.Buffers.CreateVertexBuffer(
                                        assetName + " vertex buffer " + vertexBuffers.Count, verticesNum,
                                        sizeof(MyVertexFormatPositionH4), new IntPtr(V), ResourceUsage.Immutable));
                            }
                        }
                        else
                        {
                            var vertices = new MyVertexFormatPositionSkinning[verticesNum];
                            for (int i = 0; i < verticesNum; i++)
                            {
                                vertices[i] = new MyVertexFormatPositionSkinning(
                                    positions[i],
                                    new Byte4(boneIndices[i].X, boneIndices[i].Y, boneIndices[i].Z, boneIndices[i].W),
                                    boneWeights[i]);
                            }
                            meshVertexInput = meshVertexInput.Append(MyVertexInputComponentType.POSITION_PACKED)
                                .Append(MyVertexInputComponentType.BLEND_WEIGHTS)
                                .Append(MyVertexInputComponentType.BLEND_INDICES);

                            fixed (MyVertexFormatPositionSkinning* V = vertices)
                            {
                                vertexBuffers.Add(MyManagers.Buffers.CreateVertexBuffer(
                                    assetName + " vertex buffer " + vertexBuffers.Count, verticesNum,
                                    sizeof(MyVertexFormatPositionSkinning), new IntPtr(V), ResourceUsage.Immutable));
                            }
                        }
                        // add second stream
                        {
                            var vertices = new MyVertexFormatTexcoordNormalTangent[verticesNum];
                            for (int i = 0; i < verticesNum; i++)
                            {
                                vertices[i] = new MyVertexFormatTexcoordNormalTangent(texcoords[i], normals[i], tangentBitanSgn[i]);
                            }

                            fixed (MyVertexFormatTexcoordNormalTangent* V = vertices)
                            {
                                vertexBuffers.Add(MyManagers.Buffers.CreateVertexBuffer(
                                    assetName + " vertex buffer " + vertexBuffers.Count, verticesNum,
                                    sizeof(MyVertexFormatTexcoordNormalTangent), new IntPtr(V), ResourceUsage.Immutable));
                            }

                            result.VertexExtendedData = vertices;

                            meshVertexInput = meshVertexInput
                                .Append(MyVertexInputComponentType.NORMAL, 1)
                                .Append(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1)
                                .Append(MyVertexInputComponentType.TEXCOORD0_H, 1);
                        }
                    }
                    #endregion
                }
                #region Extract lods
                if (tagData.ContainsKey(MyImporterConstants.TAG_LODS))
                {
                    var tagLODs = tagData[MyImporterConstants.TAG_LODS];
                    if (((MyLODDescriptor[])tagLODs).Length > 0)
                    {
                    }
                    LodDescriptors = (MyLODDescriptor[])((MyLODDescriptor[])tagLODs).Clone();
                }
                #endregion

                if (missingMaterial)
                {
                    Debug.WriteLine(String.Format("Mesh {0} has missing material", assetName));
                }

                //indexBuffer.SetDebugName(assetName + " index buffer");
                int c = 0;
                //vertexBuffers.ForEach(x => x.SetDebugName(assetName + " vertex buffer " + c++));

                //
                result.BoundingBox = (BoundingBox)tagData[MyImporterConstants.TAG_BOUNDING_BOX];
                result.BoundingSphere = (BoundingSphere)tagData[MyImporterConstants.TAG_BOUNDING_SPHERE];
                result.VerticesNum = verticesNum;
                result.IndicesNum = indicesNum;
                result.VertexLayout = meshVertexInput;
                result.IB = indexBuffer;
                result.VB = vertexBuffers.ToArray();
                result.IsAnimated = hasBonesInfo;
                result.Parts = submeshes.ToDictionary(x => x.Key, x => x.Value.ToArray());
                result.PartsMetadata = submeshes2.ToDictionary(x => x.Key, x => x.Value.ToArray());
                result.m_submeshes = submeshesMeta;

                IsAnimated |= result.IsAnimated;

                importer.Clear();
                return result;
            }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:101,代码来源:MyAssetMesh.cs

示例10: HtmlEntity


//.........这里部分代码省略.........
                        {8482, "trade"},
                        {8501, "alefsym"},
                        {8592, "larr"},
                        {8593, "uarr"},
                        {8594, "rarr"},
                        {8595, "darr"},
                        {8596, "harr"},
                        {8629, "crarr"},
                        {8656, "lArr"},
                        {8657, "uArr"},
                        {8658, "rArr"},
                        {8659, "dArr"},
                        {8660, "hArr"},
                        {8704, "forall"},
                        {8706, "part"},
                        {8707, "exist"},
                        {8709, "empty"},
                        {8711, "nabla"},
                        {8712, "isin"},
                        {8713, "notin"},
                        {8715, "ni"},
                        {8719, "prod"},
                        {8721, "sum"},
                        {8722, "minus"},
                        {8727, "lowast"},
                        {8730, "radic"},
                        {8733, "prop"},
                        {8734, "infin"},
                        {8736, "ang"},
                        {8743, "and"},
                        {8744, "or"},
                        {8745, "cap"},
                        {8746, "cup"},
                        {8747, "int"},
                        {8756, "there4"},
                        {8764, "sim"},
                        {8773, "cong"},
                        {8776, "asymp"},
                        {8800, "ne"},
                        {8801, "equiv"},
                        {8804, "le"},
                        {8805, "ge"},
                        {8834, "sub"},
                        {8835, "sup"},
                        {8836, "nsub"},
                        {8838, "sube"},
                        {8839, "supe"},
                        {8853, "oplus"},
                        {8855, "otimes"},
                        {8869, "perp"},
                        {8901, "sdot"},
                        {8968, "lceil"},
                        {8969, "rceil"},
                        {8970, "lfloor"},
                        {8971, "rfloor"},
                        {9001, "lang"},
                        {9002, "rang"},
                        {9674, "loz"},
                        {9824, "spades"},
                        {9827, "clubs"},
                        {9829, "hearts"},
                        {9830, "diams"},
                        {34, "quot"},
                        {38, "amp"},
                        {60, "lt"},
                        {62, "gt"},
                        {338, "OElig"},
                        {339, "oelig"},
                        {352, "Scaron"},
                        {353, "scaron"},
                        {376, "Yuml"},
                        {710, "circ"},
                        {732, "tilde"},
                        {8194, "ensp"},
                        {8195, "emsp"},
                        {8201, "thinsp"},
                        {8204, "zwnj"},
                        {8205, "zwj"},
                        {8206, "lrm"},
                        {8207, "rlm"},
                        {8211, "ndash"},
                        {8212, "mdash"},
                        {8216, "lsquo"},
                        {8217, "rsquo"},
                        {8218, "sbquo"},
                        {8220, "ldquo"},
                        {8221, "rdquo"},
                        {8222, "bdquo"},
                        {8224, "dagger"},
                        {8225, "Dagger"},
                        {8240, "permil"},
                        {8249, "lsaquo"},
                        {8250, "rsaquo"},
                        {8364, "euro"}
                    };

            _entityValue = _entityName.ToDictionary(x => x.Value, x => x.Key);

            _maxEntitySize = 8 + 1; // we add the # char
        }
开发者ID:ToFuKing,项目名称:HtmlAgilityPack,代码行数:101,代码来源:HtmlEntity.cs

示例11: DatObject

 public DatObject(Dictionary<string, string> elements, Pak pak, DatFile file)
 {
     Pak = pak;
     DatFile = file;
     _dictionary = elements.ToDictionary(x => (string)x.Key, x => (string)x.Value);
 }
开发者ID:calvin-fisher,项目名称:SimutransPak,代码行数:6,代码来源:DatObject.cs

示例12: DeleteSingle

 public DeleteItemResponse DeleteSingle(string tableName, Dictionary<string, object> dictionary)
 {
     var transformDictionary = dictionary.ToDictionary(x => x.Key, x => GetAttributeValueFromObject(x.Value));
     return _client.DeleteItem(tableName, transformDictionary);
 }
开发者ID:KyleGobel,项目名称:Chronos,代码行数:5,代码来源:Dynamo.cs

示例13: WriteSingle

 public void WriteSingle(string tableName, Dictionary<string,object> dictionary)
 {
     var transformDictionary = dictionary.ToDictionary(x => x.Key, x => GetAttributeValueFromObject(x.Value));
     _client.PutItem(tableName, transformDictionary);
 }
开发者ID:KyleGobel,项目名称:Chronos,代码行数:5,代码来源:Dynamo.cs

示例14: TypesUtil

 static TypesUtil()
 {
     PRIMITIVE_TYPES = new Dictionary<string, Type>()
     {
         {"void",   typeof(void)},         
         {"bool",    typeof(bool)},       
         {"object",   typeof(object)},       
         {"string",   typeof(string)},         
         {"char",   typeof(char)},         
         {"double",   typeof(double)},         
         {"int",   typeof(int)},         
         {"long",  typeof(long)},
         {"decimal",  typeof(decimal)}
     };
     PRIMITIVE_TYPES_REV = PRIMITIVE_TYPES.ToDictionary(a => a.Value, a => a.Key);
 }
开发者ID:exaphaser,项目名称:cs2php,代码行数:16,代码来源:TypesUtil.cs

示例15: GetLettersPositions

        /// <summary>
        /// Vrátí pozice jednotlivých písmen ve slově
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private Dictionary<char, int[]> GetLettersPositions(string text)
        {
            Dictionary<char, List<int>> positions = new Dictionary<char, List<int>>();

            for (int i = 0; i < text.Length; i++)
            {
                char currLetter = text[i];
                if (positions.ContainsKey(currLetter))
                {
                    positions[currLetter].Add(i);
                }
                else
                {
                    positions[currLetter] = new List<int>() { i };
                }
            }

            return positions.ToDictionary(x => x.Key, x => x.Value.ToArray());
        }
开发者ID:havrlant,项目名称:cryptanalysis,代码行数:24,代码来源:DictionaryAttack.cs


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