本文整理汇总了C#中IDictionary.AsReadOnly方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.AsReadOnly方法的具体用法?C# IDictionary.AsReadOnly怎么用?C# IDictionary.AsReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDictionary
的用法示例。
在下文中一共展示了IDictionary.AsReadOnly方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImapNamespaceDesc
public ImapNamespaceDesc(string prefix, string hierarchyDelimiter, IDictionary<string, string[]> extensions)
{
if (prefix == null)
throw new ArgumentNullException("prefix");
if (extensions == null)
throw new ArgumentNullException("extensions");
this.Prefix = prefix;
this.HierarchyDelimiter = hierarchyDelimiter;
this.Extensions = extensions.AsReadOnly();
}
示例2: ExportDefinition
/// <summary>
/// Initializes a new instance of the <see cref="ExportDefinition"/> class with
/// the specified contract name and metadata.
/// </summary>
/// <param name="contractName">
/// A <see cref="String"/> containing the contract name of the
/// <see cref="ExportDefinition"/>.
/// </param>
/// <param name="metadata">
/// An <see cref="IDictionary{TKey, TValue}"/> containing the metadata of the
/// <see cref="ExportDefinition"/>; or <see langword="null"/> to set the
/// <see cref="Metadata"/> property to an empty, read-only
/// <see cref="IDictionary{TKey, TValue}"/>.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="contractName"/> is <see langword="null"/>.
/// </exception>
/// <exception cref="ArgumentException">
/// <paramref name="contractName"/> is an empty string ("").
/// </exception>
public ExportDefinition(string contractName, IDictionary<string, object> metadata)
{
Requires.NotNullOrEmpty(contractName, "contractName");
_contractName = contractName;
if (metadata != null)
{
_metadata = metadata.AsReadOnly();
}
}
开发者ID:Ginichen,项目名称:Silverlight-Player-for-PlayReady-with-Token-Auth,代码行数:31,代码来源:ExportDefinition.cs
示例3: DerivedComposablePartDefinition
public DerivedComposablePartDefinition(
IDictionary<string, object> metadata,
Func<ComposablePart> partCreator,
Func<IEnumerable<ImportDefinition>> importsCreator,
Func<IEnumerable<ExportDefinition>> exportsCreator)
{
this._metadata = metadata.AsReadOnly();
this._partCreator = partCreator;
this._importsCreator = importsCreator;
this._exportsCreator = exportsCreator;
}
示例4: FakeViewRow
public FakeViewRow(IDictionary<string, object> info)
{
if (!info.TryGetValue("id", out _id))
{
_id = null;
}
object tempKey;
if (!info.TryGetValue("key", out tempKey))
{
throw new InvalidOperationException("The value 'key' was not found in the info definition.");
}
_key = (tempKey as object[]) ?? (new[] { tempKey });
_info = info.AsReadOnly();
}
示例5: GetDisallowedEntries
private static void GetDisallowedEntries( XmlNode node, int numSections, out IList<IList<int>> disallowed, out IList<IDictionary<int,string>> staticEntries )
{
IList<IList<int>> result = new IList<int>[numSections];
IList<IDictionary<int, string>> ourStatic = new IDictionary<int, string>[numSections];
XmlNode disallowedNode = node.SelectSingleNode( "DisallowedEntries" );
if ( disallowedNode != null )
{
foreach ( XmlNode node2 in disallowedNode.SelectNodes( "Section" ) )
{
int sec = Int32.Parse( node2.Attributes["value"].InnerText );
List<int> ourResult = new List<int>();
Dictionary<int, string> ourDict = new Dictionary<int, string>();
foreach ( XmlNode ent in node2.SelectNodes( "entry" ) )
{
int idx = Int32.Parse(ent.InnerText);
ourResult.Add( idx);
XmlAttribute stat = ent.Attributes["staticValue"];
if ( stat != null )
{
ourDict[idx] = stat.InnerText;
}
else
{
ourDict[idx] = string.Empty;
}
}
result[sec] = ourResult.AsReadOnly();
ourStatic[sec] = new ReadOnlyDictionary<int, string>( ourDict );
}
}
for ( int i = 0; i < result.Count; i++ )
{
if ( result[i] == null )
{
result[i] = new int[0].AsReadOnly();
}
if ( ourStatic[i] == null )
{
ourStatic[i] = new ReadOnlyDictionary<int, string>( new Dictionary<int, string>( 0 ) );
}
}
disallowed = result.AsReadOnly();
staticEntries = ourStatic.AsReadOnly();
}
示例6: FromJsonObject
public static Bug FromJsonObject(IDictionary<string, object> jsonObject)
{
jsonObject = jsonObject.WrapInMissingKeySafeDictionary ();
var bug = new Bug ();
try {
bug.AssignedTo = (string) jsonObject["assigned_to"];
bug.BlocksOn = ((JsonArray) jsonObject["blocks"]).Cast<long> ().ToArray ();
bug.Classification = (string) jsonObject["classification"];
bug.Component = (string) jsonObject["component"];
bug.Creator = (string) jsonObject["creator"];
bug.DependsOn = ((JsonArray) jsonObject["depends_on"]).Cast<long> ().ToArray ();
bug.DuplicateOf = (long?) jsonObject["duplicate_of"];
bug.Groups = ((JsonArray) jsonObject["groups"]).Cast<string> ().ToArray ();
bug.Id = (long) jsonObject["id"];
bug.Keywords = ((JsonArray) jsonObject["keywords"]).Cast<string> ().ToArray ();
bug.LastChanged = DateTime.SpecifyKind (DateTime.Parse ((string) jsonObject["last_change_time"]), DateTimeKind.Utc);
bug.Milestone = (string) jsonObject["target_milestone"];
bug.Priority = (string) jsonObject["priority"];
bug.Product = (string) jsonObject["product"];
bug.Resolution = (string) jsonObject["resolution"];
bug.SeeAlso = ((JsonArray) jsonObject["see_also"]).Cast<string> ().ToArray ();
bug.Severity = (string) jsonObject["severity"];
bug.Status = (string) jsonObject["status"];
bug.Subscribers = ((JsonArray) jsonObject["cc"]).Cast<string> ().ToArray ();
bug.Summary = (string) jsonObject["summary"];
bug.Version = (string) jsonObject["version"];
bug.Attributes = jsonObject.AsReadOnly ();
bug.Url = (string) jsonObject["url"];
} catch (Exception e) {
#if DEBUG
Console.Error.WriteLine(jsonObject.ToString());
#endif
Console.WriteLine("Failed to parse bug from JSON: {0}", e.Message);
}
return bug;
}
示例7: TermExpression
public TermExpression(IDictionary<TermExpression, TermExpression> terms)
{
if (terms == null || terms.Count == 0)
throw new CqlLinqException("Empty dictionaries are not allowed");
var firstElement = terms.First();
_type = typeof(IDictionary<,>).MakeGenericType(firstElement.Key.Type, firstElement.Value.Type);
_dictionaryTerms = terms.AsReadOnly();
_termType = CqlExpressionType.Map;
}