Exemplo n.º 1
0
		private void magix_forms_controls_panel(object sender, ActiveEventArgs e)
		{
            Node ip = Ip(e.Params);
			if (ShouldInspect(ip))
			{
				Inspect(ip);
				return;
			}

			LiteralControl ctrl = new LiteralControl();

            Node node = ip["_code"].Get<Node>();

            string idPrefix = "";
            if (ip.ContainsValue("id-prefix"))
                idPrefix = ip["id-prefix"].Get<string>();

            if (node.ContainsValue("id"))
                ctrl.ID = idPrefix + node["id"].Get<string>();
            else if (node.Value != null)
                ctrl.ID = idPrefix + node.Get<string>();

            if (node.ContainsValue("text"))
				ctrl.Text = node["text"].Get<string>();

            ip["_ctrl"].Value = ctrl;
		}
Exemplo n.º 2
0
        public static void magix_package_unpack(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.tiedown",
                    "Magix.tiedown.hyperlisp.inspect.hl",
                    "[magix.package.unpack-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.tiedown",
                    "Magix.tiedown.hyperlisp.inspect.hl",
                    "[magix.package.unpack-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            string zipFile = Expressions.GetFormattedExpression("zip", e.Params, "");
            string directory = Expressions.GetFormattedExpression("directory", e.Params, "");

            string zipAbsolutePath = HttpContext.Current.Server.MapPath(zipFile);
            string dirAbsolutePath = HttpContext.Current.Server.MapPath(directory);

            using (ZipFile zip = ZipFile.Read(zipAbsolutePath))
            {
                foreach (ZipEntry idxZipFile in zip)
                {
                    idxZipFile.Extract(dirAbsolutePath, ExtractExistingFileAction.OverwriteSilently);
                }
            }
        }
Exemplo n.º 3
0
		public static void magix_viewport_load_viewport(object sender, ActiveEventArgs e)
		{
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.tiedown",
                    "Magix.tiedown.hyperlisp.inspect.hl",
                    "[magix.viewport.load-viewport-dox].value");
                return;
			}

			Node node = new Node();
            node["file"].Value = "plugin:magix.file.load-from-resource";
            node["file"]["assembly"].Value = "Magix.tiedown";
            node["file"]["resource-name"].Value = "Magix.tiedown.hyperlisp.load-viewport.hl";

			RaiseActiveEvent(
				"magix.execute.execute-script",
				node);

            Control ctrl = ModuleControllerLoader.Instance.LoadActiveModule(node["params"]["viewport"].Get<string>());
            e.Params["viewport"].Value = ctrl;
        }
        private void magix_application_get(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.application.get-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.application.get-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            if (!ip.ContainsValue("id"))
                throw new ArgumentException("no [id] given to [magix.application.get]");
            string id = Expressions.GetFormattedExpression("id", e.Params, "");

            if (HttpContext.Current.Application[id] != null && HttpContext.Current.Application[id] is Node)
                ip.Add((HttpContext.Current.Application[id] as Node).Clone());
        }
Exemplo n.º 5
0
        public static void magix_data_count(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.data",
                    "Magix.data.hyperlisp.inspect.hl",
                    "[magix.data.count-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.data",
                    "Magix.data.hyperlisp.inspect.hl",
                    "[magix.data.count-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            Node prototype = GetPrototype(ip, dp);

            Guid transaction = e.Params.GetValue("_database-transaction", Guid.Empty);

            ip["count"].Value = Database.CountRecords(ip, prototype, transaction);
        }
Exemplo n.º 6
0
        public static void magix_math_subtract(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.math",
                    "Magix.math.hyperlisp.inspect.hl",
                    "[magix.math.subtract-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.math",
                    "Magix.math.hyperlisp.inspect.hl",
                    "[magix.math.subtract-sample]");
                return;
            }

            RunMathExpression(e.Params,
                delegate(decimal input)
                {
                    return input;
                },
                delegate(decimal input, decimal result)
                {
                    return result - input;
                });
        }
