Beispiel #1
0
        public void ResourceProxy_should_use_result_from_translate_func()
        {
            var proxy = new ResourcesProxy(text =>
            {
                _output.WriteLine(text);
                return("lala");
            });

            proxy.Command_help_description.Should().Be("lala");
            proxy.Parse_Assigning_value_to_argument("a", "b").Should().Be("lala");
        }
Beispiel #2
0
        public void ResourceProxy_uses_base_when_translate_func_returns_null()
        {
            var proxy = new ResourcesProxy(text =>
            {
                _output.WriteLine(text);
                return(null);
            });
            var resources = new Resources();

            proxy.Command_help_description.Should().Be(resources.Command_help_description);
            proxy.Parse_Assigning_value_to_argument("a", "b")
            .Should().Be(resources.Parse_Assigning_value_to_argument("a", "b"));
        }
 /// <summary>
 /// Initializes new instance of <see cref="LocalizedDescriptionAttribute"/> with localized description defined by passed <see cref="description"/>
 /// </summary>
 /// <param name="description">Translation key value.</param>
 public LocalizedDescriptionAttribute(string description)
     : base(ResourcesProxy.GetString(description))
 {
     LocalizationKey = description;
 }
Beispiel #4
0
        public void ReadXml(ref Dictionary <int, XmlDataList> dict)
        {
#if UNITY_EDITOR
            if (File.Exists(m_XmlPathInEditor))
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc = new XmlDocument();
                xmlDoc.Load(m_XmlPathInEditor);
                XmlElement root = xmlDoc.SelectSingleNode(sRoot) as XmlElement;
                if (root == null)
                {
                    return;
                }

                foreach (XmlElement xml_data in root)
                {
                    if (xml_data == null)
                    {
                        continue;
                    }

                    XmlDataList _data = new XmlDataList();
                    _data.iIndex    = Convert.ToInt32(xml_data.GetAttribute(iIndex));
                    _data.sDescribe = xml_data.GetAttribute(sDes);

                    foreach (XmlElement xml_class in xml_data)
                    {
                        XmlClassData _class = new XmlClassData();
                        _class.sLogicName = xml_class.LocalName;

                        foreach (XmlElement xml_property in xml_class)
                        {
                            XmlParamItem _property = new XmlParamItem();
                            _property.sName  = xml_property.LocalName;
                            _property.sType  = xml_property.GetAttribute("Type");
                            _property.sValue = xml_property.InnerText;

                            _class.Add(_property);
                        }

                        _data.Add(_class);
                    }

                    if (dict.ContainsKey(_data.iIndex))
                    {
                        dict.Remove(_data.iIndex);
                    }
                    dict.Add(_data.iIndex, _data);
                }
            }
#else
            string strFileCon = ResourcesProxy.LoadTextString(m_XmlFilePath);
            if (string.IsNullOrEmpty(strFileCon))
            {
                return;
            }

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc = new XmlDocument();
            try
            {
                byte[]       buffer = System.Text.Encoding.UTF8.GetBytes(strFileCon);
                MemoryStream ms     = new MemoryStream(buffer);
                xmlDoc.Load(ms);
            }
            catch (XmlException e)
            {
                Log.Debug("LoadDefine error!");
                Log.Debug("line : " + e.LineNumber + " pos : " + e.LinePosition);
                Log.Debug("reason : " + e.Message);
            }

            XmlElement root = xmlDoc.SelectSingleNode(sRoot) as XmlElement;
            if (root == null)
            {
                return;
            }

            foreach (XmlElement xml_data in root)
            {
                if (xml_data == null)
                {
                    continue;
                }

                XmlDataList _data = new XmlDataList();
                _data.iIndex    = Convert.ToInt32(xml_data.GetAttribute(iIndex));
                _data.sDescribe = xml_data.GetAttribute(sDes);

                foreach (XmlElement xml_class in xml_data)
                {
                    XmlClassData _class = new XmlClassData();
                    _class.sLogicName = xml_class.LocalName;

                    foreach (XmlElement xml_property in xml_class)
                    {
                        XmlParamItem _property = new XmlParamItem();
                        _property.sName  = xml_property.LocalName;
                        _property.sType  = xml_property.GetAttribute("Type");
                        _property.sValue = xml_property.InnerText;

                        _class.Add(_property);
                    }

                    _data.Add(_class);
                }

                if (dict.ContainsKey(_data.iIndex))
                {
                    dict.Remove(_data.iIndex);
                }
                dict.Add(_data.iIndex, _data);
            }
#endif
        }