public static string GetSafeName(this DocumentationBase @this)
        {
            var safeName = @this.Name;

            // Windows breaks if we don't keep the file name short.
            if (safeName.Length > 50)
            {
                int hash = 0;
                foreach (var c in safeName.ToCharArray())
                {
                    hash += c;
                }

                hash %= 99999;

                // Take the first part of the string so that we can recognize it.
                // Hope that the hash is enough to make it unique.
                safeName = $"{safeName.Substring(0, 45)}{hash}";
            }

            foreach (var invalid in Path.GetInvalidFileNameChars())
            {
                safeName = safeName.Replace(invalid, '_');
            }

            safeName = safeName.Replace('(', '_');
            safeName = safeName.Replace(')', '_');

            return(safeName);
        }
예제 #2
0
 public void DeleteDocumentation(DocumentationBase documentation)
 {
     Requires.NotNull(documentation);
     Requires.PropertyNotNegative(documentation, "DocumentationId");
     using (var context = DataContext.Instance())
     {
         var rep = context.GetRepository <DocumentationBase>();
         rep.Delete(documentation);
     }
 }
예제 #3
0
 public void UpdateDocumentation(DocumentationBase documentation, int userId)
 {
     Requires.NotNull(documentation);
     Requires.PropertyNotNegative(documentation, "DocumentationId");
     documentation.LastModifiedByUserID = userId;
     documentation.LastModifiedOnDate   = DateTime.Now;
     using (var context = DataContext.Instance())
     {
         var rep = context.GetRepository <DocumentationBase>();
         rep.Update(documentation);
     }
 }
예제 #4
0
 public int AddDocumentation(ref DocumentationBase documentation, int userId)
 {
     Requires.NotNull(documentation);
     Requires.PropertyNotNegative(documentation, "ModuleId");
     documentation.CreatedByUserID      = userId;
     documentation.CreatedOnDate        = DateTime.Now;
     documentation.LastModifiedByUserID = userId;
     documentation.LastModifiedOnDate   = DateTime.Now;
     using (var context = DataContext.Instance())
     {
         var rep = context.GetRepository <DocumentationBase>();
         rep.Insert(documentation);
     }
     return(documentation.DocumentationId);
 }
예제 #5
0
 public DocBuilder(DocumentationBase documentation, TypeDocumentation typeDocumentation, AssemblyDocumentation assemblyDocumentation)
 {
     this.AssemblyDocumentation = assemblyDocumentation;
     this.Documentation         = documentation;
     this.TypeDocumentation     = typeDocumentation;
 }