Exemplo n.º 7
0
        private void magix_web_get_parameter(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.web.get-parameter-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.web.get-parameter-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            if (!ip.ContainsValue("name"))
                throw new ArgumentException("no [name] given to [magix.web.get-parameter]");
            string name = Expressions.GetExpressionValue<string>(ip["name"].Get<string>(), dp, ip, false);

            if (HttpContext.Current.Request.Params[name] != null)
                ip["value"].Value = HttpUtility.UrlDecode(HttpContext.Current.Request.Params[name]);
        }
Exemplo n.º 8
0
        public static void magix_execute(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.execute-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.execute-sample]");
                return;
            }

            if (!e.Params.Contains("_ip"))
                ExecuteOutermostBlock(e.Params);
            else
            {
                if (ip.Name == "execute" && ip.Value != null && ip.Get<string>().StartsWith("["))
                {
                    ip = Expressions.GetExpressionValue<Node>(ip.Get<string>(), Dp(e.Params), ip, false); // lambda execute expression
                    if (ip == null)
                        throw new ArgumentException("[execute] value did not return a node list, expression was; '" + ip.Get<string>() + "'");
                }
                Execute(ip, e.Params);
            }
        }
Exemplo n.º 9
0
        public static void magix_execute_split(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params, true);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.split-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.split-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            // verifying syntax is correct
            if (!ip.Contains("what") && !ip.Contains("where") && !ip.Contains("trim") && !ip.Contains("regex"))
                throw new HyperlispSyntaxErrorException("[split] needs a [what], [trim], [regex] or a [where] child to understand how to split the expression");
            if (ip.Contains("what") && ip.Contains("where"))
                throw new HyperlispSyntaxErrorException("only either [what] or [where] can be submitted to [split], and not both");

            string whatToSplit = Expressions.GetExpressionValue<string>(ip.Get<string>(), dp, ip, false);
            if (whatToSplit == null)
                throw new HyperlispExecutionErrorException("couldn't make '" + ip.Get<string>() + "' into a string in [split]");

            // running actual split operation
            Split(ip, dp, whatToSplit);
        }
Exemplo n.º 10
0
		private void magix_forms_set_values(object sender, ActiveEventArgs e)
		{
            Node ip = Ip(e.Params);
			if (ShouldInspect(ip))
			{
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.forms",
                    "Magix.forms.hyperlisp.inspect.hl",
                    "[magix.forms.set-values-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.forms",
                    "Magix.forms.hyperlisp.inspect.hl",
                    "[magix.forms.set-values-sample]");
                return;
			}

            Select lst = FindControl<Select>(e.Params);
			lst.Items.Clear();
            if (ip.Contains("values"))
			{
                foreach (Node idx in ip["values"])
				{
					ListItem it = new ListItem(idx.Get<string>(), idx.Name);
                    if (!idx.GetValue("enabled", true))
                        it.Enabled = false;
					lst.Items.Add(it);
				}
			}
			lst.ReRender();
		}
Exemplo n.º 11
0
		private void magix_forms_controls_hyperlink(object sender, ActiveEventArgs e)
		{
            Node ip = Ip(e.Params);
			if (ShouldInspect(ip))
			{
				Inspect(ip);
				return;
			}

			HyperLink ret = new HyperLink();
            FillOutParameters(e.Params, ret);

            Node node = ip["_code"].Get<Node>();

            if (node.ContainsValue("value"))
				ret.Value = node["value"].Get<string>();

            if (node.ContainsValue("href"))
				ret.Href = node["href"].Get<string>().Replace("~", GetApplicationBaseUrl());

            if (node.ContainsValue("target"))
				ret.Target = node["target"].Get<string>();

            ip["_ctrl"].Value = ret;
		}
