public void postAction(string actionId, IDictionary actionProperties, string objectId, IDictionary objectProperties, string objectInstanceId = null, CarrotRequestResponse callback = null) { if(string.IsNullOrEmpty(objectId)) { throw new ArgumentNullException("objectId must not be null or empty string.", "objectId"); } if(string.IsNullOrEmpty(actionId)) { throw new ArgumentNullException("actionId must not be null or empty string.", "actionId"); } if(objectProperties == null) { throw new ArgumentNullException("objectProperties must not be null.", "objectProperties"); } else if(!objectProperties.Contains("title") || !objectProperties.Contains("description") || !objectProperties.Contains("image")) { throw new ArgumentException("objectProperties must contain keys for 'title', 'description', and 'image'.", "objectProperties"); } objectProperties["object_type"] = objectId; if(!string.IsNullOrEmpty(objectInstanceId)) objectProperties["object_instance_id"] = objectInstanceId; Dictionary<string, object> parameters = new Dictionary<string, object>() { {"action_id", actionId}, {"action_properties", actionProperties == null ? new Dictionary<string, object>() : actionProperties}, {"object_properties", objectProperties} }; StartCoroutine(cachedRequestCoroutine(ServiceType.Post, "/me/actions.json", parameters, callback)); }
/// <summary> Returns a value cast to a specific type /// * /// </summary> /// <param name="aBrc">- The BRERuleContext object /// </param> /// <param name="aMap">- The IDictionary of parameters from the XML /// </param> /// <param name="aStep">- The step that it is on /// </param> /// <returns> The value cast to the specified type /// /// </returns> public object ExecuteRule(IBRERuleContext aBrc, IDictionary aMap, object aStep) { bool staticCall = false; if (!aMap.Contains(OBJECTID)) { if (!aMap.Contains(TYPE)) throw new BRERuleException("Parameter 'Type' or 'ObjectId' not found"); else staticCall = true; } if (!aMap.Contains(MEMBER)) { throw new BRERuleException("Parameter 'Member' not found"); } else { if (staticCall) return Reflection.ClassCall((string)aMap[TYPE], (string)aMap[MEMBER], GetArguments(aMap)); else return Reflection.ObjectCall(aBrc.GetResult(aMap[OBJECTID]).Result, (string)aMap[MEMBER], GetArguments(aMap)); } }
/// <summary></summary> public ClientWorkflowInvoker(IDictionary properties, IClientChannelSinkProvider clientSinkProvider) { try { // configuration file if(properties.Contains("timeout")) _TimeOut = Convert.ToInt32(properties["timeout"]); if (properties.Contains("name")) _ChannelName = Convert.ToString(properties["name"]); if (properties.Contains("callcontextActor")) _CallContextActor = Convert.ToString(properties["callcontextActor"]); // channel provider _Provider = clientSinkProvider == null ? new BinaryClientFormatterSinkProvider() : clientSinkProvider; // add the ClientWorkflowInvokerProvider at the end IClientChannelSinkProvider provider = _Provider; while (provider.Next != null) { provider = provider.Next; } provider.Next = new ClientWorkflowInvokerProvider(); } catch(Exception ex) { Trace.WriteLine(ex); } }
public AndroidNotificationPayload(IDictionary _payloadDict) { AndroidProperties = new AndroidSpecificProperties(); // Alert if (_payloadDict.Contains(NPSettings.Notification.Android.ContentTextKey)) { //Check here which key is being received. Console.Log(Constants.kDebugTag, "[BillingTransaction] " + _payloadDict.ToJSON());//TODO object _alertUnknownType = _payloadDict[ContentTextKey] as object; // String type if ((_alertUnknownType as string) != null) { AlertBody = _alertUnknownType as string; } } if (_payloadDict.Contains(UserInfoKey)) UserInfo = _payloadDict[UserInfoKey] as IDictionary; // Fire date long _secsFromNow = _payloadDict.GetIfAvailable<long>(kFireDate); FireDate = _secsFromNow.ToDateTimeFromJavaTime(); // Sound, Badge AndroidProperties.ContentTitle = _payloadDict.GetIfAvailable<string>(ContentTitleKey); AndroidProperties.TickerText = _payloadDict.GetIfAvailable<string>(TickerTextKey); AndroidProperties.Tag = _payloadDict.GetIfAvailable<string>(TagKey); //Added in 1.03 AndroidProperties.CustomSound = _payloadDict.GetIfAvailable<string>(kCustomSound); AndroidProperties.LargeIcon = _payloadDict.GetIfAvailable<string>(kLargeIcon); }
/// <summary> /// Drops the BackgroundImage property /// </summary> /// <param name="properties">properties to remove BackGroundImage from</param> protected override void PreFilterProperties(IDictionary properties) { base.PreFilterProperties(properties); if (properties.Contains("BackgroundImage")) properties.Remove("BackgroundImage"); if (properties.Contains("DrawGrid")) properties.Remove("DrawGrid"); }
public void InitializeData(IDictionary JSON) { if(JSON.Contains("id")) { _id = System.Convert.ToString(JSON["id"]); } if(JSON.Contains("birthday")) { _Birthday =DateTime.Parse(System.Convert.ToString(JSON["birthday"])); } if(JSON.Contains("name")) { _name = System.Convert.ToString(JSON["name"]); } if(JSON.Contains("first_name")) { _first_name = System.Convert.ToString(JSON["first_name"]); } if(JSON.Contains("last_name")) { _last_name = System.Convert.ToString(JSON["last_name"]); } if(JSON.Contains("username")) { _username = System.Convert.ToString(JSON["username"]); } if(JSON.Contains("link")) { _profile_url = System.Convert.ToString(JSON["link"]); } if(JSON.Contains("email")) { _email = System.Convert.ToString(JSON["email"]); } if(JSON.Contains("locale")) { _locale = System.Convert.ToString(JSON["locale"]); } if(JSON.Contains("location")) { IDictionary loc = JSON["location"] as IDictionary; _location = System.Convert.ToString(loc["name"]); } if(JSON.Contains("gender")) { string g = System.Convert.ToString(JSON["gender"]); if(g.Equals("male")) { _gender = FB_Gender.Male; } else { _gender = FB_Gender.Female; } } }
public DynamoErrorLog(IDictionary config) { if (config == null) throw new ArgumentNullException("config"); if (!config.Contains("applicationName")) throw new InvalidOperationException("'applicationName' attribute missing from Elmah config"); string appName = (string)config["applicationName"]; ApplicationName = appName; if (config.Contains("tableName")) s_TableName = (string)config["tableName"]; }
public bool Accept(String name, IDictionary options, TextWriter writer) { if (!"project".Equals(name)) { return false; } else if (options.Count == 1) { writer.WriteLine("Creates a new VS.Net 2003 project structure"); writer.WriteLine(""); writer.WriteLine("name : Project name"); writer.WriteLine("outdir : Target directory (must exists)"); writer.WriteLine("windsor : [Optional] Enable WindsorContainer Integration"); writer.WriteLine("view : [Optional] aspnet|nvelocity (defaults to nvelocity)"); writer.WriteLine("lang : [Optional] c#|vb.net (defaults to c#)"); writer.WriteLine(""); writer.WriteLine("Example:"); writer.WriteLine(""); writer.WriteLine(@"> generator project name:My.CoR.Project windsor outdir:c:\temp"); writer.WriteLine(""); return false; } else if (!options.Contains("outdir")) { writer.WriteLine("outdir must be specified"); return false; } else if (!options.Contains("name")) { writer.WriteLine("name must be specified"); return false; } else { DirectoryInfo info = new DirectoryInfo(options["outdir"] as String); if (!info.Exists) { // info.Create(); // Is it safe to use it? writer.WriteLine("Error: The specified outdir does not exists."); return false; } } return true; }
private static double GetScaleMeters(IDictionary source, string key, IFactory factory) { var lengthMeters = Node.Net.Factories.Extension.IDictionaryExtension.GetLengthMeters(source, key); if (source.Contains(key)) return lengthMeters; if (key.Contains(",")) { var keys = key.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (var k in keys) { if (source.Contains(k)) return lengthMeters; } } return 1; }
public IDictionary Convert(IDictionary source) { if (source != null && source.Contains(nameof(Type))) { var type = source[nameof(Type)].ToString(); if (Types != null && Types.ContainsKey(type)) { try { var _type = Types[type]; if (_type == null) throw new Exception($"Types['{type}'] was null"); var dictionary = Activator.CreateInstance(_type) as IDictionary; if(dictionary == null) { throw new Exception($"unable to create instance of type {_type.FullName}"); } Copy(source, dictionary); return dictionary; } catch(Exception ex) { throw new Exception($"Exception while converting type '{type}', fullname {Types[type].FullName}", ex); } } } if(source != null) { var result = Activator.CreateInstance(source.GetType()) as IDictionary; Copy(source, result); return result; } return source; }
private void AddRemoveCorrelationToken(Type interfaceType, IDictionary properties, object corrRefProperty) { if (interfaceType != null) { object[] corrProvAttribs = interfaceType.GetCustomAttributes(typeof(CorrelationProviderAttribute), false); object[] corrParamAttribs = interfaceType.GetCustomAttributes(typeof(CorrelationParameterAttribute), false); if (corrProvAttribs.Length != 0 || corrParamAttribs.Length != 0) { if (!properties.Contains("CorrelationToken")) properties.Add("CorrelationToken", corrRefProperty); return; } } if (properties.Contains("CorrelationToken")) properties.Remove("CorrelationToken"); }
public static string GetRestActionName(string action, IDictionary actions, string httpMethod) { if (IsCollectionAction(action)) { switch (httpMethod.ToUpper()) { case "GET": return "Index"; case "POST": return "Create"; } } if (IsNewAction(action)) { return "New"; } if (!actions.Contains(action)) { switch (httpMethod.ToUpper()) { case "GET": return "Show"; case "PUT": return "Update"; case "DELETE": return "Destroy"; } } return null; }
public static void SendNew(String to, String body, String Subject, String hetType, IDictionary replacements = null) { init(); if (replacements.Contains("%webkey%")) { replacements.Remove("%webkey%"); } // Webkey aanmaken String key; key = stored.NewWebkey(to); // In database is het leraar, in de webview docent (freakytime aanpassing) String webkeyType = "student"; if (hetType.Equals("docent")) { webkeyType = "leraar"; } webkeys webkey = new webkeys() { webkey = key, type = webkeyType, email = to }; // Webkey opslaan in database WStored.StageManagerEntities.webkeys.Add(webkey); WStored.PushToDB(); // construct URL key = "http://stagemanager.modupro.nl/" + hetType + "/" + webkey.webkey; replacements.Add("%webkey%", "<a href='" + key + "'>" + key + "</a>"); // Send Send(to, body, Subject, replacements); }
public void Contains(IDictionary dic) { foreach (DictionaryEntry de in dic) { bool b = dic.Contains(de.Key); } }
public static void SendNew(String to, String body, String Subject, IDictionary replacements = null) { init(); if (replacements.Contains("%webkey%")) { replacements.Remove("%webkey%"); } String webkey; webkey = stored.NewWebkey(to); WWebkey key = new WWebkey(new webkeysets() { ConnectionKey = webkey, Status="actief" }); key.add(key.getSet()); System.Reflection.Assembly thisExe = System.Reflection.Assembly.GetExecutingAssembly(); string path = thisExe.Location; DirectoryInfo dirinfo = new DirectoryInfo(path); string folderName = dirinfo.Parent.FullName; path = folderName + "\\Config.txt"; Uri uri = new Uri(path); String s = File.ReadAllText(uri.AbsolutePath); String[] split = { "server: " }; String[] server = s.Split(split, StringSplitOptions.RemoveEmptyEntries); webkey = server[0] + webkey; replacements.Add("%webkey%", "<a href='" + webkey + "'>" + webkey + "</a>"); Send(to, body, Subject, replacements); }
public static void Send(String to, String body, String Subject, IDictionary replacements = null) { init(); char[] c = { ',', ';', ':' }; String[] To = to.Split(c); for (int i = 0; i < To.Length; i++) { MailDefinition m = new MailDefinition(); if (!replacements.Contains("\n")) { replacements.Add("\n", "<br/>"); } m.IsBodyHtml = true; m.Subject = Subject; m.From = "[email protected]"; try { mails.AddLast(m.CreateMailMessage(To[i], replacements, body, new System.Web.UI.Control())); } catch (Exception)//TODO { }; } if (!isSending) { next(null, null); } }
protected void AssertKeyExists( IDictionary names, NodeBase node, object key, String message ) { if (!names.Contains(key)) { RaiseErrorEvent( node.LexicalInfo, message ); } }
/// <summary> If passed the parameter Increment it will increment the index. /// Otherwise it will just return the current value of the index /// * /// </summary> /// <param name="aBrc">- The BRERuleContext object /// </param> /// <param name="aMap">- The IDictionary of parameters from the XML /// </param> /// <param name="aStep">- The step that it is on /// </param> /// <returns> The current value of the increment /// /// </returns> public object ExecuteRule(IBRERuleContext aBrc, IDictionary aMap, object aStep) { if (aMap.Contains(INCREMENT)) sIdx = sIdx + Int32.Parse((string) aMap[INCREMENT]); return sIdx; }
public void TestContains() { dictionary = new Dictionary<string, int>(); string[] names = { "Cero", "Uno", "Dos", "Tres", "Cuatro", "Cinco" }; //int[] numbers = (from i in Enumerable.Range(0, 6).ToArray() select i).ToArray(); for (int i = 0; i < 6; i++) { dictionary.Add(names[i], i); } Assert.AreEqual(true, dictionary.Contains(new KeyValuePair<string, int>("Cero", 0))); Assert.AreEqual(false, dictionary.Contains(new KeyValuePair<string, int>("Cero", 2))); Assert.AreEqual(false, dictionary.Contains(new KeyValuePair<string, int>("Once", 0))); }
private void DoCreateStandardAttributeTable(IDictionary parameters, IDictionary std) { // contentType will be absent if we're trying to generate a counter signature. if (parameters.Contains(CmsAttributeTableParameter.ContentType)) { if (!std.Contains(CmsAttributes.ContentType)) { DerObjectIdentifier contentType = (DerObjectIdentifier) parameters[CmsAttributeTableParameter.ContentType]; Asn1.Cms.Attribute attr = new Asn1.Cms.Attribute(CmsAttributes.ContentType, new DerSet(contentType)); std[attr.AttrType] = attr; } } if (!std.Contains(CmsAttributes.SigningTime)) { Asn1.Cms.Attribute attr = new Asn1.Cms.Attribute(CmsAttributes.SigningTime, new DerSet(new Time(DateTime.UtcNow))); std[attr.AttrType] = attr; } if (!std.Contains(CmsAttributes.MessageDigest)) { byte[] messageDigest = (byte[])parameters[CmsAttributeTableParameter.Digest]; Asn1.Cms.Attribute attr = new Asn1.Cms.Attribute(CmsAttributes.MessageDigest, new DerSet(new DerOctetString(messageDigest))); std[attr.AttrType] = attr; } }
/// <summary> /// Returns name of Cache from the property map. /// </summary> /// <param name="properties">properties map</param> /// <returns>cache name.</returns> static private CacheInfo GetCacheInfo(IDictionary properties) { if(!properties.Contains("cache")) throw new ConfigurationException("Missing configuration attribute 'cache'"); CacheInfo inf = new CacheInfo(); IDictionary cacheConfig = (IDictionary)properties[ "cache" ]; string schemeName = ""; if(cacheConfig.Contains("name")) inf.Name = Convert.ToString(cacheConfig["name"]).Trim(); if(!cacheConfig.Contains("class")) throw new ConfigurationException("Missing configuration attribute 'class'"); schemeName = Convert.ToString(cacheConfig[ "class" ]); if(inf.Name.Length < 1) inf.Name = schemeName; if(!cacheConfig.Contains("cache-classes")) throw new ConfigurationException("Missing configuration section 'cache-classes'"); IDictionary cacheClasses = (IDictionary)cacheConfig[ "cache-classes" ]; if(!cacheClasses.Contains(schemeName.ToLower())) throw new ConfigurationException("Cannot find cache class '" + schemeName + "'"); IDictionary schemeProps = (IDictionary)cacheClasses[ schemeName.ToLower() ]; if(!schemeProps.Contains("type")) throw new ConfigurationException("Cannot find the type of cache, invalid configuration for cache class '" + schemeName + "'"); inf.ClassName = Convert.ToString(schemeProps["type"]); return inf; }
/// <summary> /// Overloaded constructor. Takes the properties as a map. /// </summary> /// <param name="cacheSchemes">collection of cache schemes (config properties).</param> /// <param name="properties">properties collection for this cache.</param> /// <param name="listener">cache events listener</param> /// <param name="timeSched">scheduler to use for periodic tasks</param> public IndexedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context) : base(cacheClasses, parentCache, properties, listener, context) { IDictionary props = null; if (properties.Contains("indexes")) { props = properties["indexes"] as IDictionary; } _queryIndexManager = new QueryIndexManager(props, this, _context.CacheRoot.Name); if (!_queryIndexManager.Initialize()) _queryIndexManager = null; //+Numan16122014 _cacheStore.ISizableQueryIndexManager = _queryIndexManager; _cacheStore.ISizableEvictionIndexManager = _evictionPolicy; _cacheStore.ISizableExpirationIndexManager = _context.ExpiryMgr; _stats.MaxCount = _cacheStore.MaxCount; _stats.MaxSize = _cacheStore.MaxSize; //+Numan16122014 if (_context.PerfStatsColl != null) { if (_queryIndexManager != null) _context.PerfStatsColl.SetQueryIndexSize(_queryIndexManager.IndexInMemorySize); } }
public static DataRow Insert(string tableName, IDictionary input) { var helper = DBHelper.GetTable(tableName); var row = helper.Table.NewRow(); var cols = helper.Table.Columns.Cast<DataColumn>(); try { foreach (var col in cols) { if (!col.AutoIncrement && input.Contains(col.ColumnName)) { row[col] = input[col.ColumnName] as object ?? DBNull.Value; } } helper.Table.Rows.Add(row); helper.Adapter.Update(helper.Table); // quick dirty fix for auto-increment value problem helper.Table.Clear(); helper.Adapter.Fill(helper.Table); return helper.Table.AsEnumerable().Last(); //return row; } catch (Exception ex) { row.RejectChanges(); throw ex; } }
public XmlDocument Run(IDictionary context) { if (context == null || !context.Contains("Project")) { return Descriptor; } Project = (Project)context["Project"]; foreach (var table in Project.Database.Tables) { foreach (var column in table.Columns) { if (column.Property == null || !MustStoreAsText(column)) continue; var property = column.Property; column.DbType = System.Data.DbType.String; column.Size = GetColumnSize(property); // Change BaseSave method // Example: persistence.AddParameterAsText("@Customer_Gender", this.Gender, SoftFluent.Samples.Gender.Male); property.SetAttributeValue(Constants.ModelProducerNamespacePrefix, "addParameterMethodName", Constants.ModelProducerNamespaceUri, "AddParameterAsText"); // Change ReadRecord method // Example: this._gender = CodeFluentPersistence.GetReaderValue(reader, "Customer_Gender", Gender.Male); var readerExpression = string.Format("CodeFluentPersistence.GetReaderValue(reader, \"{1}\", {2})", property.ClrFullTypeName, property.Column.Name, property.DefaultValue); column.Property.SetAttributeValue(Constants.ModelProducerNamespacePrefix, "readValueExpression", Constants.ModelProducerNamespaceUri, readerExpression); } } return Descriptor; }
/// <summary> Returns a value cast to a specific type /// * /// </summary> /// <param name="aBrc">- The BRERuleContext object /// </param> /// <param name="aMap">- The IDictionary of parameters from the XML /// </param> /// <param name="aStep">- The step that it is on /// </param> /// <returns> The value cast to the specified type /// /// </returns> public object ExecuteRule(IBRERuleContext aBrc, IDictionary aMap, object aStep) { if (!aMap.Contains(TYPE)) { throw new BRERuleException("Parameter 'Type' not found"); } else { if (!aMap.Contains(VALUE)) { ObjectLookup ol = new ObjectLookup(); object[] arguments = ol.GetArguments(aMap); return Reflection.ClassNew((string)aMap[TYPE], arguments); } return Reflection.CastValue(aMap[VALUE], (string)aMap[TYPE]); } }
public BlobErrorLog(IDictionary config) { if (!config.Contains("connectionStringName")) throw new System.ApplicationException("Configuration string is missing for the Windows Azure Blob Storage Error Log."); this.connectionStringName = (string)config["connectionStringName"]; this.Initialize(); }
public DictionaryScope(IDictionary dictionary, object key, object value) { if (dictionary.Contains(key)) previousValue = dictionary[key]; dictionary[key] = value; this.key = key; this.dictionary = dictionary; }
/// <summary> If passed the parameter Decrement it will decrement the index. /// Otherwise it will just return the current value of the index /// * /// </summary> /// <param name="aBrc">- The BRERuleContext object /// </param> /// <param name="aMap">- The IDictionary of parameters from the XML /// </param> /// <param name="aStep">- The step that it is on /// </param> /// <returns> The current value of the index /// /// </returns> public virtual object ExecuteRule(IBRERuleContext aBrc, IDictionary aMap, object aStep) { if (aMap.Contains(DECREMENT)) { sIdx = sIdx - System.Int32.Parse((System.String) aMap[DECREMENT]); } return sIdx; }
/// <summary> /// Helper method to get a key that doesn't already exist within the dictionary /// </summary> /// <param name="dictionary"></param> protected object GetNewKey(IDictionary dictionary) { int seed = 840; object missingKey = CreateTKey(seed++); while (dictionary.Contains(missingKey) || missingKey.Equals(null)) missingKey = CreateTKey(seed++); return missingKey; }
public XmlDocument Run(IDictionary context) { if (context == null || !context.Contains("Project")) return Descriptor; Project = (Project)context["Project"]; Project.StepChanging += Project_StepChanging; return Descriptor; }