private void Swap(ref Prefecture x, ref Prefecture y)
    {
        var tmp = x;

        x = y;
        y = tmp;
    }
Exemple #2
0
 public Address(Prefecture prefecture, string city, PostCode postCode, string belowAddress)
 {
     this.prefecture   = prefecture;
     this.city         = city;
     this.postCode     = postCode;
     this.belowAddress = belowAddress;
 }
Exemple #3
0
        /// <summary>
        /// Executes Activity
        /// </summary>
        /// <param name="context"></param>
        protected override void Execute(CodeActivityContext context)
        {
            var address = AddressString.Get(context).TrimStart();

            var prefs = new string[] { "北海道"
                                       , "青森県", "岩手県", "宮城県", "秋田県", "山形県", "福島県"
                                       , "茨城県", "栃木県", "群馬県", "埼玉県", "千葉県", "東京都", "神奈川県"
                                       , "新潟県", "富山県", "石川県", "福井県", "山梨県", "長野県", "岐阜県", "静岡県", "愛知県"
                                       , "三重県", "滋賀県", "京都府", "大阪府", "兵庫県", "奈良県", "和歌山県"
                                       , "鳥取県", "島根県", "岡山県", "広島県", "山口県"
                                       , "徳島県", "香川県", "愛媛県", "高知県"
                                       , "福岡県", "佐賀県", "長崎県", "熊本県", "大分県", "宮崎県", "鹿児島県", "沖縄県" };

            foreach (string p in prefs)
            {
                if (address.StartsWith(p))
                {
                    Prefecture.Set(context, p);
                    AddressWithoutPrefecture.Set(context, p.Length < address.Length ? address.Substring(p.Length) : string.Empty);
                    return;
                }
            }

            // Not found from here.
            if (ThrowExceptionOnNoMatch.Get(context))
            {
                throw new ArgumentException("Prefecture No Match");
            }

            Prefecture.Set(context, string.Empty);
            AddressWithoutPrefecture.Set(context, address);
        }
Exemple #4
0
        private void SelectPrefecture(Prefecture prefecture)
        {
            Debug.WriteLine($"Prefecture: ID[{prefecture.ID}] Name[{prefecture.Name}]");
            Cities.Clear();
            foreach (var city in prefecture.Cities)
            {
                Cities.Add(city);
            }
            var schoolDistrictID = prefecture.SchoolDistrictId;

            SchoolDistricts.Clear();
            foreach (var schoolDistrict in AllSchoolDistricts)
            {
                if (schoolDistrict.ID == prefecture.SchoolDistrictId)
                {
                    foreach (var school in schoolDistrict.Schools)
                    {
                        school.TypeChoices = new List <string>
                        {
                            "Default",
                            "Night",
                            "Other",
                        };
                    }
                    SchoolDistricts.Add(schoolDistrict);
                }
            }
        }
Exemple #5
0
    public Prefecture targetPrefecture; //対象都道府県

    /// <summary>
    /// Itemクラスの初期化を実行します
    /// </summary>
    /// <param name="targetPrefecture">ターゲットの都道府県</param>
    /// <param name="name">Itemの名前</param>
    /// <param name="description">Itemの説明</param>
    /// <param name="attractiveness">Itemの魅力度</param>
    public void Set(Prefecture targetPrefecture, string name, string description, int attractiveness)
    {
        this.targetPrefecture = targetPrefecture;
        this.name             = name;
        this.description      = description;
        this.attractiveness   = attractiveness;
        price = 1000 * attractiveness + Random.Range(-500, 500);
    }
    public void LoadJsonData()
    {
        string Jsonstring = "";

#if !UNITY_EDITOR
        Task.Run(async() =>
        {
            UnityEngine.WSA.Application.InvokeOnAppThread(() =>
            {
                m_debugLogManager.DebugLogTextWrite("MyDebug:*****************1");
            }, false);

            var file = await KnownFolders.DocumentsLibrary.GetFileAsync("City.txt");

            UnityEngine.WSA.Application.InvokeOnAppThread(() =>
            {
                m_debugLogManager.DebugLogTextWrite("MyDebug:*****************2");
            }, false);

            Jsonstring = await FileIO.ReadTextAsync(file);

            using (var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(Jsonstring)))
            {
                var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(Prefecture));
                // クラスにデータを読み込む
                prefecture = serializer.ReadObject(stream) as Prefecture;
            }

            UnityEngine.WSA.Application.InvokeOnAppThread(() =>
            {
                m_debugLogManager.DebugLogTextWrite("MyDebug:*****************3");

                //prefecture = JsonUtility.FromJson<Prefecture>(Jsonstring);

                m_debugLogManager.DebugLogTextWrite("MyDebug:*****************4");
                m_debugLogManager.DebugLogTextWrite("MyDebug:" + prefecture.Cities.Count);
                m_debugLogManager.DebugLogTextWrite("MyDebug:" + prefecture.Cities[0].Name);
                m_debugLogManager.DebugLogTextWrite(Jsonstring);
            }, false);
        });
