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


C# Dictionary.Select方法代码示例

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


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

示例1: CreateCriteria

 public ModuleCriteria CreateCriteria(int testId, Dictionary<string, string> scormData) {
   //Velka data, zaroven se vypocitaji properties, odvozene z Results
   if (scormData != null) { ScormDataKey = scormData.Select(kv => kv.Key).ToArray(); ScormDataValue = scormData.Select(kv => kv.Value).ToArray(); }
   byte[] encode = Encode();
   //Mala proxy data
   PageResult[] res = Results; Results = null; ScormDataValue = ScormDataKey = null;
   byte[] encodeProxy = Encode();
   Results = res;
   //Uloz do DB
   ModuleCriteria crit = new ModuleCriteria() {
     CourseId = testId,
     DataBin = new IdDataBin() { Id = Id, DataBin = encode },
     ProxyDataBin = new IdDataBin() { Id = Id, DataBin = encodeProxy },
     Status = (short)Status,
     Level = (short)Level
   };
   if (Status == ExerciseStatus.Evaluated) {
     crit.Skill = Skill;
     crit.ElapsedSeconds = (short)(ElapsedTime / 1000);
     crit.Score = (short)Score.ToPercent();
     TestProxy.LevelScore score = TestProxy.GetLevelScore(this);
     crit.AbsLevel = score.absLevel;
     crit.AbsScore = (short) score.absScore;
     crit.GlobalScore = (short)score.globalScore;
   }
   return crit;
 }
开发者ID:PavelPZ,项目名称:NetNew,代码行数:27,代码来源:Objects.cs

示例2: Optimize

        public void Optimize(Dictionary<double, double> values)
        {
            var n = _f.Functions.Count();
              var xs = values.Select(v => v.Key).ToList();
              var ys = values.Select(v => v.Value).ToList();
              var fs = new List<List<double>>(n);

              for (var i = 0; i < n; i++)
              {
            fs[i] = _f.Functions[i].Evaluate(xs);
              }

              var matrix = new DenseMatrix(n, n);
              var vector = new DenseVector(n);
              for (var i = 0; i < n; i++)
              {
            for (var j = 0; j < n; j++)
            {
              matrix[i, j] = fs[i].ScalarProduct(fs[j]);
            }
            vector[i] = ys.ScalarProduct(fs[i]);
              }

              var matrixInverse = matrix.Inverse();

              var result = matrixInverse * vector;

              for (var i = 0; i < n; i++)
              {
            _f.LinearParameters[i].Value = result[i];
              }
        }
开发者ID:LucasFievet,项目名称:Tomorrow,代码行数:32,代码来源:LCFunctionLinearOptimizer.cs