Exemplo n.º 12
0
		private void magix_forms_controls_select(object sender, ActiveEventArgs e)
		{
            Node ip = Ip(e.Params);
			if (ShouldInspect(ip))
			{
				Inspect(ip);
				return;
			}

			Select ret = new Select();
			FillOutParameters(e.Params, ret);

            Node node = ip["_code"].Get<Node>();

            if (node.ContainsValue("size"))
				ret.Size = node["size"].Get<int>();

			if (ShouldHandleEvent("onselectedindexchanged", node))
			{
				Node codeNode = node["onselectedindexchanged"].Clone();
				ret.SelectedIndexChanged += delegate(object sender2, EventArgs e2)
				{
                    FillOutEventInputParameters(codeNode, sender2);
                    RaiseActiveEvent(
						"magix.execute",
						codeNode);
				};
			}

            ip["_ctrl"].Value = ret;
		}
Exemplo n.º 13
0
        private static void magix_forms_add_attribute(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.forms",
                    "Magix.forms.hyperlisp.inspect.hl",
                    "[magix.forms.add-attribute-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.forms",
                    "Magix.forms.hyperlisp.inspect.hl",
                    "[magix.forms.add-attribute-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            string name = Expressions.GetExpressionValue<string>(ip["name"].Get<string>(), dp, ip, false);
            string value = Expressions.GetExpressionValue<string>(ip["value"].Get<string>(), dp, ip, false);

            AttributeControl ctrl = FindControl<AttributeControl>(e.Params);
            ctrl.Attributes.Add(new AttributeControl.Attribute(name, value));
        }
        private void magix_forms_controls_label(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                Inspect(ip);
                return;
            }

            Label ret = new Label();
            FillOutParameters(e.Params, ret);

            Node node = ip["_code"].Get<Node>();

            if (node.ContainsValue("value"))
                ret.Value = node["value"].Get<string>();

            if (node.ContainsValue("tag"))
                ret.Tag = node["tag"].Get<string>();

            if (node.ContainsValue("for"))
                ret.For = node["for"].Get<string>();

            ip["_ctrl"].Value = ret;
        }
Exemplo n.º 15
0
        public static void magix_file_file_exist(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.file",
                    "Magix.file.hyperlisp.inspect.hl",
                    "[magix.file.file-exist-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.file",
                    "Magix.file.hyperlisp.inspect.hl",
                    "[magix.file.file-exist-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            if (!ip.ContainsValue("file"))
                throw new ArgumentException("you didn't supply a [file] for [file-exist]");

            string file = Expressions.GetFormattedExpression("file", e.Params, "");
            if (!file.Contains(":"))
                file = _basePath + file;

            ip["value"].Value = File.Exists(file);
        }
Exemplo n.º 16
0
        public static void magix_execute_with(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params, true);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.with-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.with-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            // retrieving nodes to execute inner code with as data-pointer
            Node withNodeList = Expressions.GetExpressionValue<Node>(ip.Get<string>(), dp, ip, true);
            if (withNodeList == null)
                throw new HyperlispExecutionErrorException("your [with] keyword needs to return an existing node-list, the expression was; '" + ip.Get<string>() + "'");

            // executes with
            ExecuteWith(e.Params, withNodeList);
        }
Exemplo n.º 17
0
        public static void magix_file_copy_file(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.file",
                    "Magix.file.hyperlisp.inspect.hl",
                    "[magix.file.copy-file-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.file",
                    "Magix.file.hyperlisp.inspect.hl",
                    "[magix.file.copy-file-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            if (!ip.ContainsValue("from"))
                throw new ArgumentException("you need to tell the engine which file to copy as the value of the [from]");
            string from = Expressions.GetFormattedExpression("from", e.Params, "");
            if (!from.Contains(":"))
                from = _basePath + from;

            if (!ip.ContainsValue("to"))
                throw new ArgumentException("you need to define which file to copy to, as [to] node");
            string to = Expressions.GetFormattedExpression("to", e.Params, "");
            if (!to.Contains(":"))
                to = _basePath + to;

            File.Copy(from, to, true);
        }
