Exemplo n.º 1
0
        public void Initialize()
        {
            var dispatcher = new WPFDispatcher(Application.Current.Dispatcher);

            // Initialize Settings
            var settingsImpl = new SettingsImpl((string)null);

            settings_ = new Settings(settingsImpl, dispatcher);

            // Load settings from file if it exists
            if (File.Exists(PluginInfo.SettingsFilePath))
            {
                try {
                    using (var fs = new FileStream(PluginInfo.SettingsFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                        var serializer = new DataContractSettingsSerializer();
                        serializer.Deserialize(fs, settingsImpl);
                    }
                }
                catch (Exception ex) {
                    Logger.Error("Failed to load settings from file.", ex);
                    if (ex.IsCritical())
                    {
                        throw;
                    }
                }
            }

            // Initialize settings auto expoter
            expoter_ = new SettingsAutoExpoter(
                PluginInfo.SettingsFilePath, PluginInfo.SettingsFilePath + ".temp",
                settingsImpl, new DataContractSettingsSerializer());
        }
Exemplo n.º 2
0
        public static void Generate(CliArgs cliArgs)
        {
            var settings     = new SettingsImpl();
            var template     = new Template(cliArgs.TemplatePath);
            var provider     = new RoslynMetadataProvider();
            var indexBuilder = new StringBuilder();

//detect whether its a directory or file
            foreach (var path in GetFiles(cliArgs.SourcePath, cliArgs.Recursive, cliArgs.Regex))
            {
                var file       = new FileImpl(provider.GetFile(path, settings, null));
                var outputPath = template.RenderFile(file);
                if (outputPath != null)
                {
                    indexBuilder.Append(ExportStatement(outputPath));
                }
            }

            if (cliArgs.GenerateIndex)
            {
                var @join = Path.Join(Path.GetDirectoryName(cliArgs.TemplatePath), "index.ts");
                Console.WriteLine($"Outputting to {@join}");
                File.WriteAllText(@join, indexBuilder.ToString(), new UTF8Encoding(true));
            }
        }
        private File GetFile(PartialRenderingMode partialRenderingMode)
        {
            var settings = new SettingsImpl(null)
            {
                PartialRenderingMode = partialRenderingMode
            };

            return(GetFile(@"Tests\CodeModel\Support\PartialClassInfo.cs", settings));
        }
Exemplo n.º 4
0
        private File GetFile(PartialRenderingMode partialRenderingMode)
        {
            var settings = new SettingsImpl(null)
            {
                PartialRenderingMode = partialRenderingMode
            };

            return(GetFile(@"Tests\Metadata\Support\GeneratedClass.cs", settings));
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //var stopwatch = Stopwatch.StartNew();
            var showHelp = args == null || args.Length == 0;

            string templatePath = null;
            string sourcePath   = null;

            var p = new OptionSet  {
                { "t|template=", "full path to template (*.tst) file.", v => templatePath = v },
                { "s|source=", "full path to source (*.cs) file.", v => sourcePath = v },
                { "h|help", "show this message and exit", v => showHelp = v != null }
            };

            try
            {
                p.Parse(args);
            }
            catch (OptionException e) {
                Console.Write("TypewriterCli: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `dotnet TypewriterCli.dll --help' for more information.");
                return;
            }

            try
            {
                if (showHelp)
                {
                    ShowHelp(p);
                    return;
                }

                if (templatePath == null)
                {
                    throw new InvalidOperationException("Missing required option -t|template");
                }

                if (sourcePath == null)
                {
                    throw new InvalidOperationException("Missing required option -s|source");
                }

                var settings = new SettingsImpl();
                var template = new Template(templatePath);
                var provider = new RoslynMetadataProvider();
                var file     = new FileImpl(provider.GetFile(sourcePath, settings, null));

                template.RenderFile(file);
                //Console.WriteLine("Convert {0} ms", stopwatch.ElapsedMilliseconds);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
            }
        }
Exemplo n.º 6
0
        protected File GetFile(string path, Settings settings = null, Action <string[]> requestRender = null)
        {
            if (settings == null)
            {
                settings = new SettingsImpl(null);
            }

            var metadata = metadataProvider.GetFile(Path.Combine(SolutionDirectory, path), settings, requestRender);

            return(new FileImpl(metadata));
        }
        private void KanColleClient_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (KanColleClient.Current.Homeport != null)
            {
                KanColleClient.Current.PropertyChanged -= KanColleClient_PropertyChanged;

                var admiral    = KanColleClient.Current.Homeport.Admiral;
                var dispatcher = new WPFDispatcher(Application.Current.Dispatcher);

                // Initialize Settings
                var settingsImpl = new SettingsImpl((string)null);
                settings_ = new Settings(settingsImpl, dispatcher);

                // Load settings from file if it exists
                if (File.Exists(PluginInfo.SettingsFilePath))
                {
                    try {
                        using (var fs = new FileStream(PluginInfo.SettingsFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                            var serializer = new DataContractSettingsSerializer();
                            serializer.Deserialize(fs, settingsImpl);
                        }
                    }
                    catch (Exception ex) {
                        Logger.Error("Failed to load settings from file.", ex);
                        if (ex.IsCritical())
                        {
                            throw;
                        }
                    }
                }

                // Initialize settings auto expoter
                expoter_ = new SettingsAutoExpoter(
                    PluginInfo.SettingsFilePath, PluginInfo.SettingsFilePath + ".temp",
                    settingsImpl, new DataContractSettingsSerializer());

                viewModel_ = new ViewModels.KanburaTimerToolViewModel(
                    KanColleClient.Current,
                    settings_,
                    dispatcher);

                viewModel_.StartMonitoring();
            }
        }
Exemplo n.º 8
0
        private void VerifyConnectionSettings()
        {
            if (!UrlIsValid(txtUrl.Text))
            {
                MessageBox.Show("Application URL is not valid.", "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (chkUseProxy.Checked && !UrlIsValid(txtProxyUrl.Text))
            {
                MessageBox.Show("Proxy server URL is not valid.", "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var model = new SettingsImpl();

            UpdateModel(model);
            Controller.HandleVerifyConnectionCommand(model);
        }
Exemplo n.º 9
0
        private void RegisterComponents()
        {
            var container = ServiceLocator.Instance.Container;

            container.Bind <IDataLayer>().ToConstant(dataLayer);
            container.Bind <IDataLayerInternal>().ToConstant(dataLayer);

            container.Bind <Configuration>().ToMethod(context => Configuration.Load()).InSingletonScope();
            container.Bind <ISettings>().ToMethod(context => SettingsImpl.Load()).InSingletonScope();
            container.Bind <ILoggerFactory>().To <LoggerFactory>().InSingletonScope();
            container.Bind <IEventDispatcher>().To <EventDispatcher>().InSingletonScope();

            container.Bind <IUIComponentFactory>().ToMethod(context => new UIComponentFactory(container, ServiceLocator.Instance.Get <ILoggerFactory>())).InSingletonScope();
            container.Bind <ComponentResolver <IParentWindow> >().ToConstant(new ComponentResolver <IParentWindow>(container, "Projects")).Named("Projects");
            container.Bind <ComponentResolver <IParentWindow> >().ToConstant(new ComponentResolver <IParentWindow>(container, "Workitems")).Named("Workitems");

            container.Bind <ProjectTreeController>().ToSelf().InSingletonScope();
            container.Bind <WorkitemTreeController>().ToSelf().InSingletonScope();
            container.Bind <ProjectTreeControl>().ToSelf().InSingletonScope();
            container.Bind <WorkitemTreeControl>().ToSelf().InSingletonScope();
        }
Exemplo n.º 10
0
        private Lazy <SettingsImpl> LazyConfiguration()
        {
            return(new Lazy <SettingsImpl>(() =>
            {
                var settings = new SettingsImpl(_projectItem);

                if (!_template.IsValueCreated)
                {
                    //force initialize template so _customExtensions will be loaded
                    var templateValue = _template.Value;
                }

                var templateClass = _customExtensions.FirstOrDefault();
                if (templateClass?.GetConstructor(new[] { typeof(Settings) }) != null)
                {
                    Activator.CreateInstance(templateClass, settings);
                }


                return settings;
            }));
        }
        public void Initialize()
        {
            var dispatcher = new WPFDispatcher(Application.Current.Dispatcher);

            // Initialize Settings
            var settingsImpl = new SettingsImpl((string)null);
            settings_ = new Settings(settingsImpl, dispatcher);

            // Load settings from file if it exists
            if (File.Exists(PluginInfo.SettingsFilePath)) {
                try {
                    using (var fs = new FileStream(PluginInfo.SettingsFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                        var serializer = new DataContractSettingsSerializer();
                        serializer.Deserialize(fs, settingsImpl);
                    }
                }
                catch (Exception ex) {
                    Logger.Error("Failed to load settings from file.", ex);
                    if (ex.IsCritical()) { throw; }
                }
            }

            // Initialize settings auto expoter
            expoter_ = new SettingsAutoExpoter(
                PluginInfo.SettingsFilePath, PluginInfo.SettingsFilePath + ".temp",
                settingsImpl, new DataContractSettingsSerializer());
        }