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); }
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; } }
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)); }
internal static void AddIsMethodResult(IDictionary <JsonSchema, SchemaImplementationDetails> details, IService service, IMethod method) { details.ThrowIfNull("details"); service.ThrowIfNull("service"); method.ThrowIfNull("method"); string id = method.ResponseType; if (string.IsNullOrEmpty(id)) { // Return if this method has no response type return; } // Check if this name is a valid schema if (!service.Schemas.ContainsKey(id)) { return; } ISchema schema = service.Schemas[id]; // If no implementation details have been added yet, create a new entry SchemaImplementationDetails implementationDetails = GetOrCreateDetails(details, schema.SchemaDetails); // Change the value implementationDetails.IsMethodResult = true; }
private ResponseWrapper(HttpStatusCode statusCode, IDictionary <string, string> headers, object responseBody = default) { headers.ThrowIfNull(nameof(headers)); StatusCode = statusCode; ResponseBody = responseBody; Headers = headers; }
public static List <TKey> GetAllKeysAsList <TKey, TValue>([NotNull] this IDictionary <TKey, TValue> dictionary) { dictionary.ThrowIfNull(nameof(dictionary)); return(dictionary.Select(x => x.Key) .ToList()); }
/// <summary> /// Initializes a new instance of the Message class. /// </summary> /// <param name="to">The JID of the intended recipient.</param> /// <param name="body">The content of the message.</param> /// <param name="othertagname">The tag name the others items below will be wrapped in - they will have the appropriate namespace assigned.</param> /// <param name="others">A dictionary of additional message elements after body. The dictionary /// keys denote the namespace of the message bodies. The element name should be the same for all items but you can have multiple - /// each new element will have the namespace associated with it.</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, String body, string othertagname, IDictionary <string, string> others, IDictionary <string, string> subjects = null, List <Jid> additionalAddresses = null, string thread = null, MessageType type = MessageType.Normal, CultureInfo language = null) : base(to, null, null, null, language) { to.ThrowIfNull("to"); others.ThrowIfNull("bodies"); AlternateSubjects = new XmlDictionary(element, "subject", "xml:lang"); Body = body; AlternateBodies = new XmlDictionary(element, othertagname, "xmlns"); AlternateAddresses = new XmlDictionary(element, "addresses", "xml:lang"); Type = type; foreach (var pair in others) { AlternateBodies.Add(pair.Key, pair.Value); } if (subjects != null) { foreach (var pair in subjects) { AlternateSubjects.Add(pair.Key, pair.Value); } } Thread = thread; Addresses = additionalAddresses; }
private static void Initialize(IDictionary <string, IAuthenticationProvider> authenticationProviders) { authenticationProviders.ThrowIfNull("authenticationProviders"); var discoveredProviders = ReflectionHelpers.FindAllTypesOf <IAuthenticationProvider>(); if (discoveredProviders == null) { return; } // Try configure from custom config section. var providerConfig = ProviderConfigHelper.UseConfig(); if (providerConfig != null) { SetupCustomConfigProviders(authenticationProviders, discoveredProviders, providerConfig); } var appSettings = ProviderConfigHelper.UseAppSettings(); if (appSettings != null && appSettings.Any()) { SetupAppSettingsConfigProviders(authenticationProviders, discoveredProviders, appSettings); } }
public static TValue AddOrUpdate <TKey, TValue>( this IDictionary <TKey, TValue> dictionary, [DisallowNull] TKey key, Func <TValue> newValue, Func <TValue, TValue> updateValue) where TKey : notnull { dictionary.ThrowIfNull(nameof(dictionary)); key.ThrowIfNullValue(nameof(key), assertOnPureValueTypes: false); newValue.ThrowIfNull(nameof(newValue)); updateValue.ThrowIfNull(nameof(updateValue)); if (dictionary.TryGetValue(key, out TValue value)) { value = updateValue(value); dictionary[key] = value; } else { value = newValue(); dictionary.Add(key, value); } return(value); }
/// <summary> /// Sorts a dictionary by value /// </summary> /// <typeparam name="T1">Key type</typeparam> /// <typeparam name="T2">Value type</typeparam> /// <param name="Dictionary">Dictionary to sort</param> /// <param name="Comparer">Comparer used to sort (defaults to GenericComparer)</param> /// <returns>The sorted dictionary</returns> public static IDictionary <T1, T2> SortByValue <T1, T2>(this IDictionary <T1, T2> Dictionary, IComparer <T1> Comparer = null) where T1 : IComparable { Dictionary.ThrowIfNull("Dictionary"); return(new SortedDictionary <T1, T2>(Dictionary, Comparer.NullCheck(new GenericComparer <T1>())) .OrderBy(x => x.Value) .ToDictionary(x => x.Key, x => x.Value)); }
private void InitializeConfigParameters(IDictionary config) { config.ThrowIfNull("config"); ApplicationName = ResolveConfigurationParam(config, "applicationName"); EnvironmentName = ResolveConfigurationParam(config, "environmentName"); CustomerName = ResolveConfigurationParam(config, "customerName"); }
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; }
public void SendMessage(S22.Xmpp.Jid to, IDictionary <string, string> bodies, IDictionary <string, string> subjects = null, string thread = null, MessageType type = 0, CultureInfo language = null) { this.AssertValid(); to.ThrowIfNull <S22.Xmpp.Jid>("to"); bodies.ThrowIfNull <IDictionary <string, string> >("bodies"); this.im.SendMessage(to, bodies, subjects, thread, type, language); }
public static bool TryGetValue <TKey, TValue>( this IDictionary <TKey, TValue> dictionary, Func <KeyValuePair <TKey, TValue>, bool> predicate, [MaybeNullWhen(false)] out TValue value) where TKey : notnull { dictionary.ThrowIfNull(nameof(dictionary)); predicate.ThrowIfNull(nameof(predicate)); // Use plain old foreach loop because LINQ does not help us to detect if dictionary // contains required value or not (e.g. the value is suitable and equal to default). foreach (KeyValuePair <TKey, TValue> kvPair in dictionary) { if (predicate(kvPair)) { value = kvPair.Value; return(true); } } #pragma warning disable CS8653 // A default expression introduces a null value for a type parameter. value = default; #pragma warning restore CS8653 // A default expression introduces a null value for a type parameter. return(false); }
/// <summary> /// Sorts a dictionary /// </summary> /// <typeparam name="T1">Key type</typeparam> /// <typeparam name="T2">Value type</typeparam> /// <typeparam name="T3">Order by type</typeparam> /// <param name="Dictionary">Dictionary to sort</param> /// <param name="OrderBy">Function used to order the dictionary</param> /// <param name="Comparer">Comparer used to sort (defaults to GenericComparer)</param> /// <returns>The sorted dictionary</returns> public static IDictionary <T1, T2> Sort <T1, T2, T3>(this IDictionary <T1, T2> Dictionary, Func <KeyValuePair <T1, T2>, T3> OrderBy, IComparer <T3> Comparer = null) where T3 : IComparable { Dictionary.ThrowIfNull("Dictionary"); OrderBy.ThrowIfNull("OrderBy"); return(Dictionary.OrderBy(OrderBy, Comparer.NullCheck(new GenericComparer <T3>())).ToDictionary(x => x.Key, x => x.Value)); }
/// <summary> /// Appends the parameters to the base URL. The base URL is allowed to have parameters defined already. /// Note: It is assumed the base URL already has been properly sanitized for use. Each parameter is sanitized. /// </summary> /// <param name="baseUrl">The base URL for which the parameters are appended.</param> /// <param name="parameters">The parameters to be appended.</param> /// <returns>The complete URL with parameters appended.</returns> public static string BuildUrlQuery(string baseUrl, IDictionary parameters) { baseUrl.ThrowIfNullOrWhitespace(nameof(baseUrl)); parameters.ThrowIfNull(nameof(parameters)); string result = baseUrl; foreach (DictionaryEntry it in parameters) { if ((it.Key == null) || (it.Value == null)) { continue; } string key = SerializationUtilities.PostProcessValue <string>(it.Key); string value = SerializationUtilities.PostProcessValue <string>(it.Value); if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value)) { result = AppendUrlParam(result, key, value); } } return(result); }
public static IDictionary <TValue, TKey> ConcatAllToDictionarySafe <TValue, TKey>( [NotNull] this IDictionary <TValue, TKey> dictionary, [NotNull][ItemCanBeNull] params IDictionary <TValue, TKey>[] dictionaries) { dictionary.ThrowIfNull(nameof(dictionary)); dictionaries.ThrowIfNull(nameof(dictionaries)); var result = dictionary; dictionaries.ForEach(x => { if (x == null) { return; } x.ForEach(y => { if (!result.ContainsKey(y.Key)) { result.Add(y.Key, y.Value); } }); }); return(result); }
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 = _storage.Repository.GetId(typeof(RavenJob), guid), InvocationData = invocationData, CreatedAt = createdAt, Parameters = parameters }; repository.Store(ravenJob); repository.Advanced.AddExpire(ravenJob, createdAt + expireIn); repository.SaveChanges(); return(guid); } }
public ProjectsCard(IDictionary <string, string> projects) { projects.ThrowIfNull(nameof(projects)); this.Buttons = projects .Select(p => new CardAction(ActionTypes.ImBack, p.Value, value: p.Value)) .ToList(); }
public LanguagesCard(IDictionary <string, string> languages) { languages.ThrowIfNull(nameof(languages)); this.Buttons = languages .Select(a => new CardAction(ActionTypes.ImBack, a.Key, value: a.Value)) .ToList(); }
private static void RemoveProviderFromDictionary(string providerName, IDictionary <string, IAuthenticationProvider> authenticationProviders) { providerName.ThrowIfNull("providerName"); authenticationProviders.ThrowIfNull("authenticationProviders"); authenticationProviders.Remove(providerName); }
public static string PrettyPrint <TKey, TValue>( this IDictionary <TKey, TValue> dictionary, char separator = EnumerableExtensions.PrettyPrintDefaultSeparator, uint minSeparation = EnumerableExtensions.PrettyPrintMinSeparation) { dictionary.ThrowIfNull(nameof(dictionary)); return(dictionary.AsEnumerable().PrettyPrint(separator, minSeparation)); }
public static Boolean ContainsAllKey <TKey, TValue>([NotNull] this IDictionary <TKey, TValue> dictionary, [NotNull][ItemNotNull] IEnumerable <TKey> keys) { dictionary.ThrowIfNull(nameof(dictionary)); keys.ThrowIfNull(nameof(keys)); return(keys.All(dictionary.ContainsKey)); }
public static Boolean ContainsAnyKey <TKey, TValue>([NotNull] this IDictionary <TKey, TValue> dictionary, [NotNull][ItemNotNull] params TKey[] keys) { dictionary.ThrowIfNull(nameof(dictionary)); keys.ThrowIfNull(nameof(keys)); return(keys.Any(dictionary.ContainsKey)); }
protected IDToObjectProvider(IDictionary <long, IDInformation <T, X> > cache) { cache.ThrowIfNull(nameof(cache)); m_cache = cache; m_pendingIDs = new SortedDictionary <long, X>(); m_queryPending = false; }
public TeamsCard(IDictionary <string, string> teams) { teams.ThrowIfNull(nameof(teams)); this.Buttons = teams .Select(a => new CardAction(ActionTypes.ImBack, a.Value, value: a.Value)) .ToList(); }
public AccountsCard(IDictionary <string, string> accounts) { accounts.ThrowIfNull(nameof(accounts)); this.Buttons = accounts .Select(a => new CardAction(ActionTypes.ImBack, a.Value, value: a.Value)) .ToList(); }
/// <summary> /// Overridden. Adds properties to or removes properties from the Properties grid in a design host at design time /// or provides new design-time properties that might correspond to properties on the associated control. /// </summary> /// <param name="properties">The original properties dictionary.</param> /// <exception cref="System.ArgumentNullException">properties</exception> protected override void PreFilterProperties(IDictionary properties) { properties.ThrowIfNull(nameof(properties)); base.PreFilterProperties(properties); properties["Text"] = TypeDescriptor.CreateProperty(typeof(MultiPanelPageDesigner), (PropertyDescriptor)properties["Text"], new Attribute[0]); }
public static String StringJoin <TValue, TKey>([NotNull] this IDictionary <TValue, TKey> dictionary, [CanBeNull] String keyValueSeparator = "=", [CanBeNull] String separator = "") { dictionary.ThrowIfNull(nameof(dictionary)); return(dictionary.Select(x => x.Key + keyValueSeparator + x.Value) .StringJoin(separator)); }
protected IDToObjectProvider(IDictionary <long, T> cache) { cache.ThrowIfNull(nameof(cache)); m_cache = cache; m_pendingIDs = new SortedDictionary <long, X>(); m_requested = new HashSet <long>(); m_queryPending = false; }
public int Execute(string storedProcedureName, IDictionary <string, object> parameters) { storedProcedureName.ThrowIfNullOrEmpty(); parameters.ThrowIfNull(); var command = new SqlCommand(storedProcedureName, parameters); return(_database.ExecuteStoredProcedure(command)); }
public static IDictionary <TKey, TValue> AddRange <TKey, TValue>([NotNull] this IDictionary <TKey, TValue> dictionary, [NotNull] IDictionary <TKey, TValue> otherDictionary) { dictionary.ThrowIfNull(nameof(dictionary)); otherDictionary.ThrowIfNull(nameof(otherDictionary)); otherDictionary.ForEach(x => dictionary.Add(x.Key, x.Value)); return(dictionary); }
public async Task <int> ExecuteAsync(string storedProcedureName, IDictionary <string, object> parameters) { storedProcedureName.ThrowIfNullOrEmpty(); parameters.ThrowIfNull(); var command = new SqlCommand(storedProcedureName, parameters); return(await _database.ExecuteStoredProcedureAsync(command)); }
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()); }
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)); }
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); }
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( )); }
/// <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; }
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)); } }
/// <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; }
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); }
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>>(); }
internal static void AddIsMethodResult(IDictionary<JsonSchema, SchemaImplementationDetails> details, IService service, IEnumerable<IResource> resources) { details.ThrowIfNull("details"); service.ThrowIfNull("service"); resources.ThrowIfNull("method"); foreach (IResource resource in resources) { // Check methods foreach (IMethod method in resource.Methods.Values) { AddIsMethodResult(details, service, method); } // Check subresources (if applicable) if (resource.Resources != null) { AddIsMethodResult(details, service, resource.Resources.Values); } } }
/// <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); }
internal static void ProposeNameIfNecessary(IDictionary<JsonSchema, SchemaImplementationDetails> dictionary, string name, JsonSchema schema) { schema.ThrowIfNull("schema"); name.ThrowIfNull("name"); dictionary.ThrowIfNull("name"); if (schema.Id.IsNotNullOrEmpty()) { // Already has a name -> return. return; } SchemaImplementationDetails details = GetOrCreateDetails(dictionary, schema); if (string.IsNullOrEmpty(details.ProposedName)) { details.ProposedName = name; } }
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]; }
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(); } }
internal static void AddIsMethodResult(IDictionary<JsonSchema, SchemaImplementationDetails> details, IService service, IMethod method) { details.ThrowIfNull("details"); service.ThrowIfNull("service"); method.ThrowIfNull("method"); string id = method.ResponseType; if (string.IsNullOrEmpty(id)) { // Return if this method has no response type return; } // Check if this name is a valid schema if (!service.Schemas.ContainsKey(id)) { return; } ISchema schema = service.Schemas[id]; // If no implementation details have been added yet, create a new entry SchemaImplementationDetails implementationDetails = GetOrCreateDetails(details, schema.SchemaDetails); // Change the value implementationDetails.IsMethodResult = true; }
/// <summary> /// Sets the query parameters of the URI. /// </summary> /// <param name="queryParams"> /// The query parameters to add to the URI. /// </param> /// <returns> /// A <see cref="FluentUriBuilder"/> instance to allow chaining. /// </returns> /// <exception cref="ArgumentNullException"> /// If <see cref="queryParams"/> is <c>null</c>; /// </exception> public FluentUriBuilder QueryParams(IDictionary<string, object> queryParams) { queryParams.ThrowIfNull(nameof(queryParams)); initializeQueryParamsList(); foreach (var kvp in queryParams) { this.queryParams.Add(new UriQueryParam(kvp.Key, kvp.Value.ToString())); } return this; }