本文整理汇总了C#中IDictionary.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.ThrowIfNull方法的具体用法?C# IDictionary.ThrowIfNull怎么用?C# IDictionary.ThrowIfNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDictionary
的用法示例。
在下文中一共展示了IDictionary.ThrowIfNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateAllFields
internal IList<CodeMemberField> GenerateAllFields(string name,
JsonSchema schema,
IDictionary<JsonSchema, SchemaImplementationDetails>
implDetails,
INestedClassProvider internalClassProvider)
{
schema.ThrowIfNull("schema");
name.ThrowIfNull("name");
implDetails.ThrowIfNull("details");
internalClassProvider.ThrowIfNull("internalClassProvider");
var fields = new List<CodeMemberField>();
if (schema.Properties.IsNullOrEmpty())
{
logger.Debug("No Properties found for " + name);
return fields;
}
int index = 0;
foreach (var propertyPair in schema.Properties)
{
SchemaImplementationDetails details = implDetails[propertyPair.Value];
fields.Add(
GenerateField(
propertyPair.Key, propertyPair.Value, details, index, internalClassProvider,
schema.Properties.Keys.Without(propertyPair.Key)));
index++;
}
return fields;
}
示例2: CreateExpiredJob
public override string CreateExpiredJob(
Job job,
IDictionary<string, string> parameters,
DateTime createdAt,
TimeSpan expireIn)
{
job.ThrowIfNull("job");
parameters.ThrowIfNull("parameters");
using (var repository = _storage.Repository.OpenSession()) {
var invocationData = InvocationData.Serialize(job);
var guid = Guid.NewGuid().ToString();
var ravenJob = new RavenJob {
Id = Repository.GetId(typeof(RavenJob), guid),
InvocationData = invocationData,
CreatedAt = createdAt,
Parameters = parameters
};
repository.Store(ravenJob);
repository.Advanced.AddExpire(ravenJob, createdAt + expireIn);
repository.SaveChanges();
return guid;
}
}
示例3: DecorateClass
public void DecorateClass(CodeTypeDeclaration typeDeclaration,
ISchema schema,
IDictionary<JsonSchema, SchemaImplementationDetails> implDetails,
INestedClassProvider internalClassProvider)
{
typeDeclaration.ThrowIfNull("typeDeclaration");
schema.ThrowIfNull("schema");
implDetails.ThrowIfNull("implDetails");
internalClassProvider.ThrowIfNull("internalClassProvider");
JsonSchema details = schema.SchemaDetails;
details.ThrowIfNull("schemaDetails");
// Check if this decorator can be applied to the schema);
if (details.Type != JsonSchemaType.Array)
{
return;
}
if (details.Items == null || details.Items.Count != 1)
{
logger.Warning("Found array scheme of unhandled type. {0}", details);
return; // not supported
}
// Generate or find the nested type
JsonSchema itemScheme = details.Items[0];
SchemaImplementationDetails implDetail = implDetails[itemScheme];
implDetail.ProposedName = "Entry"; // Change the name to a custom one.
CodeTypeReference item = SchemaDecoratorUtil.GetCodeType(itemScheme, implDetail, internalClassProvider);
// Insert the base type before any interface declaration
var baseType = string.Format("List<{0}>", item.BaseType);
typeDeclaration.BaseTypes.Insert(0, new CodeTypeReference(baseType));
}
示例4: DecorateClass
public void DecorateClass(CodeTypeDeclaration typeDeclaration,
ISchema schema,
IDictionary<JsonSchema, SchemaImplementationDetails> implDetails,
INestedClassProvider internalClassProvider)
{
typeDeclaration.ThrowIfNull("typeDeclaration");
schema.ThrowIfNull("schema");
implDetails.ThrowIfNull("details");
internalClassProvider.ThrowIfNull("internalClassProvider");
typeDeclaration.Members.AddRange(
GenerateAllFields(schema.Name, schema.SchemaDetails, implDetails, internalClassProvider).ToArray());
}
示例5: DecorateInternalClass
public void DecorateInternalClass(CodeTypeDeclaration typeDeclaration,
string name,
JsonSchema schema,
IDictionary<JsonSchema, SchemaImplementationDetails> implDetails,
INestedClassProvider internalClassProvider)
{
typeDeclaration.ThrowIfNull("typeDeclaration");
schema.ThrowIfNull("schema");
implDetails.ThrowIfNull("details");
internalClassProvider.ThrowIfNull("internalClassProvider");
typeDeclaration.Comments.AddRange(CreateComment(schema));
}
示例6: DecorateClass
public void DecorateClass(CodeTypeDeclaration typeDeclaration,
ISchema schema,
IDictionary<JsonSchema, SchemaImplementationDetails> implDetails,
INestedClassProvider internalClassProvider)
{
typeDeclaration.ThrowIfNull("typeDeclaration");
schema.ThrowIfNull("schema");
implDetails.ThrowIfNull("implDetails");
internalClassProvider.ThrowIfNull("internalClassProvider");
schema.SchemaDetails.ThrowIfNull("schema.SchemaDetails");
typeDeclaration.Comments.AddRange(CreateComment(schema.SchemaDetails));
AddCommentsToAllProperties(schema.Name, schema.SchemaDetails, typeDeclaration);
}
示例7: DecorateInternalClass
public void DecorateInternalClass(CodeTypeDeclaration typeDeclaration,
string name,
JsonSchema schema,
IDictionary<JsonSchema, SchemaImplementationDetails> implDetails,
INestedClassProvider internalClassProvider)
{
typeDeclaration.ThrowIfNull("typeDeclatation");
schema.ThrowIfNull("schema");
implDetails.ThrowIfNull("details");
internalClassProvider.ThrowIfNull("internalClassProvider");
typeDeclaration.Members.AddRange(
GenerateAllProperties(name, schema, implDetails, internalClassProvider, typeDeclaration.Name).ToArray(
));
}
示例8: Message
/// <summary>
/// Initializes a new instance of the Message class.
/// </summary>
/// <param name="to">The JID of the intended recipient.</param>
/// <param name="bodies">A dictionary of message bodies. The dictionary
/// keys denote the languages of the message bodies and must be valid
/// ISO 2 letter language codes.</param>
/// <param name="subjects">A dictionary of message subjects. The dictionary
/// keys denote the languages of the message subjects and must be valid
/// ISO 2 letter language codes.</param>
/// <param name="thread">The conversation thread this message belongs to.</param>
/// <param name="type">The type of the message. Can be one of the values from
/// the MessagType enumeration.</param>
/// <param name="language">The language of the XML character data of
/// the stanza.</param>
/// <exception cref="ArgumentNullException">The to parametr or the bodies
/// parameter is null.</exception>
public Message(Jid to, IDictionary<string, string> bodies,
IDictionary<string, string> subjects = null, string thread = null,
MessageType type = MessageType.Normal, CultureInfo language = null)
: base(to, null, null, null, language)
{
to.ThrowIfNull("to");
bodies.ThrowIfNull("bodies");
AlternateSubjects = new XmlDictionary(element, "subject", "xml:lang");
AlternateBodies = new XmlDictionary(element, "body", "xml:lang");
Type = type;
foreach (var pair in bodies)
AlternateBodies.Add(pair.Key, pair.Value);
if (subjects != null)
{
foreach (var pair in subjects)
AlternateSubjects.Add(pair.Key, pair.Value);
}
Thread = thread;
}
示例9: DecorateClass
public void DecorateClass(CodeTypeDeclaration typeDeclaration,
ISchema schema,
IDictionary<JsonSchema, SchemaImplementationDetails> implDetails,
INestedClassProvider internalClassProvider)
{
typeDeclaration.ThrowIfNull("typeDeclaration");
schema.ThrowIfNull("schema");
implDetails.ThrowIfNull("implDetails");
SchemaImplementationDetails details = implDetails[schema.SchemaDetails];
// If this method is refered as a result directly, add an inheritance to IResponse and implement
// the interface
if (details.IsMethodResult)
{
logger.Debug("Applying decorator to schema "+schema.Name);
typeDeclaration.BaseTypes.Add(GetIResponseBaseType());
typeDeclaration.Members.AddRange(CreateETagProperty(typeDeclaration));
}
}
示例10: CreateClass
/// <summary>
/// Creates a fully working class for the specified schema.
/// </summary>
public CodeTypeDeclaration CreateClass(ISchema schema,
IDictionary<JsonSchema, SchemaImplementationDetails> detailCollection,
IEnumerable<string> otherSchemaNames)
{
schema.ThrowIfNull("schema");
detailCollection.ThrowIfNull("detailCollection");
otherSchemaNames.ThrowIfNull("otherSchemaNames");
// Get relevant name collection
IEnumerable<string> relevantNames = otherSchemaNames.Without(schema.Name);
string className = GeneratorUtils.GetClassName(schema, relevantNames);
var typeDeclaration = new CodeTypeDeclaration(className);
var nestedClassGenerator = new NestedClassGenerator(typeDeclaration, decorators, "");
foreach (ISchemaDecorator schemaDecorator in decorators)
{
schemaDecorator.DecorateClass(typeDeclaration, schema, detailCollection, nestedClassGenerator);
}
nestedClassGenerator.GenerateNestedClasses(detailCollection);
return typeDeclaration;
}
示例11: ImplementAdditionalProperties
internal void ImplementAdditionalProperties(CodeTypeDeclaration type,
JsonSchema schema,
IDictionary<JsonSchema, SchemaImplementationDetails> implDetails,
INestedClassProvider internalClassProvider)
{
// Validate the input parameters.
type.ThrowIfNull("type");
schema.ThrowIfNull("schema");
implDetails.ThrowIfNull("implDetails");
internalClassProvider.ThrowIfNull("internalClassProvider");
// Check if this decorator applies to the specified json schema.
if (schema.AdditionalProperties == null)
{
return;
}
// Note/ToDo: Currently we only support AdditionalProperties for schemas
// specifiying no normal properties, as these won't be used
// by the newtonsoft json library if a dictionary is specified.
if (schema.Properties != null && schema.Properties.Count > 0)
{
type.Comments.Add(new CodeCommentStatement("TODO: Add support for additionalProperties on schemas"));
type.Comments.Add(new CodeCommentStatement(" which have normal properties defined."));
return;
}
// Generate the underlying type.
SchemaImplementationDetails details = implDetails[schema];
CodeTypeReference underlyingTypeRef = SchemaDecoratorUtil.GetCodeType(
schema.AdditionalProperties, details, internalClassProvider);
// Add the base type reference.
CodeTypeReference dictionaryRef = new CodeTypeReference(typeof(Dictionary<,>));
dictionaryRef.TypeArguments.Add(typeof(string));
dictionaryRef.TypeArguments.Add(underlyingTypeRef);
type.BaseTypes.Add(dictionaryRef);
}
示例12: CalculateExpectedValues
public IList<MonitorRecord<double>> CalculateExpectedValues(string configName, ReduceLevel comparisonReduceLevel, IDictionary<long, MonitorRecordComparison<double>> expectedValues, IDbConnection conn)
{
configName.ThrowIfNull("configName");
comparisonReduceLevel.ThrowIfNull("comparisonReduceLevel");
expectedValues.ThrowIfNull("expectedValues");
conn.ThrowIfNull("conn");
//Pulls out the last comparison data that was calculated
var comparisonTableName = Support.MakeComparisonName(configName, comparisonReduceLevel.Resolution);
var lastComparisonList = _commands.SelectListLastComparisonData(comparisonTableName, conn);
//Get data we need for the processing
var processingData = GetProcessingData(lastComparisonList, comparisonReduceLevel.Resolution);
//Get the data to be reduced, starting from the last point that was already reduced
var reducedTableName = Support.MakeReducedName(configName, comparisonReduceLevel.Resolution);
var reducedOrdered = _commands.SelectListNeedingToBeReduced(reducedTableName, processingData.LastPrediction != null, processingData.ReducedDataStartTime, conn);
//Start working through the result
ProcessResult(comparisonReduceLevel.Resolution, processingData.LastPredictionTime, reducedOrdered, expectedValues);
return new List<MonitorRecord<double>>();
}
示例13: GetOrCreateDetails
internal static SchemaImplementationDetails GetOrCreateDetails(
IDictionary<JsonSchema, SchemaImplementationDetails> details, JsonSchema schema)
{
details.ThrowIfNull("details");
schema.ThrowIfNull("schema");
// If no implementation details have been added yet, create a new entry);
if (!details.ContainsKey(schema))
{
details.Add(schema, new SchemaImplementationDetails());
}
return details[schema];
}
示例14: SendMessage
/// <summary>
/// Sends a chat message with the specified content to the specified JID.
/// </summary>
/// <param name="to">The JID of the intended recipient.</param>
/// <param name="bodies">A dictionary of message bodies. The dictionary
/// keys denote the languages of the message bodies and must be valid
/// ISO 2 letter language codes.</param>
/// <param name="subjects">A dictionary of message subjects. The dictionary
/// keys denote the languages of the message subjects and must be valid
/// ISO 2 letter language codes.</param>
/// <param name="thread">The conversation thread the message belongs to.</param>
/// <param name="type">The type of the message. Can be one of the values from
/// the MessagType enumeration.</param>
/// <param name="language">The language of the XML character data of
/// the stanza.</param>
/// <exception cref="ArgumentNullException">The to parameter or the bodies
/// parameter is null.</exception>
/// <exception cref="IOException">There was a failure while writing to or reading
/// from the network.</exception>
/// <exception cref="InvalidOperationException">The XmppClient instance is not
/// connected to a remote host, or the XmppClient instance has not authenticated with
/// the XMPP server.</exception>
/// <exception cref="ObjectDisposedException">The XmppClient object has been
/// disposed.</exception>
/// <remarks>
/// An XMPP chat-message may contain multiple subjects and bodies in different
/// languages. Use this method in order to send a message that contains copies of the
/// message content in several distinct languages.
/// </remarks>
/// <include file='Examples.xml' path='S22/Xmpp/Client/XmppClient[@name="SendMessage-2"]/*'/>
public void SendMessage(Jid to, IDictionary<string, string> bodies,
IDictionary<string, string> subjects = null, string thread = null,
MessageType type = MessageType.Normal, CultureInfo language = null)
{
AssertValid();
to.ThrowIfNull("to");
bodies.ThrowIfNull("bodies");
im.SendMessage(to, bodies, subjects, thread, type, language);
}
示例15: CreateExpiredJob
public override string CreateExpiredJob(
Job job,
IDictionary<string, string> parameters,
DateTime createdAt,
TimeSpan expireIn)
{
job.ThrowIfNull("job");
parameters.ThrowIfNull("parameters");
var invocationData = InvocationData.Serialize(job);
var ravenJob = new RavenJob
{
Id = Guid.NewGuid().ToString(),
InvocationData = JobHelper.ToJson(invocationData),
Arguments = invocationData.Arguments,
CreatedAt = createdAt,
ExpireAt = createdAt.Add(expireIn)
};
using (var repository = new Repository()) {
repository.Save(ravenJob);
if (parameters.Count > 0) {
foreach (var parameter in parameters) {
repository.Save(new JobParameter
{
JobId = ravenJob.Id,
Name = parameter.Key,
Value = parameter.Value
});
}
}
return ravenJob.Id.ToString();
}
}