示例3: DataUserSelectorListView

        public static void DataUserSelectorListView(BasePage page, String ObjId, Dictionary<Guid, String> SelectedUsers, List<GroupInfo> SelectedGroups, bool DisabledGroupSelector)
        {
            var ids = SelectedUsers != null && SelectedUsers.Count > 0 ? SelectedUsers.Select(i => i.Key).ToArray() : new List<Guid>().ToArray();
            var names = SelectedUsers != null && SelectedUsers.Count > 0 ? SelectedUsers.Select(i => i.Value).ToArray() : new List<string>().ToArray();

            page.RegisterInlineScript(String.Format(" SelectedUsers{0} = {1}; ",
                                                        ObjId,
                                                        JsonConvert.SerializeObject(
                                                            new
                                                            {
                                                                IDs = ids,
                                                                Names = names,
                                                                PeopleImgSrc = WebImageSupplier.GetAbsoluteWebPath("people_icon.png", ProductEntryPoint.ID),
                                                                DeleteImgSrc = WebImageSupplier.GetAbsoluteWebPath("trash_12.png"),
                                                                DeleteImgTitle = CRMCommonResource.DeleteUser,
                                                                CurrentUserID = SecurityContext.CurrentAccount.ID
                                                            })), onReady: false);
            if (!DisabledGroupSelector)
            {
                ids = SelectedGroups != null && SelectedGroups.Count > 0 ? SelectedGroups.Select(i => i.ID).ToArray() : new List<Guid>().ToArray();
                names = SelectedGroups != null && SelectedGroups.Count > 0 ? SelectedGroups.Select(i => i.Name.HtmlEncode()).ToArray() : new List<string>().ToArray();

                page.RegisterInlineScript(String.Format(" SelectedGroups{0} = {1}; ",
                                                            ObjId,
                                                            JsonConvert.SerializeObject(
                                                                    new
                                                                    {
                                                                        IDs = ids,
                                                                        Names = names,
                                                                        GroupImgSrc = WebImageSupplier.GetAbsoluteWebPath("group_12.png"),
                                                                        TrashImgSrc = WebImageSupplier.GetAbsoluteWebPath("trash_12.png"),
                                                                        TrashImgTitle = CRMCommonResource.Delete
                                                                    })), onReady: false);
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:35,代码来源:RegisterClientScriptHelper.cs

示例4: StructureVoxelModel

        public StructureVoxelModel(MyObjectBuilder_EntityBase entityBase, string voxelPath)
            : base(entityBase)
        {
            var contentPath = ToolboxUpdater.GetApplicationContentPath();

            if (voxelPath != null)
            {
                VoxelFilepath = Path.Combine(voxelPath, Name + MyVoxelMap.V2FileExtension);
                var previewFile = VoxelFilepath;

                if (!File.Exists(VoxelFilepath))
                {
                    var oldFilepath = Path.Combine(voxelPath, Name + MyVoxelMap.V1FileExtension);
                    if (File.Exists(oldFilepath))
                    {
                        SourceVoxelFilepath = oldFilepath;
                        previewFile = oldFilepath;
                        SpaceEngineersCore.ManageDeleteVoxelList.Add(oldFilepath);
                    }
                }

                ReadVoxelDetails(previewFile);
            }

            var materialList = new Dictionary<string, string>();
            foreach (MyVoxelMaterialDefinition item in SpaceEngineersCore.Resources.VoxelMaterialDefinitions.OrderBy(m => m.Id.SubtypeName))
            {
                string texture = item.GetVoxelDisplayTexture();
                materialList.Add(item.Id.SubtypeName, texture == null ? null : SpaceEngineersCore.GetDataPathOrDefault(texture, Path.Combine(contentPath, texture)));
            }

            GameMaterialList = new List<VoxelMaterialAssetModel>(materialList.Select(m => new VoxelMaterialAssetModel { MaterialName = m.Key, DisplayName = m.Key, TextureFile = m.Value }));
            EditMaterialList = new List<VoxelMaterialAssetModel> { new VoxelMaterialAssetModel { MaterialName = null, DisplayName = "Delete/Remove" } };
            EditMaterialList.AddRange(materialList.Select(m => new VoxelMaterialAssetModel { MaterialName = m.Key, DisplayName = m.Key, TextureFile = m.Value }));
        }
开发者ID:midspace,项目名称:SEToolbox,代码行数:35,代码来源:StructureVoxelModel.cs

示例5: Add_Random_Parameter_Test

 public void Add_Random_Parameter_Test()
 {
     var dictionary = new Dictionary<string, object>();
     Enumerable.Range(1, 10).ToList().ForEach(x => dictionary.AddWithUniquelyNamedKey(x));
     dictionary.Select(x => x.Key).Distinct().Count().ShouldEqual(10);
     dictionary.Select(x => x.Value).ToList().ForEach(x => x.ShouldBeType(typeof(int)));
     dictionary.Select(x => x.Value).ToList().ForEach(x => x.ShouldBeGreaterThan(0));
 }
开发者ID:mikeobrien,项目名称:Gribble,代码行数:8,代码来源:DictionaryExtensionTests.cs

示例6: Entrainer

        /// <summary>
        /// Entraine le réseau
        /// </summary>
        /// <param name="maxIteration">Nombre d'itérations max</param>
        /// <param name="pas">Pas d'apprentissage</param>
        /// <param name="lettreCible">Lettre pour laquelle on entraîne le réseau</param>
        /// <param name="jeuEssai">Jeu d'essai pour entraîner le réseau</param>
        /// <param name="biais">Biais initial</param>
        /// <returns>L'erreur du réseau à la fin de son entraînement</returns>
        public double[] Entrainer(Dictionary<string, double[]> jeuEssai, string lettreCible, int maxIteration, double pas, double biais)
        {
            // on entraîne le réseau
            Neurone neurone = Couches[0].Neurones[0]; // un seul neurone dans le Perceptron

            double erreurCible = 0;
            double[] erreurCourante = new double[] { double.MaxValue };
            int iteration = 0;
            // valeurs initiales
            neurone.Poids = new double[neurone.NbEntrees];
            neurone.Biais = biais;

            while (iteration < maxIteration && erreurCourante[0] > erreurCible)
            {
                // pour chaque élément de test
                foreach (string lettre in jeuEssai.Keys)
                {
                    // récupère le jeu d'entraînement courant
                    double[] entraineur = jeuEssai[lettre];
                    // détermine si c'est la valeur cible (1) ou pas (-1)
                    int valeurCible = (lettre == lettreCible) ? 1 : 0; // la fonction de transfert doit donc produire des -1 ou des 1

                    double sortie = neurone.CalculerSortie(entraineur);
                    // de combien la sortie s'écarte de la cible
                    double ecart = valeurCible - sortie;

                    if (ecart != 0)
                    {
                        // réévalue le poids de chaque entrée (règle de RosenBlatt)
                        for (int p = 0; p < neurone.NbEntrees; p++)
                        {
                            neurone.Poids[p] = neurone.Poids[p] + (pas * ecart * entraineur[p]);
                        }
                        // réévalue le biais
                        // le biais est considéré comme une entrée supplémentaire avec un coefficient toujours égal à 1
                        neurone.Biais = neurone.Biais + (pas * ecart);
                    }
                }

                ++iteration;
                Debug.WriteLine("Itération: " + iteration.ToString());

                // on a un biais et un jeu de poids candidat
                // calcule l'erreur faite par le réseau dans l'estimation de notre jeu d'essai avec notre candidat
                double[][] tests = jeuEssai.Select(jeu => jeu.Value).ToArray();
                double[] cibles = jeuEssai.Select(jeu => (jeu.Key == lettreCible) ? 1.0 : 0.0).ToArray();
                double[][] c = jeuEssai.Select(jeu => cibles).ToArray();
                erreurCourante = CalculerErreur(tests, cibles);
            }

            return erreurCourante;
        }
开发者ID:DeLeneMirouze,项目名称:NeuralNetwork,代码行数:61,代码来源:Perceptron.cs

示例7: Insert

 public static bool Insert(string table, Dictionary<string,object> vars)
 {
     using (SqlConnection sqlc = new SqlConnection(ConnectionString))
     {
         var sqlcom = sqlc.CreateCommand();
         sqlcom.CommandText = "INSERT INTO " + table + " ";
         sqlcom.CommandText += "(" + String.Join(",", vars.Select(elem => elem.Key)) + ")";
         sqlcom.CommandText += " VALUES (";
         sqlcom.CommandText += String.Join(",", vars.Select(elem => "@" + elem.Key));
         sqlcom = SetValues(vars, sqlcom);
         sqlcom.CommandText += ")";
         return Exec(sqlcom);
     }
 }
开发者ID:Grandman,项目名称:kursach,代码行数:14,代码来源:DB.cs

示例8: PublishSite

        private void PublishSite(Dictionary<string, string> properties)
        {
            var arguments = "/p:" + string.Join(";", properties.Select(kvp => kvp.Key + "=" + kvp.Value)) + " \"" + ProjectPath + "\"";

            var msBuildProc = new Process();
            msBuildProc.StartInfo = new ProcessStartInfo
                {
                    FileName = Path.Combine(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), "msbuild.exe"),
                    Arguments = arguments,
                    RedirectStandardError = true,
                    RedirectStandardOutput = true,
                    UseShellExecute = false,
                    CreateNoWindow = true,
                };
            msBuildProc.Start();

            var stdout = msBuildProc.StandardOutput.ReadToEnd();
            var stderr = msBuildProc.StandardError.ReadToEnd();
            msBuildProc.WaitForExit();

            var success = msBuildProc.ExitCode == 0;

            if (!success)
            {
                Console.WriteLine("The publish failed.");
                Console.WriteLine(stdout);
                Console.WriteLine(stderr);
                throw new ApplicationException("Build failed.");
            }
            else
            {
                Console.WriteLine("The publish succeeded.");
            }
        }
开发者ID:jesusgarza,项目名称:SpecsFor,代码行数:34,代码来源:IISTestRunnerAction.cs

示例9: Main

        static void Main(string[] args)
        {
            var input = Console.In;

            var amount = int.Parse(input.ReadLine());
            var numberOfTypes = int.Parse(input.ReadLine());

            var faceValues = Enumerable.Range(0, numberOfTypes)
                .Select(i => input.ReadLine())
                .Select(int.Parse)
                .OrderByDescending(i => i)
                .ToList();

            var dictionary = new Dictionary<int, int>();

            while (amount > 0)
            {
                var toUse = faceValues.First(i => i <= amount);
                if (!dictionary.ContainsKey(toUse))
                {
                    dictionary.Add(toUse,0);
                }

                dictionary[toUse] = dictionary[toUse] + 1;
                amount -= toUse;
            }

            var result = string.Join(" ", dictionary.Select(pair => pair.Value + " " + pair.Key));

            Console.Write(result);
        }
开发者ID:evilz,项目名称:isograd-tosa,代码行数:31,代码来源:Program.cs

示例10: Main

    static void Main()
    {
        Console.Write("Enter a string: ");
        string input = Console.ReadLine();
        MatchCollection words = Regex.Matches(input, @"\b\w+\b");

        Dictionary<string, int> dict = new Dictionary<string, int>();

        foreach (var word in words)
        {
            if (word.ToString() != string.Empty)
            {
                if (!dict.ContainsKey(word.ToString()))
                {
                    dict.Add(word.ToString(), 1);
                }
                else
                {
                    dict[word.ToString()]++;
                }
            }
        }

        Console.WriteLine(string.Join("\n", dict.Select(x => string.Format(@"{0} - {1}", x.Key, x.Value)).ToArray()));
    }
开发者ID:tima-t,项目名称:Telerik-Academy,代码行数:25,代码来源:Program.cs

示例11: LoadMenu

        public LoadMenu(String path, Dictionary<String, String> fileTypes, Window parentWindow)
            : base("Load Menu", Math.Min(6, Console.WindowHeight - 22), (Console.WindowWidth / 2) - 30, 60, 20, parentWindow)
        {
            BackgroundColour = ConsoleColor.White;
            FileTypes = fileTypes;

            fileSelect = new FileBrowser(PostionX + 2, PostionY + 2, 56, 13, path, "fileSelect", this, true, "txt");
            fileSelect.ChangeItem = delegate() { UpdateCurrentlySelectedFileName(); };
            fileSelect.SelectFile = delegate() { LoadFile(); };

            var openLabel = new Label("Open", PostionX + 16, PostionY + 2, "openLabel", this);
            openTxtBox = new TextBox(PostionX + 16, PostionY + 7, "openTxtBox", this, Width - 13) { Selectable = false };

            fileTypeDropdown = new Dropdown(PostionX + 18, PostionY + 40, FileTypes.Select(x => x.Value).ToList(), "fileTypeDropdown", this, 17);
            fileTypeDropdown.OnUnselect = delegate() { UpdateFileTypeFilter(); };

            loadBtn = new Button(PostionX + 18, PostionY + 2, "Load", "loadBtn", this);
            loadBtn.Action = delegate() { LoadFile(); };
            cancelBtn = new Button(PostionX + 18, PostionY + 9, "Cancel", "cancelBtn", this);
            cancelBtn.Action = delegate() { ExitWindow(); };

            Inputs.Add(fileSelect);
            Inputs.Add(loadBtn);
            Inputs.Add(cancelBtn);
            Inputs.Add(openLabel);
            Inputs.Add(openTxtBox);
            Inputs.Add(fileTypeDropdown);

            CurrentlySelected = fileSelect;

            Draw();
            MainLoop();
        }
开发者ID:wizardbeard,项目名称:ConsoleDraw,代码行数:33,代码来源:LoadMenu.cs

示例12: ReloadBuilds

 void ReloadBuilds()
 {
     try
     {
         string res = Util.GetPageSource("http://d3up.com/ajax/builds?username=" + Properties.Settings.Default.D3UpUsername);
         JObject o = JObject.Parse(res);
         if (o["builds"] != null)
         {
             var builds = o["builds"];
             _builds = builds.ToObject<Dictionary<string, string>>();
             var buildNames = _builds.Select(b => b.Value).ToArray();
             this.UIThread(() =>
             {
                 cbDefaultBuild.Items.Clear();
                 cbDefaultBuild.Items.AddRange(buildNames);
             });
             GUI.Log(_builds.Count + " Builds loaded from D3Up.com");
         }
         else
         {
             throw new Exception("No builds");
         }
     }
     catch (Exception ex)
     {
         GUI.Log("Cannot fetch default build. Please check your d3up username.");
     }
 }
开发者ID:Corv,项目名称:D3Bit,代码行数:28,代码来源:UCOptions.cs

示例13: ConvertToMessage

 private string ConvertToMessage(Dictionary<string, string> message, bool useJson)
 {
     if(useJson)
         return JsonSerializer.SerializeToString(message);
     else
         return string.Join(" ", message.Select(m => String.Format("{0}={1}", m.Key, m.Value)));
 }
开发者ID:tarwn,项目名称:InstrumentationSampleCode,代码行数:7,代码来源:HttpJsonPost.cs

示例14: Compose

 private static string Compose(string apiPath, Dictionary<string,string> extra = null)
 {
     extra = extra ?? new Dictionary<string, string>();
     var list = extra.Select(x => x.Key + "=" + x.Value).ToList();
     list.Add(apikey);
     return baseUrl + apiPath + soSite + string.Join("&", list);
 }
开发者ID:chandru9279,项目名称:zasz.me,代码行数:7,代码来源:StackUrls.cs

示例15: PeopleGetPublicPhotos

        public string PeopleGetPublicPhotos(string userId, 
            string safeSearch = null, string extras = null, 
            int? perPage = null, int? page = null)
        {
            string url = "http://api.flickr.com/services/rest?method=flickr.people.getPublicPhotos&";
            var parameters = new Dictionary<string, string>
                {
                    {"format", "json"},
                    {"nojsoncallback", "1"},
                    {"api_key", _apiKey},
                    {"user_id", userId}
                };
            if (safeSearch != null)
                parameters.Add("safe_search", safeSearch);
            if (extras != null)
                parameters.Add("extras", extras);
            if (perPage != null)
                parameters.Add("per_page", perPage.Value.ToString(CultureInfo.InvariantCulture));
            if (page != null)
                parameters.Add("page", page.Value.ToString(CultureInfo.InvariantCulture));

            var parameterArray = parameters.Select(item => item.Key + "=" + item.Value).ToArray();
            url += string.Join("&", parameterArray);

            using (var webClient = new WebClient())
            using (var stream = webClient.OpenRead(url))
            {
                if (stream == null)
                    return null;
                using (var streamReader = new StreamReader(stream))
                {
                    return streamReader.ReadToEnd();
                }
            }
        }
开发者ID:medvekoma,项目名称:portfotolio,代码行数:35,代码来源:FlickrApi.cs


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