public AcfunDownloaderConfigurationForm(SerializableDictionary<string, string> Configuration)
 {
     //初始化界面
     InitializeComponent();
     //读取插件设置
     this.Configuration = Configuration;
     //生成AcPlay设置
     string genAcPlay = Configuration.ContainsKey("GenerateAcPlay") ? Configuration["GenerateAcPlay"] : "true";
     chkGenerateAcPlay.Checked = (genAcPlay == "true");
     //自定义命名
     txtFormat.Text = Configuration.ContainsKey("CustomFileName") ?
         Configuration["CustomFileName"] : AcFunPlugin.DefaultFileNameFormat;
     //预览
     txtFormat_TextChanged(this, EventArgs.Empty);
 }
Example #2
0
        public void loadClick(DateTime time)
        {
            // 储存到文件,比如20130203.xml
            string fileName = this.logFile;
            string today = time.ToString("yyyyMMdd");
            SerializableDictionary fileDatas = new SerializableDictionary();

            using (FileStream stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read))
            {
                stream.Lock(0, stream.Length);
                XmlSerializer serializer = new XmlSerializer(typeof(SerializableDictionary));
                if (stream.Length != 0)
                {
                    fileDatas = (SerializableDictionary)serializer.Deserialize(stream);
                    if (!fileDatas.ContainsKey(today))
                    {
                        fileDatas[today] = new MouseState();
                    }
                }
                else
                {
                    fileDatas = new SerializableDictionary();
                    fileDatas[today] = new MouseState();
                }
                this.leftClickCount = fileDatas[today].leftClickCount;
                this.rightClickCount = fileDatas[today].rightClickCount;
                this.middleClickCount = fileDatas[today].middleClickCount;
            }
        }
        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;
        }
Example #4
0
 string GetDefaultAspectFromVersion9(SerializableDictionary<string, string> serializableDictionary, List<string> aspects, string defaultAspect) {
     if (serializableDictionary.ContainsKey("Schema")){
         var helper = new DictionaryHelper();
         defaultAspect = helper.GetAspectFromXml(aspects, defaultAspect);
     }
     return defaultAspect;
 }
Example #5
0
        private string GetDefaultAspectFromVersion9(SerializableDictionary<string, string> serializableDictionary, List<string> aspects, string defaultAspect) {
            if (serializableDictionary.ContainsKey("Schema")) {
                return GetAspectFromXml(aspects, defaultAspect);
            }

            return defaultAspect;
        }
		public ServerState()
		{
			Accounts = new SerializableDictionary<string, Hash>();
			if (!Accounts.ContainsKey("guest")) {
				Accounts.Add("guest", Hash.HashString("guest"));
			}
            UpgradeData = new SerializableDictionary<string, List<UpgradeDef>>();
		}
Example #7
0
        public MinerDescriptor GetMiner(DeviceKind deviceKind, CoinAlgorithm algorithm, SerializableDictionary<CoinAlgorithm, string> miners)
        {
            if (deviceKind != DeviceKind.GPU)
                return GetDefaultMiner();

            if (miners.ContainsKey(algorithm))
                return Miners.Single(m => m.Name.Equals(miners[algorithm], StringComparison.OrdinalIgnoreCase));
            else
                return DefaultMiners[algorithm];
        }
		public BilibiliDownloaderConfigurationForm(SerializableDictionary<string, string> Configuration)
		{
			//初始化界面
			InitializeComponent();
			//读取插件设置
			this.Configuration = Configuration;
			//生成AcPlay设置
			string genAcPlay = Configuration.ContainsKey("GenerateAcPlay") ? Configuration["GenerateAcPlay"] : "true";
			chkGenerateAcPlay.Checked = (genAcPlay == "true");
			//自定义命名
			txtFormat.Text = Configuration.ContainsKey("CustomFileName") ?
				Configuration["CustomFileName"] : BilibiliPlugin.DefaultFileNameFormat;
			//预览
			txtFormat_TextChanged(this, EventArgs.Empty);
			//用户名密码
			txtUsername.Text = Configuration.ContainsKey("Username") ?
				Encoding.UTF8.GetString(Convert.FromBase64String(Configuration["Username"])) : "";
			txtPassword.Text = Configuration.ContainsKey("Password") ?
				Encoding.UTF8.GetString(Convert.FromBase64String(Configuration["Password"])) : "";
		}
Example #9
0
 public void UpdateTag(string key, string value)
 {
     if (_tags.ContainsKey(key))
     {
         _tags[key] = value;
     }
     else
     {
         _tags.Add(key, value);
     }
 }
Example #10
0
    /// <summary>
    /// Return the amount of the dish <paramref name="dish"/> that the user has in inventory.
    /// </summary>
    /// <param name="dish">The dish whose count in inventory should be returned.</param>
    /// <returns>the amount of the dish <paramref name="dish"/> that the user has in inventory.</returns>
    public int GetAmountInInventory(Dish dish)
    {
        // If there is no record of the dish being in the inventory, then obviously there is 0 of it.
        if (!menuInventory.ContainsKey(dish))
        {
            this.menuInventory[dish] = 0;
        }

        // Return the corresponding entry.
        return(menuInventory[dish]);
    }
Example #11
0
 public static V TryGetElseDefault <T, V>(this SerializableDictionary <T, V> parameters, T key)
 {
     if (parameters.ContainsKey(key))
     {
         return(parameters[key]);
     }
     else
     {
         return(default(V));
     }
 }
Example #12
0
        /// <summary>
        /// this will contain each name in each bin of grouped by time.
        /// Returns not null list of items.
        /// </summary>
        private SortableList <IHistoryItem> GetTimeIntervalItems(string timeKey,
                                                                 SerializableDictionary <string, SortableList <IHistoryItem> > groupedByDate)
        {
            if (!groupedByDate.ContainsKey(timeKey))
            {
                var timeIntervalItems = new SortableList <IHistoryItem>();
                groupedByDate.Add(timeKey, timeIntervalItems);
            }

            return(groupedByDate[timeKey]);
        }
Example #13
0
 public object GetObject(Guid guid, bool comFallback)
 {
     if (_knownObjects.ContainsKey(guid))
     {
         return(GetObject(_knownObjects[guid], comFallback));
     }
     else
     {
         return(null);
     }
 }
Example #14
0
 public BaseStatsEntry this[byte level]
 {
     get
     {
         if (Entries.ContainsKey(level))
         {
             return(Entries[level]);
         }
         return(null);
     }
 }
Example #15
0
        public static T GetOrPut <T, K>(this SerializableDictionary <K, T> dictionary, K key, Func <T> creator)
        {
            if (dictionary.ContainsKey(key))
            {
                return(dictionary[key]);
            }
            var value = creator();

            dictionary[key] = value;
            return(value);
        }
