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);
        }
예제 #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));
            }
        }
예제 #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);
            }
        }
예제 #4
0
 public T UserData <T>() where T : class
 {
     return(ClassUtils.Cast <T>(userData));
 }