Exemplo n.º 18
0
        public static void magix_execute_sandbox(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params, true);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.sandbox-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.sandbox-sample]");
                return;
            }

            // verifying sandbox has a [code] block
            if (!ip.Contains("code"))
                throw new ArgumentException("you need to supply a [code] block to [sandbox] active event");

            // verifying sandbox has a [whitelist]
            if (!ip.Contains("whitelist"))
                throw new ArgumentException("you need to supply a [whitelist] block to [sandbox] active event");

            // executing sandboxed code
            SandboxCode(e.Params, ip);
        }
Exemplo n.º 19
0
        public void magix_viewport_page_load(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.viewport.page-load-dox].value");
                return;
            }

            if (Page.Session["magix.web.postpone-execution"] != null)
            {
                Node code = Page.Session["magix.web.postpone-execution"] as Node;
                Page.Session.Remove("magix.web.postpone-execution");
                foreach (Node idxNode in code)
                {
                    RaiseActiveEvent(
                        "magix.execute",
                        idxNode);
                }
            }
        }
Exemplo n.º 20
0
        private static void magix_web_get_file(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.web.get-file-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.web.get-file-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            if (!ip.ContainsValue("file"))
                throw new ArgumentException("you need to supply a [file] parameter");

            if (!ip["file"].ContainsValue("url"))
                throw new ArgumentException("you need to supply which file to load as the [url] parameter");

            string filepath = Expressions.GetExpressionValue<string>(ip["file"]["url"].Get<string>(), dp, ip, false);
            if (string.IsNullOrEmpty(filepath))
                throw new ArgumentException("you need to define which file to load, as [url]");

            DownloadFile(ip, filepath);
        }
Exemplo n.º 21
0
        public void magix_browser_redirect(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.browser.redirect-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.browser.redirect-sample]");
                return;
            }

            string url = ip.Get<string>();

            if (string.IsNullOrEmpty(url))
                throw new ArgumentException("need url as value for [magix.browser.redirect] to function");

            if (url.Contains("~"))
                url = url.Replace("~", GetApplicationBaseUrl());

            Magix.UX.Manager.Instance.Redirect(url);
        }
Exemplo n.º 22
0
        public void magix_web_postpone_execution(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.web.postpone-execution-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.web.postpone-execution-sample]");
                return;
            }

            if (!ip.Contains("code"))
                throw new ArgumentException("[magix.web.postpone-execution] needs a [code] block to execute");

            if (Page.Session["magix.web.postpone-execution"] == null)
                Page.Session["magix.web.postpone-execution"] = new Node();
            ((Node)Page.Session["magix.web.postpone-execution"]).Add(ip["code"].Clone());
        }
        private void magix_forms_controls_check_box(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                Inspect(ip);
                return;
            }

            CheckBox ret = new CheckBox();
            FillOutParameters(e.Params, ret);

            Node node = ip["_code"].Get<Node>();

            if (node.ContainsValue("checked"))
                ret.Checked = node["checked"].Get<bool>();

            if (ShouldHandleEvent("oncheckedchanged", node))
            {
                Node codeNode = node["oncheckedchanged"].Clone();
                ret.CheckedChanged += delegate(object sender2, EventArgs e2)
                {
                    FillOutEventInputParameters(codeNode, sender2);
                    RaiseActiveEvent(
                        "magix.execute",
                        codeNode);
                };
            }

            ip["_ctrl"].Value = ret;
        }
Exemplo n.º 24
0
        private void magix_web_get_cookie(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.web.get-cookie-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.web.get-cookie-sample]");
                return;
            }

            string par = ip.Get<string>();
            if (string.IsNullOrEmpty(par))
                throw new ArgumentException("[magix.web.get-cookie] needs a value to know which cookie to fetch");

            if (HttpContext.Current.Request.Cookies.Get(par) != null)
                ip["value"].Value = HttpContext.Current.Request.Cookies[par].Value;
        }
