コード例 #1
0
        void AddAndroidTargets(List <MetaData> metadata, List <IAppLinkTarget> targets)
        {
            var packages = metadata.Where(m => m.Property.Equals(KEY_ANDROID_PACKAGE, StringComparison.InvariantCultureIgnoreCase));
            var classes  = metadata.Where(m => m.Property.Equals(KEY_ANDROID_CLASS, StringComparison.InvariantCultureIgnoreCase));
            var urls     = metadata.Where(m => m.Property.Equals(KEY_ANDROID_URL, StringComparison.InvariantCultureIgnoreCase));
            var appNames = metadata.Where(m => m.Property.Equals(KEY_ANDROID_APPNAME, StringComparison.InvariantCultureIgnoreCase));

            // Package is the only required property, so we'll use it to determine the count of items to go through
            if (packages != null)
            {
                for (int i = 0; i < packages.Count(); i++)
                {
                    var target = new AndroidAppLinkTarget();

                    var p = packages.ElementAtOrDefault(i);
                    if (p == null || string.IsNullOrEmpty(p.Content))
                    {
                        continue;
                    }
                    target.Package = p.Content;

                    if (classes != null)
                    {
                        var m = classes.ElementAtOrDefault(i);
                        target.Class = m != null ? m.Content : null;
                    }
                    if (urls != null)
                    {
                        var m = urls.ElementAtOrDefault(i);
                        try {
                            target.Url = m != null ? new Uri(m.Content) : null;
                        } catch {
                        }
                    }
                    if (appNames != null)
                    {
                        var m = appNames.ElementAtOrDefault(i);
                        target.AppName = m != null ? m.Content : null;
                    }

                    targets.Add(target);
                }
            }
        }
コード例 #2
0
        List <IAppLinkTarget> parseAndroidTargets(JsonArray json)
        {
            var targets = new List <IAppLinkTarget> ();

            foreach (var item in json)
            {
                var target = new AndroidAppLinkTarget();

                if (item.ContainsKey("url"))
                {
                    target.Url = new Uri((string)item ["url"]);
                }

                if (item.ContainsKey("app_name"))
                {
                    target.AppName = (string)item ["app_name"];
                }

                if (item.ContainsKey("class"))
                {
                    target.AppName = (string)item ["class"];
                }

                if (item.ContainsKey("package"))
                {
                    target.AppName = (string)item ["package"];
                }

                if (target.Url != null)
                {
                    targets.Add(target);
                }
            }

            return(targets);
        }
コード例 #3
0
		List<IAppLinkTarget> parseAndroidTargets(JsonArray json)
		{
			var targets = new List<IAppLinkTarget> ();

			foreach (var item in json) { 
				var target = new AndroidAppLinkTarget ();

				if (item.ContainsKey ("url"))
					target.Url = new Uri ((string)item ["url"]);

				if (item.ContainsKey ("app_name"))
					target.AppName = (string)item ["app_name"];

				if (item.ContainsKey ("class"))
					target.AppName = (string)item ["class"];

				if (item.ContainsKey ("package"))
					target.AppName = (string)item ["package"];
					
				if (target.Url != null)
					targets.Add (target);
			}

			return targets;
		}
コード例 #4
0
		void AddAndroidTargets(List<MetaData> metadata, List<IAppLinkTarget> targets)
		{
			var packages = metadata.Where (m => m.Property.Equals (KEY_ANDROID_PACKAGE, StringComparison.InvariantCultureIgnoreCase));
			var classes = metadata.Where (m => m.Property.Equals (KEY_ANDROID_CLASS, StringComparison.InvariantCultureIgnoreCase));
			var urls =  metadata.Where (m => m.Property.Equals (KEY_ANDROID_URL, StringComparison.InvariantCultureIgnoreCase)); 
			var appNames = metadata.Where (m => m.Property.Equals (KEY_ANDROID_APPNAME, StringComparison.InvariantCultureIgnoreCase));

			// Package is the only required property, so we'll use it to determine the count of items to go through
			if (packages != null) {
				for (int i = 0; i < packages.Count(); i++) {
					var target = new AndroidAppLinkTarget ();

					var p = packages.ElementAtOrDefault (i);
					if (p == null || string.IsNullOrEmpty(p.Content))
						continue;
					target.Package = p.Content;

					if (classes != null) {
						var m = classes.ElementAtOrDefault (i);
						target.Class = m != null ? m.Content : null;
					}
					if (urls != null) {
						var m = urls.ElementAtOrDefault (i);
						try {
							target.Url = m != null ? new Uri(m.Content) : null;
						} catch {
						}
					}
					if (appNames != null) {
						var m = appNames.ElementAtOrDefault (i);
						target.AppName = m != null ? m.Content : null;
					}

					targets.Add (target);
				}
			}
		}