コード例 #1
0
        public override void OnImportAsset(AssetImportContext ctx)
        {
            byte[] data = Tools.Load(ctx.assetPath);
            string json = System.Text.UTF8Encoding.UTF8.GetString(data);

            LitJson.JsonData jsonData = Tools.DeserializeObject(json);
            mJsonList = new List <StringStringDictionary>();
            for (int i = 0; i < jsonData.Count; i++)
            {
                LitJson.JsonData       tmp  = jsonData[i];
                StringStringDictionary dict = new StringStringDictionary();
                IEnumerator            ite  = jsonData[i].Keys.GetEnumerator();
                while (ite.MoveNext())
                {
                    string key   = ite.Current.ToString();
                    string value = tmp[key].ToString();
                    dict.Add(key, value);
                }
                mJsonList.Add(dict);
            }

            string fileName = Path.GetFileNameWithoutExtension(ctx.assetPath);
            Object asset    = AssetDatabase.LoadAssetAtPath(ctx.assetPath, typeof(Object));

            ctx.AddObjectToAsset(fileName, asset);
            ctx.SetMainObject(asset);
        }
コード例 #2
0
ファイル: XD1100DevicePersister.cs プロジェクト: hkiaipc/C3
        /// <summary>
        /// 
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        private static string GetExtend(XD1100Device d)
        {
            StringStringDictionary ssDict = new StringStringDictionary();
            ssDict["HtmMode"] = d.HtmMode.ModeValue.ToString();

            string extend = StringStringDictionaryConverter.ToString(ssDict);
            return extend;
        }
