Example #1
0
        // GET: api/Default
        public IEnumerable <string> Get()
        {
            FlatData[] elements = new FlatData[]
            {
                new FlatData {
                    Id = 1, Text = "A"
                },
                new FlatData {
                    Id = 2, Text = "B"
                },
                new FlatData {
                    Id = 3, ParentId = 1, Text = "C"
                },
                new FlatData {
                    Id = 4, ParentId = 1, Text = "D"
                },
                new FlatData {
                    Id = 5, ParentId = 2, Text = "E"
                }
            };

            IEnumerable <NodeData> nodes = elements.RecursiveJoin(element => element.Id,
                                                                  element => element.ParentId,
                                                                  (FlatData element, IEnumerable <NodeData> children) => new NodeData()
            {
                Text     = element.Text,
                Children = children
            });
            var t = nodes.ToList();
            var p = JsonConvert.SerializeObject(t);

            return(new string[] { "value1", "value2" });
        }
Example #2
0
        void ParseFlatData(ref string[] block, ref FlatData flat)
        {
            string[] parts;
            string   line = block[0];

            // Split string into tag and value using ':' character
            parts = line.Split(' ');
            if (parts.Length != 2)
            {
                throw new Exception(string.Format("Invalid flat format for data {0} on flat with archive index {1} and record index {2}", line, flat.archive, flat.record));
            }

            // Get flat texture archive and record index
            flat.archive = ParseInt(parts[0]);
            flat.record  = ParseInt(parts[1]);

            // get flat caption
            line         = block[1];
            flat.caption = line;

            // get gender
            line        = block[2];
            flat.gender = line;

            // get currently unknown values
            line          = block[3];
            flat.unknown2 = ParseInt(line);
            line          = block[4];
            flat.unknown3 = ParseInt(line);

            // get face index
            line           = block[5];
            flat.faceIndex = ParseInt(line);
        }
Example #3
0
        /// <summary>
        /// Turns a flat int back into archive/record format
        /// </summary>
        /// <param name="flat"></param>
        /// <returns></returns>
        public static FlatData GetFlatData(int flat)
        {
            FlatData flatData = new FlatData();
            flatData.archive = flat >> 7;
            flatData.record = flat & 0x7f;

            return flatData;
        }
        public Entry100()
        {
            InitializeComponent();

            #region intro stuff
            this.Title      = "Near Hospitals with ER's";
            BackgroundColor = Color.Black; // WhiteSmoke;
            Opacity         = 0.9;
            //?//App.statusBaseLine.BackgroundColor = A_Util001.ColorInTraining();

            #endregion

            // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //
            try
            {
                var duration = TimeSpan.FromMilliseconds(1000);
                Vibration.Vibrate(duration);
            }
            catch (FeatureNotSupportedException ex)
            {
                string aa = ex.Message.ToString();
            }
            catch (Exception ex)
            {
                string aa = ex.Message.ToString();
            }


            // Get all data into global (App. global) strings
            _ = FlatData.GetHospitalDB();

            //
            // At the end of the screen build, 'GetDevLocationAsync' finds
            //
            // 1) Get Latitude, Longitude, Altitude, Accuracy from current location
            // 2) Get address from Latitude, Longitude. Post
            // 3) Generate "100 miles" address list of hospitals in range.
            // 4) With current 100-hospital list, Show Actual Nearest Hospital
            //
            _ = GeoSupport.GetDevLocationAsync_SectionA();

            if (App.MajorError)
            {
                DisplayAlert("Internet Access", "Possible issues:\n\n" +
                             "Assure you have FULL Internet Access:\n" +
                             " 1) Go to your Phone's [Settings]\n" +
                             " 2) Check CONNECTION TO Internet / WiFi\n" +
                             "    or\n" +
                             " 3) turn \"Data Usage\" on $$ fee !!\n" +
                             "    you may also need to set\n" +
                             " 4) LOCATION permission under\n" +
                             "    --> Settings --> Google --> Location\n", "Got it", " ");
            }
        }
