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


C# SerializableDictionary.Add方法代码示例

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


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

示例1: GenerateWeights

        public static SerializableDictionary<string, SerializableDictionary<string, double>> GenerateWeights(List<string> states, SIMDIST weightFlag)
        {
            SerializableDictionary<string, SerializableDictionary<string, double>> weights = new SerializableDictionary<string, SerializableDictionary<string, double>>();
            if (weightFlag == SIMDIST.SIMILARITY)
            {
                foreach (var item in states)
                {
                    weights.Add(item, new SerializableDictionary<string, double>());
                    weights[item].Add(item, 1.0);
                }
            }
            else
                foreach (var item in states)
                {
                    weights.Add(item, new SerializableDictionary<string, double>());
                    foreach (var item1 in states)
                    {
                        if (item != item1)                                                    
                            weights[item].Add(item1, 1.0);                        
                    }
                }


            return weights;
        }
开发者ID:uQlust,项目名称:uQlust-ver1.0,代码行数:25,代码来源:ProfileAutomatic.cs

示例2: Region

        public Region()
        {
            rParams = new SerializableDictionary<regPT,RegionParameter>();
            rParams.Add(regPT.X, new RegionParameter());
            rParams.Add(regPT.Y, new RegionParameter());
            rParams.Add(regPT.Z, new RegionParameter());

            regionEnabled = false;
        }
开发者ID:naegelyd,项目名称:therawii,代码行数:9,代码来源:Region.cs

示例3: Classify

        /// <summary>
        /// Calculate the probability for each category,
        /// and will determine which one is the largest
        /// and whether it exceeds the next largest by more than its threshold
        /// </summary>
        /// <param name="item">Item</param>
        /// <param name="defaultCat">Default category</param>
        /// <returns>Category which item mostly belongs to</returns>
        public string Classify(string item, string defaultCat = "unknown")
        {
            SerializableDictionary<string, double> probs = new SerializableDictionary<string, double>();
            string best = "";
            string possible = "";

            // Find the category with highest probability
            double max = 0.0;
            foreach (var category in Categories())
            {
                probs.Add(category, Probability(item, category));
                if (probs[category] > max)
                {
                    max = probs[category];
                    best = category;
                }
            }

                // Find the second suitable category
                if (probs.ContainsKey(best))
                {
                    probs.Remove(best);
                }
                max = 0.0;
                foreach (var category in probs)
                {
                    if (category.Value > max)
                    {
                        max = category.Value;
                        possible = category.Key;
                    }
                }
            probs.Add(best, Probability(item, best));
            

            // Make sure the probability exceeds threshould*next best
            foreach (var cat in probs)
            {
                if (cat.Key == best)
                {
                    continue;
                }
                if (cat.Value * GetThreshold(best) > probs[best])
                {
                    return defaultCat;
                }
            }
            return best + (possible.Length > 0 ? (" or " + possible) : "");
        }
开发者ID:DVitinnik,项目名称:UniversityApps,代码行数:57,代码来源:NaiveBayes.cs

示例4: CreateItemDataFromGameObject

    private ItemData CreateItemDataFromGameObject(GameObject gameObject)
    {
        ValidateGameObject (gameObject);

        ItemData itemData = new ItemData ();
        itemData.transformData.position = gameObject.transform.position;
        itemData.transformData.rotation = gameObject.transform.eulerAngles;
        itemData.transformData.scale = gameObject.transform.localScale;
        itemData.name = gameObject.name;

        foreach (IPersistable persistable in gameObject.GetComponents<IPersistable>()) {

          SerializableDictionary<string, object> componentConfiguration = new SerializableDictionary<string, object> ();
          foreach (FieldInfo field in persistable.GetType().GetFields()) {
        componentConfiguration.Add (field.Name, field.GetValue (persistable));
          }

          string componentName = persistable.GetType ().FullName;

          itemData.componentData.configurations.Add (componentName, componentConfiguration);
        }

        foreach (Transform child in gameObject.transform) {
          if (child.GetComponents<IPersistable> ().Length > 0) {
        itemData.children.Add (CreateItemDataFromGameObject (child.gameObject));
          }
        }

        return itemData;
    }
开发者ID:brwagner,项目名称:rocket-gilbs-v2,代码行数:30,代码来源:XmlIO.cs