Example #16
0
    public IEnumerator Attack(SkillConfig config, Vector3Int clickedPos, Unit clickedUnit)
    {
        SerializableDictionary <Vector3Int, AttackPatternField> fields = skillHandler.AttackArea(config);

        bool isAttackClicked = fields.ContainsKey(clickedPos) && fields[clickedPos] == AttackPatternField.On;

        if (isAttackClicked)
        {
            yield return(StartCoroutine(skillHandler.ExecuteAttack(config, clickedPos, clickedUnit)));
        }
    }
Example #17
0
        public void AgingData_GetAgingData_PayPlanBillInAdvanceDays_WithPendingProc()
        {
            string   suffix            = MethodBase.GetCurrentMethod().Name;
            Patient  patient           = PatientT.CreatePatient(suffix);
            long     provNum           = ProviderT.CreateProvider(suffix);
            DateTime datePayPlan       = DateTime.Today.AddDays(5);
            DateTime datePayPlanCreate = DateTime.Today.AddMonths(-1);          //Payment Plan was created a month ago.
            DateTime dateProc          = DateTime.Today;
            DateTime dateStatement     = DateTime.Today.AddDays(-5);

            //Create a payment plan where the first charge date in the future.
            PayPlanT.CreatePayPlan(patient.PatNum, 1000, 500, datePayPlan, provNum);
            //Create a completed procedure that was completed today, before the first payplan charge date.
            ProcedureT.CreateProcedure(patient, "D1100", ProcStat.C, "", 5, dateProc);
            //Insert a statement that was sent during the "bill in advance days" for the payment plan charge above.
            StatementT.CreateStatement(patient.PatNum, mode_: StatementMode.Mail, isSent: true, dateSent: dateStatement);
            //Make sure that the preference PayPlansBillInAdvanceDays is set to a day range that encompasses the first payment plan charge date.
            PrefT.UpdateLong(PrefName.PayPlansBillInAdvanceDays, 10);
            //This scenario is exploiting the fact that the statement created 5 days ago was technically created for the payment plan (in advance).
            //Because of this fact, the patient shouldn't show up in the billing list until something new happens after the statement date.
            //The procedure that was completed today should cause the patient to show up in the billing list (something new happened).
            SerializableDictionary <long, PatAgingData> dictPatAgingData = AgingData.GetAgingData(false, true, false, false, false, new List <long>());

            //Assert that the patient has been returned due to the completed procedure.
            Assert.IsTrue(dictPatAgingData.ContainsKey(patient.PatNum), "No aging data was returned for the patient.");
            //Assert all pertinent PatAgingData for this unit test.
            Assert.IsNotNull(dictPatAgingData[patient.PatNum].ListPatAgingTransactions);
            PatAgingTransaction patAgingTransactionPP = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                        .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.PayPlanCharge);

            //Act like the payment plan was created a month ago.
            patAgingTransactionPP.SecDateTEntryTrans = datePayPlanCreate;
            PatAgingTransaction patAgingTransactionProc = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                          .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.Procedure);

            Assert.IsNotNull(patAgingTransactionPP);
            Assert.IsNotNull(patAgingTransactionProc);
            Assert.AreEqual(datePayPlan, patAgingTransactionPP.DateLastTrans);
            Assert.AreEqual(dateProc, patAgingTransactionProc.DateLastTrans);
            SerializableDictionary <long, List <PatAgingTransaction> > dictPatAgingTrans = new SerializableDictionary <long, List <PatAgingTransaction> >();

            foreach (KeyValuePair <long, PatAgingData> kvp in dictPatAgingData)
            {
                dictPatAgingTrans[kvp.Key] = kvp.Value.ListPatAgingTransactions;
            }
            //The last transaction date should be the procedure date and not the pay plan charge date (even though pay plan is later).
            Assert.AreEqual(dateProc, AgingData.GetDateLastTrans(dictPatAgingTrans[patient.PatNum], dateStatement).Date);
            List <PatAging> listPatAging = Patients.GetAgingList("", DateTime.Today.AddMonths(-1), new List <long>(), false, false, 0, false, false, new List <long>(),
                                                                 false, false, new List <long>(), new List <long>(), dictPatAgingTrans);

            //Assert that the patient has been flagged to get a new statement due to procedure that was completed above.
            Assert.IsTrue(listPatAging.Any(x => x.PatNum == patient.PatNum), "The expected patient was not present in the AgingList.");
        }
 public static bool GetBool(this SerializableDictionary <string, string> hash, string key, bool defaultValue = false)
 {
     if (hash.ContainsKey(key))
     {
         bool val;
         if (bool.TryParse(hash[key].ToString(), out val))
         {
             return(val);
         }
     }
     return(defaultValue);
 }
Example #19
0
        /// <summary>
        /// Return all servers
        /// </summary>
        /// <param name="cache"></param>
        /// <returns></returns>
        public SerializableDictionary <int, IVirtualServer> GetAllServers(bool cache = false)
        {
            // clear
            //  (it's needed to update one time to cache)
            if (_isNewAllServers || !cache)
            {
                _isNewAllServers = false;

                // add to cache
                foreach (var s in _meta.getAllServers())
                {
                    var vs = new VirtualServer(s, this);
                    if (!_servers.ContainsKey(vs.Id))
                    {
                        _servers.Add(vs.Id, vs);
                    }
                }
            }

            return(_servers);
        }
        public BilibiliDownloaderConfigurationForm(SerializableDictionary <string, string> Configuration)
        {
            //初始化界面
            InitializeComponent();
            //读取插件设置
            this.Configuration = Configuration;
            //生成AcPlay设置
            string genAcPlay = Configuration.ContainsKey("GenerateAcPlay") ? Configuration["GenerateAcPlay"] : "true";

            chkGenerateAcPlay.Checked = (genAcPlay == "true");
            //自定义命名
            txtFormat.Text = Configuration.ContainsKey("CustomFileName") ?
                             Configuration["CustomFileName"] : BilibiliPlugin.DefaultFileNameFormat;
            //预览
            txtFormat_TextChanged(this, EventArgs.Empty);
            //用户名密码
            txtUsername.Text = Configuration.ContainsKey("Username") ?
                               Encoding.UTF8.GetString(Convert.FromBase64String(Configuration["Username"])) : "";
            txtPassword.Text = Configuration.ContainsKey("Password") ?
                               Encoding.UTF8.GetString(Convert.FromBase64String(Configuration["Password"])) : "";
        }
Example #21
0
        public List <Context> GetObjectContexts(Object obj)
        {
            var contexts = new List <Context>();

            if (objectContexts.ContainsKey(obj))
            {
                contexts.Add(objectContexts[obj]);
            }

            for (Transform iparent = GetContextParentOf(obj); iparent != null; iparent = iparent.parent)
            {
                if (objectContexts.ContainsKey(iparent.gameObject))
                {
                    contexts.Add(objectContexts[iparent.gameObject]);
                }
            }

            contexts.AddRange(extraContexts.Values);

            return(contexts);
        }
