DataFormatSettings ITabularDataSource.GetSourceFormat(IShellContext context)
 {
     using (var childCtx = context.CreateChildContext())
     {
         childCtx.SetVariable(context.Replace(PropertyName), context.Replace(PrimaryFile));
         return(SourceTemplate.GetSourceFormat(childCtx));
     }
 }
예제 #2
0
 public Activity Select(
     TrainingProgram trainingProgram,
     SourceTemplate sourceTemplate,
     BaseLine baseLine)
 {
     return
         (trainingProgram?.Activity
          ?? sourceTemplate?.Activity
          ?? baseLine?.Activity
          ?? throw new InvalidOperationException());
 }
        private void Button1_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + GlobalConfiguration.Documents))
            {
                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + GlobalConfiguration.Documents);
            }

            if (SourceTemplate.DoesTemplateExist(textBoxName.Text))
            {
                DialogResult result = MessageBox.Show("Template scheint schon zu existieren. Eindeutigen Namen wählen oder alte Ressource löschen und erneut versuchen?", "Alte Ressource löschen?", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    File.Delete(AppDomain.CurrentDomain.BaseDirectory + SourceTemplate.PATH + textBoxName.Text + ".xml");
                    File.Delete(AppDomain.CurrentDomain.BaseDirectory + GlobalConfiguration.Documents + "//SourceTemplates//" + textBoxName.Text + ".rtf");
                    MessageBox.Show("Alte Ressource gelöscht. Bitte erneut versuchen diese zu erstellen.");
                }
            }
            else
            {
                if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + GlobalConfiguration.Documents + "//SourceTemplates//"))
                {
                    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + GlobalConfiguration.Documents + "//SourceTemplates//");
                }
                richTextBoxDescr.SaveFile(AppDomain.CurrentDomain.BaseDirectory + GlobalConfiguration.Documents + "//SourceTemplates//" + textBoxName.Text + ".rtf");
                SourceTemplate sourceTemplate = new SourceTemplate()
                {
                    Name                    = textBoxName.Text,
                    DescriptionPath         = GlobalConfiguration.Documents + "//SourceTemplates//" + textBoxName.Text + ".rtf",
                    NeededTileAttributes    = GetLines(textBoxNeeded),
                    ForbiddenTileAttributes = GetLines(textBoxNeeded)
                };
                sourceTemplate.DepositRanges[DepositSizes.VerySmall] = new int[2] {
                    Convert.ToInt32(textBoxSmallestMin.Text), Convert.ToInt32(textBoxSmallestMax.Text)
                };
                sourceTemplate.DepositRanges[DepositSizes.Small] = new int[2] {
                    Convert.ToInt32(textBoxSmallMin.Text), Convert.ToInt32(textBoxSmallMax.Text)
                };
                sourceTemplate.DepositRanges[DepositSizes.Medium] = new int[2] {
                    Convert.ToInt32(textBoxMediumMin.Text), Convert.ToInt32(textBoxMediumMax.Text)
                };
                sourceTemplate.DepositRanges[DepositSizes.Large] = new int[2] {
                    Convert.ToInt32(textBoxBiggestMin.Text), Convert.ToInt32(textBoxBigMax.Text)
                };
                sourceTemplate.DepositRanges[DepositSizes.VeryLarge] = new int[2] {
                    Convert.ToInt32(textBoxBiggestMin.Text), Convert.ToInt32(textBoxBiggestMax.Text)
                };
                SourceTemplate.Save(sourceTemplate);
                Close();
            }
        }
        private void UpdateRessourcesTab()
        {
            //ressourcesListBox1
            ressourcesListBox1.ClearSelected();
            ressourcesListBox1.Items.Clear();
            List <string> names = Ressource.GetRessourceNames();

            foreach (string name in names)
            {
                ressourcesListBox1.Items.Add(name);
            }
            ressourcesListBox2.ClearSelected();
            ressourcesListBox2.Items.Clear();
            names = SourceTemplate.GetSourcesTemplates();
            foreach (string name in names)
            {
                ressourcesListBox2.Items.Add(name);
            }
        }
예제 #5
0
    public static CompilerResults DoCompile(string sourceCode, out string errorText)
    {
        errorText = null;

        var codeToRun = SourceTemplate.Replace("{0}", sourceCode);

        CompilerResults compilerResult = _cSharpCodeProvider.CompileAssemblyFromSource(_compilerParameter, codeToRun);

        if (compilerResult.Errors.Count > 0)
        {
            StringBuilder sb = new StringBuilder();
            foreach (CompilerError CompErr in compilerResult.Errors)
            {
                sb.Append("Line number " + CompErr.Line + ", Error Number: " + CompErr.ErrorNumber + ", '" + CompErr.ErrorText + ";" +
                          Environment.NewLine + Environment.NewLine);
            }
            errorText = sb.ToString();
        }
        return(compilerResult);
    }
예제 #6
0
        public void Execute()
        {
            //Let's assume objects being received from an external service

            TrainingProgram trainingProgram = null;
            BaseLine        baseLine        = null;
            SourceTemplate  sourceTemplate  = new SourceTemplate()
            {
                Activity = new Activity("name in Source template")
            };

            var selector = new ActualActivitySelector();

            var actualActivity = selector.Select(
                trainingProgram,
                sourceTemplate,
                baseLine);

            var name           = actualActivity.Name;
            var simplifiedName = actualActivity.SimplifiedName;
        }