Example #5
0
        /// <summary>
        /// Gets flat data from flats ID.
        /// </summary>
        /// <param name="flatID">Flat ID.</param>
        /// <param name="flatDataOut">Receives flats data.</param>
        /// <returns>True if successful.</returns>
        public bool GetFlatData(int flatID, out FlatData flatDataOut)
        {
            flatDataOut = new FlatData();
            if (flatsDict.ContainsKey(flatID))
            {
                flatDataOut = flatsDict[flatID];
                return(true);
            }

            return(false);
        }
    //	public void StartFlatConstruction (int ConstructionAreaNo)
    //	{
    //		GameObject flateArea = (GameObject)Instantiate (RoomTypePrefeb [0], PurchaseAreaPositon [ConstructionAreaNo].localPosition, Quaternion.identity)as GameObject;
    //		flateArea.name = "ConstructionAreaNo ";
    //	}

    public void Addflat(int x, int y, Transform t)
    {
        FlatData flat = new FlatData();

        flat.x                = x;
        flat.y                = y;
        flat.AreaName         = "" + x + "-" + y;
        flat.Purchased        = true;
        flat.TransformDetails = new Dictionary <string, float> ();
        flat.TransformDetails.Add("PositionX", t.position.x);
        flat.TransformDetails.Add("PositionY", t.position.y);
        flat.TransformDetails.Add("PositionZ", t.position.z);
        flat.TransformDetails.Add("RotationX", t.eulerAngles.x);
        flat.TransformDetails.Add("RotationY", t.eulerAngles.y);
        flat.TransformDetails.Add("RotationZ", t.eulerAngles.z);
        flat.TransformDetails.Add("ScaleX", t.localScale.x);
        flat.TransformDetails.Add("ScaleY", t.localScale.y);
        flat.TransformDetails.Add("ScaleZ", t.localScale.z);
        flat.AreaPrice = 0;
        flats.Add(flat);
        AddPurchasedLandNextToRoom(flat.x, flat.y, t);
//		ShowBannerofPurchase (flat.x, flat.y, t); TODO Add Purchase Land adjacent to flat....
        for (int i = 0; i < flats.Count; i++)
        {
            flats [i].AreaPrice = flats [0].AreaPrice + pricebuffer;
        }
        CheckForExtraTimers();

        List <GameObject> tempPland = new List <GameObject> ();

        for (int i = 0; i < purchaseLands.Count; i++)
        {
            for (int j = 0; j < FlatPurchasedAreaContainer.transform.childCount; j++)
            {
                if (purchaseLands [i] != null && purchaseLands [i].GetComponent <PurchasedLand> () &&
                    purchaseLands [i].transform.position.x == FlatPurchasedAreaContainer.transform.GetChild(j).position.x&& purchaseLands [i].transform.position.y == FlatPurchasedAreaContainer.transform.GetChild(j).position.y)
                {
                    PurchasedLands.Remove(purchaseLands [i].GetComponent <PurchasedLand> ());
                    Destroy(purchaseLands [i]);
                }
            }


//			for (int j = i + 1; j < purchaseLands.Count; j++) {
//				if (purchaseLands [i] != null && purchaseLands [j] != null) {
//					if (purchaseLands [i].transform.position.x == purchaseLands [j].transform.position.x && purchaseLands [i].transform.position.y == purchaseLands [j].transform.position.y)
//						Destroy (purchaseLands [j]);
//					else
//						tempPland.Add (purchaseLands [i]);
//				}
//			}
        }
        purchaseLands = tempPland;
    }
Example #7
0
        protected override FlatData ParseOffer(HtmlNode node)
        {
            var detailsNode   = node.SelectSingleNode(@".//*[@class='offer-item-details']");
            var bottomDetails = node.SelectSingleNode(@".//*[@class='offer-item-details-bottom']");

            if (IsPromo(detailsNode))
            {
                return(null);
            }

            var data = new FlatData();

            data.Url          = GetUrl(detailsNode);
            data.Rooms        = GetRooms(detailsNode);
            data.TotalPrice   = GetPrice(detailsNode);
            data.SquareMeters = GetSquareMeters(detailsNode);
            //data.Location = GetLocation(detailsNode);
            return(data);
        }
        public void RecursiveJoinTest()
        {
            FlatData[] _elements = new FlatData[]
            {
                new FlatData {
                    Id = 1, Text = "A"
                },
                new FlatData {
                    Id = 2, Text = "B"
                },
                new FlatData {
                    Id = 3, ParentId = 1, Text = "C"
                },
                new FlatData {
                    Id = 4, ParentId = 1, Text = "D"
                },
                new FlatData {
                    Id = 5, ParentId = 2, Text = "E"
                }
            };
            IEnumerable <NodeData> _nodes = _elements.RecursiveJoin(element => element.Id,
                                                                    element => element.ParentId,
                                                                    (FlatData element, IEnumerable <NodeData> children) => new NodeData()
            {
                Text     = element.Text,
                Children = children
            });

            Assert.AreEqual(2, _nodes.Count());
            IEnumerable <DeepNodeData> _nodes2 = _elements.RecursiveJoin(element => element.Id, element => element.ParentId, (FlatData element, int index, int depth, IEnumerable <DeepNodeData> children) =>
            {
                return(new DeepNodeData()
                {
                    Text = element.Text,
                    Children = children,
                    Depth = depth
                });
            });

            Assert.AreEqual(2, _nodes2.Count());
        }
        public void LengthyTest()
        {
            // Arrange
            var expected = new FlatData
            {
                Id    = new Guid("366f4bd3-6717-4b14-9c79-70515296df7e"),
                Date  = new DateTime(1999, 1, 1),
                Enum  = Enumeration.Two,
                Text  = "level 1",
                Array = new[] { 1, 2, 3, },
            };

            // Act
            var actual = ConfigurationManager.AppSettings.ToObject <FlatData>();

            // Assert
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Date, actual.Date);
            Assert.AreEqual(expected.Enum, actual.Enum);
            Assert.AreEqual(expected.Text, actual.Text);
            CollectionAssert.AreEqual(expected.Array, actual.Array);
        }
