Exemplo n.º 1
0
 public static void SetPropertiesFromYamlNode(object target, YamlNode componentYamlNode, INamingConvention nameConvertor)
 {
     foreach (PropertyInfo info in target.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
     {
         string key = nameConvertor.Apply(info.Name);
         if (componentYamlNode.HasValue(key) && info.CanWrite)
         {
             try
             {
                 info.SetValue(target, componentYamlNode.GetValue(key), null);
             }
             catch (ArgumentException)
             {
                 object[] args = new object[] { info.PropertyType, componentYamlNode.GetValue(key).GetType() };
                 UnityEngine.Debug.LogFormat("Can't convert to {0} from {1}", args);
             }
         }
     }
 }
Exemplo n.º 2
0
 private static void UpdateComponentData(Component component, YamlNode componentYamlNode, INamingConvention nameConvertor)
 {
     foreach (PropertyInfo info in component.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
     {
         string key = nameConvertor.Apply(info.Name);
         if (componentYamlNode.HasValue(key) && info.CanWrite)
         {
             info.SetValue(component, componentYamlNode.GetValue(key), null);
         }
     }
 }
Exemplo n.º 3
0
        public static string Localize(string uid)
        {
            YamlNode config = ConfigurationService.GetConfig(CONFIG_PATH);

            try
            {
                using (Dictionary <object, object> .Enumerator enumerator = ((Dictionary <object, object>)config.GetValue(uid)).GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        return((string)enumerator.Current.Value);
                    }
                }
                return(string.Empty);
            }
            catch (KeyNotFoundException)
            {
                return(string.Empty);
            }
        }