Example #1
0
            /// <summary>
            /// appends exception message of <paramref name="exception"/>to specified exception message
            /// string builder, indentated by a number of TABs specified by <paramref name="exceptionInnerLevel"/>.
            /// in addition, if <paramref name="exception"/>has an inner exception, appends its exception message as
            /// well.
            /// </summary>
            /// <remarks>
            /// exception message of <paramref name="exception"/>'s inner exception is constructed recursively
            /// so that it contains the messages of all exceptions in the inner exception chain.
            /// </remarks>
            /// <param name="exception"></param>
            /// <param name="exceptionMessageStringBuilder"></param>
            /// <param name="exceptionInnerLevel"></param>
            private static void appendExceptionMessageString(
                Exception exception,
                StringBuilder exceptionMessageStringBuilder,
                int exceptionInnerLevel)
            {
                // append exception message lines with indentation
                String[] exceptionMessageLines = exception.Message.Split(Environment.NewLine);

                for (int i = 0; i < exceptionMessageLines.Length; i++)
                {
                    string exceptionMessageLine = exceptionMessageLines[i];

                    // add indentation corresponding to exception inner level
                    StringUtils.Append(
                        exceptionMessageStringBuilder,
                        StringUtils.TabString,
                        exceptionInnerLevel);
                    exceptionMessageStringBuilder.Append(exceptionMessageLine);

                    if (i < exceptionMessageLines.Length - 1)
                    {
                        exceptionMessageStringBuilder.Append(Environment.NewLine);
                    }
                }

                // append inner exception if exists
                if (exception.InnerException != null)
                {
                    exceptionMessageStringBuilder.Append(Environment.NewLine);

                    appendExceptionMessageString(
                        exception.InnerException,
                        exceptionMessageStringBuilder,
                        exceptionInnerLevel + 1);
                }
            }
Example #2
0
    //[MenuItem(kBuildAssetBundlesMenu)]
    public static void BuildAssetBundles(BuildTarget buildTarget, List <string> buildingAssets = null)
    {
        Debug.Log("Start Build Assetbundles");

        //ProjectBuilder.SetBuildVersion_fromEnvVariable();
        // Choose the output path according to the build target.
        string outputPath = Path.Combine(kAssetBundlesOutputPath, BaseLoader.GetPlatformFolderForAssetBundles(buildTarget));

        if (!Directory.Exists(outputPath))
        {
            Directory.CreateDirectory(outputPath);
        }

        string[]        existingFilesPath = Directory.GetFiles(outputPath);
        List <FileInfo> existingFiles     = new List <FileInfo>();

        if (existingFilesPath != null)
        {
            for (int i = 0; i < existingFilesPath.Length; ++i)
            {
                FileInfo eachFile = new FileInfo(existingFilesPath[i]);
                existingFiles.Add(eachFile);
            }
        }


        //total assets
        string[] bundles = AssetDatabase.GetAllAssetBundleNames();

        AssetBundleManifest totalManifest;

        //BuildPipeline.BuildAssetBundles (outputPath, 0, EditorUserBuildSettings.activeBuildTarget);
        if (buildingAssets == null || buildingAssets.Count <= 0)
        {
            totalManifest =
                BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.None, buildTarget);   // hash값 유지?
        }
        else if (bundles != null)
        {
            List <AssetBundleBuild> tempListBundles = new List <AssetBundleBuild>();

            for (int i = 0; i < buildingAssets.Count; ++i)
            {
                bool isRightAssetName = false;
                for (int j = 0; j < bundles.Length; ++j)
                {
                    if (bundles[j].Equals(buildingAssets[i]) == true)
                    {
                        isRightAssetName = true;
                        break;
                    }
                }

                if (isRightAssetName == true)
                {
                    AssetBundleBuild newStructInfo = new AssetBundleBuild();
                    newStructInfo.assetBundleName = buildingAssets[i];
                    newStructInfo.assetNames      = AssetDatabase.GetAssetPathsFromAssetBundle(buildingAssets[i]);

                    tempListBundles.Add(newStructInfo);
                }
            }

            AssetBundleBuild[] arrBundles = tempListBundles.ToArray();
            totalManifest =
                BuildPipeline.BuildAssetBundles(outputPath, arrBundles, BuildAssetBundleOptions.None, buildTarget);
        }
        else
        {
            Debug.LogError("There is no assetbundle to build");
            return;
        }

        string deviceManifestPath = Path.Combine(outputPath, buildTarget.ToString());
        uint   deviceCRC          = 0;

        BuildPipeline.GetCRCForAssetBundle(deviceManifestPath, out deviceCRC);
        FileInfo totalManiFile = new FileInfo(deviceManifestPath);

        //total manifest
        stAssetInfo totalAssetManifest = new stAssetInfo();

        totalAssetManifest.Name     = buildTarget.ToString();
        totalAssetManifest.CRC      = deviceCRC;
        totalAssetManifest.FileSize = totalManiFile.Length;
        //each assets
        string[] BuiltBundles = totalManifest.GetAllAssetBundles();

        List <stAssetInfo> listAssetInfo = new List <stAssetInfo>();

        listAssetInfo.Add(totalAssetManifest);

        if (BuiltBundles == null)
        {
            Debug.LogError("bundles is null");
            return;
        }

        int invalidCount = 0;

        for (int i = 0; i < BuiltBundles.Length; ++i)
        {
            //어셋 파일 존재 검증
            string targetPath = Path.Combine(outputPath, BuiltBundles[i]);
            if (File.Exists(targetPath) == false)
            {
                invalidCount++;
                Debug.LogError(BuiltBundles[i] + " is not exist");
            }
        }

        if (invalidCount > 0)
        {
            return;
        }

        string buildTargetBundle   = buildTarget.ToString();
        string buildTargetManifest = buildTargetBundle + ".manifest";

        IEnumerable <FileInfo> deleteTarget = existingFiles.Where(
            (fileInfo) =>
        {
            if (fileInfo.Name.Equals(buildTargetBundle) || fileInfo.Name.Equals(buildTargetManifest) || fileInfo.Name.Equals("patch.xml"))
            {
                return(false);
            }

            IEnumerable <string> foundBundles = from bundleName in bundles
                                                where (fileInfo.Name.Equals(bundleName) || fileInfo.Name.Equals(StringUtils.Append(bundleName, ".manifest")))
                                                select bundleName;

            if (foundBundles.Count() > 0)
            {
                return(false);
            }

            return(true);
        }
            );

        Debug.Log("Start Delete non-asset files");
        foreach (FileInfo deleteFile in deleteTarget)
        {
            Debug.Log("Deleting " + deleteFile.Name + " ......");
            deleteFile.Delete();
        }

        for (int i = 0; i < bundles.Length; ++i)
        {
            stAssetInfo newInfo = new stAssetInfo();

            string bundleName = bundles[i];

            string targetPath = Path.Combine(outputPath, bundleName);
            uint   crc        = 0;
            if (BuildPipeline.GetCRCForAssetBundle(targetPath, out crc) == true)
            {
                FileInfo assetFile = new FileInfo(targetPath);

                newInfo.Name     = bundleName;
                newInfo.CRC      = crc;
                newInfo.FileSize = assetFile.Length;

                listAssetInfo.Add(newInfo);
            }
        }

        VersionXML.MakeVersionFile(deviceCRC, outputPath, listAssetInfo);

        Debug.Log("End Build Assetbundles");
    }