Example #22
0
    /// <summary>
    /// 更新游戏排行榜数据
    /// </summary>
    /// <param name="_ms"></param>
    public bool UpdateGameRankingData(UMessage _ms)
    {
        CCustomDialog.CloseCustomWaitUI();
        RightChessScrolllRect.vertical = true;
        byte State = _ms.ReadByte();

        if (State != 0)
        {
            Debug.Log("比赛排行榜数据错误!错误码:" + State);
            return(false);
        }

        SerializableDictionary <int, CPlayerRankingInfo> GameRankingDataDictionary = null;
        long ContestID = _ms.ReadLong();

        if (!ContestRankingDataDictionary.ContainsKey(ContestID))
        {
            ContestRankingDataDictionary.Add(ContestID, new SerializableDictionary <int, CPlayerRankingInfo>());
        }
        GameRankingDataDictionary = ContestRankingDataDictionary[ContestID];
        ushort             StartIndex        = _ms.ReaduShort();
        byte               DataNum           = _ms.ReadByte();
        ushort             EndIndex          = (ushort)(StartIndex + DataNum - 1);
        CPlayerRankingInfo PlayerRankingInfo = null;

        for (int index = 0; index < DataNum; ++index)
        {
            PlayerRankingInfo                = new CPlayerRankingInfo();
            PlayerRankingInfo.PlayerName     = _ms.ReadString();
            PlayerRankingInfo.PlayerIconUrl  = _ms.ReadString();
            PlayerRankingInfo.PlayerFaceID   = _ms.ReadInt();
            PlayerRankingInfo.PlayerScore    = _ms.ReadInt();
            PlayerRankingInfo.PlayerOppScore = _ms.ReadInt();
            PlayerRankingInfo.ShengJuValue   = _ms.ReadByte();
            PlayerRankingInfo.ZhiShengValue  = _ms.ReadByte();
            PlayerRankingInfo.HouShouValue   = _ms.ReadByte();
            int RankIndex = StartIndex + index;
            if (GameRankingDataDictionary.ContainsKey(RankIndex))
            {
                GameRankingDataDictionary[RankIndex] = PlayerRankingInfo;
            }
            else
            {
                GameRankingDataDictionary.Add(RankIndex, PlayerRankingInfo);
            }
        }

        if (m_ContestID == ContestID)
        {
            RefreshGameContestRankingPlayerPanel(StartIndex, EndIndex);
        }
        return(true);
    }
 public static float GetFloat(this SerializableDictionary <string, string> hash, string key, float defaultValue = 0)
 {
     if (hash.ContainsKey(key))
     {
         float val;
         if (float.TryParse(hash[key].ToString(), out val))
         {
             return(val);
         }
     }
     return(defaultValue);
 }
Example #24
0
        public void TestDictionaryXmlSerialisation()
        {
            SerializableDictionary <string, string> d1 = new SerializableDictionary <string, string>();

            d1["Hello"] = "World";

            try
            {
                XmlSerializer s  = new XmlSerializer(typeof(SerializableDictionary <string, string>));
                MemoryStream  ms = new MemoryStream();
                s.Serialize(ms, d1);

                ms.Seek(0, SeekOrigin.Begin);

                XmlSerializer s2 = new XmlSerializer(typeof(SerializableDictionary <string, string>));
                SerializableDictionary <string, string> d1e = (SerializableDictionary <string, string>)s2.Deserialize(ms);

                Assert.IsTrue(d1e.ContainsKey("Hello"));
                Assert.AreEqual(d1e["Hello"], "World");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }


            SerializableDictionary <int, NonSerializableClass> d2 = new SerializableDictionary <int, NonSerializableClass>();

            d2[42] = new NonSerializableClass()
            {
                Prop = "Truth"
            };

            try
            {
                XmlSerializer s  = new XmlSerializer(typeof(SerializableDictionary <int, NonSerializableClass>));
                MemoryStream  ms = new MemoryStream();
                s.Serialize(ms, d2);

                ms.Seek(0, SeekOrigin.Begin);

                XmlSerializer s2 = new XmlSerializer(typeof(SerializableDictionary <int, NonSerializableClass>));
                SerializableDictionary <int, NonSerializableClass> d2e = (SerializableDictionary <int, NonSerializableClass>)s2.Deserialize(ms);

                Assert.IsTrue(d2e.ContainsKey(42));
                Assert.AreEqual(d2e[42], d2[42]);
                Assert.Fail();
            }
            catch
            {
            }
        }
Example #25
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (customproperties.ContainsKey(textBox1.Text))
            {
                MessageBox.Show("A Custom Property with that name already exists.");
                return;
            }

            if (textBox1.Text.Length == 0)
            {
                MessageBox.Show("Please enter a Property Name.");
                return;
            }

            //CustomProperty cp = new CustomProperty();
            cp.name        = textBox1.Text;
            cp.description = textBox2.Text;
            if (radioButton1.Checked)
            {
                cp.type  = typeof(string);
                cp.value = "";
            }
            if (radioButton2.Checked)
            {
                cp.type  = typeof(bool);
                cp.value = false;
            }
            if (radioButton3.Checked)
            {
                cp.type  = typeof(Vector2);
                cp.value = new Vector2(1, 1);
            }
            if (radioButton4.Checked)
            {
                cp.type  = typeof(Color);
                cp.value = Color.White;
            }
            if (radioButton5.Checked)
            {
                cp.type  = typeof(GameObject);
                cp.value = null;
            }
            if (radioButton6.Checked)
            {
                cp.type  = typeof(Rectangle);
                cp.value = new Rectangle();
            }


            customproperties[cp.name] = cp;
            this.Close();
        }
        public void Scan()
        {
            _logger.LogTrace($"Layout sheet controller scanning {_document.Filename}");
            Database acCurDb = _document;

            Transaction  acTrans = acCurDb.TransactionManager.TopTransaction;
            DBDictionary layouts = acTrans.GetObject(acCurDb.LayoutDictionaryId, OpenMode.ForRead) as DBDictionary;

            // Step through and list each named layout and Model
            foreach (DBDictionaryEntry item in layouts)
            {
                if (!Sheets.ContainsKey(item.Key) && item.Key != "Model")
                {
                    _logger.LogTrace($"Sheet {item.Key} found");
                    Layout      acLayout = acTrans.GetObject(item.Value, OpenMode.ForRead) as Layout;
                    LayoutSheet ls       = new LayoutSheet(_logger, acLayout);

                    _logger.LogTrace($"Sheet {item.Key} added");
                    Sheets.Add(item.Key, ls);
                }
            }
        }
