System.Collections.Generic.Dictionary.Add(string, object)

Here are the examples of the csharp api System.Collections.Generic.Dictionary.Add(string, object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4861 Examples 7

19 View Source File : ConfigurationBase.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public Dictionary<string, object> GetConfigurations()
		{
			BindingFlags flag = BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic;
			lock (_root)
			{
				Dictionary<string, object> dic = new Dictionary<string, object>();
				FieldInfo[] fields = this.GetType().GetFields(flag);
				foreach (FieldInfo f in fields)
				{
					if (!f.IsPrivate)
						dic.Add(f.Name, f.GetValue(this));
				}
				PropertyInfo[] props = this.GetType().GetProperties(flag);
				foreach (PropertyInfo p in props)
					dic.Add(p.Name, p.GetValue(this, null));
				return dic;
			}
		}

19 View Source File : TelemetryWebgl.cs
License : MIT License
Project Creator : alen-smajic

string GetPostBody()
		{
			List<Dictionary<string, object>> eventList = new List<Dictionary<string, object>>();
			Dictionary<string, object> jsonDict = new Dictionary<string, object>();

			long unixTimestamp = (long)Mapbox.Utils.UnixTimestampUtils.To(DateTime.UtcNow);

			jsonDict.Add("event", "appUserTurnstile");
			jsonDict.Add("created", unixTimestamp);
			jsonDict.Add("userId", SystemInfo.deviceUniqueIdentifier);
			jsonDict.Add("enabled.telemetry", false);
			jsonDict.Add("sdkIdentifier", GetSDKIdentifier());
			jsonDict.Add("skuId", Constants.SDK_SKU_ID);
			jsonDict.Add("sdkVersion", Constants.SDK_VERSION);

			// user-agent cannot be set from web broswer, so we send in payload, instead!
			jsonDict.Add("userAgent", GetUserAgent());

			eventList.Add(jsonDict);

			var jsonString = JsonConvert.SerializeObject(eventList);
			return jsonString;
		}

19 View Source File : VssHttpUriUtility.cs
License : MIT License
Project Creator : actions

private static void AddRouteValueIfNotPresent(Dictionary<String, Object> dictionary, String key, Object value)
        {
            if (!dictionary.ContainsKey(key))
            {
                dictionary.Add(key, value);
            }
        }

19 View Source File : RoleStoreStub.cs
License : Apache License 2.0
Project Creator : Aguafrommars

protected override void SetIndex(Dictionary<string, object> rules, string key, object index)
        {
            var indexOverride = new Dictionary<string, object>();
            var jObject = rules.Where(kv => kv.Key == _testDb).Select(kv => kv.Value).FirstOrDefault() as JObject;
            if (jObject != null)
            {
                foreach(var o in jObject)
                {
                    indexOverride.Add(o.Key, o.Value);
                }
            }
            
            indexOverride[key] = index;
            base.SetIndex(rules, _testDb, indexOverride);
        }

19 View Source File : ObjectCacheExtensions.cs
License : MIT License
Project Creator : Adoxio

public static Dictionary<string, object> GetCacheFootprintJson(this ObjectCache cache, bool expanded, Uri requestUrl)
		{
			var alternateLink = new Uri(requestUrl.GetLeftPart(UriPartial.Path));

			var enreplacedies = new List<Dictionary<string, object>>();
			
			var footprint = GetCacheFootprint(cache, alternateLink);
			foreach (var enreplacedyType in footprint)
			{
				var enreplacedy = new Dictionary<string, object>
				{
					{ "Name", enreplacedyType.Name },
					{ "Count", enreplacedyType.GetCount() },
					{ "Size", enreplacedyType.GetSize() }
				};

				if (expanded)
				{
					var records = new Collection<Dictionary<string, object>>();
					foreach (var item in enreplacedyType.Items)
					{
						var record = new Dictionary<string, object>
						{
							{ "LogicalName", item.Enreplacedy.LogicalName },
							{ "Name", item.Enreplacedy.GetAttributeValueOrDefault("adx_name", string.Empty) },
							{ "Id", item.Enreplacedy.Id }
						};

						var recordCache = new Dictionary<string, object>
						{
							{ "Id", item.CacheItemKey },
							{ "Type", item.CacheItemType },
							{ "Link", item.Link.ToString() },
							{ "Size", GetEnreplacedySizeInMemory(item.Enreplacedy) }
						};

						record.Add("Cache", recordCache);
						records.Add(record);
					}
					enreplacedy.Add("Items", records);
				}

				enreplacedies.Add(enreplacedy);
			}

			var enreplacediesWrapper = new Dictionary<string, object>();
			if (!expanded)
			{
				// Add link to the Expanded view with enreplacedy record details
				var query = System.Web.HttpUtility.ParseQueryString(requestUrl.Query);
				query[Web.Handlers.CacheFeedHandler.QueryKeys.Expanded] = bool.TrueString;
				var uriBuilder = new UriBuilder(requestUrl.ToString()) { Query = query.ToString() };
				enreplacediesWrapper.Add("ExpandedView", uriBuilder.ToString());
			}
			enreplacediesWrapper.Add("Enreplacedies", enreplacedies.OrderByDescending(e => e["Size"]));
			var retval = new Dictionary<string, object> { { "CacheFootprint", enreplacediesWrapper } };
			return retval;
		}

19 View Source File : LootParser.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static Dictionary<string, object> ParseFile(string filename)
        {
            var lines = File.ReadAllLines(filename);

            var tables = new Dictionary<string, object>();

            //Console.WriteLine($"Parsed {filename}");

            for (var i = 0; i < lines.Length; i++)
            {
                var line = lines[i];

                if (line.Contains("List<"))
                    continue;

                if (!line.Contains("ChanceTable<") || !line.Contains(" = new") || !line.Contains("()"))
                    continue;

                if (line.Contains("readonly") || line.EndsWith(";"))
                    continue;

                var table = ParseChanceTable(lines, i);

                tables.Add(table.tableName, table.table);
            }
            return tables;
        }

19 View Source File : DCSMission.cs
License : GNU General Public License v3.0
Project Creator : akaAgar

internal void AddMediaFile(string fileName, byte[] mediaFileBytes)
        {
            if (string.IsNullOrEmpty(fileName) || MediaFiles.ContainsKey(fileName)) return;
            MediaFiles.Add(fileName, mediaFileBytes);
        }

19 View Source File : JSONParser.cs
License : MIT License
Project Creator : 5minlab

static object ParseAnonymousValue(string json) {
            if (json.Length == 0)
                return null;
            if (json[0] == '{' && json[json.Length - 1] == '}') {
                List<string> elems = Split(json);
                if (elems.Count % 2 != 0)
                    return null;
                var dict = new Dictionary<string, object>(elems.Count / 2);
                for (int i = 0; i < elems.Count; i += 2)
                    dict.Add(elems[i].Substring(1, elems[i].Length - 2), ParseAnonymousValue(elems[i + 1]));
                return dict;
            }
            if (json[0] == '[' && json[json.Length - 1] == ']') {
                List<string> items = Split(json);
                var finalList = new List<object>(items.Count);
                for (int i = 0; i < items.Count; i++)
                    finalList.Add(ParseAnonymousValue(items[i]));
                return finalList;
            }
            if (json[0] == '\"' && json[json.Length - 1] == '\"') {
                string str = json.Substring(1, json.Length - 2);
                return str.Replace("\\", string.Empty);
            }
            if (char.IsDigit(json[0]) || json[0] == '-') {
                if (json.Contains(".")) {
                    double result;
                    double.TryParse(json, out result);
                    return result;
                } else {
                    int result;
                    int.TryParse(json, out result);
                    return result;
                }
            }
            if (json == "true")
                return true;
            if (json == "false")
                return false;
            // handles json == "null" as well as invalid JSON
            return null;
        }

19 View Source File : ApplePush.cs
License : Apache License 2.0
Project Creator : alexalok

public ApplePush AddCustomProperty(string key, object value, bool addToApsDict = false)
        {
            if (addToApsDict)
            {
                CustomApsProperties ??= new Dictionary<string, object>();
                CustomApsProperties.Add(key, value);
            }
            else
            {
                CustomProperties ??= new Dictionary<string, object>();
                CustomProperties.Add(key, value);
            }
            return this;
        }

19 View Source File : TestAmf3Reader.cs
License : MIT License
Project Creator : a1q123456

public void AddDynamic(string key, object data)
        {
            _dynamicFields.Add(key, data);
        }

19 View Source File : OriginalRecordStatus.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

protected override void OnBeginPropertyChangingInner(PropertyChangingEventArgsEx args)
        {
            if (!this.OriginalValues.ContainsKey(args.PropertyName))
            {
                this.OriginalValues.Add(args.PropertyName, args.OldValue);
            }
        }

19 View Source File : ThemeApp.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn

private static void CreateThemeLists()
        {

            if (Directory.Exists(Path.Combine(Helper.DirectoryPath, "replacedets", "skins")))
            {
                string[] skins = Directory.GetFiles(Path.Combine(Helper.DirectoryPath, "replacedets", "skins"), "*_landscape.png");

                foreach (string path in skins)
                {
                    try
                    {
                        Texture2D skin = Helper.Content.Load<Texture2D>(Path.Combine("replacedets", "skins", Path.GetFileName(path).Replace("_landscape", "")));
                        Texture2D skinl = Helper.Content.Load<Texture2D>(Path.Combine("replacedets", "skins", Path.GetFileName(path)));
                        if (skin != null && skinl != null)
                        {
                            skinDict.Add(Path.Combine("replacedets", "skins", Path.GetFileName(path).Replace("_landscape", "")), new Texture2D[] { skin, skinl });
                            Monitor.Log($"loaded skin {path.Replace("_landscape", "")}");
                        }
                        else
                            Monitor.Log($"Couldn't load skin {path.Replace("_landscape", "")}: texture was null", LogLevel.Error);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Couldn't load skin {path.Replace("_landscape", "")}: {ex}", LogLevel.Error);
                    }
                }
            }

            if (Directory.Exists(Path.Combine(Helper.DirectoryPath, "replacedets", "backgrounds")))
            {
                string[] papers = Directory.GetFiles(Path.Combine(Helper.DirectoryPath, "replacedets", "backgrounds"), "*_landscape.png");
                foreach (string path in papers)
                {
                    try
                    {
                        Texture2D back = Helper.Content.Load<Texture2D>(Path.Combine("replacedets", "backgrounds", Path.GetFileName(path).Replace("_landscape", "")));
                        Texture2D backl = Helper.Content.Load<Texture2D>(Path.Combine("replacedets", "backgrounds", Path.GetFileName(path)));
                        if (back != null && backl != null)
                        {
                            backgroundDict.Add(Path.Combine("replacedets", "backgrounds", Path.GetFileName(path).Replace("_landscape", "")), new Texture2D[] { back, backl });
                            Monitor.Log($"loaded background {path.Replace("_landscape", "")}");
                        }
                        else
                            Monitor.Log($"Couldn't load background {path.Replace("_landscape", "")}: texture was null", LogLevel.Error);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Couldn't load background {path.Replace("_landscape", "")}: {ex}", LogLevel.Error);
                    }
                }
            }


            if (Directory.Exists(Path.Combine(Helper.DirectoryPath, "replacedets", "ringtones")))
            {
                string[] rings = Directory.GetFiles(Path.Combine(Helper.DirectoryPath, "replacedets", "ringtones"), "*.wav");
                foreach (string path in rings)
                {
                    try
                    {
                        object ring;
                        try
                        {
                            var type = Type.GetType("System.Media.SoundPlayer, System");
                            ring = Activator.CreateInstance(type, new object[] { path });
                        }
                        catch 
                        {
                            ring = SoundEffect.FromStream(new FileStream(path, FileMode.Open));
                        }
                        if (ring != null)
                        {
                            ringDict.Add(Path.GetFileName(path).Replace(".wav", ""), ring);
                            Monitor.Log($"loaded ring {path}");
                        }
                        else
                            Monitor.Log($"Couldn't load ring {path}", LogLevel.Error);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Couldn't load ring {path}:\r\n{ex}", LogLevel.Error);
                    }
                }
                rings = Config.BuiltInRingTones.Split(',');
                foreach (string ring in rings)
                {
                    ringDict.Add(ring, null);
                }
            }
            ringList = ringDict.Keys.ToList();
            skinList = skinDict.Keys.ToList();
            backgroundList = backgroundDict.Keys.ToList();
        }

19 View Source File : Amf0Reader.cs
License : MIT License
Project Creator : a1q123456

public bool TryGetEcmaArray(Span<byte> buffer, out Dictionary<string, object> value, out int consumedLength)
        {
            value = default;
            consumedLength = default;
            int consumed = 0;

            if (!TryDescribeData(buffer, out var type, out _))
            {
                return false;
            }

            if (type != Amf0Type.EcmaArray)
            {
                return false;
            }

            var obj = new Dictionary<string, object>();
            _referenceTable.Add(obj);

            var elementCount = NetworkBitConverter.ToUInt32(buffer.Slice(Amf0CommonValues.MARKER_LENGTH, sizeof(uint)));

            var arrayBodyBuffer = buffer.Slice(Amf0CommonValues.MARKER_LENGTH + sizeof(uint));
            consumed = Amf0CommonValues.MARKER_LENGTH + sizeof(uint);
            if (StrictMode)
            {
                for (int i = 0; i < elementCount; i++)
                {
                    if (!TryGetKeyValuePair(arrayBodyBuffer, out var kv, out _, out var kvConsumed))
                    {
                        return false;
                    }
                    arrayBodyBuffer = arrayBodyBuffer.Slice(kvConsumed);
                    consumed += kvConsumed;
                    obj.Add(kv.Key, kv.Value);
                }
                if (!TryGetStringImpl(arrayBodyBuffer, Amf0CommonValues.STRING_HEADER_LENGTH, out var emptyStr, out var emptyStrConsumed))
                {
                    return false;
                }
                if (emptyStr.Any())
                {
                    return false;
                }
                consumed += emptyStrConsumed;
                arrayBodyBuffer = arrayBodyBuffer.Slice(emptyStrConsumed);
                if (!TryDescribeData(arrayBodyBuffer, out var objEndType, out var objEndConsumed))
                {
                    return false;
                }
                if (objEndType != Amf0Type.ObjectEnd)
                {
                    return false;
                }
                consumed += objEndConsumed;
            }
            else
            {
                while (true)
                {
                    if (!TryGetKeyValuePair(arrayBodyBuffer, out var kv, out var isEnd, out var kvConsumed))
                    {
                        return false;
                    }
                    arrayBodyBuffer = arrayBodyBuffer.Slice(kvConsumed);
                    consumed += kvConsumed;
                    if (isEnd)
                    {
                        break;
                    }
                    obj.Add(kv.Key, kv.Value);
                }
            }


            value = obj;
            consumedLength = consumed;
            return true;
        }

19 View Source File : Serialization.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public static Dictionary<string, object> ToDictionary(object obj)
		{
			System.Diagnostics.Debug.replacedert(obj != null);
			Dictionary<string, object> dic = new Dictionary<string, object>();
			FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
			foreach (FieldInfo f in fields)
				dic.Add(f.Name, f.GetValue(obj));
			PropertyInfo[] props = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
			foreach (PropertyInfo p in props)
				dic.Add(p.Name, p.GetValue(obj, null));
			return dic;
		}

19 View Source File : Restful.cs
License : MIT License
Project Creator : 2881099

async public static Task<bool> Use(HttpContext context, IFreeSql fsql, string restfulRequestPath, Dictionary<string, Type> dicEnreplacedyTypes) {
			HttpRequest req = context.Request;
			HttpResponse res = context.Response;

			var remUrl = req.Path.ToString().Substring(restfulRequestPath.Length).Trim(' ', '/').Split('/');
			var enreplacedyName = remUrl.FirstOrDefault();

			if (!string.IsNullOrEmpty(enreplacedyName)) {

				if (dicEnreplacedyTypes.TryGetValue(enreplacedyName, out var enreplacedyType) == false) throw new Exception($"UseFreeAdminLtePreview 错误,找不到实体类型:{enreplacedyName}");

				var tb = fsql.CodeFirst.GetTableByEnreplacedy(enreplacedyType);
				if (tb == null) throw new Exception($"UseFreeAdminLtePreview 错误,实体类型无法映射:{enreplacedyType.FullName}");

				using (var db = new FreeContext(fsql)) {
					var dbset = db.Set<object>();
					dbset.AsType(enreplacedyType);

					switch (req.Method.ToLower()) {
						case "get":
							if (remUrl.Length == 1) {
								int.TryParse(req.Query["page"].FirstOrDefault(), out var getpage);
								int.TryParse(req.Query["limit"].FirstOrDefault(), out var getlimit);
								if (getpage <= 0) getpage = 1;
								if (getlimit <= 0) getlimit = 20;
								long getlistTotal = 0;

								var getselect = fsql.Select<object>().AsType(enreplacedyType);
								if (getpage == 1) getlistTotal = await getselect.CountAsync();
								var getlist = await getselect.Page(getpage, getlimit).ToListAsync();
								var gethashlists = new Dictionary<string, object>[getlist.Count];
								var gethashlistsIndex = 0;
								foreach (var getlisreplacedem in getlist) {
									var gethashlist = new Dictionary<string, object>();
									foreach (var getcol in tb.ColumnsByCs) {
										gethashlist.Add(getcol.Key, tb.Properties[getcol.Key].GetValue(getlisreplacedem));
									}
									gethashlists[gethashlistsIndex++] = gethashlist;
								}
								if (getpage == 1) {
									await Utils.Jsonp(context, new { code = 0, message = "Success", data = gethashlists, totalCount = getlistTotal });
									return true;
								}
								await Utils.Jsonp(context, new { code = 0, message = "Success", data = gethashlists });
								return true;
							}
							if (remUrl.Length - 1 != tb.Primarys.Length) throw new Exception($"UseFreeAdminLtePreview 查询,参数数目与主键不匹配,应该相同");
							var gereplacedem = Activator.CreateInstance(enreplacedyType);
							var getindex = 1;
							foreach (var getpk in tb.Primarys)
								fsql.SetEnreplacedyValueWithPropertyName(enreplacedyType, gereplacedem, getpk.CsName, remUrl[getindex++]);
							gereplacedem = await fsql.Select<object>().AsType(enreplacedyType).WhereDynamic(gereplacedem).FirstAsync();
							var gethash = new Dictionary<string, object>();
							foreach (var getcol in tb.ColumnsByCs) {
								gethash.Add(getcol.Key, tb.Properties[getcol.Key].GetValue(gereplacedem));
							}
							await Utils.Jsonp(context, new { code = 0, message = "Success", data = gethash });
							return true;
						case "post":
							var postbodyraw = await Utils.GetBodyRawText(req);
							var postjsonitem = Newtonsoft.Json.JsonConvert.DeserializeObject(postbodyraw, enreplacedyType);
							await dbset.AddAsync(postjsonitem);
							await db.SaveChangesAsync();
							await Utils.Jsonp(context, new { code = 0, message = "Success", data = postjsonitem });
							return true;
						case "put":
							if (remUrl.Length - 1 != tb.Primarys.Length) throw new Exception($"UseFreeAdminLtePreview 更新错误,参数数目与主键不匹配,应该相同");
							var putbodyraw = await Utils.GetBodyRawText(req);
							var putjsonitem = Newtonsoft.Json.JsonConvert.DeserializeObject(putbodyraw, enreplacedyType);
							var putindex = 1;
							foreach (var putpk in tb.Primarys)
								fsql.SetEnreplacedyValueWithPropertyName(enreplacedyType, putjsonitem, putpk.CsName, remUrl[putindex++]);
							await dbset.UpdateAsync(putjsonitem);
							await db.SaveChangesAsync();
							await Utils.Jsonp(context, new { code = 0, message = "Success" });
							return true;
						case "delete":
							if (remUrl.Length - 1 != tb.Primarys.Length) throw new Exception($"UseFreeAdminLtePreview 删除错误,参数数目与主键不匹配,应该相同");
							var delitem = Activator.CreateInstance(enreplacedyType);
							var delindex = 1;
							foreach (var delpk in tb.Primarys)
								fsql.SetEnreplacedyValueWithPropertyName(enreplacedyType, delitem, delpk.CsName, remUrl[delindex++]);
							dbset.Remove(delitem);
							await db.SaveChangesAsync();
							await Utils.Jsonp(context, new { code = 0, message = "Success" });
							return true;
					}
				}
			}
			return false;
		}

19 View Source File : SubscriptionListener.cs
License : Apache License 2.0
Project Creator : ajuna-network

public void RegisterCallBackHandler<T>(string subscriptionId, Action<string, T> callback)
        {
            if (!_headerCallbacks.ContainsKey(subscriptionId))
            {
                Logger.Debug($"Register {callback} for subscription '{subscriptionId}'");
                _headerCallbacks.Add(subscriptionId, callback);
            }

            if (_pendingHeaders.ContainsKey(subscriptionId))
            {
                foreach (var h in _pendingHeaders[subscriptionId])
                    // we don't wait on the tasks to finish
                    callback(subscriptionId, (T) h);
                _pendingHeaders.Remove(subscriptionId);
            }
        }

19 View Source File : PropertiesCollection.cs
License : MIT License
Project Creator : actions

public void Add(String key, Object value)
        {
            if (this.ValidateNewValues)
            {
                PropertyValidation.ValidatePropertyName(key);
                PropertyValidation.ValidatePropertyValue(key, value);
            }

            m_innerDictionary.Add(key, value);
        }

19 View Source File : TelemetryFallback.cs
License : MIT License
Project Creator : alen-smajic

string GetPostBody()
		{
			List<Dictionary<string, object>> eventList = new List<Dictionary<string, object>>();
			Dictionary<string, object> jsonDict = new Dictionary<string, object>();

			long unixTimestamp = (long)Mapbox.Utils.UnixTimestampUtils.To(DateTime.UtcNow);

			jsonDict.Add("event", "appUserTurnstile");
			jsonDict.Add("created", unixTimestamp);
			jsonDict.Add("userId", SystemInfo.deviceUniqueIdentifier);
			jsonDict.Add("enabled.telemetry", false);
			jsonDict.Add("sdkIdentifier", GetSDKIdentifier());
			jsonDict.Add("skuId", Constants.SDK_SKU_ID);
			jsonDict.Add("sdkVersion", Constants.SDK_VERSION);
			eventList.Add(jsonDict);

			var jsonString = JsonConvert.SerializeObject(eventList);
			return jsonString;
		}

19 View Source File : DbQuery.cs
License : Apache License 2.0
Project Creator : 1448376744

private string ResolveUpdate()
        {
            var table = GetTableMetaInfo().TableName;
            var builder = new StringBuilder();
            if (_setExpressions.Count > 0)
            {
                var where = ResolveWhere();
                foreach (var item in _setExpressions)
                {
                    var column = new BooleanExpressionResovle(item.Column).Resovle();
                    var expression = new BooleanExpressionResovle(item.Expression, _parameters).Resovle();
                    builder.Append($"{column} = {expression},");
                }
                var sql = $"UPDATE {table} SET {builder.ToString().Trim(',')}{where}";
                return sql;
            }
            else
            {
                var filters = new GroupExpressionResovle(_filterExpression).Resovle().Split(',');
                var where = ResolveWhere();
                var columns = GetColumnMetaInfos();
                var updcolumns = columns
                    .Where(a => !filters.Contains(a.ColumnName))
                    .Where(a => !a.IsComplexType)
                    .Where(a => !a.IsIdenreplacedy && !a.IsPrimaryKey && !a.IsNotMapped)
                    .Where(a => !a.IsConcurrencyCheck)
                    .Select(s => $"{s.ColumnName} = @{s.CsharpName}");
                if (string.IsNullOrEmpty(where))
                {
                    var primaryKey = columns.Where(a => a.IsPrimaryKey).FirstOrDefault()
                        ?? columns.First();
                    where = $" WHERE {primaryKey.ColumnName} = @{primaryKey.CsharpName}";
                    if (columns.Exists(a => a.IsConcurrencyCheck))
                    {
                        var checkColumn = columns.Where(a => a.IsConcurrencyCheck).FirstOrDefault();
                        where += $" AND {checkColumn.ColumnName} = @{checkColumn.CsharpName}";
                    }
                }
                var sql = $"UPDATE {table} SET {string.Join(",", updcolumns)}";
                if (columns.Exists(a => a.IsConcurrencyCheck))
                {
                    var checkColumn = columns.Where(a => a.IsConcurrencyCheck).FirstOrDefault();
                    sql += $",{checkColumn.ColumnName} = @New{checkColumn.CsharpName}";
                    if (checkColumn.CsharpType.IsValueType)
                    {
                        var version = Convert.ToInt32((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                        _parameters.Add($"New{checkColumn.CsharpName}", version);
                    }
                    else
                    {
                        var version = Guid.NewGuid().ToString("N");
                        _parameters.Add($"New{checkColumn.CsharpName}", version);
                    }
                }
                sql += where;
                return sql;
            }
        }

19 View Source File : JSON.cs
License : MIT License
Project Creator : AlenToma

internal object ParseDictionary(Dictionary<string, object> d, Dictionary<string, object> globaltypes, Type type, object input)
        {
            object tn = "";
            if (type == typeof(NameValueCollection))
                return JsonHelper.CreateNV(d);
            if (type == typeof(StringDictionary))
                return JsonHelper.CreateSD(d);

            if (d.TryGetValue("$i", out tn))
            {
                object v = null;
                _cirrev.TryGetValue((int)(long)tn, out v);
                return v;
            }

            if (d.TryGetValue("$types", out tn))
            {
                _usingglobals = true;
                if (globaltypes == null)
                    globaltypes = new Dictionary<string, object>();
                foreach (var kv in (Dictionary<string, object>)tn)
                {
                    globaltypes.Add((string)kv.Value, kv.Key);
                }
            }
            if (globaltypes != null)
                _usingglobals = true;

            bool found = d.TryGetValue("$type", out tn);
#if !SILVERLIGHT
            if (found == false && type == typeof(System.Object))
            {
                return d;   // CreateDataset(d, globaltypes);
            }
#endif
            if (found)
            {
                if (_usingglobals)
                {
                    object tname = "";
                    if (globaltypes != null && globaltypes.TryGetValue((string)tn, out tname))
                        tn = tname;
                }
                type = Reflection.Instance.GetTypeFromCache((string)tn);
            }

            if (type == null)
                throw new Exception("Cannot determine type");

            string typename = type.FullName;
            object o = input;
            if (o == null)
            {
                if (_params.ParametricConstructorOverride)
                    o = System.Runtime.Serialization.FormatterServices.GetUninitializedObject(type);
                else
                    o = FastDeepCloner.DeepCloner.CreateInstance(type);
            }
            int circount = 0;
            if (_circobj.TryGetValue(o, out circount) == false)
            {
                circount = _circobj.Count + 1;
                _circobj.Add(o, circount);
                _cirrev.Add(circount, o);
            }

            var props = Reflection.Instance.Getproperties(type, typename);
            foreach (var kv in d)
            {
                var n = kv.Key;
                var v = kv.Value;

                string name = n;//.ToLower();
                if (name == "$map")
                {
                    ProcessMap(o, props, (Dictionary<string, object>)d[name]);
                    continue;
                }
                myPropInfo pi;
                if (props.TryGetValue(name, out pi) == false)
                    if (props.TryGetValue(name.ToLowerInvariant(), out pi) == false)
                        continue;

                if (pi.CanWrite)
                {
                    if (v != null)
                    {
                        object oset = null;

                        switch (pi.Type)
                        {
                            case myPropInfoType.Int: oset = (int)JsonHelper.AutoConv(v); break;
                            case myPropInfoType.Long: oset = JsonHelper.AutoConv(v); break;
                            case myPropInfoType.String: oset = v.ToString(); break;
                            case myPropInfoType.Bool: oset = JsonHelper.BoolConv(v); break;
                            case myPropInfoType.DateTime: oset = JsonHelper.CreateDateTime((string)v, _params.UseUTCDateTime); break;
                            case myPropInfoType.Enum: oset = JsonHelper.CreateEnum(pi.pt, v); break;
                            case myPropInfoType.Guid: oset = JsonHelper.CreateGuid((string)v); break;

                            case myPropInfoType.Array:
                                if (!pi.IsValueType)
                                    oset = CreateArray((List<object>)v, pi.pt, pi.bt, globaltypes);
                                // what about 'else'?
                                break;
                            case myPropInfoType.ByteArray: oset = Convert.FromBase64String((string)v); break;
#if !SILVERLIGHT
                            case myPropInfoType.DataSet: oset = CreateDataset((Dictionary<string, object>)v, globaltypes); break;
                            case myPropInfoType.DataTable: oset = CreateDataTable((Dictionary<string, object>)v, globaltypes); break;
                            case myPropInfoType.Hashtable: // same case as Dictionary
#endif
                            case myPropInfoType.Dictionary: oset = CreateDictionary((List<object>)v, pi.pt, pi.GenericTypes, globaltypes); break;
                            case myPropInfoType.StringKeyDictionary: oset = CreateStringKeyDictionary((Dictionary<string, object>)v, pi.pt, pi.GenericTypes, globaltypes); break;
                            case myPropInfoType.NameValue: oset = JsonHelper.CreateNV((Dictionary<string, object>)v); break;
                            case myPropInfoType.StringDictionary: oset = JsonHelper.CreateSD((Dictionary<string, object>)v); break;
                            case myPropInfoType.Custom: oset = Reflection.Instance.CreateCustom((string)v, pi.pt); break;
                            default:
                                {
                                    if (pi.IsGenericType && pi.IsValueType == false && v is List<object>)
                                        oset = CreateGenericList((List<object>)v, pi.pt, pi.bt, globaltypes);

                                    else if ((pi.IsClreplaced || pi.IsStruct || pi.IsInterface) && v is Dictionary<string, object>)
                                        oset = ParseDictionary((Dictionary<string, object>)v, globaltypes, pi.pt, null);// pi.getter(o));

                                    else if (v is List<object>)
                                        oset = CreateArray((List<object>)v, pi.pt, typeof(object), globaltypes);

                                    else if (pi.IsValueType)
                                        oset = ChangeType(v, pi.changeType);

                                    else
                                        oset = v;
                                }
                                break;
                        }

                        pi.Property.SetValue(o, oset);
                    }
                }
            }
            return o;
        }

19 View Source File : TypeDefinitionConstructor.cs
License : GNU General Public License v3.0
Project Creator : Adam-Wilkinson

public void AddProperty(string propertyName, object propertyValue)
        {
            _properties.Add(propertyName, propertyValue);
        }

19 View Source File : Deserializer.cs
License : MIT License
Project Creator : ADeltaX

public static Dictionary<string, object> GetCompositeValue(byte[] data)
        {
            Dictionary<string, object> dict = new Dictionary<string, object>();

            int currentPos = 0;

            do
            {
                var compositeLength = GetInt32(data, currentPos);
                var compositeTypeData = (DataTypeEnum)((int)(DataTypeEnum.RegUwpByte) + GetUInt32(data, currentPos + 4) - 1);
                var compositeKeyLength = GetInt32(data, currentPos + 8) * 2 + 2; //* sizeof wchar + null-termination

                var padding = 8 - (compositeLength % 8);

                if (padding == 8)
                    padding = 0;

                var keyStr = GetString(data, currentPos + 12, compositeKeyLength - 2); //we don't need null-termination bc it's not winrt hstring

                object value = null;

                currentPos += 12 + compositeKeyLength; //header (4 byte * 3) + compositeKeyLength
                var valueLength = compositeLength - compositeKeyLength - 12; //minus header

                switch (compositeTypeData)
                {
                    case DataTypeEnum.RegUwpByte:
                        value = GetByte(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpInt16:
                        value = GetInt16(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpUint16:
                        value = GetUInt16(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpInt32:
                        value = GetInt32(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpUint32:
                        value = GetUInt32(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpInt64:
                        value = GetInt64(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpUint64:
                        value = GetUInt64(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpSingle:
                        value = GetSingle(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpDouble:
                        value = GetDouble(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpChar:
                        value = GetChar(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpBoolean:
                        value = GetBoolean(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpString:
                        value = GetString(data, currentPos, valueLength - 2); //minus null-termination
                        break;
                    case DataTypeEnum.RegUwpDateTimeOffset:
                        value = GetDateTimeOffset(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpTimeSpan:
                        value = GetTimeSpan(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpGuid:
                        value = GetGuid(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpPoint:
                        value = GetPoint(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpSize:
                        value = GetSize(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpRect:
                        value = GetRect(data, currentPos);
                        break;
                    case DataTypeEnum.RegUwpArrayByte:
                        value = GetArray(currentPos, valueLength, 1, i => GetByte(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayInt16:
                        value = GetArray(currentPos, valueLength, 2, i => GetInt16(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayUint16:
                        value = GetArray(currentPos, valueLength, 2, i => GetUInt16(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayInt32:
                        value = GetArray(currentPos, valueLength, 4, i => GetInt32(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayUint32:
                        value = GetArray(currentPos, valueLength, 4, i => GetUInt32(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayInt64:
                        value = GetArray(currentPos, valueLength, 8, i => GetInt64(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayUint64:
                        value = GetArray(currentPos, valueLength, 8, i => GetUInt64(data, i));
                        break;
                    case DataTypeEnum.RegUwpArraySingle:
                        value = GetArray(currentPos, valueLength, 4, i => GetSingle(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayDouble:
                        value = GetArray(currentPos, valueLength, 8, i => GetDouble(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayChar16:
                        value = GetArray(currentPos, valueLength, 2, i => GetChar(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayBoolean:
                        value = GetArray(currentPos, valueLength, 1, i => GetBoolean(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayString:
                        value = GetStringArray(currentPos, valueLength, data);
                        break;
                    case DataTypeEnum.RegUwpArrayDateTimeOffset:
                        value = GetArray(currentPos, valueLength, 8, i => GetDateTimeOffset(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayTimeSpan:
                        value = GetArray(currentPos, valueLength, 8, i => GetTimeSpan(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayGuid:
                        value = GetArray(currentPos, valueLength, 16, i => GetGuid(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayPoint:
                        value = GetArray(currentPos, valueLength, 4 * 2, i => GetPoint(data, i));
                        break;
                    case DataTypeEnum.RegUwpArraySize:
                        value = GetArray(currentPos, valueLength, 4 * 2, i => GetSize(data, i));
                        break;
                    case DataTypeEnum.RegUwpArrayRect:
                        value = GetArray(currentPos, valueLength, 4 * 4, i => GetRect(data, i));
                        break;
                    default:
                        break;
                }
                
                if (value != null)
                    dict.Add(keyStr, value);

                currentPos += valueLength + padding;

            } while (currentPos < data.Length);

            return dict;
        }

19 View Source File : ContextDataSlots.cs
License : MIT License
Project Creator : 1996v

public void AllocateNamedDataSlot(string name, object data)
        {
            if (storeSlots == null)
            {
                storeSlots = new Dictionary<string, object>();
            }

            storeSlots.Add(name, data);
        }

19 View Source File : CrmChartBuilder.cs
License : MIT License
Project Creator : Adoxio

private List<Dictionary<string, object>> ConvertRecordsToDictionary(OrganizationServiceContext serviceContext, IEnumerable<Enreplacedy> records, EnreplacedyMetadata enreplacedyMetadata)
		{
			var data = new List<Dictionary<string, object>>();
			var organizationMoneyFormatInfo = new OrganizationMoneyFormatInfo(serviceContext);

			foreach (var record in records)
			{
				var row = new Dictionary<string, object>
				{
					{ "RowId", record.Id.ToString("B", CultureInfo.InvariantCulture).ToUpper(CultureInfo.InvariantCulture) },
					{ "RowType", enreplacedyMetadata.ObjectTypeCode.GetValueOrDefault(0).ToString() }
				};

				// DateGrouping require us to also retrieve a datetime value so we can format series labels correctly. Grouping by day for example with a date like 9/23/2016 will result in the value 23 to be stored in the data. The DataDefinition is manually revised to add this aggregate attribute into the fetch so we get the actual date value 9/23/2016 displayed in the chart series.
				KeyValuePair<string, object> groupbyAttribute = new KeyValuePair<string, object>();
				object dategroupValue = null;
				var dategroupAttribute = record.Attributes.FirstOrDefault(a => a.Key.EndsWith("_dategroup_value"));
				if (!string.IsNullOrEmpty(dategroupAttribute.Key))
				{
					var aliasedDateGroupValue = dategroupAttribute.Value as AliasedValue;
					dategroupValue = aliasedDateGroupValue == null ? dategroupAttribute.Value : aliasedDateGroupValue.Value;
					groupbyAttribute = record.Attributes.FirstOrDefault(a =>
						a.Key != dategroupAttribute.Key
						&&
						a.Key.StartsWith(dategroupAttribute.Key.Substring(0, dategroupAttribute.Key.IndexOf("_dategroup_value", StringComparison.InvariantCulture))));
				}

				foreach (var attribute in record.Attributes)
				{
					var aliasedValue = attribute.Value as AliasedValue;
					var value = aliasedValue != null ? aliasedValue.Value : attribute.Value;
					var formattedValue = string.Empty;
					var attributeLogicalName = aliasedValue != null ? aliasedValue.AttributeLogicalName : attribute.Key;
					var attributeEnreplacedyLogicalName = aliasedValue != null ? aliasedValue.EnreplacedyLogicalName : enreplacedyMetadata.LogicalName;
					var attributeMetadata = this.GetAttributeMetadata(attributeLogicalName, attributeEnreplacedyLogicalName);
					
					if (record.FormattedValues.Contains(attribute.Key))
					{
						formattedValue = record.FormattedValues[attribute.Key];
					}

					if (attributeMetadata != null && value != null)
					{
						switch (attributeMetadata.AttributeType)
						{
							case AttributeTypeCode.Customer:
							case AttributeTypeCode.Lookup:
							case AttributeTypeCode.Owner:
								var enreplacedyReference = value as EnreplacedyReference;
								if (enreplacedyReference != null)
								{
									formattedValue = enreplacedyReference.Name;
								}
								break;
							case AttributeTypeCode.State:
							case AttributeTypeCode.Status:
							case AttributeTypeCode.Picklist:
								var optionSetValue = value as OptionSetValue;
								if (optionSetValue != null)
								{
									formattedValue =
										Adxstudio.Xrm.Core.OrganizationServiceContextExtensions.GetOptionSetValueLabel(attributeMetadata,
											optionSetValue.Value, this.contextLanguage.IsCrmMultiLanguageEnabled ? this.contextLanguage.ContextLanguage.CrmLcid : this.culture.LCID);
								}
								break;
							case AttributeTypeCode.Money:
								var money = value as Money;
								if (money != null)
								{
									value = money.Value;
									var moneyFormatter = new BaseCurrencyMoneyFormatter(organizationMoneyFormatInfo, CultureInfo.CurrentCulture);
									formattedValue = string.Format(moneyFormatter, "{0}", money);
								}
								break;
							case AttributeTypeCode.DateTime:
								if (!string.IsNullOrEmpty(dategroupAttribute.Key) && attribute.Key == groupbyAttribute.Key && dategroupValue != null)
								{
									value = dategroupValue;
								}
								if (value is DateTime)
								{
									formattedValue = ((DateTime)value).ToString(this.culture.DateTimeFormat.ShortDatePattern);
								}
								break;
							case AttributeTypeCode.BigInt:
							case AttributeTypeCode.Integer:
								if (value is int)
								{
									formattedValue = ((int)value).ToString("N", this.culture);
								}
								break;
							case AttributeTypeCode.Decimal:
								var decimalAttributeMetadata = attributeMetadata as DecimalAttributeMetadata;
								if (decimalAttributeMetadata != null && value is decimal)
								{
									formattedValue =
										((decimal)value).ToString(string.Format("N{0}", decimalAttributeMetadata.Precision.GetValueOrDefault(2)),
											this.culture);
								}
								break;
							case AttributeTypeCode.Double:
								var doubleAttributeMetadata = attributeMetadata as DoubleAttributeMetadata;
								if (doubleAttributeMetadata != null && value is double)
								{
									formattedValue =
										((double)value).ToString(string.Format("N{0}", doubleAttributeMetadata.Precision.GetValueOrDefault(2)),
											this.culture);
								}
								break;
						}
					}

					if (string.IsNullOrWhiteSpace(formattedValue))
					{
						try
						{
							formattedValue = value.ToString();
						}
						catch
						{
							// ignored
						}
					}

					if (!string.IsNullOrEmpty(formattedValue))
					{
						formattedValue = formattedValue.Replace("<", "<").Replace(">", ">");
					}

					row.Add(attribute.Key, formattedValue);
					row.Add(string.Format("{0}_Value", attribute.Key), value);
				}

				data.Add(row);
			}

			return data;
		}

19 View Source File : Amf3Object.cs
License : MIT License
Project Creator : a1q123456

public void Add(string memberName, object member)
        {
            _fields.Add(memberName, member);
        }

19 View Source File : FunctionDictionaryBase.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public void AnnexDelegate<TAction>(TAction action, string name = null) where TAction : clreplaced
        {
            if (string.IsNullOrEmpty(name))
            {
                var type = typeof(TAction);
                if (_dependencyDictionary.ContainsKey(type))
                {
                    if (Equals(action, null))
                    {
                        _dependencyDictionary.Remove(type);
                    }
                    else
                    {
                        _dependencyDictionary[type] = action;
                    }
                }
                else if (!Equals(action, null))
                {
                    _dependencyDictionary.Add(type, action);
                }
            }
            else if (_nameDictionary.ContainsKey(name))
            {
                if (Equals(action, null))
                {
                    _nameDictionary.Remove(name);
                }
                else
                {
                    _nameDictionary[name] = action;
                }
            }
            else if (!Equals(action, null))
            {
                _nameDictionary.Add(name, action);
            }
        }

19 View Source File : ServerServiceDefinition.cs
License : MIT License
Project Creator : AElfProject

public Builder AddMethod<TRequest, TResponse>(
                Method<TRequest, TResponse> method,
                UnaryServerMethod<TRequest, TResponse> handler)
                    where TRequest : clreplaced
                    where TResponse : clreplaced
            {
                duplicateDetector.Add(method.FullName, null);
                addMethodActions.Add((serviceBinder) => serviceBinder.AddMethod(method, handler));
                return this;
            }

19 View Source File : Amf0Reader.cs
License : MIT License
Project Creator : a1q123456

private bool TryGetObjectImpl(Span<byte> objectBuffer, out Dictionary<string, object> value, out int bytesConsumed)
        {
            value = default;
            bytesConsumed = default;
            var obj = new Dictionary<string, object>();
            _referenceTable.Add(obj);
            var consumed = 0;
            while (true)
            {
                if (!TryGetStringImpl(objectBuffer, Amf0CommonValues.STRING_HEADER_LENGTH, out var key, out var keyLength))
                {
                    return false;
                }
                consumed += keyLength;
                objectBuffer = objectBuffer.Slice(keyLength);

                if (!TryGetValue(objectBuffer, out var dataType, out var data, out var valueLength))
                {
                    return false;
                }
                consumed += valueLength;
                objectBuffer = objectBuffer.Slice(valueLength);

                if (!key.Any() && dataType == Amf0Type.ObjectEnd)
                {
                    break;
                }
                obj.Add(key, data);
            }
            value = obj;
            bytesConsumed = consumed;
            return true;
        }

19 View Source File : Map.cs
License : Apache License 2.0
Project Creator : Aguafrommars

public static Dictionary<string, object> ToDictionary<T>(T obj)
        {
            var type = obj.GetType();
            var properties = type.GetProperties()
                .Where(p => p.PropertyType.IsValueType || p.PropertyType == typeof(string));
            var dictionary = new Dictionary<string, object>(properties.Count());
            foreach (var property in properties)
            {
                dictionary.Add(property.Name, property.GetValue(obj));
            }
            return dictionary;
        }

19 View Source File : Admin.cs
License : MIT License
Project Creator : 2881099

async public static Task<bool> Use(HttpContext context, IFreeSql fsql, string requestPathBase, Dictionary<string, Type> dicEnreplacedyTypes) {
			HttpRequest req = context.Request;
			HttpResponse res = context.Response;

			var remUrl = req.Path.ToString().Substring(requestPathBase.Length).Trim(' ', '/').Split('/');
			var enreplacedyName = remUrl.FirstOrDefault();

			if (!string.IsNullOrEmpty(enreplacedyName)) {

				if (dicEnreplacedyTypes.TryGetValue(enreplacedyName, out var enreplacedyType) == false) throw new Exception($"UseFreeAdminLtePreview 错误,找不到实体类型:{enreplacedyName}");

				var tb = fsql.CodeFirst.GetTableByEnreplacedy(enreplacedyType);
				if (tb == null) throw new Exception($"UseFreeAdminLtePreview 错误,实体类型无法映射:{enreplacedyType.FullName}");

				var tpl = _tpl.Value;

				switch (remUrl.ElementAtOrDefault(1)?.ToLower()) {
					case null:
						//首页
						if (true) {
							MakeTemplateFile($"{enreplacedyName}-list.html", Views.List);

							//ManyToOne/OneToOne
							var getlistFilter = new List<(TableRef, string, string, Dictionary<string, object>, List<Dictionary<string, object>>)>();
							foreach (var prop in tb.Properties) {
								if (tb.ColumnsByCs.ContainsKey(prop.Key)) continue;
								var tbref = tb.GetTableRef(prop.Key, false);
								if (tbref == null) continue;
								switch (tbref.RefType) {
									case TableRefType.OneToMany: continue;
									case TableRefType.ManyToOne:
										getlistFilter.Add(await Utils.GetTableRefData(fsql, tbref));
										continue;
									case TableRefType.OneToOne:
										continue;
									case TableRefType.ManyToMany:
										getlistFilter.Add(await Utils.GetTableRefData(fsql, tbref));
										continue;
								}
							}

							int.TryParse(req.Query["page"].FirstOrDefault(), out var getpage);
							int.TryParse(req.Query["limit"].FirstOrDefault(), out var getlimit);
							if (getpage <= 0) getpage = 1;
							if (getlimit <= 0) getlimit = 20;

							var getselect = fsql.Select<object>().AsType(enreplacedyType);
							foreach (var getlistF in getlistFilter) {
								var qv = req.Query[getlistF.Item3].ToArray();
								if (qv.Any()) {
									switch (getlistF.Item1.RefType) {
										case TableRefType.OneToMany: continue;
										case TableRefType.ManyToOne:
											getselect.Where(Utils.GetObjectWhereExpressionContains(tb, enreplacedyType, getlistF.Item1.Columns[0].CsName, qv));
											continue;
										case TableRefType.OneToOne:
											continue;
										case TableRefType.ManyToMany:
											if (true) {
												var midType = getlistF.Item1.RefMiddleEnreplacedyType;
												var midTb = fsql.CodeFirst.GetTableByEnreplacedy(midType);
												var midISelect = typeof(ISelect<>).MakeGenericType(midType);

												var funcType = typeof(Func<,>).MakeGenericType(typeof(object), typeof(bool));
												var expParam = Expression.Parameter(typeof(object), "a");
												var midParam = Expression.Parameter(midType, "mdtp");

												var anyMethod = midISelect.GetMethod("Any");
												var selectExp = qv.Select(c => Expression.Convert(Expression.Constant(FreeSql.Internal.Utils.GetDataReaderValue(getlistF.Item1.MiddleColumns[1].CsType, c)), getlistF.Item1.MiddleColumns[1].CsType)).ToArray();
												var expLambad = Expression.Lambda<Func<object, bool>>(
													Expression.Call(
														Expression.Call(
															Expression.Call(
																Expression.Constant(fsql),
																typeof(IFreeSql).GetMethod("Select", new Type[0]).MakeGenericMethod(midType)
															),
															midISelect.GetMethod("Where", new[] { typeof(Expression<>).MakeGenericType(typeof(Func<,>).MakeGenericType(midType, typeof(bool))) }),
															Expression.Lambda(
																typeof(Func<,>).MakeGenericType(midType, typeof(bool)),
																Expression.AndAlso(
																	Expression.Equal(
																		Expression.MakeMemberAccess(Expression.TypeAs(expParam, enreplacedyType), tb.Properties[getlistF.Item1.Columns[0].CsName]),
																		Expression.MakeMemberAccess(midParam, midTb.Properties[getlistF.Item1.MiddleColumns[0].CsName])
																	),
																	Expression.Call(
																		Utils.GetLinqContains(getlistF.Item1.MiddleColumns[1].CsType),
																		Expression.NewArrayInit(
																			getlistF.Item1.MiddleColumns[1].CsType,
																			selectExp
																		),
																		Expression.MakeMemberAccess(midParam, midTb.Properties[getlistF.Item1.MiddleColumns[1].CsName])
																	)
																),
																midParam
															)
														),
														anyMethod,
														Expression.Default(anyMethod.GetParameters().FirstOrDefault().ParameterType)
													),
													expParam);

												getselect.Where(expLambad);
											}
											continue;
									}
								}
							}

							var getlistTotal = await getselect.CountAsync();
							var getlist = await getselect.Page(getpage, getlimit).ToListAsync();
							var gethashlists = new Dictionary<string, object>[getlist.Count];
							var gethashlistsIndex = 0;
							foreach (var getlisreplacedem in getlist) {
								var gethashlist = new Dictionary<string, object>();
								foreach (var getcol in tb.ColumnsByCs) {
									gethashlist.Add(getcol.Key, tb.Properties[getcol.Key].GetValue(getlisreplacedem));
								}
								gethashlists[gethashlistsIndex++] = gethashlist;
							}

							var options = new Dictionary<string, object>();
							options["tb"] = tb;
							options["getlist"] = gethashlists;
							options["getlistTotal"] = getlistTotal;
							options["getlistFilter"] = getlistFilter;
							var str = _tpl.Value.RenderFile($"{enreplacedyName}-list.html", options);
							await res.WriteAsync(str);
						}
						return true;
					case "add":
					case "edit":
						//编辑页
						object gereplacedem = null;
						Dictionary<string, object> gethash = null;
						if (req.Query.Any()) {
							gereplacedem = Activator.CreateInstance(enreplacedyType);
							foreach (var getpk in tb.Primarys) {
								var reqv = req.Query[getpk.CsName].ToArray();
								if (reqv.Any())
									fsql.SetEnreplacedyValueWithPropertyName(enreplacedyType, gereplacedem, getpk.CsName, reqv.Length == 1 ? (object)reqv.FirstOrDefault() : reqv);
							}
							gereplacedem = await fsql.Select<object>().AsType(enreplacedyType).WhereDynamic(gereplacedem).FirstAsync();
							if (gereplacedem != null) {
								gethash = new Dictionary<string, object>();
								foreach (var getcol in tb.ColumnsByCs) {
									gethash.Add(getcol.Key, tb.Properties[getcol.Key].GetValue(gereplacedem));
								}
							}
						}

						if (req.Method.ToLower() == "get") {
							MakeTemplateFile($"{enreplacedyName}-edit.html", Views.Edit);

							//ManyToOne/OneToOne
							var getlistFilter = new Dictionary<string, (TableRef, string, string, Dictionary<string, object>, List<Dictionary<string, object>>)>();
							var getlistManyed = new Dictionary<string, IEnumerable<string>>();
							foreach (var prop in tb.Properties) {
								if (tb.ColumnsByCs.ContainsKey(prop.Key)) continue;
								var tbref = tb.GetTableRef(prop.Key, false);
								if (tbref == null) continue;
								switch (tbref.RefType) {
									case TableRefType.OneToMany: continue;
									case TableRefType.ManyToOne:
										getlistFilter.Add(prop.Key, await Utils.GetTableRefData(fsql, tbref));
										continue;
									case TableRefType.OneToOne:
										continue;
									case TableRefType.ManyToMany:
										getlistFilter.Add(prop.Key, await Utils.GetTableRefData(fsql, tbref));

										if (gereplacedem != null) {
											var midType = tbref.RefMiddleEnreplacedyType;
											var midTb = fsql.CodeFirst.GetTableByEnreplacedy(midType);
											var manyed = await fsql.Select<object>().AsType(midType)
												.Where(Utils.GetObjectWhereExpression(midTb, midType, tbref.MiddleColumns[0].CsName, fsql.GetEnreplacedyKeyValues(enreplacedyType, gereplacedem)[0]))
												.ToListAsync();
											getlistManyed.Add(prop.Key, manyed.Select(a => fsql.GetEnreplacedyValueWithPropertyName(midType, a, tbref.MiddleColumns[1].CsName).ToString()));
										}
										continue;
								}
							}

							var options = new Dictionary<string, object>();
							options["tb"] = tb;
							options["gethash"] = gethash;
							options["getlistFilter"] = getlistFilter;
							options["getlistManyed"] = getlistManyed;
							options["postaction"] = $"{requestPathBase}restful-api/{enreplacedyName}";
							var str = _tpl.Value.RenderFile($"{enreplacedyName}-edit.html", options);
							await res.WriteAsync(str);

						} else {
							if (gereplacedem == null) {
								gereplacedem = Activator.CreateInstance(enreplacedyType);
								foreach(var getcol in tb.Columns.Values) {
									if (new[] { typeof(DateTime), typeof(DateTime?) }.Contains(getcol.CsType) && new[] { "create_time", "createtime" }.Contains(getcol.CsName.ToLower()))
										fsql.SetEnreplacedyValueWithPropertyName(enreplacedyType, gereplacedem, getcol.CsName, DateTime.Now);
								}
							}
							var manySave = new List<(TableRef, object[], List<object>)>();
							if (req.Form.Any()) {
								foreach(var getcol in tb.Columns.Values) {
									if (new[] { typeof(DateTime), typeof(DateTime?) }.Contains(getcol.CsType) && new[] { "update_time", "updatetime" }.Contains(getcol.CsName.ToLower()))
										fsql.SetEnreplacedyValueWithPropertyName(enreplacedyType, gereplacedem, getcol.CsName, DateTime.Now);

									var reqv = req.Form[getcol.CsName].ToArray();
									if (reqv.Any())
										fsql.SetEnreplacedyValueWithPropertyName(enreplacedyType, gereplacedem, getcol.CsName, reqv.Length == 1 ? (object)reqv.FirstOrDefault() : reqv);
								}
								//ManyToMany
								foreach (var prop in tb.Properties) {
									if (tb.ColumnsByCs.ContainsKey(prop.Key)) continue;
									var tbref = tb.GetTableRef(prop.Key, false);
									if (tbref == null) continue;
									switch (tbref.RefType) {
										case TableRefType.OneToMany: continue;
										case TableRefType.ManyToOne:
											continue;
										case TableRefType.OneToOne:
											continue;
										case TableRefType.ManyToMany:
											var midType = tbref.RefMiddleEnreplacedyType;
											var mtb = fsql.CodeFirst.GetTableByEnreplacedy(midType);

											var reqv = req.Form[$"mn_{prop.Key}"].ToArray();
											var reqvIndex = 0;
											var manyVals = new object[reqv.Length];
											foreach (var rv in reqv) {
												var miditem = Activator.CreateInstance(midType);
												foreach (var getcol in tb.Columns.Values) {
													if (new[] { typeof(DateTime), typeof(DateTime?) }.Contains(getcol.CsType) && new[] { "create_time", "createtime" }.Contains(getcol.CsName.ToLower()))
														fsql.SetEnreplacedyValueWithPropertyName(midType, miditem, getcol.CsName, DateTime.Now);

													if (new[] { typeof(DateTime), typeof(DateTime?) }.Contains(getcol.CsType) && new[] { "update_time", "updatetime" }.Contains(getcol.CsName.ToLower()))
														fsql.SetEnreplacedyValueWithPropertyName(midType, miditem, getcol.CsName, DateTime.Now);
												}
												//fsql.SetEnreplacedyValueWithPropertyName(midType, miditem, tbref.MiddleColumns[0].CsName, fsql.GetEnreplacedyKeyValues(enreplacedyType, gereplacedem)[0]);
												fsql.SetEnreplacedyValueWithPropertyName(midType, miditem, tbref.MiddleColumns[1].CsName, rv);
												manyVals[reqvIndex++] = miditem;
											}
											var molds = await fsql.Select<object>().AsType(midType).Where(Utils.GetObjectWhereExpression(mtb, midType, tbref.MiddleColumns[0].CsName, fsql.GetEnreplacedyKeyValues(enreplacedyType, gereplacedem)[0])).ToListAsync();
											manySave.Add((tbref, manyVals, molds));
											continue;
									}
								}
							}


							using (var db = fsql.CreateDbContext()) {

								var dbset = db.Set<object>();
								dbset.AsType(enreplacedyType);

								await dbset.AddOrUpdateAsync(gereplacedem);

								foreach (var ms in manySave) {
									var midType = ms.Item1.RefMiddleEnreplacedyType;
									var moldsDic = ms.Item3.ToDictionary(a => fsql.GetEnreplacedyKeyString(midType, a, true));

									var manyset = db.Set<object>();
									manyset.AsType(midType);
									
									foreach (var msVal in ms.Item2) {
										fsql.SetEnreplacedyValueWithPropertyName(midType, msVal, ms.Item1.MiddleColumns[0].CsName, fsql.GetEnreplacedyKeyValues(enreplacedyType, gereplacedem)[0]);
										await manyset.AddOrUpdateAsync(msVal);
										moldsDic.Remove(fsql.GetEnreplacedyKeyString(midType, msVal, true));
									}
									manyset.RemoveRange(moldsDic.Values);
								}

								await db.SaveChangesAsync();
							}
							gethash = new Dictionary<string, object>();
							foreach (var getcol in tb.ColumnsByCs) {
								gethash.Add(getcol.Key, tb.Properties[getcol.Key].GetValue(gereplacedem));
							}

							await Utils.Jsonp(context, new { code = 0, success = true, message = "Success", data = gethash });
						}
						return true;
					case "del":
						if (req.Method.ToLower() == "post") {

							var delitems = new List<object>();
							var reqv = new List<string[]>();
							foreach(var delpk in tb.Primarys) {
								var reqvs = req.Form[delpk.CsName].ToArray();
								if (reqv.Count > 0 && reqvs.Length != reqv[0].Length) throw new Exception("删除失败,联合主键参数传递不对等");
								reqv.Add(reqvs);
							}
							if (reqv[0].Length == 0) return true;

							using (var ctx = fsql.CreateDbContext()) {
								var dbset = ctx.Set<object>();
								dbset.AsType(enreplacedyType);

								for (var a = 0; a < reqv[0].Length; a++) {
									object delitem = Activator.CreateInstance(enreplacedyType);
									var delpkindex = 0;
									foreach (var delpk in tb.Primarys)
										fsql.SetEnreplacedyValueWithPropertyName(enreplacedyType, delitem, delpk.CsName, reqv[delpkindex++][a]);
									dbset.Remove(delitem);
								}
								await ctx.SaveChangesAsync();
							}

							await Utils.Jsonp(context, new { code = 0, success = true, message = "Success" });
							return true;
						}
						break;
				}
			}
			return false;
		}

19 View Source File : UserOnlyStoreStub.cs
License : Apache License 2.0
Project Creator : Aguafrommars

protected override void SetIndex(Dictionary<string, object> rules, string key, object index)
        {
            var indexOverride = new Dictionary<string, object>();
            var jObject = rules.Where(kv => kv.Key == _testDb).Select(kv => kv.Value).FirstOrDefault() as JObject;
            rules.Clear();
            if (jObject != null)
            {
                foreach(var o in jObject)
                {
                    indexOverride.Add(o.Key, o.Value);
                }
            }
            
            indexOverride[key] = index;
            base.SetIndex(rules, _testDb, indexOverride);
        }

19 View Source File : TestAmf0Writer.cs
License : MIT License
Project Creator : a1q123456

public void AddDynamic(string key, object data)
            {
                _dynamicFields.Add(key, data);
            }

19 View Source File : ConfigurationBase.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public Dictionary<string, object> GetConfigurations()
		{
			lock (_root)
			{
				Dictionary<string, object> dic = new Dictionary<string, object>();
				FieldInfo[] fields = this.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
				foreach (FieldInfo f in fields)
					dic.Add(f.Name, f.GetValue(this));
				PropertyInfo[] props = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
				foreach (PropertyInfo p in props)
					dic.Add(p.Name, p.GetValue(this, null));
				return dic;
			}
		}

19 View Source File : XmlQuery.cs
License : Apache License 2.0
Project Creator : 1448376744

public void AddDbParameter(string name,object value)
        {
            if (_parameters == null)
            {
                _parameters = new Dictionary<string, object>();
            }
            if (_parameters.ContainsKey(name))
            {
                _parameters[name] = value;
            }
            else
            {
                _parameters.Add(name,value);
            }
        }

19 View Source File : ConfigurationService.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public bool SetAdminPreplacedword(string pwd)
		{
			if (!string.IsNullOrEmpty(pwd))
			{
				Dictionary<string, object> dic = new Dictionary<string, object>();
				dic.Add("AdminPreplacedword", Encryption.Encrypt(pwd));
				StorageEngine.UpdateConfigurations(dic);
				Global.Config.SetConfigurations(dic);
				return true;
			}
			return false;
		}

19 View Source File : JsonWebTokenUtilities.cs
License : MIT License
Project Creator : actions

internal static IDictionary<string, object> TranslateToJwtClaims(IEnumerable<Claim> claims)
        {
            ArgumentUtility.CheckForNull(claims, nameof(claims));

            Dictionary<string, object> ret = new Dictionary<string, object>();

            //there are two claim names that get special treatment
            foreach (Claim claim in claims)
            {
                string claimName = claim.Type;
                if (string.Compare(claimName, JsonWebTokenClaims.NameIdLongName, StringComparison.Ordinal) == 0)
                {
                    claimName = JsonWebTokenClaims.NameId;
                }
                else if (string.Compare(claimName, JsonWebTokenClaims.IdenreplacedyProviderLongName, StringComparison.Ordinal) == 0)
                {
                    claimName = JsonWebTokenClaims.IdenreplacedyProvider;
                }

                ret.Add(claimName, claim.Value);
            }

            return ret;
        }

19 View Source File : DCSMission.cs
License : GNU General Public License v3.0
Project Creator : akaAgar

internal void AddMediaFile(string fileName, string sourceFilePath)
        {
            if (string.IsNullOrEmpty(fileName) || MediaFiles.ContainsKey(fileName)) return;
            if (!File.Exists(sourceFilePath)) return;
            MediaFiles.Add(fileName, sourceFilePath);
        }

19 View Source File : Utils.cs
License : MIT License
Project Creator : 2881099

async public static Task<(TableRef, string, string, Dictionary<string, object>, List<Dictionary<string, object>>)> GetTableRefData(IFreeSql fsql, TableRef tbref) {
			var reftb = fsql.CodeFirst.GetTableByEnreplacedy(tbref.RefEnreplacedyType);
			var reflist = await fsql.Select<object>().AsType(tbref.RefEnreplacedyType).ToListAsync();
			var fitlerTextCol = reftb.ColumnsByCs.Values.Where(a => a.CsType == typeof(string)).FirstOrDefault();
			var filterTextProp = fitlerTextCol == null ? null : reftb.Properties[fitlerTextCol.CsName];
			var filterValueProp = reftb.Properties[reftb.Primarys.FirstOrDefault().CsName];
			var filterKv = new Dictionary<string, object>();
			var gethashlist = new List<Dictionary<string, object>>();
			foreach (var refitem in reflist) {
				filterKv[string.Concat(filterValueProp.GetValue(refitem))] = filterTextProp == null ? refitem : filterTextProp.GetValue(refitem);
				var gethash = new Dictionary<string, object>();
				foreach (var getcol in reftb.ColumnsByCs) {
					gethash.Add(getcol.Key, reftb.Properties[getcol.Key].GetValue(refitem));
				}
				gethashlist.Add(gethash);
			}
			return (
				tbref,
				tbref.RefEnreplacedyType.Name,
				tbref.RefEnreplacedyType.Name + "_" + reftb.Primarys.FirstOrDefault().CsName,
				filterKv,
				gethashlist
			);
		}

19 View Source File : AreaContextService.cs
License : MIT License
Project Creator : akinix

private void Init()
        {
            MainDictionary.Add(FirsreplacedemKey, new Dictionary<string, object>());
        }

19 View Source File : WrappedException.cs
License : MIT License
Project Creator : actions

private void TryWrapCustomProperties(Exception exception)
        {
            var customPropertiesWithDataMemberAttribute = GetCustomPropertiesInfo();

            if (customPropertiesWithDataMemberAttribute.Any())
            {
                this.CustomProperties = new Dictionary<string, object>();
            }

            foreach (var customProperty in customPropertiesWithDataMemberAttribute)
            {
                try
                {
                    this.CustomProperties.Add(customProperty.Name, customProperty.GetValue(exception));
                }
                catch
                {
                    // skip this property
                }
            }
        }

19 View Source File : TelemetryFallback.cs
License : MIT License
Project Creator : alen-smajic

string GetPostBody()
		{
			List<Dictionary<string, object>> eventList = new List<Dictionary<string, object>>();
			Dictionary<string, object> jsonDict = new Dictionary<string, object>();

			long unixTimestamp = (long)Mapbox.Utils.UnixTimestampUtils.To(DateTime.UtcNow);

			jsonDict.Add("event", "appUserTurnstile");
			jsonDict.Add("created", unixTimestamp);
			jsonDict.Add("userId", SystemInfo.deviceUniqueIdentifier);
			jsonDict.Add("enabled.telemetry", false);
			jsonDict.Add("sdkIdentifier", GetSDKIdentifier());
			jsonDict.Add("skuId", Constants.SDK_SKU_ID);
			jsonDict.Add("sdkVersion", Constants.SDK_VERSION);
			eventList.Add(jsonDict);

			var jsonString = JsonConvert.SerializeObject(eventList);
			return jsonString;
		}

19 View Source File : BooleanExpressionResovle.cs
License : Apache License 2.0
Project Creator : 1448376744

private void SetParameterValue(Expression expression)
        {
            var value = VisitConstantValue(expression);
            var parameterName = $"P_{_parameters.Count}";
            _parameters.Add(parameterName, value);
            _textBuilder.Append($"{_prefix}{parameterName}");
        }

19 View Source File : TelemetryWebgl.cs
License : MIT License
Project Creator : alen-smajic

string GetPostBody()
		{
			List<Dictionary<string, object>> eventList = new List<Dictionary<string, object>>();
			Dictionary<string, object> jsonDict = new Dictionary<string, object>();

			long unixTimestamp = (long)Mapbox.Utils.UnixTimestampUtils.To(DateTime.UtcNow);

			jsonDict.Add("event", "appUserTurnstile");
			jsonDict.Add("created", unixTimestamp);
			jsonDict.Add("userId", SystemInfo.deviceUniqueIdentifier);
			jsonDict.Add("enabled.telemetry", false);
			jsonDict.Add("sdkIdentifier", GetSDKIdentifier());
			jsonDict.Add("skuId", Constants.SDK_SKU_ID);
			jsonDict.Add("sdkVersion", Constants.SDK_VERSION);

			// user-agent cannot be set from web broswer, so we send in payload, instead!
			jsonDict.Add("userAgent", GetUserAgent());

			eventList.Add(jsonDict);

			var jsonString = JsonConvert.SerializeObject(eventList);
			return jsonString;
		}

19 View Source File : AspectContextExtensions.cs
License : MIT License
Project Creator : ad313

public static Dictionary<string, object> GetParamsDictionary(this AspectContext context)
        {
            //得到方法的参数
            var pars = context.ProxyMethod.GetParameters();

            //设置参数名和值 加入字典
            var dicValue = new Dictionary<string, object>();
            for (var i = 0; i < pars.Length; i++)
            {
                dicValue.Add(pars[i].Name, context.Parameters[i]);
            }
            return dicValue;
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 8x8

public String SignWith(RSA privateKey)
            {
                var rsaSecurityKey = new RsaSecurityKey(privateKey);
                var jwk = JsonWebKeyConverter.ConvertFromRSASecurityKey(rsaSecurityKey);
                jwk.KeyId = apiKey;

                var context = new Dictionary<String, Object>();
                context.Add("user", userClaims);
                context.Add("features", featureClaims);
                payload.Add("context", context);

                var cred = new SigningCredentials(jwk, SecurityAlgorithms.RsaSha256);
                var secToken = new JwtSecurityToken(new JwtHeader(cred), this.payload);
                var jwtHandler = new JwtSecurityTokenHandler();

                return jwtHandler.WriteToken(secToken);
            }

19 View Source File : DbContext.cs
License : Apache License 2.0
Project Creator : 1448376744

private void Initialize(IDbCommand cmd, string sql, object parameter, int? commandTimeout = null, CommandType? commandType = null)
        {
            var dbParameters = new List<IDbDataParameter>();
            cmd.Transaction = _transaction;
            cmd.CommandText = sql;
            if (commandTimeout.HasValue)
            {
                cmd.CommandTimeout = commandTimeout.Value;
            }
            if (commandType.HasValue)
            {
                cmd.CommandType = commandType.Value;
            }
            if (parameter is IDbDataParameter)
            {
                dbParameters.Add(parameter as IDbDataParameter);
            }
            else if (parameter is IEnumerable<IDbDataParameter> parameters)
            {
                dbParameters.AddRange(parameters);
            }
            else if (parameter is Dictionary<string, object> keyValues)
            {
                foreach (var item in keyValues)
                {
                    var param = CreateParameter(cmd, item.Key, item.Value);
                    dbParameters.Add(param);
                }
            }
            else if (parameter != null)
            {
                var handler = GlobalSettings.EnreplacedyMapperProvider.GetDeserializer(parameter.GetType());
                var values = handler(parameter);
                foreach (var item in values)
                {
                    var param = CreateParameter(cmd, item.Key, item.Value);
                    dbParameters.Add(param);
                }
            }
            if (dbParameters.Count > 0)
            {
                foreach (IDataParameter item in dbParameters)
                {
                    if (item.Value == null)
                    {
                        item.Value = DBNull.Value;
                    }
                    var pattern = [email protected]"in\s+([\@,\:,\?]?{item.ParameterName})";
                    var options = RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Multiline;
                    if (cmd.CommandText.IndexOf("in", StringComparison.OrdinalIgnoreCase) != -1 && Regex.IsMatch(cmd.CommandText, pattern, options))
                    {
                        var name = Regex.Match(cmd.CommandText, pattern, options).Groups[1].Value;
                        var list = new List<object>();
                        if (item.Value is IEnumerable<object> || item.Value is Array)
                        {
                            list = (item.Value as IEnumerable).Cast<object>().Where(a => a != null && a != DBNull.Value).ToList();
                        }
                        else
                        {
                            list.Add(item.Value);
                        }
                        if (list.Count() > 0)
                        {
                            cmd.CommandText = Regex.Replace(cmd.CommandText, name, $"({string.Join(",", list.Select(s => $"{name}{list.IndexOf(s)}"))})");
                            foreach (var iitem in list)
                            {
                                var key = $"{item.ParameterName}{list.IndexOf(iitem)}";
                                var param = CreateParameter(cmd, key, iitem);
                                cmd.Parameters.Add(param);
                            }
                        }
                        else
                        {
                            cmd.CommandText = Regex.Replace(cmd.CommandText, name, $"(SELECT 1 WHERE 1 = 0)");
                        }
                    }
                    else
                    {
                        cmd.Parameters.Add(item);
                    }
                }
            }
            if (Logging != null)
            {
                var parameters = new Dictionary<string, object>();
                foreach (IDbDataParameter item in cmd.Parameters)
                {
                    parameters.Add(item.ParameterName, item.Value);
                }
                Logging.Invoke(cmd.CommandText, parameters, commandTimeout, commandType);
            }
        }

19 View Source File : DbQuery.cs
License : Apache License 2.0
Project Creator : 1448376744

private void ResovleParameter(T enreplacedy)
        {
            var serializer = GlobalSettings.EnreplacedyMapperProvider.GetDeserializer(typeof(T));
            var values = serializer(enreplacedy);
            foreach (var item in values)
            {
                if (_parameters.ContainsKey(item.Key))
                {
                    _parameters[item.Key] = item.Value;
                }
                else
                {
                    _parameters.Add(item.Key, item.Value);
                }
            }
        }

19 View Source File : MapCodeGenResolverTest.cs
License : MIT License
Project Creator : 1996v

[Fact]
        public void Map1Deserialize_FormatterIsCorrectly()
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add(nameof(_Clreplaced_1.A1), (int)3);
            dic.Add(nameof(_Clreplaced_1.B1), (long)3);
            dic.Add(nameof(_Clreplaced_1.C1), (short)3);
            dic.Add(nameof(_Clreplaced_1.D1), (byte)3);
            dic.Add(nameof(_Clreplaced_1._1234567A), "f");
            dic.Add(nameof(_Clreplaced_1._2234567B), Guid.NewGuid());
            dic.Add(nameof(_Clreplaced_1._3234567C), DateTime.Now);

            var buf = BssomSerializer.Serialize(dic);
            var c1 = BssomSerializer.Deserialize<_Clreplaced_1>(buf);
            c1.A1.Is(dic["A1"]);
            c1.B1.Is(dic["B1"]);
            c1.C1.Is(dic["C1"]);
            c1.D1.Is(dic["D1"]);
            c1._1234567A.Is(dic["_1234567A"]);
            c1._2234567B.Is(dic["_2234567B"]);
            c1._3234567C.Is(dic["_3234567C"]);
        }

19 View Source File : Amf3Object.cs
License : MIT License
Project Creator : a1q123456

public void AddDynamic(string memberName, object member)
        {
            _dynamicFields.Add(memberName, member);
        }

19 View Source File : AttributeDictionary.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public bool Set<T>(string name, T value)
        {
            if (Dictionary.TryGetValue(name, out object value1))
            {
                if (Equals(value, default(T)))
                {
                    Dictionary.Remove(name);
                    return true;
                }
                if (Equals(value1, value))
                {
                    return false;
                }
                Dictionary[name] = value;
                return true;
            }
            if (Equals(value, default( T )))
            {
                return false;
            }
            Dictionary.Add(name, value);
            return true;
        }

See More Examples