Beispiel #1
0
        static List <CodeExample> MergeExamples(List <CodeExample> foundExamplesCS, List <CodeExample> foundExamplesVB)
        {
            List <CodeExample> result = new List <CodeExample>();

            int count = foundExamplesCS.Count;

            for (int i = 0; i < count; i++)
            {
                CodeExample itemCS = foundExamplesCS[i];

                CodeExample itemVB = foundExamplesVB[i];
                if (itemCS.HumanReadableGroupName == itemVB.HumanReadableGroupName &&
                    itemCS.RegionName == itemVB.RegionName)
                {
                    CodeExample merged = new CodeExample();
                    merged.RegionName             = itemCS.RegionName;
                    merged.HumanReadableGroupName = itemCS.HumanReadableGroupName;
                    merged.CodeCS = itemCS.CodeCS;
                    merged.CodeVB = itemVB.CodeVB;
                    result.Add(merged);
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }

            return(result);
        }
        public string ShowExample(CodeExample oldExample, CodeExample newExample)
        {
            InnerRichEditControl richEditControlCs = codeEditorCs.InnerControl;
            InnerRichEditControl richEditControlVb = codeEditorVb.InnerControl;

            if (oldExample != null)
            {
                oldExample.CodeCS = richEditControlCs.Text;
                oldExample.CodeVB = richEditControlVb.Text;
            }
            string exampleCode = String.Empty;

            if (newExample != null)
            {
                try
                {
                    forceTextChangesCounter = 2;
                    exampleCode             = (CurrentExampleLanguage == ExampleLanguage.Csharp) ? newExample.CodeCS : newExample.CodeVB;
                    richEditControlCs.Text  = newExample.CodeCS;
                    richEditControlVb.Text  = newExample.CodeVB;

                    richEditTextChanged = false;
                }
                finally
                {
                    richEditTextChanged = true;
                }
            }
            return(exampleCode);
        }
Beispiel #3
0
        internal void Merge(CodeExample n)
        {
            this.CodeCS += Environment.NewLine;
            this.CodeCS += n.CodeCS;

            this.CodeVB += Environment.NewLine;
            this.CodeVB += n.CodeVB;
        }
Beispiel #4
0
        protected CodeExample CreateSpreadsheetExample(string exampleGroup, string regionName, string exampleCode)
        {
            CodeExample result = new CodeExample();

            SetExampleCode(exampleCode, result);
            result.RegionName             = regionName;
            result.HumanReadableGroupName = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(exampleGroup);
            return(result);
        }
Beispiel #5
0
        private void OnNewExampleSelected(object sender, CurrentItemChangedEventArgs e)
        {
            CodeExample newExample = e.NewItem as CodeExample;
            CodeExample oldExample = e.OldItem as CodeExample;

            if (newExample == null)
            {
                return;
            }

            if (codeEditor == null)
            {
                return;
            }

            string exampleCode = codeEditor.ShowExample(oldExample, newExample);

            codeExampleNameLbl.Content = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(newExample.RegionName) + " example";

            CodeEvaluationEventArgs args = new CodeEvaluationEventArgs();

            InitializeCodeEvaluationEventArgs(args);
            evaluator.ForceCompile(args);
        }
Beispiel #6
0
 protected override void SetExampleCode(string code, CodeExample newExample)
 {
     newExample.CodeCS = code;
 }
Beispiel #7
0
 protected abstract void SetExampleCode(string exampleCode, CodeExample newExample);