Esempio n. 1
0
        public static ExpandProperties PropertiesFromArgs(Dictionary <string, string> args)
        {
            ExpandProperties properties = new ExpandProperties();

            string value  = null;
            double dValue = 0;

            if ((args.TryGetValue("width", out value)) && (double.TryParse(value, out dValue)))
            {
                properties.width = dValue;
            }

            if ((args.TryGetValue("height", out value)) && (double.TryParse(value, out dValue)))
            {
                properties.height = dValue;
            }

            if ((args.TryGetValue("useCustomClose", out value)) && (value == Const.True))
            {
                properties.useCustomClose = true;
            }
            else
            {
                properties.useCustomClose = false;
            }

            return(properties);
        }
        public static ExpandProperties PropertiesFromArgs(Dictionary<string, string> args)
        {
            ExpandProperties properties = new ExpandProperties();

            string value = null;
            double dValue = 0;

            if ((args.TryGetValue("width", out value)) &&  (double.TryParse(value, out dValue)))
            {
                properties.width = dValue;
            }

            if ((args.TryGetValue("height", out value)) &&  (double.TryParse(value, out dValue)))
            {
                properties.height = dValue;
            }

            if ((args.TryGetValue("useCustomClose", out value)) && (value == Const.True))
            {
                properties.useCustomClose = true;
            }
            else
            {
                properties.useCustomClose = false;
            }

            return properties;
        }
Esempio n. 3
0
        public void SetExpandProperties(ExpandProperties expandProperties)
        {
            string arg = expandProperties.ToString();
            string js  = string.Format("mraid.setExpandProperties({0});", arg);

            EvalJS(js);
        }
Esempio n. 4
0
        public bool ParseRequest(Uri uri)
        {
            if (uri.Scheme != Const.Scheme)
                return false;

            string command = uri.Host;
            string query = uri.Query.Trim(new char[] { '?' });

            Dictionary<string, string> args = new Dictionary<string, string>();

            if (string.IsNullOrEmpty(query) == false)
            {
                string[] queryItems = query.Split(new char[] { '&' });
                foreach (string queryItem in queryItems)
                {
                    string[] keyValue = queryItem.Split(new char[] { '=' });
                    if (keyValue.Length == 2)
                    {
                        string key = Uri.UnescapeDataString(keyValue[0]);
                        string value = Uri.UnescapeDataString(keyValue[1]);

                        // TODO: This was done on iOS to preserve formatting, but it looks like
                        // URL/Uri formats here will be escaped as needed by the runtime.
                        //if (key != Const.CommandArgUrl)
                        //    value = Uri.UnescapeDataString(value);

                        args[key] = value;
                    }
                }
            }

            switch (command)
            {
                case Const.CommandClose:
                    this.handler.mraidClose(this);
                    break;

                case Const.CommandOpen:
                    {
                        string url = null;
                        args.TryGetValue(Const.CommandArgUrl, out url);
                        this.handler.mraidOpen(this, url);
                    }
                    break;

                case Const.CommandUpdateCurrentPosition:
                    this.handler.mraidUpdateCurrentPosition(this);
                    break;

                case Const.CommandExpand:
                    {
                        string url = null;
                        args.TryGetValue(Const.CommandArgUrl, out url);
                        this.handler.mraidExpand(this, url);
                    }
                    break;

                case Const.CommandResize:
                    this.handler.mraidResize(this);
                    break;

                case Const.CommandSetExpandProperties:
                    {
                        ExpandProperties expandProperties = ExpandProperties.PropertiesFromArgs(args);
                        this.expandProperties = expandProperties;
                        this.handler.mraidUpdatedExpandProperties(this);
                    }
                    break;

                case Const.CommandSetResizeProperties:
                    {
                        ResizeProperties resizeProperties = ResizeProperties.PropertiesFromArgs(args);
                        this.resizeProperties = resizeProperties;
                        this.handler.mraidUpdatedResizeProperties(this);
                    }
                    break;

                case Const.CommandSetOrientationProperties:
                    {
                        OrientationProperties orientationProperties = OrientationProperties.PropertiesFromArgs(args);
                        this.orientationProperties = orientationProperties;
                        this.handler.mraidUpdatedOrientationProperties(this);
                    }
                    break;

                case Const.CommandPlayVideo:
                    {
                        string url = null;
                        args.TryGetValue(Const.CommandArgUrl, out url);
                        this.handler.mraidPlayVideo(this, url);
                    }
                    break;

                case Const.CommandCreateCalendarEvent:
                    {
                        string calendarEvent = null;
                        args.TryGetValue(Const.CommandArgEvent, out calendarEvent);
                        this.handler.mraidCreateCalendarEvent(this, calendarEvent);
                    }
                    break;

                case Const.CommandStorePicture:
                    {
                        string url = null;
                        args.TryGetValue(Const.CommandArgUrl, out url);
                        this.handler.mraidStorePicture(this, url);
                    }
                    break;
            }

            return true;
        }
