GetPath() 공개 메소드

public GetPath ( String baseFolder, DocumentType documentType ) : String
baseFolder String
documentType DocumentType
리턴 String
예제 #1
0
        public static void CopyDocument(this FrameworkEntity entity, String baseFolder, DocumentType sourceType, DocumentType destinationType)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            String sourcePath       = entity.GetPath(baseFolder, sourceType);
            String destintationPath = entity.GetPath(baseFolder, destinationType);

            if (!File.Exists(sourcePath))
            {
                // Do nothing
            }
            else if (!File.Exists(destintationPath))
            {
                File.Copy(sourcePath, destintationPath, true);
            }
            else if (File.GetLastWriteTimeUtc(destintationPath) < File.GetLastWriteTimeUtc(sourcePath))
            {
                File.Copy(sourcePath, destintationPath, true);
            }
        }
        protected void PatchDiscussion(String baseFolder, DocSet docSet, Framework f, FrameworkEntity entity)
        {
            String path = entity.GetPath (baseFolder, this.Type);
            if (path == null || !File.Exists(path)) {
                return;
            }

            String contents = File.ReadAllText (path);
            bool modified = false;

            // Search for discussion parts
            int index = 0;
            int beginning = 0;
            int ending = 0;
            while ((beginning = contents.IndexOf(DISCUSSION_BEGIN, index)) != -1) {
                ending = contents.IndexOf (DISCUSSION_END, beginning);
                String content = contents.Substring (beginning, ending + DISCUSSION_END.Length - beginning);
                String replacement = content;

                // Count opening and closing paragraphs
                int opening = DISCUSSION_OPENING_REGEX.Matches (replacement).Count;
                int closing = DISCUSSION_CLOSING_REGEX.Matches (replacement).Count;

                if (opening < closing) {
                    throw new NotSupportedException ();
                }
                if (opening > closing) {
                    replacement = replacement.Replace ("<!-- begin discussion -->", String.Empty);
                    replacement = replacement.Replace ("<!-- end discussion -->", String.Empty);
                    for (int i = closing; i < opening; i++) {
                        replacement += "</p>";
                    }
                    replacement = "<!-- begin discussion -->" + replacement;
                    replacement = replacement + "<!-- end discussion -->";

                    contents = contents.Replace (content, replacement);
                    modified |= true;
                }

                index = beginning + replacement.Length;
            }

            if (modified) {
                this.Log (Level.Info, String.Format ("Patching {0} for '{1}'...", this.Type, entity.name));
                File.WriteAllText (path, contents);
            } else {
                this.Log (Level.Debug, String.Format ("Skipping {0} for '{1}'...", this.Type, entity.name));
            }
        }
예제 #3
0
        protected void Patch(String baseFolder, FrameworkEntity entity, IEnumerable<PatchReplace> replacements)
        {
            String path = entity.GetPath (baseFolder, this.Type);
            if (path == null) {
                return;
            }

            IList<String> paths = new List<String>();
            switch(this.Type) {
            case DocumentType.Generated:
                paths.Add(path + ".cs");
                paths.Add(path + ".Class.cs");
                paths.Add(path + ".Constants.cs");
                paths.Add(path + ".Constructors.cs");
                paths.Add(path + ".Protocol.cs");
                paths.Add(path + ".Protocols.cs");
                break;
            default:
                paths.Add(path);
                break;
            }

            this.Patch(paths, entity, replacements);
        }