Example #27
0
        public void UpdatePlayers(List <PlayerItem> playerItems)
        {
            lock (Instance)
            {
                foreach (PlayerItem item in playerItems)
                {
                    if (playerLogins.ContainsKey(item.SteamId))
                    {
                        if (item.LastLogin > playerLogins[item.SteamId].LastLogin)
                        {
                            UpdatePlayer(item);
                        }
                    }
                    else
                    {
                        AddPlayer(item);
                    }
                }

                Save();
            }
        }
Example #28
0
        private SerializableDictionary <Guid, GuideUpcomingProgram> BuildUpcomingProgramsDictionary(ScheduleType scheduleType)
        {
            SerializableDictionary <Guid, GuideUpcomingProgram> result = new SerializableDictionary <Guid, GuideUpcomingProgram>();

            foreach (GuideUpcomingProgram upcomingProgram in _model.UpcomingProgramsByType[scheduleType])
            {
                if (!result.ContainsKey(upcomingProgram.UpcomingProgramId))
                {
                    result.Add(upcomingProgram.UpcomingProgramId, upcomingProgram);
                }
            }
            return(result);
        }
        public static void AddNodeToList(profileNode node, string type)
        {
            profileNode nn = GetNode(node.internalName);

            if (nn == null)
            {
                if (!internalList.ContainsKey(node))
                {
                    internalList.Add(node, type);
                    SaveProfiles();
                }
            }
        }
Example #30
0
        /// <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) : ""));
        }
Example #31
0
        public static JObject GetProfile(this  Category c)
        {
            if (c.Other == null || !(c.Other is SerializableDictionary <string, string>))
            {
                return(null);
            }
            SerializableDictionary <string, string> d = c.Other as SerializableDictionary <string, string>;

            if (!d.ContainsKey(NetflixUtils.Profile))
            {
                return(null);
            }
            return((JObject)JsonConvert.DeserializeObject((string)d[NetflixUtils.Profile]));
        }
Example #32
0
        public void AgingData_GetAgingData_PayPlanBillInAdvanceDays_WithNewPayPlan()
        {
            string   suffix            = MethodBase.GetCurrentMethod().Name;
            Patient  patient           = PatientT.CreatePatient(suffix);
            long     provNum           = ProviderT.CreateProvider(suffix);
            DateTime datePayPlanCharge = DateTime.Today.AddDays(5);
            DateTime datePayPlanCreate = DateTime.Today;          //The payment plan that we are about to create will automatically have this date as the SecTDateEntry
            DateTime dateProc          = DateTime.Today.AddDays(-1);
            DateTime dateStatement     = DateTime.Today.AddDays(-1);

            //Create a payment plan where the first charge date in the future.
            PayPlanT.CreatePayPlan(patient.PatNum, 1000, 500, datePayPlanCharge, provNum);
            //Create a completed procedure that was completed yesterday, before the first payplan charge date AND before the payment plan creation date.
            ProcedureT.CreateProcedure(patient, "D1100", ProcStat.C, "", 5, dateProc);
            //Insert a statement that was sent during the "bill in advance days" for the payment plan charge AND before the payment plan creation date.
            StatementT.CreateStatement(patient.PatNum, mode_: StatementMode.Mail, isSent: true, dateSent: dateStatement);
            //Make sure that the preference PayPlansBillInAdvanceDays is set to a day range that encompasses the first payment plan charge date.
            PrefT.UpdateLong(PrefName.PayPlansBillInAdvanceDays, 10);
            //This scenario is exploiting the fact that the statement created yesterday was NOT technically created for the payment plan (in advance).
            //Because of this fact, the patient should show up in the billing list because something new has happened after the statement date.
            //The new payment plan should not be associated to the previous statement due to the SecTDateEntry.
            SerializableDictionary <long, PatAgingData> dictPatAgingData = AgingData.GetAgingData(false, true, false, false, false, new List <long>());

            //Assert that the patient has been returned due to owing money on the payment plan that was created.
            Assert.IsTrue(dictPatAgingData.ContainsKey(patient.PatNum), "No aging data was returned for the patient.");
            Assert.IsNotNull(dictPatAgingData[patient.PatNum].ListPatAgingTransactions);
            PatAgingTransaction patAgingTransactionPP = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                        .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.PayPlanCharge);
            PatAgingTransaction patAgingTransactionProc = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                          .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.Procedure);

            Assert.IsNotNull(patAgingTransactionPP);
            Assert.IsNotNull(patAgingTransactionProc);
            Assert.AreEqual(datePayPlanCharge, patAgingTransactionPP.DateLastTrans);
            Assert.AreEqual(dateProc, patAgingTransactionProc.DateLastTrans);
            SerializableDictionary <long, List <PatAgingTransaction> > dictPatAgingTrans = new SerializableDictionary <long, List <PatAgingTransaction> >();

            foreach (KeyValuePair <long, PatAgingData> kvp in dictPatAgingData)
            {
                dictPatAgingTrans[kvp.Key] = kvp.Value.ListPatAgingTransactions;
            }
            //The last transaction date should be the charge date of the pay plan charge which indicates that the statement doesn't apply
            //to the payment plan because the payment plan was created AFTER the statement that just so happens to fall within the "bill in advance days".
            Assert.AreEqual(datePayPlanCharge, AgingData.GetDateLastTrans(dictPatAgingTrans[patient.PatNum], dateStatement).Date);
            List <PatAging> listPatAging = Patients.GetAgingList("", DateTime.Today.AddMonths(-1), new List <long>(), false, false, 0, false, false, new List <long>(),
                                                                 false, false, new List <long>(), new List <long>(), dictPatAgingTrans);

            Assert.IsTrue(listPatAging.Any(x => x.PatNum == patient.PatNum), "The expected patient was not present in the AgingList.");
        }
Example #33
0
        public bool Validate(CustomValidationService service)
        {
            ValidationErrors = new SerializableDictionary <string, string>();

            if (string.IsNullOrWhiteSpace(ExternalServiceId))
            {
                ValidationErrors.Add(LambdaHelper <Service> .GetPropertyName(x => x.ExternalServiceId), "Service.ExternalServiceId is a mandatory field.");
            }

            if (Priority == null || Priority < 1)
            {
                ValidationErrors.Add(LambdaHelper <Service> .GetPropertyName(x => x.Priority), "Service.Priority is a mandatory field.");
            }

            if (ProvisionSequence == null || ProvisionSequence < 1)
            {
                ValidationErrors.Add(LambdaHelper <Service> .GetPropertyName(x => x.ProvisionSequence), "Service.ProvisionSequence is a mandatory field and must be greater then 0.");
            }

            if (ProvisionDate == null || ProvisionDate == DateTime.MinValue)
            {
                ValidationErrors.Add(LambdaHelper <Service> .GetPropertyName(x => x.ProvisionDate), "Service.ProvisionDate is a mandatory field.");
            }

            //Note: Validation the child class as well.

            if (Locations == null)
            {
                ValidationErrors.Add(LambdaHelper <Service> .GetPropertyName(x => x.Locations), "Service.Locations is a mandatory field.");
            }
            else
            {
                foreach (var location in Locations)
                {
                    if (location.Validate(service))
                    {
                        foreach (var validationError in location.ValidationErrors)
                        {
                            if (!ValidationErrors.ContainsKey(validationError.Key))
                            {
                                ValidationErrors.Add(validationError.Key, validationError.Value);
                            }
                        }
                    }
                }
            }

            return(ValidationErrors.Count > 0);
        }