Esempio n. 5
0
 public void SetExpandProperties(ExpandProperties expandProperties)
 {
     string arg = expandProperties.ToString();
     string js = string.Format("mraid.setExpandProperties({0});", arg);
     EvalJS(js);
 }
Esempio n. 6
0
        public bool ParseRequest(Uri uri)
        {
            if (uri.Scheme != Const.Scheme)
            {
                return(false);
            }

            string command = uri.Host;
            string query   = uri.Query.Trim(new char[] { '?' });

            Dictionary <string, string> args = new Dictionary <string, string>();

            if (string.IsNullOrEmpty(query) == false)
            {
                string[] queryItems = query.Split(new char[] { '&' });
                foreach (string queryItem in queryItems)
                {
                    string[] keyValue = queryItem.Split(new char[] { '=' });
                    if (keyValue.Length == 2)
                    {
                        string key   = Uri.UnescapeDataString(keyValue[0]);
                        string value = Uri.UnescapeDataString(keyValue[1]);

                        // TODO: This was done on iOS to preserve formatting, but it looks like
                        // URL/Uri formats here will be escaped as needed by the runtime.
                        //if (key != Const.CommandArgUrl)
                        //    value = Uri.UnescapeDataString(value);

                        args[key] = value;
                    }
                }
            }

            switch (command)
            {
            case Const.CommandClose:
                this.handler.mraidClose(this);
                break;

            case Const.CommandOpen:
            {
                string url = null;
                args.TryGetValue(Const.CommandArgUrl, out url);
                this.handler.mraidOpen(this, url);
            }
            break;

            case Const.CommandUpdateCurrentPosition:
                this.handler.mraidUpdateCurrentPosition(this);
                break;

            case Const.CommandExpand:
            {
                string url = null;
                args.TryGetValue(Const.CommandArgUrl, out url);
                this.handler.mraidExpand(this, url);
            }
            break;

            case Const.CommandResize:
                this.handler.mraidResize(this);
                break;

            case Const.CommandSetExpandProperties:
            {
                ExpandProperties expandProperties = ExpandProperties.PropertiesFromArgs(args);
                this.expandProperties = expandProperties;
                this.handler.mraidUpdatedExpandProperties(this);
            }
            break;

            case Const.CommandSetResizeProperties:
            {
                ResizeProperties resizeProperties = ResizeProperties.PropertiesFromArgs(args);
                this.resizeProperties = resizeProperties;
                this.handler.mraidUpdatedResizeProperties(this);
            }
            break;

            case Const.CommandSetOrientationProperties:
            {
                OrientationProperties orientationProperties = OrientationProperties.PropertiesFromArgs(args);
                this.orientationProperties = orientationProperties;
                this.handler.mraidUpdatedOrientationProperties(this);
            }
            break;

            case Const.CommandPlayVideo:
            {
                string url = null;
                args.TryGetValue(Const.CommandArgUrl, out url);
                this.handler.mraidPlayVideo(this, url);
            }
            break;

            case Const.CommandCreateCalendarEvent:
            {
                string calendarEvent = null;
                args.TryGetValue(Const.CommandArgEvent, out calendarEvent);
                this.handler.mraidCreateCalendarEvent(this, calendarEvent);
            }
            break;

            case Const.CommandStorePicture:
            {
                string url = null;
                args.TryGetValue(Const.CommandArgUrl, out url);
                this.handler.mraidStorePicture(this, url);
            }
            break;
            }

            return(true);
        }