Exemplo n.º 25
0
        public static void magix_execute_while(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params, true);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.while-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.while-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            // verifying syntax is correct
            if (!ip.Contains("code"))
                throw new HyperlispSyntaxErrorException("you need to supply a [code] block to the [while] keyword");

            // executing [while]
            WhileChecked(e.Params, ip, dp);
        }
        public static void magix_configuration_get_connection_string(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.configuration.get-connection-string-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.web",
                    "Magix.web.hyperlisp.inspect.hl",
                    "[magix.configuration.get-connection-string-sample]");
                return;
            }

            Node dp = Dp(e.Params);
            if (!ip.ContainsValue("id"))
                throw new ArgumentException("no [id] given to [magix.configuration.get-connection-string]");
            string id = Expressions.GetExpressionValue<string>(ip["id"].Get<string>(), dp, ip, false);

            ip["value"].Value = System.Web.Configuration.WebConfigurationManager.ConnectionStrings[id].ConnectionString;
        }
Exemplo n.º 27
0
        public static void magix_file_list_files(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);
            if (ShouldInspect(e.Params))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.file",
                    "Magix.file.hyperlisp.inspect.hl",
                    "[magix.file.list-files-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.file",
                    "Magix.file.hyperlisp.inspect.hl",
                    "[magix.file.list-files-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            string dir = ip.ContainsValue("directory") ?
                Expressions.GetFormattedExpression("directory", e.Params, "").TrimStart('/') :
                "";
            string filter = ip.ContainsValue("filter") ?
                Expressions.GetExpressionValue<string>(ip["filter"].Get<string>(), dp, ip, false) :
                null;

            string[] files = null;

            bool absolutePath = true;
            if (!dir.Contains(":"))
            {
                dir = _basePath + dir;
                absolutePath = false;
            }

            if (string.IsNullOrEmpty(filter))
                files = Directory.GetFiles(dir);
            else
            {
                List<string> searchPatterns = new List<string>(filter.Split(';'));
                List<string> filesList = new List<string>();
                foreach (string idxPattern in searchPatterns)
                {
                    filesList.AddRange(Directory.GetFiles(dir, idxPattern));
                }
                files = filesList.ToArray();
            }

            string rootDir = _basePath;
            foreach (string idxFile in files)
            {
                string fileName = idxFile;
                if (!absolutePath)
                    fileName = idxFile.Substring(rootDir.Length);
                fileName = fileName.Replace("\\", "/");

                ip["files"][fileName].Value = null;
            }
        }
Exemplo n.º 28
0
		private void magix_forms_controls_timer(object sender, ActiveEventArgs e)
		{
            Node ip = Ip(e.Params);
			if (ShouldInspect(ip))
			{
				Inspect(ip);
				return;
			}

            Timer ret = new Timer();
            FillOutParameters(e.Params, ret);

            Node node = ip["_code"].Get<Node>();

            if (node.ContainsValue("interval"))
                ret.Interval = node["interval"].Get<int>();

			if (ShouldHandleEvent("ontick", node))
			{
				Node codeNode = node["ontick"].Clone();
				ret.Tick += delegate(object sender2, EventArgs e2)
				{
                    FillOutEventInputParameters(codeNode, sender2);
                    RaiseActiveEvent(
						"magix.execute",
						codeNode);
				};
			}

            ip["_ctrl"].Value = ret;
		}
Exemplo n.º 29
0
        public static void magix_execute_else_if(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params, true);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.else-if-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.else-if-sample]");
                return;
            }

            // checking syntax
            VerifySyntaxElseIf(ip);

            // making sure previous [if] or [else-if] didn't execute before we run comparison to see if we should execute body of [else-if]
            if (!CheckState(e.Params))
                IfElseIfImplementation(
                    e.Params,
                    "magix.execute.else-if");
            else
            {
                // checking to see if next keyword is [else] or [else-if], and if not, we remove signaling state ("_state_if") from state
                Node next = ip.Next();
                if (next == null || (next.Name != "else-if" && next.Name != "magix.execute.else-if"
                    && next.Name != "else" && next.Name != "magix.execute.else"))
                    PopState(e.Params, ip);
            }
        }
