Exemple #1
0
        private static System.Reflection.Assembly GetControlAssembly(ISubExample exampleInfo)
        {
            var controlName     = exampleInfo.PackageName;
            var controlAssembly = AssemblyCache.GetInstance()[controlName];

            return(controlAssembly);
        }
Exemple #2
0
        public static List <CodeFileInfo> GetCodeFilesForExample(ISubExample example)
        {
            List <CodeFileInfo> codeFilesList = new List <CodeFileInfo>();

            var exampleInfo = example as ISubExample;

            if (exampleInfo == null)
            {
                throw new ArgumentException("Something went wrong. Example should be an ExampleInfo.");
            }
            else
            {
                var      controlAssembly         = GetControlAssembly(exampleInfo);
                string[] resourceNamesInAssembly = controlAssembly.GetManifestResourceNames();
                var      textToMatch             = exampleInfo.Name.Substring(0, exampleInfo.Name.LastIndexOf('.') + 1);
                var      resourcesWithCode       = resourceNamesInAssembly.Where(r => !r.Contains("AssemblyInfo.cs") && r.StartsWith(textToMatch) && !IsDataFile(r));

                foreach (var resourceName in resourcesWithCode)
                {
                    using (var stream = controlAssembly.GetManifestResourceStream(resourceName))
                    {
                        using (StreamReader streamReader = new StreamReader(stream))
                        {
                            var codeText = streamReader.ReadToEnd();
                            codeFilesList.Add(new CodeFileInfo {
                                FileName = resourceName, CodeContent = codeText
                            });
                        }
                    }
                }
            }

            return(codeFilesList);
        }
        public void Initialize(ISubExample exampleInfo)
        {
            this.exampleObject      = null;
            this.configuratorObject = null;
            this.hints   = null;
            this.Example = new ExampleInfo {
                ControlName = exampleInfo.PackageName, PackageName = exampleInfo.PackageName, Name = exampleInfo.Name, HeaderText = exampleInfo.Title
            };                   // exampleInfo;
            this.Control = null; // exampleInfo.ExampleGroup.Control;
            this.ExampleCodeFilesCollectionViewSource = new CollectionViewSource()
            {
                Source = ExampleSourceCodeHelper.GetCodeFilesForExample(exampleInfo)
            };

            this.NavigationContext = exampleInfo.NavigationParameter;

            var warningSuppression = this.RefreshAsyncProperties();
        }