CopyTrackedBundleVersionInfo() public static méthode

public static CopyTrackedBundleVersionInfo ( ) : bool
Résultat bool
Exemple #1
0
    public override string GenerateCode()
    {
        object trackedBundleVersionInfo = CreateInstance("TrackedBundleVersionInfo");

        if (trackedBundleVersionInfo == null)
        {
            if (!BundleVersionChecker.CopyTrackedBundleVersionInfo())
            {
                // doesn't make sense without TrackedBundleVersionInfo
                return(null);
            }
        }
        int       versionInfoIndex = 0;
        ArrayList history          = GetHistoryFromLastVersionObject();
        string    oldVersionsToAdd = "";
        string    code             = Line(0, "using System.Collections;", 2);

        code += Line(0, "public class " + className);
        code += Line(0, "{");
        code += Line(1, "public static readonly string bundleIdentifier = \"" + bundleIdentifier + "\";", 2);
        if (history != null)
        {
            foreach (object versionObject in history)
            {
                string trackedVersion = GetVersionFromVersionInfoObject(versionObject);
                string f = FormatVersionConstantNames(trackedVersion);
                code += Line(1, "public static readonly TrackedBundleVersionInfo " + f +
                             " =  new TrackedBundleVersionInfo (\"" + trackedVersion + "\", " + versionInfoIndex + ");");
                oldVersionsToAdd += Line(2, "history.Add (" + f + ");");
                versionInfoIndex++;
            }
        }
        // Add a constant for the current label too:
        code += Line(1, "public static readonly TrackedBundleVersionInfo " + FormatVersionConstantNames(bundleVersion) +
                     " =  new TrackedBundleVersionInfo (\"" + bundleVersion + "\", " + versionInfoIndex + ");");
        code += Line(1, "");
        code += Line(1, "public ArrayList history = new ArrayList ();", 2);
        code += Line(1, "public TrackedBundleVersionInfo " + Current + " = new TrackedBundleVersionInfo (\"" + bundleVersion +
                     "\", " + versionInfoIndex + ");", 2);
        code += Line(1, "public  " + className + "() {");
        code += oldVersionsToAdd;
        code += Line(2, "history.Add (" + Current + ");");
        code += Line(1, "}", 2);
        code += "}";
        return(code);
    }
    public override string GenerateCode()
    {
        object trackedBundleVersionInfoObject = CreateInstance("TrackedBundleVersionInfo");

        if (trackedBundleVersionInfoObject == null)
        {
            // we are creating TrackedBundleVersion.cs the very first time
            if (!BundleVersionChecker.CopyTrackedBundleVersionInfo())
            {
                // doesn't make sense without TrackedBundleVersionInfo
                return(null);
            }
        }
        int       versionInfoIndex = 0;
        ArrayList history          = GetHistoryFromLastVersionObject();
        string    oldVersionsToAdd = "";
        string    code             = Line(0, "using System.Collections;", 2);

        code += Line(0, "// GENERATED CODE.");
        code += Line(0, "public class " + className);
        code += Line(0, "{");
        code += Line(1, "public static readonly string bundleIdentifier = \"" + bundleIdentifier + "\";", 2);
        string currentVersionInfoName  = null;
        int    currentVersionInfoIndex = -1;

        if (history != null)
        {
            foreach (object versionObject in history)
            {
                string trackedVersion = GetVersionFromVersionInfoObject(versionObject);
                string f = string.Format("{0}_{1}", FormatVersionConstantNames(trackedVersion), versionInfoIndex);
                code += Line(1, "public static readonly TrackedBundleVersionInfo " + f +
                             " =  new TrackedBundleVersionInfo (\"" + trackedVersion + "\", " + versionInfoIndex + ");");
                oldVersionsToAdd += Line(2, "history.Add (" + f + ");");
                if (trackedVersion == bundleVersion)
                {
                    currentVersionInfoName  = f;
                    currentVersionInfoIndex = versionInfoIndex;
                }
                versionInfoIndex++;
            }
        }
        if (currentVersionInfoIndex < 0 || currentVersionInfoName == null)
        {
            // Add a constant for the current label too:
            currentVersionInfoName = string.Format("{0}_{1}", FormatVersionConstantNames(bundleVersion), versionInfoIndex);
            code += Line(1, "public static readonly TrackedBundleVersionInfo " + currentVersionInfoName +
                         " =  new TrackedBundleVersionInfo (\"" + bundleVersion + "\", " + versionInfoIndex + ");");
            currentVersionInfoIndex = versionInfoIndex;
        }
        code += Line(1, "");
        code += Line(1, "public static readonly TrackedBundleVersion Instance = new TrackedBundleVersion ();", 2);
        code += Line(1, "public static TrackedBundleVersionInfo Current { get { return Instance.current; } }", 2);
        // TODO_kay: Workaround to get current Android bundleVersionCode, provide historic information in the future
        code += Line(1, "public static int CurrentBuildVersion { get { return " + PlayerSettings.Android.bundleVersionCode + "; } }", 2);

        code += Line(1, "public ArrayList history = new ArrayList ();", 2);
        code += Line(1, "public TrackedBundleVersionInfo " + Current + " = " + currentVersionInfoName + ";", 2);
        code += Line(1, "public  " + className + "() {");
        code += oldVersionsToAdd;
        if (currentVersionInfoIndex == versionInfoIndex)
        {
            // default case: current version is the most recent so it is not yet contained in history;
            // after a version number rollback the current entry is already contained in history
            code += Line(2, "history.Add (" + Current + ");");
        }
        code += Line(1, "}", 2);
        code += "}";
        return(code);
    }