Exemplo n.º 30
0
        public static void magix_execute_else(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params, true);
            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.else-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.else-sample]");
                return;
            }

            // verifying an [else] is only followed by an [if] or an [else-if]
            VerifySyntaxElse(ip);

            // saving state before we pop it to see if we should execute [else] body
            bool state = CheckState(e.Params);

            // removing signaling state ("_state_if") from state
            PopState(e.Params, ip);

            // checking to see if previous [if] or [else-if] executed, before we execute [else]
            if (!state)
                RaiseActiveEvent(
                    "magix.execute",
                    e.Params);
        }
Exemplo n.º 31
0
        protected virtual void magix_viewport_clear_controls(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);

            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.Core",
                    "Magix.Core.hyperlisp.inspect.hl",
                    "[magix.viewport.clear-controls-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.Core",
                    "Magix.Core.hyperlisp.inspect.hl",
                    "[magix.viewport.clear-controls-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            string container  = Expressions.GetExpressionValue <string>(ip.GetValue("container", ""), dp, ip, false);
            bool   resetClass = ip.ContainsValue("reset-class") ?
                                Expressions.GetExpressionValue <bool>(ip["reset-class"].Get <string>(), dp, ip, false) :
                                false;

            string resetClassNewClass = null;

            if (ip.Contains("reset-class") && ip["reset-class"].Contains("new-class"))
            {
                resetClassNewClass = ip["reset-class"]["new-class"].Get <string>("");
            }

            if (ip.ContainsValue("all") && ip["all"].Get <bool>())
            {
                foreach (string idx in GetAllDefaultContainers())
                {
                    DynamicPanel dyn = Selector.FindControl <DynamicPanel>(
                        this,
                        idx);
                    ClearControls(dyn);
                    if (resetClass || !string.IsNullOrEmpty(resetClassNewClass))
                    {
                        if (!string.IsNullOrEmpty(resetClassNewClass))
                        {
                            dyn.Class = resetClassNewClass;
                        }
                        else
                        {
                            dyn.Class = "";
                        }
                    }
                }
            }
            else
            {
                DynamicPanel dyn = Selector.FindControl <DynamicPanel>(
                    this,
                    container);

                if (dyn == null)
                {
                    return;
                }
                ClearControls(dyn);
                if (resetClass || !string.IsNullOrEmpty(resetClassNewClass))
                {
                    if (!string.IsNullOrEmpty(resetClassNewClass))
                    {
                        dyn.Class = resetClassNewClass;
                    }
                    else
                    {
                        dyn.Class = "";
                    }
                }
            }
        }
Exemplo n.º 32
0
        protected virtual void magix_viewport_load_module(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);

            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.Core",
                    "Magix.Core.hyperlisp.inspect.hl",
                    "[magix.viewport.load-module-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.Core",
                    "Magix.Core.hyperlisp.inspect.hl",
                    "[magix.viewport.load-module-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            string container = GetDefaultContainer();

            if (ip.ContainsValue("container"))
            {
                container = Expressions.GetExpressionValue <string>(ip["container"].Get <string>(), dp, ip, false);
            }

            DynamicPanel dyn = Selector.FindControl <DynamicPanel>(
                this,
                container);

            if (dyn == null && ip.ContainsValue("container"))
            {
                return;
            }

            string moduleName = Expressions.GetExpressionValue <string>(ip["name"].Get <string>(), dp, ip, false);

            ClearControls(dyn);

            if (ip.ContainsValue("class"))
            {
                dyn.Class = Expressions.GetExpressionValue <string>(ip["class"].Get <string>(), dp, ip, false);
            }

            if (ip.ContainsValue("style"))
            {
                // clearing old styles
                foreach (string idx in dyn.Style.Keys)
                {
                    dyn.Style[idx] = "";
                }

                // setting new styles
                string[] styles =
                    ip["style"].Get <string>().Replace("\n", "").Replace("\r", "").Split(
                        new char[] { ';' },
                        StringSplitOptions.RemoveEmptyEntries);
                foreach (string idxStyle in styles)
                {
                    dyn.Style[idxStyle.Split(':')[0]] = idxStyle.Split(':')[1];
                }
            }

            dyn.LoadControl(moduleName, e.Params);
        }