Example #34
0
        /// <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) : "");
        }
Example #35
0
        private static string LookupTableName(Type type)
        {
            var entityToTable = new SerializableDictionary <string, string>();
            var fullName      = type.FullName;

            if (fullName != null)
            {
                if (entityToTable.ContainsKey(fullName))
                {
                    return(entityToTable[fullName]);
                }
            }

            return(type.Name);
        }
Example #36
0
 public AnotatedAnimation GetAnotatedAnimation(string aName)
 {
     if (aName == null)
     {
         return(null);
     }
     else if (analyzedAnimations.ContainsKey(aName))
     {
         return(analyzedAnimations[aName]);
     }
     else
     {
         return(null);
     }
 }
Example #37
0
        /// <summary>
        /// Creates a new writeable dictionary from the supplied one and injects the supplied property
        /// </summary>
        /// <typeparam name="TKey">The type of the key.</typeparam>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="propertyBag">The locked property bag.</param>
        /// <param name="key">The key to inject.</param>
        /// <param name="value">The value to be injected.</param>
        /// <returns>
        /// A writeable property bag
        /// </returns>
        public static SerializableDictionary <TKey, TValue> Inject <TKey, TValue>(this IReadOnlyDictionary <TKey, TValue> propertyBag, TKey key, TValue value)
        {
            var writableDictionary = new SerializableDictionary <TKey, TValue>();

            foreach (var oldKey in propertyBag.Keys)
            {
                writableDictionary.Add(oldKey, propertyBag[oldKey]);
            }

            if (!writableDictionary.ContainsKey(key))
            {
                writableDictionary.Add(key, value);
            }

            return(writableDictionary);
        }
Example #38
0
        public MinerDescriptor GetMiner(DeviceKind deviceKind, CoinAlgorithm algorithm, SerializableDictionary <CoinAlgorithm, string> miners)
        {
            if (deviceKind != DeviceKind.GPU)
            {
                return(GetDefaultMiner());
            }

            if (miners.ContainsKey(algorithm))
            {
                return(Miners.Single(m => m.Name.Equals(miners[algorithm], StringComparison.OrdinalIgnoreCase)));
            }
            else
            {
                return(DefaultMiners[algorithm]);
            }
        }
Example #39
0
        /*********
        ** Private methods
        *********/
        /// <summary>
        /// Method used by event methods to get the tiles adjacent to the player and check if any of them are a ladder. This is determined by checking the index of the tile for 173.
        /// </summary>
        private void CheckAdjacentTilesForLadder()
        {
            List <Vector2> adjTiles     = Utility.getAdjacentTileLocations(Game1.player.getTileLocation());
            Layer          currentLayer = Game1.currentLocation.map.GetLayer("Buildings");

            foreach (Vector2 tile in adjTiles)
            {
                Tile currentTile = currentLayer.PickTile(new Location((int)tile.X, (int)tile.Y) * Game1.tileSize, Game1.viewport.Size);
                if (currentTile != null && currentTile.TileIndex == 173 && !ladderList.ContainsKey(new Vector2((int)tile.X, (int)tile.Y)))
                {
                    this.Monitor.Log($"Ladder found at {tile}", LogLevel.Info);
                    currentTile.TileIndexProperties.Add(new KeyValuePair <string, PropertyValue>("Passable", propValue));
                    ladderList.Add(new Vector2((int)tile.X, (int)tile.Y), currentTile);
                }
            }
        }
Example #40
0
        public MinerDescriptor GetMiner(DeviceKind deviceKind, CoinAlgorithm algorithm, SerializableDictionary<string, string> miners)
        {
            if (deviceKind != DeviceKind.GPU)
                return GetDefaultMiner();

            string algorithmName = algorithm.Name;

			MinerDescriptor result = null;

            if (miners.ContainsKey(algorithmName))
				// SingleOrDefault - the user may have a config file with a backend
				// miner registered that no longer exists in their Miners\ folder
				result = Miners.SingleOrDefault(m => m.Name.Equals(miners[algorithmName], StringComparison.OrdinalIgnoreCase));
            if ((result == null) && (algorithm.DefaultMiner != null))
				result = Miners.Single(m => m.Name.Equals(algorithm.DefaultMiner, StringComparison.OrdinalIgnoreCase));

            return result;
        }
Example #41
0
        // 将action保存到文件中
        public void saveAction(DateTime time)
        {
            int leftClickCount;
            int rightClickCount;
            int middleClickCount;

            lock (this)
            {
                leftClickCount = this.leftClickCount;
                rightClickCount = this.rightClickCount;
                middleClickCount = this.middleClickCount;

            }

            // 储存到文件,比如20130203.xml
            string fileName = this.logFile;
            string today = time.ToString("yyyyMMdd");

            SerializableDictionary fileDatas = new SerializableDictionary();
            MouseState fileData = new MouseState();
            using (FileStream stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                stream.Lock(0, stream.Length);
                XmlSerializer serializer = new XmlSerializer(typeof(SerializableDictionary));
                if (stream.Length != 0)
                {
                    fileDatas = (SerializableDictionary)serializer.Deserialize(stream);
                    if (!fileDatas.ContainsKey(today))
                    {
                        fileDatas[today] = new MouseState();
                    }
                }
                else
                {
                    fileDatas = new SerializableDictionary();
                    fileDatas[today] = new MouseState();
                }

                fileDatas[today].leftClickCount = leftClickCount;
                fileDatas[today].rightClickCount = rightClickCount;
                fileDatas[today].middleClickCount = middleClickCount;
                stream.Position = 0;

                XmlWriter writer = new XmlTextWriter(stream, Encoding.UTF8);
                serializer.Serialize(writer, fileDatas);
            }
        }