예제 #7
0
        private TemplateElement CreateTag(Match match)
        {
            Group  param = match.Groups["param"];
            string name  = match.Groups["name"].Value;

            bool closed = false;

            TemplateElementTypes type = TemplateElementTypes.Tag;

            name = name.ToLower();

            switch (name)
            {
            case "if":
                type = TemplateElementTypes.IfExpression;
                break;

            case "else":
                if (SourceTemplate.IndexOf("if ", param.Index, param.Length, StringComparison.OrdinalIgnoreCase) == param.Index)
                {
                    type = TemplateElementTypes.ElseIfExpression;
                }
                else
                {
                    type = TemplateElementTypes.ElseExpression;
                }
                break;

            case "load":
                type = TemplateElementTypes.LoadExpression;
                break;

            //case "pre-include":
            //    type = TemplateElementTypes.PreIncludeExpression;
            //    break;

            case "loop":
                type = TemplateElementTypes.LoopExpression;
                break;

            case "ajaxpanel":
                type = TemplateElementTypes.AjaxPanel;
                break;
            }

            closed = match.Groups["close"].Success ||
                     type == TemplateElementTypes.ElseExpression ||
                     type == TemplateElementTypes.ElseIfExpression ||
                     type == TemplateElementTypes.LoadExpression;
            //|| type == TemplateElementTypes.PreIncludeExpression;

            Hashtable items = new Hashtable(2);

            items.Add(KEY_NAME, name);
            items.Add(KEY_CLOSED, closed);

            int index         = match.Index + match.Length;
            int contentLength = closed ? match.Length : SourceTemplate.Length - index;

            if (closed)
            {
                items.Add("END", index);
            }

            TemplateElement result = new TemplateElement(this.Document, type, index, contentLength, items);

            if (type == TemplateElementTypes.IfExpression || type == TemplateElementTypes.ElseIfExpression)
            {
                result.ChildNodes.Insert(0, CreateConditionExpression(param, type == TemplateElementTypes.ElseIfExpression));
            }
            else if (type == TemplateElementTypes.LoopExpression)
            {
                result.ChildNodes.Insert(0, CreateLoopExpressionParam(param));
            }
            else
            {
                result.ChildNodes.Insert(0, CreateAttributeList(param));
            }

            return(result);
        }
예제 #8
0
        private void ParseTemplateTag(int index, int length)
        {
            int tagBegin = SourceTemplate.IndexOf(TAG_BEGIN, index, length);

            if (tagBegin >= 0)
            {
                ParseTemplateCode(index, tagBegin - index, true, false);

                length = length - (tagBegin - index);
                index  = tagBegin;

                Match match = null;

                if ((match = TemplateTagBeginRegex.Match(SourceTemplate, index, length)).Success)
                {
                    TemplateElement tag = CreateTag(match);

                    ChildNodes.Add(tag);

                    //if (tag.Type == TemplateElementTypes.PreIncludeExpression)
                    //{
                    //    if (tag.ChildNodes[0].ChildNodes.Count >= 1)
                    //    {
                    //        TemplateElement element = tag.ChildNodes[0].ChildNodes[0];

                    //        if (element.ChildNodes[0].Type == TemplateElementTypes.Literal)
                    //        {
                    //            string path = element.ChildNodes[0].Text;

                    //            if (path.StartsWith("/") == false && path.StartsWith("~/") == false)
                    //            {
                    //                path = this.Document.TemplateFile.Owner.VirtualPath + path;
                    //            }

                    //            path = HttpContext.Current.Server.MapPath(path);

                    //            if (File.Exists(path))
                    //            {
                    //                string content = File.ReadAllText(path);

                    //                TemplateElement doc = CreateDocument(content, null);

                    //                tag.ChildNodes.Add(doc);

                    //                this.Document.TemplateFile.AddWatcher(path);
                    //            }
                    //        }
                    //    }
                    //}

                    if (tag.Items.Contains("END") == false)
                    {
                        throw new TemplateTagNotCloseException(tag.Items["name"].ToString(), TemplateFile.FilePath, SourceTemplate, index);
                    }

                    int tagEndIndex = (int)tag.Items["END"];

                    if (tagEndIndex > 0)
                    {
                        int leavingLength = SourceTemplate.Length - tagEndIndex;

                        if (leavingLength > 0)
                        {
                            ParseTemplateTag(tagEndIndex, leavingLength);
                        }
                    }
                }
                else if ((match = TemplateTagEndRegex.Match(SourceTemplate, index, length)).Success)
                {
                    if ((Type == TemplateElementTypes.Tag || Type == TemplateElementTypes.IfExpression || Type == TemplateElementTypes.LoopExpression || Type == TemplateElementTypes.AjaxPanel) &&
                        StringUtil.EqualsIgnoreCase(match.Groups["name"].Value, (string)Items[KEY_NAME]))
                    {
                        Length = match.Index - Index;

                        Items["END"] = match.Index + match.Length;
                    }
                    else
                    {
                        ChildNodes.Add(CreateLiteral(match.Index, match.Length));

                        int tagEnd = match.Index + match.Length;

                        ParseTemplateTag(tagEnd, length - (tagEnd - index));
                    }
                }
                else
                {
                    ChildNodes.Add(CreateLiteral(tagBegin, TAG_BEGIN.Length));

                    ParseTemplateTag(tagBegin + TAG_BEGIN.Length, length - TAG_BEGIN.Length);
                }
            }
            else
            {
                ParseTemplateCode(index, length, true, false);
            }
        }