Esempio n. 1
0
        public DataEditorViewModel(TemplateServiceProvider templateServiceProvider)
        {
            _templateServiceProvider = templateServiceProvider;
            DataSourceProviders      = new ObservableCollection <IDataSourceProvider>();
            DataSourceProviders.Add(new JsonDataProvider());
            DataSourceProviders.Add(new CSharpCompilerViewModel());

            foreach (var dataSourceProvider in DataSourceProviders)
            {
                var typeName = dataSourceProvider.GetType().Assembly.GetName().Name;
                //try
                //{
                //	App.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
                //	{
                //		Source = new Uri($"pack://application:,,,/{typeName};component/Resources/DataTemplates.xaml")
                //	});
                //}
                //catch (Exception e)
                //{

                //}
            }

            SelectedDataSourceProvider = DataSourceProviders.First();
        }
Esempio n. 2
0
        public TemplateEditorViewModel(TemplateServiceProvider templateServiceProvider)
        {
            _templateServiceProvider = templateServiceProvider;
            TemplateChangedCommand   = new DelegateCommand(TemplateChangedExecute, CanTemplateChangedExecute);
            _template              = new TextDocument();
            _template.TextChanged += _template_TextChanged;
            var service = _template.ServiceProvider.GetService(typeof(IServiceContainer)) as IServiceContainer;

            TextMarkerService = new TextMarkerService(Template);

            service.AddService(typeof(ITextMarkerService), TextMarkerService);
            string path = null;

            if (File.Exists("../../MorestachioHightlight.xml"))
            {
                path = "../../MorestachioHightlight.xml";
            }
            else if (File.Exists("MorestachioHightlight.xml"))
            {
                path = "MorestachioHightlight.xml";
            }

            if (path != null)
            {
                var xshdSyntaxDefinition = HighlightingLoader.Load(
                    new XmlTextReader(new FileStream(path, FileMode.Open)), null);
                HighlightingManager.Instance.RegisterHighlighting("Morestachio", new string[0], xshdSyntaxDefinition);
                MorestachioSyntax = xshdSyntaxDefinition;
            }

            _templateServiceProvider.TemplateCreated += TemplateServiceProviderOnTemplateCreated;
        }
Esempio n. 3
0
        /// <summary>
        /// 设置当前应用程序正在使用的模板服务提供者。
        /// </summary>
        public static void SetProvider(TemplateServiceProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("TemplateServiceProvider");
            }

            currentProvider = provider;
        }
Esempio n. 4
0
        public ParserOptionsViewModel(TemplateServiceProvider service)
        {
            _service = service;
            _service.ParserOptions = this;
            var parserOptions = new ParserOptions("");

            NullSubstitute               = parserOptions.Null;
            MaxSize                      = parserOptions.MaxSize;
            DisableContentEscaping       = parserOptions.DisableContentEscaping;
            PartialStackSize             = parserOptions.PartialStackSize;
            PartialStackOverflowBehavior = parserOptions.StackOverflowBehavior;
            Timeout                      = parserOptions.Timeout;
        }
        public FormatterEditorViewModel(TemplateServiceProvider service)
        {
            _service = service;
            RemoveFormatterCommand =
                new DelegateCommand <FormatterGroup>(RemoveFormatterExecute, CanRemoveFormatterExecute);
            AddFormatterCommand     = new DelegateCommand(AddFormatterExecute, CanAddFormatterExecute);
            LoadFromExternalCommand = new DelegateCommand(LoadFromExternalExecute, CanLoadFromExternalExecute);
            FormatterGroups         = new ThreadSaveObservableCollection <FormatterGroup>();

            var dllToLoad = Path.Combine(Directory.GetCurrentDirectory(), "Morestachio.Formatter.Linq.dll");

            if (File.Exists(dllToLoad))
            {
                LoadAndAddFromExternal(dllToLoad);
            }
        }
        public MainWindowViewModel()
        {
            var service = new TemplateServiceProvider();

            TemplateResultViewModel  = new TemplateResultViewModel(service);
            TemplateEditorViewModel  = new TemplateEditorViewModel(service);
            DataEditorViewModel      = new DataEditorViewModel(service);
            FormatterEditorViewModel = new FormatterEditorViewModel(service);
            StoreData = new ThreadSaveObservableCollection <StoreMetaModel>();


            LoadStoreDataCommand = new DelegateCommand <StoreMetaModel>(LoadStoreDataExecute, CanLoadStoreDataExecute);
            SaveStoreDataCommand = new DelegateCommand(SaveStoreDataExecute, CanSaveStoreDataExecute);
            if (!Directory.Exists(StorePath))
            {
                Directory.CreateDirectory(StorePath);
            }
            EnumerateStoreFiles();
        }
Esempio n. 7
0
 public FormatterViewModel(TemplateServiceProvider service)
 {
     Service   = service;
     Arguments = new ThreadSaveObservableCollection <FormatterArgument>();
     Service.CreateFormatter += _service_CreateFormatter;
 }
 public TemplateEditorViewModel(TemplateServiceProvider templateServiceProvider)
 {
     _templateServiceProvider = templateServiceProvider;
     TemplateChangedCommand   = new DelegateCommand(TemplateChangedExecute, CanTemplateChangedExecute);
 }
Esempio n. 9
0
 public TemplateResultViewModel(TemplateServiceProvider templateServiceProvider)
 {
     _templateServiceProvider = templateServiceProvider;
     _templateServiceProvider.TemplateChanged += _templateServiceProvider_TemplateChanged;
     GenerateTemplateCommand = new DelegateCommand(GenerateTemplateExecute, CanGenerateTemplateExecute);
 }
Esempio n. 10
0
 public ExternalFormatterViewModel(TemplateServiceProvider service, string file, MethodInfo methodInfo) : base(service)
 {
     _methodInfo = methodInfo;
     File        = file;
     IsExternal  = true;
 }