public Product(int price, String name, TM tm, Category category) { this.price = price; this.name = name; this.tm = tm; this.category = category; }
/// <summary> /// try to reconnect to TM after tm failed. It need to register itself to TM as well /// </summary> public static void ReconnectToTM() { TM tempTM = null; while (tempTM == null) { Console.WriteLine("Trying to reconnect to TM"); tempTM = (TP.TM)System.Activator.GetObject(typeof(TP.TM), tmUrl); try { tempTM.Ping(); foreach (string url in urls) { tempTM.Register(url + "$" + GlobalState.Name); } } catch (WebException) { tempTM = null; Console.WriteLine("Waiting 0.5 second for Transaction Manager \"{0}\"", tmUrl); System.Threading.Thread.Sleep(500); } } Interlocked.Exchange <TM>(ref _transactionManager, tempTM); Console.WriteLine("Connected to Transaction Manager \"{0}\"", tmUrl); }
public void ShowBombAttackEffect() { if (myMage.isDecoyBomb) { TM.surroundingTiles.Clear(); TM.GetSurroundingTiles(myCurrentTile, 1, true, false); //Hago daño a las unidades adyacentes for (int i = 0; i < TM.surroundingTiles.Count; ++i) { if (TM.surroundingTiles[i] != null) { tilesInEnemyHover.Add(TM.surroundingTiles[i]); } } } for (int i = 0; i < tilesInEnemyHover.Count; i++) { tilesInEnemyHover[i].ColorAttack(); if (tilesInEnemyHover[i].unitOnTile != null) { tilesInEnemyHover[i].unitOnTile.ColorAvailableToBeAttackedAndNumberDamage(damageWithMultipliersApplied); } } }
private void LHFDP_DragDrop(object sender, DragEventArgs e) { if (e.Effect != DragDropEffects.Copy) { return; } string ourFile = ((string[])e.Data.GetData(DataFormats.FileDrop))[0]; try { THeader TH = TM.LoadFromFile(ourFile); DialogResult DR = MessageBox.Show("Are you sure you want to load the headers from this file?", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (DR == DialogResult.Yes) { TM.UpdateHeadersFromFile(TH); } else { return; } } catch (Exception) { MessageBox.Show("Error Loading Headers File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void CheckIfIsLonely() { if (buffLonelyArea) { TM.GetSurroundingTiles(myCurrentTile, 1, true, false); for (int i = 0; i < myCurrentTile.surroundingNeighbours.Count; ++i) { if (myCurrentTile.surroundingNeighbours[i].unitOnTile != null) { if (myCurrentTile.surroundingNeighbours[i].unitOnTile.GetComponent <PlayerUnit>()) { isLonelyIcon.SetActive(false); isLonelyLikeMe = false; break; } else { isLonelyIcon.SetActive(true); isLonelyLikeMe = true; } } else { isLonelyIcon.SetActive(true); isLonelyLikeMe = true; } } if (isLonelyLikeMe) { isLonelyIcon.SetActive(true); } } }
public override void NewTurn() { TemporaryHP = 0; TempStatus = new List <string>(Status); Status.Clear(); if (HasStatus("Deployed")) { AddStatus("Was Deployed"); } // Check if any modules have reached their lifetimes // (they will remove themselves, so iterate through a copied list). List <Module> allModulesCopy = new List <Module>(AllModules); foreach (Module module in allModulesCopy) { module.CheckLifetime(this); } foreach (INewTurnModule TM in NewTurnModules) { TM.NewTurn(); } foreach (Module M in AllModules) { M.NewTurnGeneric(); } TempStatus = null; }
public void AddDialoguePin() { GameObject pinObj = Resources.Load(GlobalData.resourcePath + "/Prefabs/ShowDialogue") as GameObject; pinObj = Instantiate(pinObj, PinParent); Button b = pinObj.transform.GetChild(0).GetComponent <Button>(); b.onClick.AddListener(delegate { if (Input.GetMouseButton(1)) //If right clicked { Debug.Log("OKAY"); return; } Transform t = Instantiate(Resources.Load(GlobalData.resourcePath + "/Prefabs/Panels/DialoguePopUp") as GameObject, GameObject.Find("Canvas").transform).transform; t.gameObject.SetActive(true); t.GetComponentInChildren <ReaderEntryManagerScript>().SetPin(b.transform); t.GetComponentInChildren <ReaderDialogueManagerScript>().PopulateDialogue(b.transform); if (t.Find("Image")) { t.Find("Image").GetComponent <Image>().color = DS.GetImage(TM.getCurrentSection()).color; //ds.GetImage(tm.getCurrentSection()) != null ? ds.GetImage(tm.getCurrentSection()).color : GlobalData.GDS.defaultGreen; } }); pinObj.tag = "Value"; pinObj.name = "Dialogue" + "Pin"; pinObj.SetActive(!pinStartHidden); }
public void AddQuizPin() { GameObject pinObj = Resources.Load(GlobalData.resourcePath + "/Prefabs/QuizPinIcon") as GameObject; if (PinParent.Find("DialoguePin")) { pinObj = Instantiate(pinObj.transform.Find("ShowQuiz").gameObject, PinParent.Find("DialoguePin")); } else { pinObj = Instantiate(pinObj, PinParent); pinObj.SetActive(!pinStartHidden); } Button b = pinObj.GetComponentInChildren <Button>(); b.onClick.AddListener(delegate { Transform t = Instantiate(Resources.Load(GlobalData.resourcePath + "/Prefabs/Panels/QuizPopUp") as GameObject, DS.transform).transform; t.gameObject.SetActive(true); t.GetComponentInChildren <ReaderEntryManagerScript>().SetPin(b.transform); t.GetComponentInChildren <ReaderEntryManagerScript>().PopulatePanel(b.transform); t.Find("Image").GetComponent <Image>().color = DS.GetImage(TM.getCurrentSection()).color; }); pinObj.tag = "Value"; pinObj.name = "Quiz" + "Pin"; }
private void ProcessStimBuffer() { TargetTrackingManager TM; foreach (GameObject GO in registrants) { TM = GO.GetComponent <TargetTrackingManager>(); foreach (Stimulus stim in stimBuffer) { if (stim.m_type == Stimulus.StimulusTypes.AudioMovement) { float range = Mathf.Abs((stim.m_location - GO.transform.position).magnitude); if (range < stim.m_Radius)// if the simulus is in range of the AI accept the stimulus { TM.AcceptFilteredStimulus(stim); } } if (stim.m_type == Stimulus.StimulusTypes.VisualCanSee) { TM.AcceptFilteredStimulus(stim);// if the AI can see the enemy the accept the stimulus } } } stimBuffer.Clear();// clear the stimulation list }
///<summary> /// Creates a VH. /// <param name="message">The Message to which this Type belongs</param> /// <param name="description">The description of this type</param> ///</summary> public VH(IMessage message, string description) : base(message, description){ data = new IType[4]; data[0] = new ID(message, 267,"Start Day Range"); data[1] = new ID(message, 267,"End Day Range"); data[2] = new TM(message,"Start Hour Range"); data[3] = new TM(message,"End Hour Range"); }
///<summary> /// Creates a VH. /// <param name="message">The Message to which this Type belongs</param> /// <param name="description">The description of this type</param> ///</summary> public VH(IMessage message, string description) : base(message, description){ data = new IType[4]; data[0] = new ID(message, 0,"Start day range"); data[1] = new ID(message, 0,"End day range"); data[2] = new TM(message,"Start hour range"); data[3] = new TM(message,"End hour range"); }
public void testadd() { TM timenmat = new TM(); timenmat.add(); }
public static void Initialize() { TM.SetTitle("Loading .."); var render = Render = new GameRender(Console.BufferWidth, Console.BufferHeight); }
public void ChangePosition(Mage mage2Move) { CreateAttackCommand(mage2Move); IndividualTiles magePreviousTile = mage2Move.myCurrentTile; mage2Move.MoveToTilePushed(myCurrentTile); mage2Move.UpdateInformationAfterMovement(myCurrentTile); this.MoveToTilePushed(magePreviousTile); UpdateInformationAfterMovement(magePreviousTile); mage2Move.hasMoved = true; LM.UnitHasFinishedMovementAndRotation(); UIM.RefreshTokens(); if (mage2Move.isDecoyBomb2) { TM.GetSurroundingTiles(myCurrentTile, 1, true, false); //Hago daño a las unidades adyacentes for (int i = 0; i < TM.surroundingTiles.Count; ++i) { if (TM.surroundingTiles[i] != null) { TM.surroundingTiles[i].ColorAttack(); } } StartCoroutine("WaitToDamageSurroundingAfterChangePos"); } HideAttackEffect(null); }
//Al igual que con la bomba he sacado la parte del intercambio del ShowAttack public void ShowInterchangeEffect() { if (LM.selectedCharacter != null) { Cursor.SetCursor(LM.UIM.movementCursor, Vector2.zero, CursorMode.Auto); ChangePositionIconFeedback(true); if (myMage.isDecoyBomb2) { TM.GetSurroundingTiles(myMage.myCurrentTile, 1, true, false); //Hago daño a las unidades adyacentes for (int i = 0; i < TM.surroundingTiles.Count; ++i) { if (TM.surroundingTiles[i] != null) { tilesInEnemyHover.Add(TM.surroundingTiles[i]); } } } } for (int i = 0; i < tilesInEnemyHover.Count; i++) { tilesInEnemyHover[i].ColorAttack(); if (tilesInEnemyHover[i].unitOnTile != null) { CalculateDamage(tilesInEnemyHover[i].unitOnTile); tilesInEnemyHover[i].unitOnTile.ColorAvailableToBeAttackedAndNumberDamage(damageWithMultipliersApplied); } } }
public GameRender(int sizeX, int sizeY) { TM.SetTitle("Loading .."); SizeX = sizeX; SizeY = sizeY; Render(); }
public override void HideAttackEffect(UnitBase _unitToAttack) { //No usa la base porque es el propio monje if (rotatorTime) { if (rotatorTime2) { if (_unitToAttack.isMarked) { PutQuitMark(_unitToAttack, this, false, false); //COMPROBAR QUE NO DE ERROR EN OTRAS COSAS TM.surroundingTiles.Clear(); TM.GetSurroundingTiles(_unitToAttack.myCurrentTile, 1, true, false); //Marco a las unidades adyacentes si no están marcadas for (int i = 0; i < TM.surroundingTiles.Count; ++i) { if (TM.surroundingTiles[i].unitOnTile != null) { if (TM.surroundingTiles[i].unitOnTile.GetComponent <EnemyUnit>() && !TM.surroundingTiles[i].unitOnTile.GetComponent <EnemyUnit>().isMarked) { if (!hasAttacked) { PutQuitMark(TM.surroundingTiles[i].unitOnTile, this, false, false); } } } } } _unitToAttack.hoverRotateIcon.SetActive(false); } else { if (!hasAttacked) { PutQuitMark(_unitToAttack, this, false, false); } _unitToAttack.hoverRotateIcon.SetActive(false); } } //Monje DisableCanvasHover(); ResetColor(); myCurrentTile.ColorDeselect(); //Enemigo PutQuitMark(_unitToAttack, this, false, false); _unitToAttack.ResetColor(); _unitToAttack.DisableCanvasHover(); }
public void Should_Serialize_HHmm() { var date = new TM(9, 22); Assert.AreEqual("0922", date.Value); date = new TM(9, 22, null, null, null, -2); Assert.AreEqual("0922-0200", date.Value); }
public void Should_Serialize_HHmmss_s() { var date = new TM(11, 11, 2, 400); Assert.AreEqual("111102.4", date.Value); date = new TM(11, 11, 2, 400, null, -5); Assert.AreEqual("111102.4-0500", date.Value); }
public void Should_Serialize_HHmmss_ssss() { var date = new TM(11, 11, 2, 364, 5); Assert.AreEqual("111102.3645", date.Value); date = new TM(11, 11, 2, 364, 5, 4); Assert.AreEqual("111102.3645+0400", date.Value); }
public void Should_Serialize_HHMM() { var date = new TM(14, 0); Assert.AreEqual("1400", date.Value); date = new TM(14, 0, null, null, null, 3, 30); Assert.AreEqual("1400+0330", date.Value); }
public void Should_Serialize_HHmmss() { var date = new TM(11, 11, 2); Assert.AreEqual("111102", date.Value); date = new TM(11, 11, 2, null, null, -2, 15); Assert.AreEqual("111102-0215", date.Value); }
public void CheckBlockStatus(Unit Attacker, Unit Target, TargettingData TD) { int dummy = 0; //target parameter in TM is 'this' so blocking must only depend on attacker and blocker, not actual target unit foreach (BlockingModule TM in BlockingModules) { TM.Run(Attacker, Target, TD, ref dummy); } }
private void BtnAddTreader_OnClick(object sender, RoutedEventArgs e) { Treader treader = TreaderFactory.CreateTreader; var f = new FrmTreaderEditor(treader); if (f.ShowDialog() != true) { return; } TM.Add(treader); }
public void CheckPasiveUpgrades(UnitBase _unitToAttack) { if (afterKillBonus) { if (_unitToAttack.isDead) { if (afterKillBonus2) { baseDamage += bonusAttackAfterKill; StartCoroutine("ParticleWait"); } else if (maxbonusAttackAfterKill > 0) { baseDamage += bonusAttackAfterKill; StartCoroutine("ParticleWait"); maxbonusAttackAfterKill--; } } } else if (smokeBomb) { if (_unitToAttack.isDead) { if (smokeBomb2) { TM.surroundingTiles.Clear(); TM.GetSurroundingTiles(myCurrentTile, 1, true, false); GameObject smokeBombRef1 = Instantiate(smokeBombPref, myCurrentTile.transform.position, myCurrentTile.transform.rotation); smokeBombRef1.GetComponent <SmokeTile>().myRogueReference = this; realBombsSpawned.Add(smokeBombRef1); //Hago daño a las unidades adyacentes for (int i = 0; i < TM.surroundingTiles.Count; ++i) { if (TM.surroundingTiles[i] != null) { GameObject smokeBombRef = Instantiate(smokeBombPref, TM.surroundingTiles[i].transform.position, TM.surroundingTiles[i].transform.rotation); smokeBombRef.GetComponent <SmokeTile>().myRogueReference = this; realBombsSpawned.Add(smokeBombRef); } } } else { GameObject smokeBombRef = Instantiate(smokeBombPref, myCurrentTile.transform.position, myCurrentTile.transform.rotation); smokeBombRef.GetComponent <SmokeTile>().myRogueReference = this; realBombsSpawned.Add(smokeBombRef); } } } }
internal int GetCostByTM(TM tm) { int costByTM = 0; foreach (Product product in products) { if (product.tm == tm) { costByTM += product.price; } } return(costByTM); }
public void Should_Serialize_HHmmss_ss() { var date = new TM(11, 11, 2, 40); Assert.AreEqual("111102.04", date.Value); date = new TM(11, 11, 2, 240); Assert.AreEqual("111102.24", date.Value); date = new TM(11, 11, 2, 40, null, -5); Assert.AreEqual("111102.04-0500", date.Value); date = new TM(11, 11, 2, 240, null, -8); Assert.AreEqual("111102.24-0800", date.Value); }
///<summary> /// Returns a single repetition of Explicit Time(TQ1-4). /// throws HL7Exception if the repetition number is invalid. /// <param name="rep">The repetition number (this is a repeating field)</param> ///</summary> public TM GetExplicitTime(int rep) { TM ret = null; try { IType t = this.GetField(4, rep); ret = (TM)t; } catch (System.Exception ex) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex); throw new System.Exception("An unexpected error ocurred", ex); } return ret; }
private string getTM(TM tm) { string ret = $@"[{tm.name}] "; for (int i = 0; i < tm.species.Count; i++) { ret += tm.species[i]; if (i != tm.species.Count - 1) { ret += ","; } } return(ret); }
/// <summary> Returns a single repetition of Explicit Time (TQ1-4).</summary> /// <param name="rep">the repetition number (this is a repeating field) /// </param> /// <throws> HL7Exception if the repetition number is invalid. </throws> public virtual TM getExplicitTime(int rep) { TM ret = null; try { Type t = this.getField(4, rep); ret = (TM)t; } catch (System.InvalidCastException) { throw new Exception(); } return(ret); }
private void BtnStart_OnClick(object sender, RoutedEventArgs e) { var btn = (Button)sender; if (btn.Content.ToString() == "Start") { TM.StartTrade(); btn.Content = "Stop"; } else { TM.StopTreading(); btn.Content = "Start"; } }
public TM GetZhiXingSjd(int rep) { TM tM = null; try { IType field = GetField(10, rep); return((TM)field); } catch (Exception ex) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex); throw new Exception("An unexpected error ocurred", ex); } }
static void Main(string[] args) { isReady = false; // set isReady false because we want to make sure the actual code is not executed before the rm is going into the stable loop waiting. RMParser parser = new RMParser(); if (!parser.Parse(args)) { return; } GlobalState.Name = parser["n"].ToLower(); string port_num = parser["p"]; System.Collections.Specialized.ListDictionary channelProperties = new System.Collections.Specialized.ListDictionary(); channelProperties.Add("port", port_num); channelProperties.Add("name", GlobalState.Name); HttpChannel channel = new HttpChannel(channelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider()); System.Console.WriteLine(string.Format("Starting resource manager for {0} on port {1}", GlobalState.Name, port_num)); System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false); System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType (Type.GetType("MyRM.MyRM") // Assembly name , "RM.soap" // URI , System.Runtime.Remoting.WellKnownObjectMode.Singleton // Instancing mode ); if (String.Compare(parser["tm"], "none", true) != 0) { while (_transactionManager == null) { tmUrl = parser["tm"]; try { _transactionManager = (TP.TM)System.Activator.GetObject(typeof(TP.TM), tmUrl); _transactionManager.Ping(); urls = channel.GetUrlsForUri("RM.soap"); foreach (string url in urls) { _transactionManager.Register(url + "$" + GlobalState.Name); } } catch (ArgumentException) { _transactionManager = null; Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", parser["tm"]); System.Threading.Thread.Sleep(1000); } } } Console.WriteLine("{0} RM: Transaction Manager retrieved at {1}", GlobalState.Name, parser["tm"]); while (GlobalState.Mode == GlobalState.RunMode.Loop) { try { _transactionManager.Ping(); } catch(WebException) { _transactionManager = null; ReconnectToTM(); } isReady = true; System.Threading.Thread.Sleep(2000); } int loopCount = 0; while (GlobalState.Mode == GlobalState.RunMode.Wait && loopCount < 15) { System.Threading.Thread.Sleep(1000); loopCount++; Console.WriteLine("{0}: Waiting for transaction complete ({1} second(s))", GlobalState.Name, loopCount); } Console.WriteLine("{0}: Exitting", GlobalState.Name); }
private void button1_Click(object sender, EventArgs e) { tmb.list_tm.Clear(); for (int i = 0; i < listView_MT .Items .Count ; i++) { string cont = listView_MT.Items[i].SubItems[1].Text; string[] str_d = listView_MT.Items[i].SubItems[2].Text.Split(' ').Where<string >((o) => { return !string.IsNullOrEmpty(o); }).ToArray(); double[] dou_attr = new double[str_d.Length ]; for (int j = 0; j < str_d .Length ; j++) { dou_attr[j] = double.Parse(str_d [j]); } TM tmptm = new TM(); tmptm.attributes = dou_attr; tmptm.bmp = (Bitmap )listView_MT.Items[i].Tag; tmptm.context = cont; tmb.list_tm.Add(tmptm ); //str_d.Where<string>((o)=> { return true; }); } VerifyTools.Serialize<TMBank>(tmb,@"D:\testtmb.cfg"); }
/// <summary> /// Currently does not involve TM, will do it in later step /// Call to TM to enlist for distributed transaction /// </summary> /// <param name="context"></param> public void Enlist(TP.Transaction context) { WaitForReady(); try { _transactionManager.Enlist(context, this.GetName()); return; } catch (WebException) { } catch(ApplicationException) { } _transactionManager = null; ReconnectToTM(); WaitForReady(); }
public void Should_Serialize_HHmmss_sss() { var date = new TM(11, 11, 2, 4); Assert.AreEqual("111102.004", date.Value); date = new TM(11, 11, 2, 14); Assert.AreEqual("111102.014", date.Value); date = new TM(11, 11, 2, 104); Assert.AreEqual("111102.104", date.Value); date = new TM(11, 11, 2, 124); Assert.AreEqual("111102.124", date.Value); date = new TM(11, 11, 2, 4, null, -5); Assert.AreEqual("111102.004-0500", date.Value); date = new TM(11, 11, 2, 14, null, -5); Assert.AreEqual("111102.014-0500", date.Value); date = new TM(11, 11, 2, 104, null, -5); Assert.AreEqual("111102.104-0500", date.Value); date = new TM(11, 11, 2, 124, null, -5); Assert.AreEqual("111102.124-0500", date.Value); }
/*=================================MatchTimeMark================================== **Action: Parse the time mark (AM/PM) from string starting at str.Index. **Returns: TM_AM or TM_PM. **Arguments: str: a __DTString. The parsing will start from the ** next character after str.Index. **Exceptions: FormatException if a time mark can not be found. ==============================================================================*/ private static bool MatchTimeMark(ref __DTString str, DateTimeFormatInfo dtfi, ref TM result) { result = TM.NotSet; // In some cultures have empty strings in AM/PM mark. E.g. af-ZA (0x0436), the AM mark is "", and PM mark is "nm". if (dtfi.AMDesignator.Length == 0) { result = TM.AM; } if (dtfi.PMDesignator.Length == 0) { result = TM.PM; } if (str.GetNext()) { String searchStr = dtfi.AMDesignator; if (searchStr.Length > 0) { if (str.MatchSpecifiedWord(searchStr)) { // Found an AM timemark with length > 0. str.Index += (searchStr.Length - 1); result = TM.AM; return (true); } } searchStr = dtfi.PMDesignator; if (searchStr.Length > 0) { if (str.MatchSpecifiedWord(searchStr)) { // Found a PM timemark with length > 0. str.Index += (searchStr.Length - 1); result = TM.PM; return (true); } } str.Index--; // Undo the GetNext call. } if (result != TM.NotSet) { // If one of the AM/PM marks is empty string, return the result. return (true); } return false; }
private static bool AdjustHour(ref int hour, TM timeMark) { if (timeMark != TM.NotSet) { if (timeMark == TM.AM) { if ((hour < 0) || (hour > 12)) { return false; } hour = (hour == 12) ? 0 : hour; } else { if ((hour < 0) || (hour > 0x17)) { return false; } if (hour < 12) { hour += 12; } } } return true; }
private static bool MatchAbbreviatedTimeMark(ref __DTString str, DateTimeFormatInfo dtfi, ref TM result) { if (str.GetNext()) { if (str.GetChar() == dtfi.AMDesignator[0]) { result = TM.AM; return true; } if (str.GetChar() == dtfi.PMDesignator[0]) { result = TM.PM; return true; } } return false; }
protected TM GetTM() { bool done = false; while (!done) { try { if (null == s_tm) { s_tm = (TM)System.Activator.GetObject(typeof(TM), "http://localhost:8089/TM.soap"); } s_tm.ToString(); done = true; } catch (Exception) { s_tm = null; } } return s_tm; }
// // Adjust hour according to the time mark. // private static Boolean AdjustHour(ref int hour, TM timeMark) { if (timeMark != TM.NotSet) { if (timeMark == TM.AM) { if (hour < 0 || hour > 12) { return false; } hour = (hour == 12) ? 0 : hour; } else { if (hour < 0 || hour > 23) { return false; } if (hour < 12) { hour += 12; } } } return true; }
private static bool MatchTimeMark(ref __DTString str, DateTimeFormatInfo dtfi, ref TM result) { result = TM.NotSet; if (dtfi.AMDesignator.Length == 0) { result = TM.AM; } if (dtfi.PMDesignator.Length == 0) { result = TM.PM; } if (str.GetNext()) { string aMDesignator = dtfi.AMDesignator; if ((aMDesignator.Length > 0) && str.MatchSpecifiedWord(aMDesignator)) { str.Index += aMDesignator.Length - 1; result = TM.AM; return true; } aMDesignator = dtfi.PMDesignator; if ((aMDesignator.Length > 0) && str.MatchSpecifiedWord(aMDesignator)) { str.Index += aMDesignator.Length - 1; result = TM.PM; return true; } str.Index--; } return (result != TM.NotSet); }
/*=================================MatchAbbreviatedTimeMark================================== **Action: Parse the abbreviated time mark (AM/PM) from string starting at str.Index. **Returns: TM_AM or TM_PM. **Arguments: str: a __DTString. The parsing will start from the ** next character after str.Index. **Exceptions: FormatException if a abbreviated time mark can not be found. ==============================================================================*/ private static bool MatchAbbreviatedTimeMark(ref __DTString str, DateTimeFormatInfo dtfi, ref TM result) { // NOTENOTE : the assumption here is that abbreviated time mark is the first // character of the AM/PM designator. If this invariant changes, we have to // change the code below. if (str.GetNext()) { if (str.GetChar() == dtfi.AMDesignator[0]) { result = TM.AM; return (true); } if (str.GetChar() == dtfi.PMDesignator[0]) { result = TM.PM; return (true); } } return false; }
public DummyDataContext() { Europa = new Continent(); Europa.ContinentID = 1; Europa.Name = "Europa"; Graad = new Grade(1); Belgium = new Country("Belgie",Europa); England = new Country("England",Europa); Belgium.CountryID = 1; England.CountryID = 2; //Belgium.AboveEquator = true; //England.AboveEquator = false; //voor te testen. England ligt obviously boven de Equator int[] temp = new int[]{1,5,3,4,5,6,7,8,9,10,40,12}; int[] sed = new int[] {10, 206, 30, 200, 50, 60, 70, 80, 20, 100, 110, 120}; int[] temp2 = new int[] { 1, 2, 3, 0, -10, -12, 7, 8, 9, 10, 11, 12 }; int[] sed2 = new int[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120 }; NegTempClimateChart = new ClimateChart("Chelsea",2000,2030,temp2,sed2, -20, 10); NegTempClimateChart.Country = England; NegTempClimateChart.ClimateChartID = 2; England.ClimateCharts = new List<ClimateChart>{NegTempClimateChart}; Gent = new ClimateChart("gent",1950,1960,temp,sed, 55, 6); Gent.Country = Belgium; Gent.ClimateChartID = 1; ClimateCharts = new List<ClimateChart>{ Gent }; Belgium.ClimateCharts = ClimateCharts; Countries = new List<Country>{ Belgium,England }; Europa.Countries = Countries; Continenten = new List<Continent>{ Europa }; Graad.Continents = Continenten; Parameter tw = new TW("Wat is de temperatuur van de warmste maand (TW)?"); Parameter mw = new MW("Wat is de warmste maand?"); Parameter mk = new MK("Wat is de temperatuur van de koudste maand?"); Parameter tk = new TK("Wat is de temperatuur van de koudste maand (TK)?"); Parameter d = new D("Hoeveel droge maanden zijn er?"); Parameter nz = new NZ("Hoeveelheid neerslag in de zomer?"); Parameter nw = new NW("Hoeveelheid neerslag in de winter?"); Parameter tj = new TJ(""); Parameter nj = new NJ(""); Parameter tm = new TM(""); //ClauseComponent tw10 = new Clause("TW <= 10", tw, "<=", 10); //ClauseComponent CC2 = new Clause("TW <= 10", tw, "<", 10); //ClauseComponent CC3 = new Clause("TW <= 10", tw, ">=", 10); //ClauseComponent CC4 = new Clause("TW <= 10", tw, ">", 10); //ClauseComponent res1 = new Result("YES", "geen woestijn"); //ClauseComponent res2 = new Result("NO", "woestijn"); //tw10.ClauseComponentId = 1; //res1.ClauseComponentId = 2; //res2.ClauseComponentId = 3; //tw10.Add(true, res1); //tw10.Add(false, res2); //CC2.Add(true, res1); //CC2.Add(false, res2); //CC3.Add(true, res1); //CC3.Add(false, res2); //CC4.Add(true, res1); //CC4.Add(false, res2); //DetTable = new DeterminateTable(); //DetTable2 = new DeterminateTable(); //DetTable3 = new DeterminateTable(); //DetTable4 = new DeterminateTable(); Graad.DeterminateTableProp = DetTable; Country belgië = new Country { Name = "België" }; temps = new int[] { 10, 12, 12, 14, 15, 20, 28, 32, 28, 16, 6, 2 }; sed = new[] { 120, 145, 200, 120, 150, 100, 140, 40, 100, 120, 130, 100 }; chart = new ClimateChart("Gent", 1990, 1991, temps, sed, 55, 6); chart.Country = belgië; temps2 = new int[] { 14, 15, 17, 21, 25, 27, 28, 27, 26, 23, 19, 15 }; sed2 = new[] { 7, 4, 4, 2, 0, 0, 0, 0, 0, 1, 3, 5 }; chart2 = new ClimateChart("Kaïro", 1961, 1990, temps2, sed2, -20, 2); Country egypte = new Country { Name = "Egypte" }; //egypte.AboveEquator = false; chart2.Country = egypte; temps3 = new int[] { 0, 1, 5, 11, 17, 22, 25, 24, 20, 14, 9, 3 }; sed3 = new[] { 77, 73, 91, 96, 97, 91, 103, 95, 86, 77, 97, 86 }; chart3 = new ClimateChart("New York", 1961, 1990, temps3, sed3, 50, -50); Country newyork = new Country { Name = "New York" }; chart3.Country = newyork; temps4 = new int[] { 25, 1, 5, 11, 17, 22, 25, 24, 20, 14, 9, 3 }; sed4 = new[] { 1, 2, 0, 0, 0, 100, 100, 100, 100, 100, 0, 0 }; chart4 = new ClimateChart("Fictief", 1961, 1990, temps4, sed4, 60, 20); Country fictief = new Country { Name = "Fictief" }; chart4.Country = fictief; byte[] picture = null; ClauseComponent tw10 = new Clause("TW <= 10", tw, "<=", 10); ClauseComponent tw0 = new Clause("TW <= 0", tw, "<=", 0); ClauseComponent tw0Yes = new Result("Koud klimaat zonder dooiseizoen", "Ijswoestijnklimaat", picture); ClauseComponent tw0No = new Result("Koud klimaat met dooiseizoen", "Toendraklimaat", picture); tw0.Add(true, tw0Yes); tw0.Add(false, tw0No); tw10.Add(true, tw0); ClauseComponent tj0 = new Clause("TJ <= 0", tj, "<=", 0); tw10.Add(false, tj0); ClauseComponent tj0Yes = new Result("Koudgematigd klimaat met strenge winter", "Taigaklimaat", picture); tj0.Add(true, tj0Yes); ClauseComponent nj200 = new Clause("NJ <= 200", nj, "<=", 200); ClauseComponent tk15 = new Clause("TK <= 15", tk, "<=", 15); ClauseComponent tk15Yes = new Result("Gematigd altijd droog klimaat", "Woestijnklimaat van de middelbreedten", picture); ClauseComponent tk15No = new Result("Warm altijd droog klimaat", "Woestijnklimaat van de tropen", picture); tk15.Add(true, tk15Yes); tk15.Add(false, tk15Yes); nj200.Add(true, tk15); tj0.Add(false, nj200); ClauseComponent tk18 = new Clause("TK <= 18", tk, "<=", 18); ClauseComponent nj400 = new Clause("NJ <= 400", nj, "<=", 400); ClauseComponent nj400Yes = new Result("Gematigd, droog klimaat", "Steppeklimaat", picture); ClauseComponent tk10N = new Clause("TK <= -10", tk, "<=", -10); ClauseComponent tk10NYes = new Result("Koudgematigd klimaat met strenge winter", "Taigaklimaat", picture); ClauseComponent d1 = new Clause(" D <= 1", d, "<=", 1); ClauseComponent tk3N = new Clause("TK <= -3", tk, "<=", -3); ClauseComponent tk3NYes = new Result("Koelgematigd klimaat met koude winter", "Gemengd-woudklimaat", picture); ClauseComponent tw22 = new Clause(" TW <= 22", tw, "<=", 22); ClauseComponent tw22Yes = new Result("Koelgematigd klimaat met zachte winter", "Loofbosklimaat", picture); ClauseComponent tw22No = new Result("Warmgematigd altijd nat klimaat", "Subtropisch regenwoudklimaat", picture); ClauseComponent nznw = new Clause("NZ <= NW", nz, nw); ClauseComponent tw222 = new Clause("TW <= 22", tw, "<=", 22); ClauseComponent tw222Yes = new Result("Koelgematigd klimaat met natte winter", "Hardbladige-vegetatieklimaat van de centrale middelbreedten", picture); ClauseComponent tw222No = new Result("Warmgematigd klimaat met natte winter", "Hardbladige-vegetatieklimaat van de subtropen", picture); ClauseComponent nznwNo = new Result("Warmgematigd klimaat met natte zomer", "Subtropisch savanneklimaat", picture); tw222.Add(true, tw222Yes); tw222.Add(false, tw222No); nznw.Add(true, tw222); nznw.Add(false, nznwNo); tw22.Add(true, tw22Yes); tw22.Add(false, tw22No); tk3N.Add(true, tk3NYes); tk3N.Add(false, tw22); d1.Add(true, tk3N); d1.Add(false, nznw); tk10N.Add(true, tk10NYes); tk10N.Add(false, d1); nj400.Add(true, nj400Yes); nj400.Add(false, tk10N); tk18.Add(true, nj400); nj200.Add(false, tk18); ClauseComponent d12 = new Clause("D <= 1", d, "<=", 1); ClauseComponent d12Yes = new Result("Warm klimaat met nat seizoen", "Tropisch savanneklimaat", picture); ClauseComponent d12No = new Result("Warm altijd nat klimaat", "Tropisch regenwoudklimaat", picture); d12.Add(true, d12Yes); d12.Add(false, d12No); tk18.Add(false, d12); dTable = new DeterminateTable(); List<ClauseComponent> results1 = (new ClauseComponent[] { tw0, tj0,nj200, tk15,tk18, nj400, tk10N, d1, tk3N, tw22, nznw, tw222, d12, tw0Yes, tw0No, tj0Yes, tk15Yes, tk15No, nj400Yes, tk10NYes, tk3NYes, tw22Yes, tw22No, tw222Yes, tw222No, nznwNo, d12Yes, d12No, tw10 }).ToList(); results1.ForEach(r => dTable.AllClauseComponents.Add(r)); }