Example #42
0
 private SerializableDictionary<Guid, GuideUpcomingProgram> BuildUpcomingProgramsDictionary(ScheduleType scheduleType)
 {
     SerializableDictionary<Guid, GuideUpcomingProgram> result = new SerializableDictionary<Guid, GuideUpcomingProgram>();
     foreach (GuideUpcomingProgram upcomingProgram in _model.UpcomingProgramsByType[scheduleType])
     {
         if (!result.ContainsKey(upcomingProgram.UpcomingProgramId))
         {
             result.Add(upcomingProgram.UpcomingProgramId, upcomingProgram);
         }
     }
     return result;
 }
 void OnReadUserData(SerializableDictionary<string, string> userData)
 {
     for (int position = 1; position <= MaxFileHistoryCount; ++position)
     {
         string key = "RecentFile[" + position.ToString() + "]";
         if (userData.ContainsKey(key))
         {
             this._recentFiles.Add(userData[key]);
         }
     }
 }
Example #44
0
 private bool HasImage(string imageKey, SerializableDictionary<string, byte[]> dictImage)
 {
     lock (dictImage)
         return dictImage.ContainsKey(imageKey);
 }
Example #45
0
        /// <summary>
        /// Load placeholders dictionary with serialized values
        /// </summary>
        protected void DeserializePlaceHolders (string content)
        {
            XmlSerializer s = new XmlSerializer(Placeholders.GetType());
            SerializableDictionary<string, PlaceHolder> tempPlaceHolders = new SerializableDictionary<string, PlaceHolder>();
            TextReader r = new StringReader(content);
            tempPlaceHolders = (SerializableDictionary<string, PlaceHolder>)s.Deserialize(r);
            r.Close();

            foreach (PlaceHolder ph in Placeholders.Values)
            {
                if (tempPlaceHolders.ContainsKey(ph.Name))
                {
                    PlaceHolder phI = tempPlaceHolders[ph.name];
                    try
                    {
                        long ticks = 0;
                        // If it is a date and it was saved when no template was present it will be in ticks
                        // SetPlaceHolder will format it according to templates culture.
                        if (Placeholders[ph.Name].DataType == typeof(DateTime) && long.TryParse(phI.Value, out ticks))
                            SetPlaceHolder(ph.Name, new DateTime(ticks));
                        else
                            SetPlaceHolder(ph.Name, phI.Value);
                    }
                    catch (Exception)
                    {
                        SetPlaceHolder(ph.Name, "[*Invalid Value*]");
                    }
                }
            }
        }
        private bool LoadCatalog(string p, string catalog, SerializableDictionary<string, CatalogObject> dict)
        {

            System.IO.StreamReader fi = null;

            try
            {
                fi = System.IO.File.OpenText(p);
                while (!fi.EndOfStream)
                {
                    string newl = fi.ReadLine();
                    newl.Trim();
                    if (newl.Length > 0 )
                    {
                        CatalogObject obj = null;
                        if (newl.Contains(":"))
                        {
                            if (CatalogObject.TryParse(newl, catalog, out obj) && !dict.ContainsKey(obj.Name))
                                dict.Add(obj.Name, obj);
                        }
                        else
                        {
                            if (CatalogObject.TryParseDouble(newl, catalog, out obj) && !dict.ContainsKey(obj.Name))
                                dict.Add(obj.Name, obj);
                        }
                    }
                }
            }
            catch
            {
                return false;
            }
            finally
            {
                if (fi != null) fi.Close();
            }

            return true;
        }
Example #47
0
        public void ReorderSubGroups(List<string> subGroupsOrderList)
        {
            SerializableDictionary<string, GameItemsSubGroup> newSubGroups =
                new SerializableDictionary<string, GameItemsSubGroup>();

            foreach (string ident in subGroupsOrderList)
            {
                if (_subGroups.ContainsKey(ident) && !newSubGroups.ContainsKey(ident))
                {
                    GameItemsSubGroup subGroup = _subGroups[ident];
                    newSubGroups.Add(ident, subGroup);
                    _subGroups.Remove(ident);
                }
            }

            foreach (string orphantIdent in _subGroups.Keys)
            {
                if (!newSubGroups.ContainsKey(orphantIdent))
                {
                    GameItemsSubGroup subGroup = _subGroups[orphantIdent];
                    newSubGroups.Add(orphantIdent, subGroup);
                }
            }

            _subGroups = newSubGroups;
        }
Example #48
0
    // Use this for initialization
    public void Init()
    {
        if (allAnimations)
        {
            int num = 0;
            foreach ( AnimationState anim in animation )
                if (anim.name != "TPose")
                    num++;

            animationNames = new string[num];
            int index = 0;
            foreach ( AnimationState anim in animation )
            {
                if (anim.name != "TPose")
                {
                    animationNames[index] = anim.name;
                    index++;
                }
            }
        }

        walkingAnimations = 0;
        maxStepSize = 0;
        sumStepsSizes = 0;
        meanStepSize = 0;
        meanActionDuration = 0;
        maxActionDuration = 0;

        Vector3 startPosition = transform.position;
        Quaternion startRotation = transform.rotation;

        transform.position = new Vector3(0,0,0);
        transform.rotation = Quaternion.identity; //new Quaternion(0,0,0,0);
        //transform.forward = new Vector3(0,0,1);
        //transform.right = new Vector3(1,0,0);

        // We ensure that no animation is played
        RemoveAnimations(animation);

        // We create and fill a Dictionary of AnotatedAnimations
        analyzedAnimations = new SerializableDictionary<string,AnotatedAnimation>();

        int id=0;
        foreach ( string anim in animationNames )
        {
            if (!analyzedAnimations.ContainsKey(anim) && !anim.Contains("TPose") )
            {
                analyzedAnimations.Add( anim, AnalyzeAnimation(animation[anim],id));
                id++;
            }
        }

        transform.position = startPosition;
        transform.rotation = startRotation;

        UpdateGlobalInfo();

        initialized = true;

        //R = mass*RMassProportion;
    }
