forked from ClearFoundry/ClearScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocumentInfo.cs
More file actions
77 lines (67 loc) · 2.39 KB
/
DocumentInfo.cs
File metadata and controls
77 lines (67 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
using System.IO;
using Microsoft.ClearScript.Util;
namespace Microsoft.ClearScript
{
/// <summary>
/// Contains information about a script document.
/// </summary>
public struct DocumentInfo
{
internal const string DefaultName = "Script Document";
private readonly string name;
private readonly Uri uri;
/// <summary>
/// Initializes a new <see cref="DocumentInfo"/> structure with the specified document name.
/// </summary>
/// <param name="name">The document name.</param>
public DocumentInfo(string name)
: this()
{
this.name = MiscHelpers.EnsureNonBlank(name, DefaultName);
}
/// <summary>
/// Initializes a new <see cref="DocumentInfo"/> structure with the specified document URI.
/// </summary>
/// <param name="uri">The document URI.</param>
public DocumentInfo(Uri uri)
: this()
{
MiscHelpers.VerifyNonNullArgument(uri, "uri");
this.uri = uri.IsAbsoluteUri ? uri : new Uri(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + uri);
name = Path.GetFileName(this.uri.AbsolutePath);
}
/// <summary>
/// Gets the document's name.
/// </summary>
/// <remarks>
/// This property always returns a non-blank string. If a null or blank document name was
/// specified at instantiation time, this property returns a default document name.
/// </remarks>
public string Name
{
get { return MiscHelpers.EnsureNonBlank(name, DefaultName); }
}
/// <summary>
/// Gets the document's URI.
/// </summary>
/// <remarks>
/// This property returns <c>null</c> if a URI was not specified at instantiation time.
/// </remarks>
public Uri Uri
{
get { return uri; }
}
/// <summary>
/// Gets or sets a source map URI for the document.
/// </summary>
public Uri SourceMapUri { get; set; }
/// <summary>
/// Gets or sets optional document attributes.
/// </summary>
public DocumentFlags? Flags { get; set; }
internal string UniqueName { get; set; }
}
}