@@ -28,37 +28,42 @@ public class AzureStorageContext
28
28
/// <summary>
29
29
/// Storage account name used in this context
30
30
/// </summary>
31
- public string StorageAccountName { get ; private set ; }
31
+ public string StorageAccountName { get ; protected set ; }
32
32
33
33
/// <summary>
34
34
/// Blob end point of the storage context
35
35
/// </summary>
36
- public string BlobEndPoint { get ; private set ; }
36
+ public virtual string BlobEndPoint { get ; protected set ; }
37
37
38
38
/// <summary>
39
39
/// Table end point of the storage context
40
40
/// </summary>
41
- public string TableEndPoint { get ; private set ; }
41
+ public virtual string TableEndPoint { get ; protected set ; }
42
42
43
43
/// <summary>
44
44
/// Queue end point of the storage context
45
45
/// </summary>
46
- public string QueueEndPoint { get ; private set ; }
46
+ public virtual string QueueEndPoint { get ; protected set ; }
47
+
48
+ /// <summary>
49
+ /// File end point of the storage context
50
+ /// </summary>
51
+ public virtual string FileEndPoint { get ; protected set ; }
47
52
48
53
/// <summary>
49
54
/// Self reference, it could enable New-AzureStorageContext can be used in pipeline
50
55
/// </summary>
51
- public AzureStorageContext Context { get ; private set ; }
56
+ public AzureStorageContext Context { get ; protected set ; }
52
57
53
58
/// <summary>
54
59
/// Name place holder, and force pipeline to ignore this property
55
60
/// </summary>
56
- public string Name { get ; private set ; }
61
+ public virtual string Name { get ; protected set ; }
57
62
58
63
/// <summary>
59
64
/// Storage account in context
60
65
/// </summary>
61
- public CloudStorageAccount StorageAccount { get ; private set ; }
66
+ public virtual CloudStorageAccount StorageAccount { get ; protected set ; }
62
67
63
68
/// <summary>
64
69
/// Endpoint suffix (everything after "table.", "blob." or "queue.")
@@ -70,41 +75,31 @@ public string EndPointSuffix
70
75
{
71
76
get
72
77
{
73
- if ( string . IsNullOrEmpty ( BlobEndPoint ) || string . IsNullOrEmpty ( TableEndPoint ) )
78
+ if ( ! string . IsNullOrEmpty ( BlobEndPoint ) )
74
79
{
75
- return string . Empty ;
80
+ string blobSpliter = "blob." ;
81
+ if ( BlobEndPoint . LastIndexOf ( blobSpliter ) >= 0 )
82
+ return BlobEndPoint . Substring ( BlobEndPoint . LastIndexOf ( blobSpliter ) + blobSpliter . Length ) ;
76
83
}
77
-
78
- string suffix ;
79
-
80
- if ( StorageAccountName . EndsWith ( "blob" , StringComparison . InvariantCultureIgnoreCase ) )
84
+ if ( ! string . IsNullOrEmpty ( TableEndPoint ) )
81
85
{
82
- // Cannot use the blob endpoint if the account name ends with blob...
83
- // However it is OK if "blob" is in the account name but not as a suffix
84
- int tableIndex = TableEndPoint . IndexOf ( "table." , 0 , StringComparison . InvariantCultureIgnoreCase ) ;
85
- if ( tableIndex <= 0 )
86
- {
87
- suffix = string . Empty ;
88
- }
89
- else
90
- {
91
- suffix = TableEndPoint . Substring ( tableIndex + "table." . Length ) ;
92
- }
86
+ string tableSpliter = "table." ;
87
+ if ( TableEndPoint . LastIndexOf ( tableSpliter ) >= 0 )
88
+ return TableEndPoint . Substring ( TableEndPoint . LastIndexOf ( tableSpliter ) + tableSpliter . Length ) ;
93
89
}
94
- else
90
+ if ( ! string . IsNullOrEmpty ( QueueEndPoint ) )
95
91
{
96
- int blobIndex = BlobEndPoint . IndexOf ( "blob." , 0 , StringComparison . InvariantCultureIgnoreCase ) ;
97
- if ( blobIndex <= 0 )
98
- {
99
- suffix = string . Empty ;
100
- }
101
- else
102
- {
103
- suffix = BlobEndPoint . Substring ( blobIndex + "blob." . Length ) ;
104
- }
92
+ string queueSpliter = "queue." ;
93
+ if ( QueueEndPoint . LastIndexOf ( queueSpliter ) >= 0 )
94
+ return QueueEndPoint . Substring ( QueueEndPoint . LastIndexOf ( queueSpliter ) + queueSpliter . Length ) ;
105
95
}
106
-
107
- return suffix ;
96
+ if ( ! string . IsNullOrEmpty ( FileEndPoint ) )
97
+ {
98
+ string fileSpliter = "file." ;
99
+ if ( FileEndPoint . LastIndexOf ( fileSpliter ) >= 0 )
100
+ return FileEndPoint . Substring ( FileEndPoint . LastIndexOf ( fileSpliter ) + fileSpliter . Length ) ;
101
+ }
102
+ return string . Empty ;
108
103
}
109
104
}
110
105
@@ -131,6 +126,11 @@ public AzureStorageContext(CloudStorageAccount account)
131
126
QueueEndPoint = account . QueueEndpoint . ToString ( ) ;
132
127
}
133
128
129
+ if ( account . FileEndpoint != null )
130
+ {
131
+ FileEndPoint = account . FileEndpoint . ToString ( ) ;
132
+ }
133
+
134
134
StorageAccountName = account . Credentials . AccountName ;
135
135
Context = this ;
136
136
Name = String . Empty ;
@@ -152,7 +152,7 @@ public AzureStorageContext(CloudStorageAccount account)
152
152
/// Proivides a private constructor for building empty instance which
153
153
/// contains no account information.
154
154
/// </summary>
155
- private AzureStorageContext ( )
155
+ protected AzureStorageContext ( )
156
156
{
157
157
}
158
158
0 commit comments