Example #3
0
            /// <summary>
            /// prints <see cref="CoinTicker"/> data corresponding to coin name / symbols
            /// contained in <paramref name="commandArguments"/> in tabular format.
            /// returns whether command was executed successfully.
            /// </summary>
            /// <seealso cref="CoinListingManager.FetchCoinIds(string[])"/>
            /// <seealso cref="CoinTickerManager.GetCoinTickerDisplayTableString(int[])"/>
            /// <param name="commandArguments"></param>
            protected override bool Execute(string[] commandArguments)
            {
                bool commandExecutedSuccessfuly;

                try
                {
                    // fetch coin ids corresponding to coin names / symbols
                    long[] coinIds = CoinListingManager.Instance.FetchCoinIds(commandArguments);

                    // only coin ids which corresponding ticker entry in ticker manager
                    // has been initialized are displayed
                    List <int>    coinIdsWithInitalizedTicker      = new List <int>();
                    List <string> coinNamesWithoutInitalizedTicker = new List <string>();

                    // get coin ids with initialized ticker data
                    foreach (int coinId in coinIds)
                    {
                        if (CoinTickerManager.Instance.HasCoinTicker(coinId))
                        {
                            coinIdsWithInitalizedTicker.Add(coinId);
                        }
                        else
                        {
                            string coinName = CoinListingManager.Instance.GetCoinNameById(coinId);
                            coinNamesWithoutInitalizedTicker.Add(coinName);
                        }
                    }

                    if (coinIdsWithInitalizedTicker.Count > 0)
                    {
                        // print coin listing display table containing coin listings corresponding
                        // to fetched coin ids
                        string coinTickerTableString =
                            CoinTickerManager.Instance.GetCoinTickerDisplayTableString(
                                coinIdsWithInitalizedTicker.ToArray());
                        ConsoleIOManager.Instance.PrintData(
                            coinTickerTableString,
                            ConsoleIOManager.eOutputReportType.CommandExecution);
                    }

                    // if data for coin ids with uninitialized tickers was requested,
                    // display an appropriate message to user
                    if (coinNamesWithoutInitalizedTicker.Count > 0)
                    {
                        string errorMessage = StringUtils.Append(
                            "Coin ticker data for the following coin(s) was not yet initialized: ",
                            ", ",
                            coinNamesWithoutInitalizedTicker.ToArray())
                                              + ".";
                        ConsoleIOManager.Instance.LogError(
                            errorMessage,
                            ConsoleIOManager.eOutputReportType.CommandExecution);
                    }

                    commandExecutedSuccessfuly = true;
                }
                catch (CoinListingManager.CoinNameOrSymbolNotFoundException coinNameOrSymbolNotFoundException)
                {
                    ConsoleIOManager.Instance.LogError(
                        coinNameOrSymbolNotFoundException.Message,
                        ConsoleIOManager.eOutputReportType.CommandExecution);
                    commandExecutedSuccessfuly = false;
                }

                return(commandExecutedSuccessfuly);
            }
