private static CCommand ResolveCommand(Type type)
        {
            CCommandAttribute cmdAttr = GetCustomAttribute <CCommandAttribute>(type);

            if (cmdAttr != null)
            {
                string commandName = cmdAttr.Name;
                if (!IsCorrectPlatform(cmdAttr.Flags))
                {
                    Debug.LogWarning("Skipping command: " + commandName);
                    return(null);
                }

                CCommand command = ClassUtils.CreateInstance <CCommand>(type);
                if (command != null)
                {
                    command.Name        = commandName;
                    command.Description = cmdAttr.Description;
                    if (cmdAttr.Values != null)
                    {
                        command.Values = cmdAttr.Values.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    }
                    command.Flags |= cmdAttr.Flags;
                    ResolveOptions(command);

                    return(command);
                }
                else
                {
                    Log.e("Unable to register command: name={0} type={1}", commandName, type);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        private static PlatformImpl CreateImpl()
        {
            try
            {
                if (Application.isEditor)
                {
                    Type type = ClassUtils.TypeForName(EditorPlatformType);
                    if (type != null)
                    {
                        return(ClassUtils.CreateInstance <PlatformImpl>(type));
                    }
                    else
                    {
                        Debug.LogError("Can't find " + EditorPlatformType + " type");
                    }
                }

                return(new PlatformDefault());
            }
            catch (MissingMethodException) // FIXME: I don't like this
            {
                // unit test running
                Type type = ClassUtils.TypeForName("LunarPluginInternal.TestingPlatform");
                return(ClassUtils.CreateInstance <PlatformImpl>(type));
            }
        }
Ejemplo n.º 3
0
        internal void Init(Object sender, string name, params object[] pairs)
        {
            Sender = sender;
            Name   = name;

            Assert.IsTrue(pairs.Length % 2 == 0);
            for (int i = 0; i < pairs.Length;)
            {
                string key   = ClassUtils.Cast <string>(pairs [i++]);
                object value = pairs [i++];

                this.Set(key, value);
            }
        }
Ejemplo n.º 4
0
 public T UserData <T>() where T : class
 {
     return(ClassUtils.Cast <T>(userData));
 }