#else
        var textAsset = Resources.Load("City") as TextAsset;
        Jsonstring = textAsset.text;
        using (var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(Jsonstring)))
        {
            var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(Prefecture));
            // クラスにデータを読み込む
            prefecture = serializer.ReadObject(stream) as Prefecture;
        }
        //prefecture = JsonUtility.FromJson<Prefecture>(Jsonstring);

        m_debugLogManager.DebugLogTextWrite("MyDebug:" + prefecture.Cities.Count);
        m_debugLogManager.DebugLogTextWrite("MyDebug:" + prefecture.Cities[0].Name);
        m_debugLogManager.DebugLogTextWrite(Jsonstring);
#endif
    }
Exemple #7
0
        public static string GetShortName(this Prefecture pref)
        {
            var attr = pref.GetType().GetField(pref.ToString()).GetCustomAttribute <PrefectureNameAttribute>();

            if (attr == null)
            {
                return("不明");
            }
            return(attr.ShortName);
        }
Exemple #8
0
        public async Task <long> GetPrefecturePopulation(Prefecture prefecture)
        {
            List <PrefecturePopulation> populations =
                await this.prefecturePopulationRepository.GetPopulationForPrefecture(prefecture.iso);

            long totalPoluation = 0;

            populations.ForEach(elem => {
                totalPoluation = totalPoluation + long.Parse(elem.population);
            });

            return(totalPoluation);
        }
 private Prefecture Median(Prefecture x, Prefecture y, Prefecture z)
 {
     if (x.population.CompareTo(y.population) > 0)
     {
         Swap(ref x, ref y);
     }
     if (x.population.CompareTo(z.population) > 0)
     {
         Swap(ref x, ref z);
     }
     if (y.population.CompareTo(z.population) > 0)
     {
         Swap(ref x, ref z);
     }
     return(y);
 }
    //クイックソート
    private void QuickSort(Prefecture[] prefectures, int left, int right)
    {
        if (left >= right)
        {
            return;
        }

        Prefecture pivot = Median(
            prefectures[left],
            prefectures[(left + right) / 2],
            prefectures[right]
            );

        int i = left;
        int j = right;

        while (i <= j)
        {
            while (i < right && prefectures[i].population.CompareTo(pivot.population) > 0)
            {
                i++;
            }
            while (j > left && prefectures[j].population.CompareTo(pivot.population) < 0)
            {
                j--;
            }

            if (i >= j)
            {
                break;
            }
            Swap(ref prefectures[i], ref prefectures[j]);

            i++;
            j--;
        }

        QuickSort(prefectures, left, i - 1);
        QuickSort(prefectures, j + 1, right);
    }
        public PrefectureList(string body)
        {
            string[] lines = body._GetLines(true, true);

            int number = 0;

            foreach (string line in lines)
            {
                string[] tokens = line._Split(StringSplitOptions.None, ',');
                if (tokens.Length == 3)
                {
                    Prefecture p = new Prefecture(++number, tokens[0], tokens[1], tokens[2]);

                    _List.Add(p);
                }
            }

            foreach (var p in _List)
            {
                this._ByKanji.TryAdd(p.Kanji, p);
            }
        }
 /// <summary>
 /// 都道府県をクリックしたときの処理を実行します
 /// </summary>
 public void PrefectureClick(Prefecture prefecture)
 {
     if (playerState == PlayerState.Item)
     {
         prefecture.itemList.Add(pickUpItem);
         pickUpItem  = null;
         playerState = PlayerState.None;
         SelectItemDispController.gameObject.SetActive(false);
         DebugLog();
     }
     else if (playerState == PlayerState.None)
     {
         pickUpPrefecture = prefecture;
         playerState      = PlayerState.Prefecture;
         DebugLog();
     }
     else
     {
         pickUpPrefecture = prefecture;
         DebugLog();
     }
     PrefectureSelectController.SetSelectedPrefectureText(pickUpPrefecture?.prefectureName);
 }
 public AuthorsController(ListDetailDbContext context)
 {
     _context = context;
     Prefecture.Initialize(_context);
 }
Exemple #14
0
 public override string ToString()
 {
     return(Province?.ToString() + Prefecture?.ToString() + County?.ToString()
            + Township?.ToString() + Village?.ToString() + ResidentialGroup?.ToString()
            + Detail);
 }
Exemple #15
0
 public PeopleController(ApplicationDbConttext context)
 {
     _context = context;
     //初回のみ都道府県を挿入する
     Prefecture.Initialize(_context);
 }
 /// <summary>
 /// 選択中の都道府県をリセットします
 /// </summary>
 public void ResetPickUpPrefecture()
 {
     pickUpPrefecture = null;
     PrefectureSelectController.SetSelectedPrefectureText("");
 }
 public PeopleController(ApplicationDbContext context)
 {
     _context = context;
     // 都道府県テーブルの初期データ投入
     Prefecture.Initialize(_context);
 }
            public override int GetHashCode()
            {
                var hashCode = Prefecture.GetHashCode();

                return(hashCode);
            }
Exemple #19
0
        public async Task <PrefectureResult> GetPrefectureResult(Prefecture prefecture)
        {
            long totalPoluation = await GetPrefecturePopulation(prefecture);

            return(new PrefectureResult(prefecture, totalPoluation));
        }
 public PrefectureResult(Prefecture prefecture, long population)
 {
     this.population        = population;
     this.prefectureDetails = prefecture;
 }