当前位置: 首页>>代码示例>>C#>>正文


C# IDictionary.ThrowIfNull方法代码示例

本文整理汇总了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;
        }
开发者ID:JANCARLO123,项目名称:google-apis,代码行数:31,代码来源:StandardPropertyFieldDecorator.cs

示例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;
            }
        }
开发者ID:cady-io,项目名称:hangfire-ravendb,代码行数:29,代码来源:RavenConnection.cs

示例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));
        }
开发者ID:nick0816,项目名称:LoggenCSG,代码行数:35,代码来源:ArraySchemaDecorator.cs

示例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());
 }
开发者ID:JANCARLO123,项目名称:google-apis,代码行数:12,代码来源:StandardPropertyFieldDecorator.cs

示例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));
        }
开发者ID:JANCARLO123,项目名称:google-apis,代码行数:13,代码来源:StandardSchemaCommentDecorator.cs

示例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);
        }
开发者ID:nick0816,项目名称:LoggenCSG,代码行数:14,代码来源:StandardSchemaCommentDecorator.cs

示例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(
             ));
 }
开发者ID:nick0816,项目名称:LoggenCSG,代码行数:14,代码来源:StandardPropertyDecorator.cs

示例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;
 }
开发者ID:jbautistam,项目名称:BauXmppMessenger,代码行数:36,代码来源:Message.cs

示例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));
            }
        }
开发者ID:JANCARLO123,项目名称:google-apis,代码行数:20,代码来源:ResponseInterfaceDecorator.cs

示例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;
        }
开发者ID:jithuin,项目名称:infogeezer,代码行数:25,代码来源:SchemaGenerator.cs

示例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);
        }
开发者ID:jithuin,项目名称:infogeezer,代码行数:38,代码来源:AdditionalPropertiesSchemaDecorator.cs

示例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>>();
        }
开发者ID:Zocdoc,项目名称:ZocMon,代码行数:23,代码来源:ProcessingInstructionAccumulate.cs

示例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];
        }
开发者ID:jithuin,项目名称:infogeezer,代码行数:13,代码来源:ImplementationDetailsGenerator.cs

示例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);
 }
开发者ID:REPLDigital,项目名称:Sharp.Xmpp,代码行数:39,代码来源:XmppClient.cs

示例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();
            }
        }
开发者ID:krivulcik,项目名称:hangfire-ravendb,代码行数:37,代码来源:RavenConnection.cs


注:本文中的IDictionary.ThrowIfNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。