コード例 #1
0
        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 = CClassUtils.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
                {
                    CLog.e("Unable to register command: name={0} type={1}", commandName, type);
                }
            }

            return(null);
        }
コード例 #2
0
ファイル: CPlatform.cs プロジェクト: tonymtz/super-unity-bros
        private static CPlatformImpl CreateImpl()
        {
            try
            {
                if (Application.isEditor)
                {
                    Type type = CClassUtils.TypeForName(EditorPlatformType);
                    if (type != null)
                    {
                        return(CClassUtils.CreateInstance <CPlatformImpl>(type));
                    }
                    else
                    {
                        Debug.LogError("Can't find " + EditorPlatformType + " type");
                    }
                }

                return(new CPlatformDefault());
            }
            catch (MissingMethodException) // FIXME: I don't like this
            {
                // unit test running
                Type type = CClassUtils.TypeForName("LunarPluginInternal.CTestingPlatform");
                return(CClassUtils.CreateInstance <CPlatformImpl>(type));
            }
        }