public static void Save(RamlProperties props, string refFilePath)
 {
     var contents = BuildContent(props.Namespace, props.Source, props.ClientName, props.UseAsyncMethods);
     var fileInfo = new FileInfo(refFilePath) { IsReadOnly = false };
     File.WriteAllText(refFilePath, contents);
     fileInfo.IsReadOnly = true;
 }
        public static void Save(RamlProperties props, string refFilePath)
        {
            var contents = BuildContent(props.Namespace, props.Source, props.ClientName, props.UseAsyncMethods);
            var fileInfo = new FileInfo(refFilePath)
            {
                IsReadOnly = false
            };

            File.WriteAllText(refFilePath, contents);
            fileInfo.IsReadOnly = true;
        }
        public static void Save(RamlProperties props, string refFilePath)
        {
            var contents = BuildContent(props);
            var fileInfo = new FileInfo(refFilePath)
            {
                IsReadOnly = false
            };

            File.WriteAllText(refFilePath, contents);
            fileInfo.IsReadOnly = true;
        }
Esempio n. 4
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            var ramlProperties = new RamlProperties
            {
                Namespace       = Namespace,
                Source          = Source,
                ClientName      = ClientName,
                UseAsyncMethods = UseAsyncMethods
            };

            RamlPropertiesManager.Save(ramlProperties, ramlPath);
            DialogResult = true;
            Close();
        }
        public static string BuildContent(RamlProperties properties)
        {
            var source = string.Empty;

            if (properties.Source != null && properties.Source.StartsWith("http")) // only store source if is from web (i.e.: an URL)
            {
                source = properties.Source;
            }

            var content = string.Format("// do not edit this file{0}source: {1}{0}namespace: {2}{0}",
                                        Environment.NewLine, source, properties.Namespace);

            if (!string.IsNullOrWhiteSpace(properties.ClientName))
            {
                content += string.Format("client: {0}{1}", properties.ClientName, Environment.NewLine);
            }

            if (!string.IsNullOrWhiteSpace(properties.ClientName))
            {
                return(content);
            }

            // Server only properties
            content += string.Format("async: {0}{1}", properties.UseAsyncMethods ?? false, Environment.NewLine);

            content += string.Format("includeApiVersionInRoutePrefix: {0}{1}",
                                     properties.IncludeApiVersionInRoutePrefix ?? false, Environment.NewLine);

            content += string.Format("modelsFolder: {0}{1}", properties.ModelsFolder ?? string.Empty,
                                     Environment.NewLine);

            content += string.Format("implementationControllersFolder: {0}{1}",
                                     properties.ImplementationControllersFolder ?? string.Empty, Environment.NewLine);

            content += string.Format("addGeneratedSuffix: {0}{1}", properties.AddGeneratedSuffix ?? false,
                                     Environment.NewLine);
            return(content);
        }
        public static string AddRefFile(string ramlSourceFile, string destFolderPath, string targetFileName, RamlProperties properties)
        {
            var refFileName = Path.GetFileNameWithoutExtension(targetFileName) + ".ref";
            var refFilePath = Path.Combine(destFolderPath, refFileName);
            var content     = RamlPropertiesManager.BuildContent(properties);

            if (File.Exists(refFilePath))
            {
                new FileInfo(refFilePath).IsReadOnly = false;
            }

            File.WriteAllText(refFilePath, content);
            new FileInfo(refFilePath).IsReadOnly = true;

            return(refFilePath);
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            var ramlProperties = new RamlProperties
            {
                Namespace = Namespace,
                Source = Source,
                ClientName = ClientName,
                UseAsyncMethods = UseAsyncMethods
            };

            RamlPropertiesManager.Save(ramlProperties, ramlPath);
            DialogResult = true;
            Close();
        }