コード例 #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public static string ToString(StringStringDictionary parameterHashtable)
 {
     string s = string.Empty;
     foreach ( string key in parameterHashtable.Keys )
     {
         s += string.Format("{0}={1};", key, parameterHashtable[key]);
     }
     return s;
 }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        static public string ToString(StringStringDictionary parameterHashtable)
        {
            string s = string.Empty;

            foreach (string key in parameterHashtable.Keys)
            {
                s += string.Format("{0}={1};", key, parameterHashtable[key]);
            }
            return(s);
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        private static string GetExtend(XD1100Device d)
        {
            StringStringDictionary ssDict = new StringStringDictionary();

            ssDict["HtmMode"] = d.HtmMode.ModeValue.ToString();

            string extend = StringStringDictionaryConverter.ToString(ssDict);

            return(extend);
        }
コード例 #6
0
        public void SetUp()
        {
            _dictionary = new StringStringDictionary();
            _readOnly   = _dictionary.AsReadOnly();
            Assert.AreEqual(0, _dictionary.Count);

            _dictionary.Add("one", "first value");
            _dictionary.Add("two", "second value");
            _dictionary.Add("three", "third value");
            Assert.AreEqual(3, _dictionary.Count);
        }
コード例 #7
0
        public void Constructor()
        {
            StringStringDictionary dictionary = new StringStringDictionary();

            dictionary.Add("foo", "foo value");
            dictionary.Add("bar", "bar value");
            Assert.AreEqual(2, dictionary.Count);

            StringStringDictionary clone = new StringStringDictionary(dictionary);

            Assert.AreEqual(2, clone.Count);
        }
コード例 #8
0
    public StringStringDictionary getFields()
    {
        StringStringDictionary fields = StringStringDictionary.New <StringStringDictionary>();

        fields.dictionary.Add("x", gameObject.transform.position.x + "");
        fields.dictionary.Add("y", gameObject.transform.position.y + "");
        fields.dictionary.Add("xv", initialForces.x + "");
        fields.dictionary.Add("yv", initialForces.y + "");
        fields.dictionary.Add("mass", rigidbody.mass + "");
        fields.dictionary.Add("col", "#" + ColorUtility.ToHtmlStringRGB(col));
        return(fields);
    }
コード例 #9
0
        public void Clone()
        {
            StringStringDictionary clone = (StringStringDictionary)_readOnly.Clone();

            Assert.IsFalse(clone.IsReadOnly);

            Assert.AreEqual(_dictionary.Count, clone.Count);
            foreach (StringStringPair item in clone)
            {
                Assert.IsTrue(_dictionary.Contains(item));
                Assert.AreEqual(_dictionary[item.Key], item.Value);
                Assert.AreSame(_dictionary[item.Key], item.Value);
            }
        }
コード例 #10
0
        public void Copy()
        {
            StringStringDictionary copy = _readOnly.Copy();

            Assert.IsFalse(copy.IsReadOnly);

            Assert.AreEqual(_dictionary.Count, copy.Count);
            foreach (StringStringPair item in copy)
            {
                Assert.IsTrue(_dictionary.Contains(item));
                Assert.AreEqual(_dictionary[item.Key], item.Value);
                Assert.AreNotSame(_dictionary[item.Key], item.Value);
            }
        }
コード例 #11
0
        public void AddRange()
        {
            StringStringDictionary dictionary = new StringStringDictionary();

            dictionary.Add(new StringStringPair("four", "fourth value"));
            dictionary.Add(new StringStringPair("five", "fifth value"));

            Assert.Throws <NotSupportedException>(() => _readOnly.AddRange(dictionary));
            _dictionary.AddRange(dictionary);

            Assert.AreEqual(5, _dictionary.Count);
            Assert.IsTrue(_dictionary.ContainsKey("four"));
            Assert.IsTrue(_dictionary.ContainsValue("fourth value"));
            Assert.IsTrue(_dictionary.ContainsKey("five"));
            Assert.IsTrue(_dictionary.ContainsValue("fifth value"));

            Assert.Throws <ArgumentException>(() => _dictionary.AddRange(dictionary));
        }
コード例 #12
0
        public void Equals()
        {
            StringStringDictionary dictionary = new StringStringDictionary();

            dictionary.Add("one", "first value");
            dictionary.Add("two", "second value");
            dictionary.Add("three", "third value");
            Assert.IsTrue(_dictionary.Equals(dictionary));

            dictionary["two"] = "foo value";
            Assert.IsFalse(_dictionary.Equals(dictionary));

            dictionary["two"] = "second value";
            Assert.IsTrue(_dictionary.Equals(dictionary));

            dictionary["foo"] = "second value";
            Assert.IsFalse(_dictionary.Equals(dictionary));
        }
コード例 #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static StringStringDictionary Parse(string s)
        {
            StringStringDictionary  ht = new StringStringDictionary();
            string[] pairs = s.Split(ItemSplitChar);
            foreach (string pair in pairs)
            {
                string[] kv = pair.Split(KeyValueSplitChar);
                if (kv.Length == 2)
                {
                    string k = kv[0].Trim ();
                    string v = kv[1].Trim ();

                    if (k.Length > 0)
                    {
                        ht[k] = v;
                    }
                }
            }
            return ht;
        }
コード例 #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="deviceExtendParameters"></param>
        /// <returns></returns>
        private FluxPlace GetFluxPlace(string deviceExtendParameters)
        {
            FluxPlace p = FluxPlace.Unknown;
            StringStringDictionary ssd = StringStringDictionaryConverter.Parse(deviceExtendParameters);

            if (ssd.ContainsKey(PlaceDeviceBase.PN_FLUXPLACE))
            {
                string place = ssd[PlaceDeviceBase.PN_FLUXPLACE];

                try
                {
                    p = (FluxPlace)Enum.Parse(typeof(FluxPlace), place);
                }
                catch (Exception ex)
                {
                    log.Error(ex.ToString());
                }
            }
            return(p);
        }
コード例 #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        static public StringStringDictionary Parse(string s)
        {
            StringStringDictionary ht = new StringStringDictionary();

            string[] pairs = s.Split(ItemSplitChar);
            foreach (string pair in pairs)
            {
                string[] kv = pair.Split(KeyValueSplitChar);
                if (kv.Length == 2)
                {
                    string k = kv[0].Trim();
                    string v = kv[1].Trim();

                    if (k.Length > 0)
                    {
                        ht[k] = v;
                    }
                }
            }
            return(ht);
        }
コード例 #16
0
 public ScriptableObjectDatabase()
 {
     m_DbDictionary = StringStringDictionary.New <StringStringDictionary>();
 }
コード例 #17
0
 public void TearDown()
 {
     _dictionary.Clear();
     _dictionary = null;
 }
コード例 #18
0
ファイル: User.cs プロジェクト: Aestial/Fisiomed
 public UserData()
 {
     properties = new StringStringDictionary();
     progress   = new IntStringDictionary();
 }
コード例 #19
0
    IEnumerator DoActionGetInfo()
    {
        GoogleSheetReader _googleSheetReader = new GoogleSheetReader(googleSheetAppID, spreadSheetID);

        Debug.Log("Load Key Localize From Google!!!");
        yield return(_googleSheetReader.Load(fromCell, toCell, sheetID));

        var _value = _googleSheetReader.GetValues();

        Debug.Log("Start Load Key: " + _googleSheetReader.rawResult);
        listDetail = new List <string>();
        for (int i = 0; i < _value.Count; i++)
        {
            for (int j = 0; j < _value[i].Count; j++)
            {
                string _tmp = _value[i][j].Value;
                if (string.IsNullOrEmpty(_tmp))
                {
                    Debug.LogError("Bug : i = " + i + " + j = " + j);
                    yield break;
                }
                if (_tmp.Equals("NULL"))
                {
                    listDetail.Add(string.Empty);
                    continue;
                }
                // _tmp = _tmp.ToLower();
                _tmp = _tmp.TrimStart();
                _tmp = _tmp.TrimEnd();
                // _tmp = _tmp.Replace("%", string.Empty);
                listDetail.Add(_tmp);
            }
        }

        if (listDetail == null || listDetail.Count == 0)
        {
            Debug.Log("listDetail is null!!!");
            yield break;
        }

        myListLocalizeInfo.localize_En.store = StringStringDictionary.New <StringStringDictionary>();

        for (int i = 0; i < listDetail.Count; i++)
        {
            string[] _fields = listDetail[i].Split('#');
            if (_fields == null || _fields.Length == 0)
            {
                continue;
            }
            string _nameSheet = _fields[0];
            for (int j = 1; j < _fields.Length; j++)
            {
                if (string.IsNullOrEmpty(_fields[j]))
                {
                    Debug.LogWarning("Skip At Index : " + i + " with detail : " + j);
                    break;
                }
                string[] _fields_01 = _fields[j].Split(';');
                if (_fields_01 == null || _fields_01.Length == 0)
                {
                    continue;
                }
                string _key     = _fields_01[0];
                string _valueEN = _fields_01[1];
                myListLocalizeInfo.localize_En.store.dictionary.Add(_nameSheet + "/" + _key, _valueEN);
            }
        }

        UnityEditor.EditorUtility.SetDirty(myListLocalizeInfo.localize_En);

        Debug.Log("Completed!!!");
    }