Example #49
0
        public static SerializableDictionary<int, Location> BuildMapGrid(List<RoomTemplate> rooms)
        {
            SerializableDictionary<int, Location> mapGrid = new SerializableDictionary<int, Location>();

            if( rooms.Count < 1 )
            {
                return mapGrid;
            }

            Location location = new Location();
            location.x = 0;
            location.y = 0;
            location.z = 0;

            for(int count = 0; count < rooms.Count; count++ )
            {
                if (!mapGrid.ContainsKey(rooms[count].IndexNumber))
                {
                    mapGrid.Add(rooms[count].IndexNumber, location);
                }
                else
                {
                    location = mapGrid[rooms[count].IndexNumber];
                }

                for (int exit = 0; exit < Limits.MAX_DIRECTION; exit++)
                {
                    if (rooms[count].ExitData[exit] != null)
                    {
                        if( !mapGrid.ContainsKey( rooms[count].ExitData[exit].IndexNumber ))
                        {
                            Location newLocation = new Location();
                            newLocation.x = location.x;
                            newLocation.y = location.y;
                            newLocation.z = location.z;
                            switch( exit )
                            {
                                case (int)Exit.Direction.down:
                                    newLocation.z -= 1;
                                    break;
                                case (int)Exit.Direction.east:
                                    newLocation.x += 1;
                                    break;
                                case (int)Exit.Direction.north:
                                    newLocation.y += 1;
                                    break;
                                case (int)Exit.Direction.northeast:
                                    newLocation.x += 1;
                                    newLocation.y += 1;
                                    break;
                                case (int)Exit.Direction.northwest:
                                    newLocation.x -= 1;
                                    newLocation.y += 1;
                                    break;
                                case (int)Exit.Direction.south:
                                    newLocation.y -= 1;
                                    break;
                                case (int)Exit.Direction.southeast:
                                    newLocation.y -= 1;
                                    newLocation.x += 1;
                                    break;
                                case (int)Exit.Direction.southwest:
                                    newLocation.x -= 1;
                                    newLocation.y -= 1;
                                    break;
                                case (int)Exit.Direction.up:
                                    newLocation.z += 1;
                                    break;
                                case (int)Exit.Direction.west:
                                    newLocation.x -= 1;
                                    break;
                            }
                            mapGrid.Add(rooms[count].ExitData[exit].IndexNumber, newLocation);
                        }
                    }

                    if (!mapGrid.ContainsKey(rooms[count].IndexNumber))
                    {
                        MessageBox.Show("Bad room " + rooms[count].IndexNumber + ": not in entry list");
                        mapGrid.Add(rooms[count].IndexNumber, location);
                    }
                }
            }

            return mapGrid;
        }
Example #50
0
 public static SerializableDictionary<string, SerializableList<string>> GetDDFields(CQ dom)
 {
     var data = new SerializableDictionary<string, SerializableList<string>>();
     foreach (var dd in dom.Select(x => x.Cq()))
     {
         var topField = dd[0].InnerText.Trim();
         if (!data.ContainsKey(topField))
         {
             data.Add(ToolsHelper.MakeXmlSafe(topField), new SerializableList<string>());
         }
         if (!dd.Find("li").Any())
         {
             data[topField].Add(ToolsHelper.MakeXmlSafe(topField));
         }
         else
         {
             foreach (var li in dd.Find("li").Select(x => x.Cq()))
             {
                 data[topField].Add(li.Text().Trim());
             }
         }
     }
     return data;
 }
        void OnReadUserData(SerializableDictionary<string, string> userData)
        {
            if (userData.ContainsKey("UserWatches"))
            {
                string[] tokens = userData["UserWatches"].Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (string token in tokens)
                {
                    UnrealDebuggerIDE.Commands.AddWatch(token);
                }
            }
        }
        private SerializableDictionary<string, List<WorkStatusType>> GetWorkStatusList(SerializableDictionary<string, List<WorkStatusType>> readWorkStatus)
        {
            SerializableDictionary<string, List<WorkStatusType>> result = new SerializableDictionary<string, List<WorkStatusType>>();

            foreach (KeyValuePair<string, int> comSendCount in _comSenderList)
            {
                if (!result.ContainsKey(comSendCount.Key))
                {
                    result.Add(comSendCount.Key, new List<WorkStatusType>());
                }
                if (readWorkStatus.ContainsKey(comSendCount.Key))
                {
                    for (int i = 0; i < readWorkStatus[comSendCount.Key].Count; i++)
                    {
                        result[comSendCount.Key].Add(readWorkStatus[comSendCount.Key][i]);
                    }
                }
                else
                {
                    result[comSendCount.Key].Add(WorkStatusType.SenderCardError);
                }

                //for (int i = 0; i < comSendCount.Value; i++)
                //{
                //    if (readWorkStatus.ContainsKey(comSendCount.Key))
                //    {
                //        if (i < readWorkStatus[comSendCount.Key].Count)
                //        {
                //            result[comSendCount.Key].Add(readWorkStatus[comSendCount.Key][i]);
                //            continue;
                //        }
                //    }
                //    result[comSendCount.Key].Add(WorkStatusType.SenderCardError);
                //}
            }
            return result;
        }
 private static void addCustomProperty(string key, object value, string desc, SerializableDictionary dict)
 {
     if(!dict.ContainsKey(key))
         dict.Add(key, new CustomProperty(key, value, value.GetType(), desc));
 }
        private void SetPhysicalDisplayInfoUpdated(LEDDisplayInfoCollection infoCollection)
        {
            _allCommPortLedDisplayDic = new SerializableDictionary<string, List<ILEDDisplayInfo>>();

            foreach (KeyValuePair<string, List<SimpleLEDDisplayInfo>> keyValue
                in infoCollection.LedSimples)
            {
                foreach (SimpleLEDDisplayInfo simple in keyValue.Value)
                {
                    if (!_allCommPortLedDisplayDic.ContainsKey(keyValue.Key))
                    {
                        _allCommPortLedDisplayDic.Add(keyValue.Key, new List<ILEDDisplayInfo>());
                    }
                    _allCommPortLedDisplayDic[keyValue.Key].Add(
                        new SimpleLEDDisplayInfo(simple.PixelColsInScanBd,
                            simple.PixelRowsInScanBd, simple.ScanBdCols, simple.ScanBdRows, simple.PortCols,
                            simple.PortRows, simple.SenderIndex, simple.X, simple.Y,
                            simple.VirtualMode, simple.PortScanBdInfoList));
                }
            }
            foreach (KeyValuePair<string, List<StandardLEDDisplayInfo>> keyValue
                in infoCollection.LedStandards)
            {
                foreach (StandardLEDDisplayInfo standard in keyValue.Value)
                {
                    if (!_allCommPortLedDisplayDic.ContainsKey(keyValue.Key))
                    {
                        _allCommPortLedDisplayDic.Add(keyValue.Key, new List<ILEDDisplayInfo>());
                    }
                    _allCommPortLedDisplayDic[keyValue.Key].Add((StandardLEDDisplayInfo)standard.Clone());
                }
            }
            foreach (KeyValuePair<string, List<ComplexLEDDisplayInfo>> keyValue
                in infoCollection.LedComplex)
            {
                foreach (ComplexLEDDisplayInfo complex in keyValue.Value)
                {
                    if (!_allCommPortLedDisplayDic.ContainsKey(keyValue.Key))
                    {
                        _allCommPortLedDisplayDic.Add(keyValue.Key, new List<ILEDDisplayInfo>());
                    }
                    _allCommPortLedDisplayDic[keyValue.Key].Add((ComplexLEDDisplayInfo)complex.Clone());
                }
            }
        }