示例5: SaveData

        /// <summary>
        /// If you need to get a clear savegame, use this method. But be careful, could erase other data
        /// </summary>
        public SaveData()
        {
            KilledPoulpis = 0;
            GameHasBeenEnded = false;

            #if DEBUG
            LastLevel = LevelSelectionScreen.WorldCount;
            #else
            LastLevel = 0;
            #endif
            ScoresBylevel = new SerializableDictionary<ScoreType, SerializableDictionary<String, ScoreLine[]>>();
            ScoresBylevel.Add(ScoreType.Single, new SerializableDictionary<String, ScoreLine[]>());
            ScoresBylevel.Add(ScoreType.Coop, new SerializableDictionary<String, ScoreLine[]>());

            this.OptionsData = new OptionsData();
        }
开发者ID:Azzhag,项目名称:The-Great-Paper-Adventure,代码行数:19,代码来源:Saver.cs

示例6: GetLanguageStrings

        public static SerializableDictionary<string, string> GetLanguageStrings(Stream javaMessagesStream)
        {
            var result = new SerializableDictionary<string, string>();

            using (var reader = new StreamReader(javaMessagesStream))
            {
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();

                    var deviderIndex = line.IndexOf('=');
                    if (deviderIndex != -1 && line[0] != '#')
                    {
                        var text = line.Substring(deviderIndex + 1);

                        var regex = new Regex(@"\\u[A-Za-z0-9]{4}");

                        text = regex.Replace(text, m => ((Char)UInt16.Parse(m.Value.Substring(2), System.Globalization.NumberStyles.AllowHexSpecifier)).ToString());

                        var key = line.Substring(0, deviderIndex);
                        if (!result.ContainsKey(key))
                            result.Add(key, text);
                    }
                }
            }
            return result;
        }
开发者ID:nokiadatagathering,项目名称:WP7-Official,代码行数:27,代码来源:JavaMessagesParser.cs

示例7: Frm_FanPowerAdvanceSetting

 public Frm_FanPowerAdvanceSetting(List<ILEDDisplayInfo> oneLedInfos,string sn,string commPort,
                                   SerializableDictionary<string, byte> curAllSettingDic, 
                                   SettingCommInfo commInfo)
 {
     InitializeComponent();
     _oneLedInfos = oneLedInfos;
     _sn = sn;
     _commPort = commPort;
     _curConfigDic = new SerializableDictionary<string, byte>();
     if (curAllSettingDic != null)
     {
         foreach(string addr in curAllSettingDic.Keys)
         {
             _curConfigDic.Add(addr, curAllSettingDic[addr]);
         }
     }
     try
     {
         _commonInfo = (SettingCommInfo)commInfo.Clone();
     }
     catch
     {
         _commonInfo = new SettingCommInfo();
     }
 }
开发者ID:hardborn,项目名称:MonitorManager,代码行数:25,代码来源:Frm_FanPowerAdvanceSetting.cs

示例8: Parse

        internal static SerializableDictionary<string, object> Parse(string worstPointFile)
        {
            IEnumerable<string> lines = System.IO.File.ReadLines(worstPointFile);

            if (lines == null || lines.Count() < 2) throw new ArgumentException("Invalid file");
            else
            {
                lines = lines.Skip(1);
                SerializableDictionary<string, object> input = new SerializableDictionary<string, object>();
                string[] numbers = (lines.First()).Split(',');
                input.Add("Frequency", Double.Parse(numbers[0], CultureInfo.InvariantCulture));
                input.Add("Desired", Double.Parse(numbers[1], CultureInfo.InvariantCulture));
                input.Add("ObjectiveFunctionValue", ObjectiveFunctionValueParser.Parse(numbers[2]));

                return input;
            }
        }
开发者ID:sac16controllertester,项目名称:ControllerTester,代码行数:17,代码来源:SingleStateSearchParser.cs

示例9: ServerState

		public ServerState()
		{
			Accounts = new SerializableDictionary<string, Hash>();
			if (!Accounts.ContainsKey("guest")) {
				Accounts.Add("guest", Hash.HashString("guest"));
			}
            UpgradeData = new SerializableDictionary<string, List<UpgradeDef>>();
		}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:8,代码来源:ServerState.cs

示例10: Test1

        public void Test1()
        {
            SerializableDictionary<string, string> value;
            using (MemoryStream ms = new MemoryStream(0x1000))
            {
                SerializableDictionary<string, string> value0 = new SerializableDictionary<string, string>();
                value0.Add("a", "b");
                value0.Add("c", "d");
                value0.Add("e", "f");

                Util.Serialize(ms, value0);
                ms.Position = 0;

                value = Util.Deserialize<SerializableDictionary<string, string>>(ms);
            }
            Assert.AreEqual("b", value["a"]);
            Assert.AreEqual("d", value["c"]);
            Assert.AreEqual("f", value["e"]);
        }
