Exemplo n.º 1
0
        private UIBarButtonItem _createButtonItemFor(string property, JsonValue json, JsonObject valuesJson)
        {
            var    item = (JsonObject)json[property];
            string datavalue = null, id = null;

            id = item.asString(Constants.Id);
            Activity        action = null;
            UIBarButtonItem button;

            if (valuesJson != null && !string.IsNullOrEmpty(id))
            {
                datavalue = valuesJson.asString(id);
            }

            if (item.ContainsKey(Constants.Action))
            {
                action = new ControllerAction(datavalue ?? item.asString(Constants.Action));
            }
            else if (item.ContainsKey(Constants.Activity))
            {
                action = ActivityFactory.Create(item.asString(Constants.Activity));
            }

            if (action == null)
            {
                return(null);
            }

            if (item.ContainsKey(Constants.Image))
            {
                button = new UIBarButtonItem(UIImage.FromBundle(item.asString(Constants.Image)), UIBarButtonItemStyle.Plain, (object o, EventArgs a) => {
                    action.Execute(this, null, null);
                });
            }
            else
            {
                button = new UIBarButtonItem(item.asString(Constants.Caption), UIBarButtonItemStyle.Plain, (object o, EventArgs a) => {
                    action.Execute(this, null, null);
                });
            }
            return(button);
        }
Exemplo n.º 2
0
        public void ExpressionTest()
        {
            int a    = 2;
            int b    = 3;
            int c    = 0;// c=(a+b)*100
            var act1 = ActivityFactory.Create(
                "expression",
                (id) =>
            {
                return(File.OpenRead(Path.Combine(
                                         Environment.CurrentDirectory,
                                         "../../wf", id + ".xaml")));
            });
            var rtv = WorkflowInvoker.Invoke(act1, new Dictionary <string, object>()
            {
                { "a", a },
                { "b", b }
            });

            c = (int)rtv["c"];
            Assert.AreEqual(c, (a + b) * 100);
        }
Exemplo n.º 3
0
        public void Create_Stream_Fail_Test()
        {
            var act1 = ActivityFactory.Create(
                "simple",
                (id) =>
            {
                return(File.OpenRead(Path.Combine(
                                         Environment.CurrentDirectory,
                                         "../../wf", id + ".xaml")));
            },
                false);
            var act2 = ActivityFactory.Create(
                "simple",
                (id) =>
            {
                return(File.OpenRead(Path.Combine(
                                         Environment.CurrentDirectory,
                                         "../../wf", id + ".xaml")));
            },
                false);

            Assert.AreEqual(act1, act2);
        }
Exemplo n.º 4
0
        public void Create_String_True_Test()
        {
            var act1 = ActivityFactory.Create(
                "simple",
                (id) =>
            {
                return(Path.Combine(
                           Environment.CurrentDirectory,
                           "../../wf", id + ".xaml"));
            },
                true);
            var act2 = ActivityFactory.Create(
                "simple",
                (id) =>
            {
                return(Path.Combine(
                           Environment.CurrentDirectory,
                           "../../wf", id + ".xaml"));
            },
                true);

            Assert.AreNotEqual(act1, act2);
        }
Exemplo n.º 5
0
 public ActivityElement(string caption, string activity, string value) : base(caption, new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray), false)
 {
     _activityName = activity;
     _activity     = ActivityFactory.Create(_activityName);
 }