Example #4
0
            /// <summary>
            /// prints portfolio data corresponding to coin name / symbols
            /// contained in <paramref name="commandArguments"/> (or all coins in portfolio if
            /// <paramref name="commandArguments"/>.Length == 0) in tabular format.
            /// returns whether command was executed successfully.
            /// </summary>
            /// <seealso cref="CoinListingManager.FetchCoinIds(string[])"/>
            /// <seealso cref="PortfolioManager.GetPortfolioEntryDisplayTableString(int[])"/>
            /// <param name="commandArguments"></param>
            protected override bool Execute(string[] commandArguments)
            {
                bool commandExecutedSuccessfuly;

                try
                {
                    // only coin ids which have a corresponding portfolio entry are displayed
                    List <long>   coinIdsWithPortfolioEntry      = new List <long>();
                    List <string> coinNamesWithoutPortfolioEntry = new List <string>();

                    if (commandArguments.Length == 0)
                    {
                        // if no command args are provided, display all entries in portfolio
                        long[] allCoinIdsInPortfolio = PortfolioManager.Instance.CoinIds;
                        coinIdsWithPortfolioEntry.AddRange(allCoinIdsInPortfolio);
                    }
                    else // single / multiple PortfolioEntry s
                    {
                        // fetch coin ids corresponding to coin names / symbols
                        long[] coinIds = CoinListingManager.Instance.FetchCoinIds(commandArguments);

                        // get coin ids with initialized ticker data
                        foreach (int coinId in coinIds)
                        {
                            if (PortfolioManager.Instance.IsInPortfolio(coinId))
                            {
                                coinIdsWithPortfolioEntry.Add(coinId);
                            }
                            else
                            {
                                string coinName = CoinListingManager.Instance.GetCoinNameById(coinId);
                                coinNamesWithoutPortfolioEntry.Add(coinName);
                            }
                        }
                    }
                    if (coinIdsWithPortfolioEntry.Count == 0) // no PortfolioEntries to display
                    {
                        string noticeMessage = "No portfolio entries to display.";
                        ConsoleIOManager.Instance.LogNotice(
                            noticeMessage,
                            ConsoleIOManager.eOutputReportType.CommandExecution);
                    }
                    else if (coinIdsWithPortfolioEntry.Count == 1) // a single PortfolioEntry
                    {
                        // print PortfolioEntry's detailed data string
                        long           portfolioEntryCoinId = coinIdsWithPortfolioEntry[0];
                        PortfolioEntry portfolioEntry       =
                            PortfolioManager.Instance.GetPortfolioEntry(portfolioEntryCoinId);
                        ConsoleIOManager.Instance.PrintData(
                            portfolioEntry.GetDetailedString(),
                            ConsoleIOManager.eOutputReportType.CommandExecution);
                    }

                    if (coinIdsWithPortfolioEntry.Count > 1) // // multiple PortfolioEntries requested
                    {
                        // print coin PortfolioEntry display table containing portfolio entries corresponding
                        // to fetched coin ids
                        string portfolioEntryDisplayTableString =
                            PortfolioManager.Instance.GetPortfolioEntryDisplayTableString(
                                coinIdsWithPortfolioEntry.ToArray());
                        ConsoleIOManager.Instance.PrintData(
                            portfolioEntryDisplayTableString,
                            ConsoleIOManager.eOutputReportType.CommandExecution);
                    }

                    // if data for coin ids which don't have corresponding porfolio entries was requested,
                    // display an appropriate message to user
                    if (coinNamesWithoutPortfolioEntry.Count > 0)
                    {
                        string noticeMessage = StringUtils.Append(
                            "Following coin(s) were not in portfolio: ",
                            ", ",
                            coinNamesWithoutPortfolioEntry.ToArray())
                                               + ".";
                        ConsoleIOManager.Instance.LogNotice(
                            noticeMessage,
                            ConsoleIOManager.eOutputReportType.CommandExecution);
                    }

                    commandExecutedSuccessfuly = true;
                }
                // user specified coin names / symbols which don't exist in CoinListingManager
                catch (CoinListingManager.CoinNameOrSymbolNotFoundException coinNameOrSymbolNotFoundException)
                {
                    ConsoleIOManager.Instance.LogError(
                        coinNameOrSymbolNotFoundException.Message,
                        ConsoleIOManager.eOutputReportType.CommandExecution);
                    commandExecutedSuccessfuly = false;
                }
                catch (DatabaseCommunicationException databaseCommunicationException)
                {
                    PortfolioCommand.HandleDatabaseCommunicationException(databaseCommunicationException);
                    commandExecutedSuccessfuly = false;
                }

                return(commandExecutedSuccessfuly);
            }