Example #55
0
 private bool HasRelationship(string siblingAccount, SerializableDictionary<string, string> dictRelation)
 {
     lock (dictRelation)
         return dictRelation.ContainsKey(siblingAccount.ToLowerInvariant());
 }
        public List<Job> CreateJobs(string pathToBuildOutput)
        {
            var jobCollection = jobCollections[0];

            Dictionary<string, List<Job>> jobsToRun = new Dictionary<string, List<Job>>();

            foreach (var jobRef in jobCollection.Job)
            {
                List<string> definedBy = new List<string>();
                definedBy.Add(jobRef.JobPath);
                var job = jobMap[jobRef.JobPath];
                SerializableDictionary<string, string> isos = new SerializableDictionary<string, string>();
                foreach (var isoRef in job.ISOs)
                {
                    definedBy.Add(isoRef.Target);
                    var iso = isoMap[isoRef.Target];
                    string isoPath = iso.Path;
                    if (iso.PathType == JobManagerInterfaces.XML.ISOPathType.BuildRelative)
                    {
                        isoPath = Path.Combine(pathToBuildOutput, isoPath);
                    }

                    isos[isoRef.Key] = isoPath;
                }

                SerializableDictionary<string, string> properties = new SerializableDictionary<string, string>();

                foreach (var property in job.Properties)
                {
                    properties[property.Key] = property.Value;
                }

                List<ExecutablePackage> packages = new List<ExecutablePackage>();
                var sequence = sequenceMap[job.ExecutableSequence];
                definedBy.Add(job.ExecutableSequence);

                foreach (string packagePath in sequence.Package)
                {
                    definedBy.Add(packagePath);
                    var package = packageMap[packagePath];
                    string dir = package.MainDirectory.Path;
                    if (package.MainDirectory.PathType == JobManagerInterfaces.XML.PathTPathType.BuildRelative)
                    {
                        dir = Path.Combine(pathToBuildOutput, dir);
                    }

                    SerializableDictionary<string, string> subDirectories = new SerializableDictionary<string, string>();

                    foreach (var subDirectory in package.AdditionalSubDirectories)
                    {
                        string name = subDirectory.Name;
                        if (String.IsNullOrEmpty(name))
                        {
                            name = Path.GetDirectoryName(subDirectory.Path);
                        }
                        if (subDirectory.PathType == JobManagerInterfaces.XML.PathTPathType.BuildRelative)
                        {
                            subDirectories[name] = Path.Combine(pathToBuildOutput, subDirectory.Path);
                        }
                        else if (subDirectory.PathType == JobManagerInterfaces.XML.PathTPathType.Absolute)
                        {
                            subDirectories[name] = subDirectory.Path;
                        }
                    }

                    SerializableDictionary<string, string> packageProperties = new SerializableDictionary<string, string>();

                    foreach (var property in package.Properties)
                    {
                        packageProperties[property.Key] = property.Value;
                    }

                    packages.Add(new ExecutablePackage(packagePath, dir, package.DLLFileName, package.JobRunnerClassName, subDirectories, packageProperties));
                }

                foreach (var configPath in job.Configurations)
                {
                    SerializableDictionary<string, string> jobProperties = new SerializableDictionary<string, string>(properties);
                    var config = configMap[configPath];
                    foreach (var property in config.Properties)
                    {
                        if (!jobProperties.ContainsKey(property.Key))
                        {
                            jobProperties[property.Key] = property.Value;
                        }
                    }
                    Job j = new Job(pathToBuildOutput, config.VM, isos, packages, jobProperties);
                    j.ConfigurationXML = configPath;
                    j.JobXML = jobRef.JobPath;
                    j.SequenceXML = job.ExecutableSequence;
                    if (!jobsToRun.ContainsKey(jobRef.JobPath))
                    {
                        jobsToRun[jobRef.JobPath] = new List<Job>();
                    }
                    jobsToRun[jobRef.JobPath].Add(j);
                }
            }

            foreach (var jobRef in jobCollection.Job)
            {
                var baseJobPath = jobRef.DependsOn;
                if (baseJobPath != null)
                {
                    foreach (Job baseJob in jobsToRun[baseJobPath])
                    {
                        foreach (Job j in jobsToRun[jobRef.JobPath])
                        {
                            j.DependsOnJobIds.Add(baseJob.JobID);
                        }
                    }
                }
            }

            List<Job> jobs = new List<Job>();

            foreach (List<Job> jobList in jobsToRun.Values)
            {
                foreach (Job j in jobList)
                {
                    jobs.Add(j);
                }
            }
            return jobs;
        }
Example #57
0
        /// <summary>
        /// Calculates Clearcasting, mana usage, dps and lag per second.
        /// </summary>
        private void calculateProperties()
        {
            mps = 0f; //summing up total manacost
            dps = 0f; //summing up total damage
            lag = 0f;
            cc = new SerializableDictionary<Type, float>(); //clear casting
            spelldps = new SerializableDictionary<Type, float>(); //dps broken up per spell type
            spelltype = new SerializableDictionary<Type, Spell>(); //all used spells by type
            Dictionary<Type, int> count = new Dictionary<Type, int>(); //counting spells
            Spell prev1 = null, prev2 = null;
            for (int i = -2; i < Casts.Count; i++)
            {
                Spell s = getCast(i);
                if(i>=0) //the first two are just saved in order to calculate clear casting
                {
                    float thisdps = 0f;
                    if(!cc.ContainsKey(s.GetType()))
                    {
                        cc.Add(s.GetType(), 0f);
                        spelldps.Add(s.GetType(), 0f);
                        spelltype.Add(s.GetType(), s);
                        count.Add(s.GetType(), 0);
                    }
                    float ccc = 0f;
                    if (Talents.ElementalFocus > 0)
                        ccc = 1f - (1f - prev1.CCCritChance) * (1f - prev2.CCCritChance);
                    mps += s.ManaCost * ((s is Totem)?1f:(1 - .4f * ccc)); //totems are unaffected by cc
                    if (s.Duration > 0) //dot
                    {
                        int j = getSpellNumber(i);
                        float durationActive = getNextCastTime(j) - (GetTime(j) + s.CastTimeWithoutGCD);
                        thisdps = s.HitChance * (s.AvgDamage * (1 + .05f * Talents.ElementalOath * ccc) + s.PeriodicDamage(durationActive)); //bad for FS ticks.
                    }
                    else
                        thisdps = s.HitChance * s.TotalDamage * (1 + .05f * Talents.ElementalOath * ccc); //bad for FS ticks.
                    dps += thisdps;
                    spelldps[s.GetType()] += thisdps;
                    cc[s.GetType()] += ccc;
                    lag += s.Latency;
                    count[s.GetType()]++;
                }
                if (!(s is Totem)) //totems are unaffected by cc
                {
                    prev2 = prev1;
                    prev1 = s;
                }
            }
            foreach (Type t in count.Keys)
            {
                spelldps[t] /= GetTime();
                cc[t] /= count[t];
            }
            mps /= Duration; //divide by rotation time
            dps /= Duration;
            lag /= Duration;

            dps = 1;
            mps = 1;
        }