开发者ID:kaijin-games,项目名称:larning-english-game,代码行数:19,代码来源:SerializableDictionaryTest.cs

示例11: GetDeafultColumnMapping

        public override SerializableDictionary<string, string> GetDeafultColumnMapping()
        {
            SerializableDictionary<string, string> columnMapping = new SerializableDictionary<string, string>();

            IEnumerable<Field> fields = this.PrimaryKeys.Union(this.Fields).Union(this.ForeKeys).Where(row => row.Enable);

            foreach (var item in fields.Select(row => row.Name).Distinct())
            {
                columnMapping.Add(item, item);
            }
            return columnMapping;
        }
开发者ID:piaolingzxh,项目名称:Justin,代码行数:12,代码来源:Table.cs

示例12: CreateNavMap

        public void CreateNavMap()
        {
            List<PathNode> nodes = this.CreateNode();

            SerializableDictionary<PathNode, List<PathNode>> edges = new SerializableDictionary<PathNode, List<PathNode>>();

            foreach (PathNode node in nodes)
            {
                edges.Add(node, node.Location.CreateEdges(nodes));
            }

            this.NavMap.GenerateArbitraryMap(edges);
        }
开发者ID:Tragedian-HLife,项目名称:HLife,代码行数:13,代码来源:City.cs

示例13: OkBtn_Click

        private void OkBtn_Click(object sender, EventArgs e)
        {

            if (textBox3.Text.Length == 0)
            {
                this.DialogResult = DialogResult.None;
                MessageBox.Show("Output filename must be provided");
                return;
            }
            if (textBox1.Text.Length == 0)
            {
                this.DialogResult = DialogResult.None;
                MessageBox.Show("Name of the profile must be provided");
                return;

            }

            profile.profName = textBox1.Text;
            profile.profProgram = textBox2.Text;
            profile.OutFileName = textBox3.Text;
            profile.removeOutFile = checkBox1.Checked;
            profile.progParameters =textBox4.Text;

            this.DialogResult = DialogResult.OK;

            profile.profWeights.Clear();
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Cells[0].Value != null && dataGridView1.Rows[i].Cells[0].Value != null && dataGridView1.Rows[i].Cells[1].Value != null)
                {
                    string item1 = (string)dataGridView1.Rows[i].Cells[0].Value;
                    string item2 = (string)dataGridView1.Rows[i].Cells[1].Value;
                    if (profile.profWeights.ContainsKey(item1))
                    {
                        if (profile.profWeights[item1].ContainsKey(item2))
                            profile.profWeights[item1].Remove(item2);
                        profile.profWeights[item1].Add(item2, Convert.ToDouble((string)dataGridView1.Rows[i].Cells[2].Value));
                    }
                    else
                    {
                        SerializableDictionary<string, double> ww = new SerializableDictionary<string, double>();
                        ww.Add(item2, Convert.ToDouble((string)dataGridView1.Rows[i].Cells[2].Value));
                        profile.profWeights.Add(item1, ww);
                    }
                }

            }

            this.Close();
        }
开发者ID:uQlust,项目名称:uQlust-ver1.0,代码行数:50,代码来源:ProfileDefinition.cs

示例14: AllSettingsAsXML

        public static string AllSettingsAsXML()
        {
            // Defaults would be...
            //foreach (System.Configuration.SettingsProperty prop in Properties.Settings.Default.Properties)

            // Current values
            SerializableDictionary<string, string> serialisedSettings = new SerializableDictionary<string, string>();
            foreach (System.Configuration.SettingsPropertyValue prop in Properties.Settings.Default.PropertyValues)
            {
                serialisedSettings.Add(prop.Name, (string)prop.SerializedValue);
            }

            return XMLHelper.Serialize<SerializableDictionary<string, string>>(serialisedSettings);
        }
开发者ID:jchappo,项目名称:remotepotato,代码行数:14,代码来源:EPGExporter.cs

示例15: GetDeafultColumnMapping

        public override SerializableDictionary<string, string> GetDeafultColumnMapping()
        {
            SerializableDictionary<string, string> columnMapping = new SerializableDictionary<string, string>();
            string sql = this.SQL + " where 1=0";
            DataTable table = OleDbHelper.ExecuteDataTable(this.Connection, sql);

            IEnumerable<DataColumn> fields = table.Columns.Cast<DataColumn>().Where(col => col.ColumnName != "_row_num");

            foreach (var item in fields.Select(row => row.ColumnName).Distinct())
            {
                columnMapping.Add(item, item);
            }
            return columnMapping;
        }
开发者ID:piaolingzxh,项目名称:Justin,代码行数:14,代码来源:View.cs


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