Example #10
0
        protected override FlatData ParseOffer(HtmlNode node)
        {
            var ogloszenieInfo = node.SelectSingleNode(@".//*[@class='ogloszenieInfo']");
            var data           = new FlatData();

            try
            {
                data.Url = GetUrl(node);
                //data.Location = GetLocation(ogloszenieInfo);
                data.Rooms        = GetRooms(ogloszenieInfo);
                data.TotalPrice   = GetPrice(node);
                data.SquareMeters = GetSquareMeters(ogloszenieInfo);
                //data.Year = GetYear(ogloszenieInfo);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Skipped: {ogloszenieInfo?.InnerHtml ?? "No inner HTML"} \n" + e);
                return(null);
            }

            return(data);
        }
Example #11
0
        public void LengthyTest()
        {
            // Arrange
            var expected = new FlatData
            {
                Id = new Guid("366f4bd3-6717-4b14-9c79-70515296df7e"),
                Date = new DateTime(1999, 1, 1),
                Enum = Enumeration.Two,
                Text = "level 1",
                Array = new[] { 1, 2, 3, },
            };

            // Act
            var actual = ConfigurationManager.AppSettings.ToObject<FlatData>();

            // Assert
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Date, actual.Date);
            Assert.AreEqual(expected.Enum, actual.Enum);
            Assert.AreEqual(expected.Text, actual.Text);
            CollectionAssert.AreEqual(expected.Array, actual.Array);
        }
        public void MissingValueSafe()
        {
            // Arrange
            var appSettings = new NameValueCollection(ConfigurationManager.AppSettings);

            appSettings.Remove("Text");

            var expected = new FlatData
            {
                Id   = new Guid("366f4bd3-6717-4b14-9c79-70515296df7e"),
                Date = new DateTime(1999, 1, 1),
                Enum = Enumeration.Two,
            };

            // Act
            var actual = appSettings.ToObject <FlatData>();

            // Assert
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Date, actual.Date);
            Assert.AreEqual(expected.Enum, actual.Enum);
            Assert.AreEqual(expected.Text, actual.Text);
        }
Example #13
0
        public void MissingPropertySafe()
        {
            // Arrange
            var appSettings = new NameValueCollection(ConfigurationManager.AppSettings);
            appSettings.Add("Extra property", "whatever");

            var expected = new FlatData
            {
                Id = new Guid("366f4bd3-6717-4b14-9c79-70515296df7e"),
                Date = new DateTime(1999, 1, 1),
                Enum = Enumeration.Two,
                Text = "level 1",
            };

            // Act
            var actual = appSettings.ToObject<FlatData>();

            // Assert
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Date, actual.Date);
            Assert.AreEqual(expected.Enum, actual.Enum);
            Assert.AreEqual(expected.Text, actual.Text);
        }
Example #14
0
        void ParseFlats(string txt)
        {
            // Clear existing dictionary
            flatsDict.Clear();

            // First pass reads each flat text block in order
            List <string[]> flatBlocks = new List <string[]>();

            using (StringReader reader = new StringReader(txt))
            {
                List <string> currentblock = new List <string>();
                while (true)
                {
                    // Handle end of file
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        // Store final block
                        if (currentblock.Count > 0)
                        {
                            flatBlocks.Add(currentblock.ToArray());
                        }
                        break;
                    }

                    // empty lines is end of current block
                    if (string.IsNullOrEmpty(line))
                    {
                        if (currentblock.Count > 0)
                        {
                            flatBlocks.Add(currentblock.ToArray());
                        }
                        currentblock.Clear();
                        continue;
                    }

                    // trim and add line to current flat block
                    line = line.Trim();
                    currentblock.Add(line);
                }
            }

            // Second pass parses the text block into FlatsData
            for (int i = 0; i < flatBlocks.Count; i++)
            {
                // Start a new flat
                FlatData flat  = new FlatData();
                string[] block = flatBlocks[i];

                // Parse flat block
                ParseFlatData(ref block, ref flat);

                int flatID = GetFlatID(flat.archive, flat.record);

                // Store flat just read
                if (!flatsDict.ContainsKey(flatID))
                {
                    flatsDict.Add(flatID, flat);
                }
            }
        }
Example #15
0
        /// <summary>
        /// Turns a flat int back into archive/record format
        /// </summary>
        /// <param name="flat"></param>
        /// <returns></returns>
        public FlatData GetFlatData(int flat)
        {
            FlatData flatData = flatsDict[flat];

            return(flatData);
        }