- Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathMetadataChange.cs
141 lines (126 loc) · 4.74 KB
/
MetadataChange.cs
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
usingSystem;
usingSystem.Collections.Generic;
namespaceFirebase.Storage{
/// <summary>
/// MetadataChange is a set of new metadata values used during object upload
/// or when modifying the metadata of an object.
/// A MetadataChange can be created from an existing <see cref="StorageMetadata"/>
/// or it can be created from scratch.
/// </summary>
publicclassMetadataChange{
privatereadonlyStorageMetadatametadata;
/// <summary>Creates an empty set of metadata.</summary>
publicMetadataChange(){
metadata=newStorageMetadata();
}
/// <summary>Used to create a modified version of the original set of metadata.</summary>
/// <param name="original">The source of the metadata to build from.</param>
publicMetadataChange(StorageMetadataoriginal){
metadata=newStorageMetadata(original);
}
/// <summary>
/// Build StorageMetadata from this class.
/// </summary>
internalStorageMetadataBuild(){
returnnewStorageMetadata(metadata);
}
/// <summary>
/// Build StorageMetadata from the specified class.
/// </summary>
/// <param name="metadataChange"></param>
/// <returns>StorageMetadata instance if the specified MetadataChange is not null, null
/// otherwise.</returns>
internalstaticStorageMetadataBuild(MetadataChangemetadataChange){
returnmetadataChange!=null?metadataChange.Build():null;
}
/// <summary>
/// Gets or sets the content language for the
/// <see cref="StorageReference" />.
/// This must be an
/// <see href="https://www.loc.gov/standards/iso639-2/php/code_list.php">ISO 639-1</see>
/// two-letter language code. E.g. "zh", "es", "en".
/// </summary>
publicstringContentLanguage{
get{returnmetadata.ContentLanguage;}
set{metadata.Internal.ContentLanguage=value;}
}
/// <summary>
/// Gets or sets the content encoding for the
/// <see cref="StorageReference" />.
/// </summary>
publicstringContentEncoding{
get{returnmetadata.ContentEncoding;}
set{metadata.Internal.ContentEncoding=value;}
}
/// <summary>
/// Gets or sets the content disposition for the
/// <see cref="StorageReference" />.
/// </summary>
publicstringContentDisposition{
get{returnmetadata.ContentDisposition;}
set{metadata.Internal.ContentDisposition=value;}
}
/// <summary>
/// Gets or sets the Cache Control for the
/// <see cref="StorageReference" />.
/// </summary>
publicstringCacheControl{
get{returnmetadata.CacheControl;}
set{metadata.Internal.CacheControl=value;}
}
/// <summary>
/// Gets or sets custom metadata.
/// To use this in an object initalizer, you may use the form:
/// var change = new MetadataChange
/// {
/// CustomMetadata = new Dictionary<string, string> {
/// {"customkey1", "customValue1"},
/// {"customkey2", "customValue2"}
/// }
/// }
/// </summary>
publicIDictionary<string,string>CustomMetadata{
set{
varmetadataMap=newStringStringMap();
foreach(varkvinvalue)metadataMap[kv.Key]=kv.Value;
metadata.Internal.CustomMetadata=metadataMap;
}
get{
varmetadataMap=newDictionary<string,string>();
foreach(varkvinmetadata.Internal.CustomMetadata)metadataMap[kv.Key]=kv.Value;
returnmetadataMap;
}
}
/// <summary>Sets custom metadata</summary>
/// <param name="key">the key of the new value</param>
/// <param name="value">the value to set.</param>
privatevoidSetCustomMetadata(stringkey,stringvalue){
varmodifiedMetadata=CustomMetadata;
modifiedMetadata[key]=value;
CustomMetadata=modifiedMetadata;
}
/// <summary>
/// Gets or sets the Content Type of this associated
/// <see cref="StorageReference" />.
/// </summary>
publicstringContentType{
get{returnmetadata.ContentType;}
set{metadata.Internal.ContentType=value;}
}
}
}