コード例 #1
0
        /// <summary>
        ///     Defines an asset bundle. If a Leanplum variable with the same name and type exists,
        ///     this will return the existing variable.
        /// </summary>
        /// <returns>Leanplum variable.</returns>
        /// <param name="name">Name of variable.</param>
        /// <param name="realtimeUpdating">Setting it to <c>false</c> will prevent Leanplum from
        /// reloading assetbundles as they change in development mode.</param>
        /// <param name="iosBundleName">Filename of iOS assetbundle.</param>
        /// <param name="androidBundleName">Filename of Android assetbundle.</param>
        /// <param name="standaloneBundleName">Filename of Standalone assetbundle.</param>
        public override Var <AssetBundle> DefineAssetBundle(string name,
                                                            bool realtimeUpdating       = true, string iosBundleName = "", string androidBundleName = "",
                                                            string standaloneBundleName = "")
        {
            string platform     = LeanplumNative.CompatibilityLayer.GetPlatformName();
            string resourceName = Constants.Values.RESOURCES_VARIABLE + '.' + platform +
                                  " Assets." + name;
            string bundleName = String.Empty;

            if (platform == "iOS")
            {
                bundleName = iosBundleName;
            }
            else if (platform == "Android")
            {
                bundleName = androidBundleName;
            }
            else if (platform == "Standalone")
            {
                bundleName = standaloneBundleName;
            }

            var variable = DefineHelper <AssetBundle>(resourceName, Constants.Kinds.FILE, null);

            if (variable != null)
            {
                variable.SetFilename(bundleName);
                variable.fileReady             = false;
                variable.realtimeAssetUpdating = realtimeUpdating;

                VarCache.RegisterVariable(variable);
                variable.Update();
            }
            return(variable);
        }
コード例 #2
0
        /// <summary>
        ///     Defines a new variable with a default value. If a Leanplum variable with the
        ///     same name and type exists, this will return the existing variable.
        /// </summary>
        /// <param name="name"> Name of the variable. </param>
        /// <param name="defaultValue"> Default value of the variable. Can't be null. </param>
        public override Var <U> Define <U>(string name, U defaultValue)
        {
            string kind = null;

            if (defaultValue is int || defaultValue is long || defaultValue is short ||
                defaultValue is char || defaultValue is sbyte || defaultValue is byte)
            {
                kind = Constants.Kinds.INT;
            }
            else if (defaultValue is float || defaultValue is double || defaultValue is decimal)
            {
                kind = Constants.Kinds.FLOAT;
            }
            else if (defaultValue is string)
            {
                kind = Constants.Kinds.STRING;
            }
            else if (defaultValue is IList || defaultValue is Array)
            {
                kind = Constants.Kinds.ARRAY;
            }
            else if (defaultValue is IDictionary)
            {
                kind = Constants.Kinds.DICTIONARY;
            }
            else if (defaultValue is bool)
            {
                kind = Constants.Kinds.BOOLEAN;
            }
            else
            {
                Util.MaybeThrow(new LeanplumException(
                                    "Default value for \"" + name + "\" not recognized or supported."));
                return(null);
            }

            var variable = DefineHelper <U>(name, kind, defaultValue);

            if (variable != null)
            {
                variable.defaultClonedContainer = DeepCopyContainer(defaultValue);
                variable._defaultValue          = defaultValue;

                VarCache.RegisterVariable(variable);
                variable.Update();
            }


            return(variable);
        }