System.Collections.Generic.List.Add(object)

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

3557 Examples 7

19 Source : ConfigurationBase.cs
with GNU General Public License v3.0
from aiportal

public object[] GetSystemInfo()
		{
			List<object> objs = new List<object>();
			{
				var drv = new DriveInfo(Application.StartupPath);
				objs.Add(new { Name = "CurrentTime", Value = DateTime.Now });
				//objs.Add(new { Name = "DiskFree", Value = drv.AvailableFreeSpace / (1024 * 1024 * 1024) });
				//array.Add(new { name = "DiskUsage", value = storage.GetTotalSpace() / (1024 * 1024 * 1024) });
				//array.Add(new { name = "EarliestDate", value = storage.MinSessionDate().ToLongDateString() });
			}
			return objs.ToArray();
		}

19 Source : ConfigurationBase.cs
with GNU General Public License v3.0
from aiportal

public object[] GetADItems()
		{
			List<object> objs = new List<object>();
			if (Global.Config.ADValid)
			{
				try
				{
					var cfg = Global.Config;
					var ad = new bfbd.Common.Windows.ADUserAccess(cfg.ADPath, cfg.ADUser, cfg.ADPreplacedwordValue, cfg.ADOrganization);
					foreach (var item in ad.EnumADItems(bfbd.Common.Windows.ADSchema.All))
					{
						objs.Add(new
						{
							Id = item.Id,
							ParentId = item.ParentId,
							Schema = item.Schema,
							Name = item.Name,
							Caption = item.DisplayName,
							Desc = item.Description,
							Domain = ad.DomainName
						});
					}
				}
				catch (Exception ex) { TraceLogger.Instance.WriteException(ex); }
			}
			return objs.ToArray();
		}

19 Source : ConfigurationService.cs
with GNU General Public License v3.0
from aiportal

public object GetLicenseInfo()
		{
			var sn = new SerialNumber();
			var mid = sn.MachineId;
			if (File.Exists(_licensePath))
			{
				string lic = File.ReadAllText(_licensePath);
				sn = SerialNumber.DeSerialize(lic.Substring(8), Global.Config.InstallTime);
				sn.MachineId = mid;
			}

			string type = null;
			if (sn.License == LicenseType.Demo)
				type = "Trial";
			else if (sn.License == LicenseType.Professional)
				type = "Professional";

			List<object> array = new List<object>();
			array.Add(new { name = "Version", value = "2.0.0" });
			array.Add(new { name = "LicenseType", value = type });
			array.Add(new { name = "MachineId", value = sn.MachineId });
			array.Add(new { name = "CreateTime", value = sn.CreateTime > DateTime.MinValue ? sn.CreateTime.ToLongDateString() : null });
			array.Add(new { name = "ExpireTime", value = sn.ExpireTime > DateTime.MinValue ? sn.ExpireTime.ToLongDateString() : null });
			array.Add(new { name = "IsValid", value = sn.IsValid() });
			array.Add(new { name = "Website", value = "<a href='http://www.ultragis.com' target='_blank'>http://www.ultragis.com</a>" });
			return new { total = array.Count, rows = array.ToArray() };
		}

19 Source : ConfigurationService.cs
with GNU General Public License v3.0
from aiportal

public object[] GetConfigurations()
		{
			List<object> objs = new List<object>();
			var dic = Serialization.ToDictionary(Global.Config);
			foreach (var key in dic.Keys)
			{
				string val = DataConverter.Serialize(dic[key]);
				if (dic[key] != null && dic[key].GetType() == typeof(DateTime))
					val = ((DateTime)dic[key]).ToLongDateString();
				objs.Add(new
				{
					Name = key,
					Value = val,
				});
			}
			long freeSpace = new DriveInfo(Application.StartupPath).AvailableFreeSpace / (1024 * 1024 * 1024);
			objs.Add(new { name = "DiskFree", value = freeSpace - 1 });

			return objs.ToArray();
		}

19 Source : DataQueryBase.cs
with GNU General Public License v3.0
from aiportal

public object[] GetUsers()
		{
			var users = Database.Execute(db => db.SelectObjects<DomainUser>("SessionInfo", null, "DISTINCT UserName", "Domain"));
			List<object> objs = new List<object>();
			_users.Clear();
			foreach (var user in users)
			{
				_users[user] = null;
				objs.Add(new { Name = user.ToString() });
			}
			return objs.ToArray();
		}

19 Source : DataQueryBase.cs
with GNU General Public License v3.0
from aiportal

public object[] GetApplications()
		{
			var apps = Database.Execute(db => db.SelectArray<string>("ApplicationInfo", "DISTINCT ProcessName", null));
			List<object> objs = new List<object>();
			_progs.Clear();
			foreach (var app in apps)
			{
				_progs[app] = null;
				objs.Add(new { Name = app });
			}
			return objs.ToArray();
		}

19 Source : DataQueryService.cs
with GNU General Public License v3.0
from aiportal

public object[] SnapshotsByUrl(Guid sid, string host, string url)
		{
			StringBuilder filter = new StringBuilder();
			filter.AppendFormat("SessionId='{0}'", sid.ToString("n"));
			filter.Append(" AND ImageLen > 0 ");
			if (!string.IsNullOrEmpty(host))
				filter.AppendFormat(" AND UrlHost='{0}' ", host);
			if (!string.IsNullOrEmpty(url) && ValidMd5(url))
				filter.AppendFormat(" AND md5(WindowUrl)='{0}' ", url.ToUpper());

			var snapshots = Database.Execute(db => db.SelectObjects<Snapshot>("SnapshotView", filter.ToString(),
				"SnapTime", 0,
				"SnapshotId", "BackgroundId", "UrlHost", "WindowUrl", "SnapTime", "MouseState as Mouse"));

			List<object> objs = new List<object>();
			foreach (var ss in snapshots)
				objs.Add(new
				{
					//SID = sid.ToString("n"),
					SSID = ss.SnapshotId.Replace("-", ""),
					BGID = ss.BackgroundId,
					Host = ss.UrlHost,
					Url = ss.WindowUrl,
					Time = string.Format("{0:HH:mm:ss}", ss.SnapTime),
					Mouse = ss.Mouse
				});

			return objs.ToArray();
		}

19 Source : DataQueryService.cs
with GNU General Public License v3.0
from aiportal

public object[] Searchreplacedle(DateTime start, DateTime end, string user, string prog, string replacedle)
		{
			StringBuilder filter = new StringBuilder();
			filter.AppendFormat(" '{0:yyyy-MM-dd}'<=date(StartTime) AND date(StartTime)<='{1:yyyy-MM-dd}' ", start, end);
			if (!string.IsNullOrEmpty(user) && ValidUser(user))
			{
				var domainUser = DomainUser.Create(user);
				if (domainUser != null)
					filter.AppendFormat(" AND Domain='{0}' AND UserName='{1}'", domainUser.Domain, domainUser.UserName);
			}
			if (!string.IsNullOrEmpty(prog) && ValidProgram(prog))
				filter.AppendFormat(" AND ProcessName='{0}' ", prog);
			if (!string.IsNullOrEmpty(replacedle) && ValidKey(replacedle))
				filter.AppendFormat(" AND Windowreplacedle LIKE '%{0}%' ", replacedle);

			var segments = Database.Execute(db => db.SelectObjects<SnapshotGroup>("Searchreplacedle", filter.ToString(),
				"SessionDate", "SessionId", "Domain", "UserName", "ProcessName", "Windowreplacedle", "StartTime", "EndTime", "SnapshotCount"));

			List<object> objs = new List<object>();
			foreach (var sg in segments)
				objs.Add(new
				{
					Date = sg.SessionDate,
					User = sg.User,
					Prog = sg.ProcessName,
					replacedle = sg.Windowreplacedle,
					SID = sg.SessionId,
					Time = sg.TimeRange,
					Count = sg.SnapshotCount,
				});
			return objs.ToArray();
		}

19 Source : DataQueryService.cs
with GNU General Public License v3.0
from aiportal

public object[] SearchText(DateTime start, DateTime end, string user, string prog, string text)
		{
			StringBuilder filter = new StringBuilder();
			filter.AppendFormat(" '{0:yyyy-MM-dd}'<=date(StartTime) AND date(StartTime)<='{1:yyyy-MM-dd}' ", start, end);
			filter.Append(" AND length(trim(InputText)) > 0 ");
			if (!string.IsNullOrEmpty(user) && ValidUser(user))
			{
				var domainUser = DomainUser.Create(user);
				if (domainUser != null)
					filter.AppendFormat(" AND Domain='{0}' AND UserName='{1}'", domainUser.Domain, domainUser.UserName);
			}
			if (!string.IsNullOrEmpty(prog) && ValidProgram(prog))
				filter.AppendFormat(" AND ProcessName='{0}' ", prog);
			if (!string.IsNullOrEmpty(text) && ValidKey(text))
				filter.AppendFormat(" AND InputText LIKE '%{0}%' ", text);

			var segments = Database.Execute(db => db.SelectObjects<SnapshotGroup>("SearchText", filter.ToString(),
				"SessionDate", "SessionId", "Domain", "UserName", "ProcessName", "Windowreplacedle", "StartTime", "EndTime", "InputText", "SnapshotCount"));

			List<object> objs = new List<object>();
			foreach (var sg in segments)
				objs.Add(new
				{
					Date = sg.SessionDate,
					User = sg.User,
					Prog = sg.ProcessName,
					replacedle = sg.Windowreplacedle,
					Text = sg.Text,
					SID = sg.SessionId,
					Time = sg.TimeRange,
					Count = sg.SnapshotCount,
				});
			return objs.ToArray();
		}

19 Source : StatisticBase.cs
with GNU General Public License v3.0
from aiportal

public object[] GetUsers()
		{
			var users = Database.Execute(db => db.SelectObjects<DomainUser>("SessionInfo", null, "DISTINCT UserName", "Domain"));
			List<object> objs = new List<object>();
			//_users.Clear();
			foreach (var user in users)
			{
				//_users[user] = null;
				objs.Add(new { Name = user.ToString() });
			}
			return objs.ToArray();
		}

19 Source : HttpService.cs
with GNU General Public License v3.0
from aiportal

private object[] MakeInvokeParameters(MethodInfo mi, HttpListenerRequest Request, HttpListenerResponse Response)
		{
			var attrs = mi.GetCustomAttributes(false);
			if (Array.Exists(attrs, a => a is RawRequestAttribute))
			{
				return Array.Exists(attrs, a => a is RawResponseAttribute) ?
					new object[] { Request, Response } :
					new object[] { Request };
			}
			else if (Array.Exists(attrs, a => a is RawParametersAttribute))
			{
				return Array.Exists(attrs, a => a is RawResponseAttribute) ?
						new object[] { Request.GetParameters(), Response } :
						new object[] { Request.GetParameters() };
			}
			else
			{
				List<object> ps = new List<object>();
				var prams = Request.GetParameters();
				foreach (var p in mi.GetParameters())
				{
					if (prams[p.Name] != null)
						ps.Add(DataConverter.ChangeType(prams[p.Name], p.ParameterType));
					else
						ps.Add(p.RawDefaultValue == DBNull.Value ? null : p.RawDefaultValue);
				};
				return ps.ToArray();
			}
		}

19 Source : HttpService.cs
with GNU General Public License v3.0
from aiportal

private object[] MakeInvokeParameters(MethodInfo mi, HttpListenerRequest Request, HttpListenerResponse Response)
		{
			var attrs = mi.GetCustomAttributes(false);
			if (Array.Exists(attrs, a => a is RawRequestAttribute))
			{
				return Array.Exists(attrs, a => a is RawResponseAttribute) ?
					new object[] { Request, Response } :
					new object[] { Request };
			}
			else if (Array.Exists(attrs, a => a is RawParametersAttribute))
			{
				return Array.Exists(attrs, a => a is RawResponseAttribute) ?
						new object[] { Request.GetParameters(), Response } :
						new object[] { Request.GetParameters() };
			}
			else
			{
				List<object> ps = new List<object>();
				var prams = Request.GetParameters();
				foreach (var p in mi.GetParameters())
				{
					if (prams[p.Name] != null)
						ps.Add(DataConverter.ChangeType(prams[p.Name], p.ParameterType));
					else
						ps.Add(p.RawDefaultValue == DBNull.Value ? null : p.RawDefaultValue);
				};
				return ps.ToArray();
			}
		}

19 Source : ConfigurationService.cs
with GNU General Public License v3.0
from aiportal

public object GetLicenseInfo()
		{
			string lic = Database.Invoke(db => db.GetConfiguration("LicenseKey"));
			var sn = new SerialNumber();
			if (!string.IsNullOrEmpty(lic))
			{
				Call.Execute(() =>
				{
					sn = SerialNumber.DeSerialize(lic.Substring(8), "Monkey", Global.Config.InstallTime);
				});
			}

			List<object> array = new List<object>();
			array.Add(new { name = "Version", value = "2.0.0" });
			array.Add(new { name = "LicenseType", value = sn.LicenseType.ToString() });
			array.Add(new { name = "MachineId", value = sn.MachineId });
			array.Add(new { name = "CreateTime", value = sn.CreateTime > DateTime.MinValue ? sn.CreateTime.ToLongDateString() : null });
			array.Add(new { name = "ExpireTime", value = sn.ExpireTime > DateTime.MinValue ? sn.ExpireTime.ToLongDateString() : null });
			array.Add(new { name = "IsValid", value = sn.IsValid() });
			array.Add(new { name = "Website", value = "<a href='http://www.ultragis.com' target='_blank'>http://www.ultragis.com</a>" });
			array.Add(new { name = "Support", value = "<a href='mailto:[email protected]' target='_blank'>[email protected]</a>" });
			return new { total = array.Count, rows = array.ToArray() };
		}

19 Source : DataQueryService.cs
with GNU General Public License v3.0
from aiportal

public object[] SnapshotsByreplacedle(Guid sid, string prog, string replacedle)
		{
			StringBuilder filter = new StringBuilder();
			filter.AppendFormat("SessionId='{0}'", sid.ToString("n"));
			filter.Append(" AND ImageLen > 0 ");
			if (!string.IsNullOrEmpty(prog) && ValidProgram(prog))
				filter.AppendFormat(" AND ProcessName='{0}' ", prog);
			if (!string.IsNullOrEmpty(replacedle) && ValidMd5(replacedle))
				filter.AppendFormat(" AND md5(Windowreplacedle)='{0}' ", replacedle.ToUpper());

			var snapshots = Database.Execute(db => db.SelectObjects<Snapshot>("SnapshotView", filter.ToString(),
				"SnapTime", 0,
				"SnapshotId", "BackgroundId", "ProcessName", "Windowreplacedle", "SnapTime", "MouseState as Mouse"));

			List<object> objs = new List<object>();
			foreach (var ss in snapshots)
				objs.Add(new
				{
					//SID = sid.ToString("n"),
					SSID = ss.SnapshotId.Replace("-",""),
					BGID = ss.BackgroundId,
					Prog = ss.ProcessName,
					replacedle = ss.Windowreplacedle,
					Time = string.Format("{0:HH:mm:ss}", ss.SnapTime),
					Mouse = ss.Mouse
				});

			return objs.ToArray();
		}

19 Source : DataQueryService.cs
with GNU General Public License v3.0
from aiportal

public object[] SearchUrl(DateTime start, DateTime end, string user, string host, string url)
		{
			StringBuilder filter = new StringBuilder();
			filter.AppendFormat(" '{0:yyyy-MM-dd}'<=date(StartTime) AND date(StartTime)<='{1:yyyy-MM-dd}' ", start, end);
			if (!string.IsNullOrEmpty(user) && ValidUser(user))
			{
				var domainUser = DomainUser.Create(user);
				if (domainUser != null)
					filter.AppendFormat(" AND Domain='{0}' AND UserName='{1}'", domainUser.Domain, domainUser.UserName);
			}
			if (!string.IsNullOrEmpty(host) && ValidHost(host))
				filter.AppendFormat(" AND UrlHost='{0}' ", host);
			else
				filter.Append(@" AND UrlHost NOT LIKE '_:'");
			if (!string.IsNullOrEmpty(url) && ValidKey(url))
				filter.AppendFormat(" AND WindowUrl LIKE '%{0}%' ", url);

			var segments = Database.Execute(db => db.SelectObjects<SnapshotGroup>("SearchUrl", filter.ToString(),
				"SessionDate", "SessionId", "Domain", "UserName", "StartTime", "EndTime", "UrlHost", "WindowUrl", "SnapshotCount"));

			List<object> objs = new List<object>();
			foreach (var sg in segments)
				objs.Add(new
				{
					SID = sg.SID,
					Date = sg.SessionDate,
					User = sg.User,
					Host = sg.UrlHost,
					Time = sg.TimeRange,
					Url = sg.WindowUrl,
					Count = sg.SnapshotCount,
				});

			return objs.ToArray();
		}

19 Source : DataQueryService.cs
with GNU General Public License v3.0
from aiportal

public object[] SearchFile(DateTime start, DateTime end, string user, string drive, string file)
		{
			StringBuilder filter = new StringBuilder();
			filter.AppendFormat(" '{0:yyyy-MM-dd}'<=date(StartTime) AND date(StartTime)<='{1:yyyy-MM-dd}' ", start, end);
			if (!string.IsNullOrEmpty(user) && ValidUser(user))
			{
				var domainUser = DomainUser.Create(user);
				if (domainUser != null)
					filter.AppendFormat(" AND Domain='{0}' AND UserName='{1}'", domainUser.Domain, domainUser.UserName);
			}
			if (!string.IsNullOrEmpty(drive) && ValidDrive(drive))
				filter.AppendFormat(" AND UrlHost='{0}' ", drive);
			else
				filter.AppendFormat(" AND UrlHost LIKE '_:'");
			if (!string.IsNullOrEmpty(file) && ValidKey(file))
				filter.AppendFormat(" AND WindowUrl LIKE 'file:///%{0}%' ", file);

			var segments = Database.Execute(db => db.SelectObjects<SnapshotGroup>("SearchUrl", filter.ToString(),
				"SessionDate", "SessionId", "Domain", "UserName", "StartTime", "EndTime", "UrlHost", "WindowUrl", "SnapshotCount"));

			List<object> objs = new List<object>();
			foreach (var sg in segments)
				objs.Add(new
				{
					SID = sg.SID,
					Date = sg.SessionDate,
					User = sg.User,
					Host = sg.UrlHost,
					Time = sg.TimeRange,
					Url = sg.WindowUrl,
					Count = sg.SnapshotCount,
				});

			return objs.ToArray();
		}

19 Source : StatisticService.cs
with GNU General Public License v3.0
from aiportal

public object[] ProgramUsage(DateTime start, DateTime end, string user)
		{
			Debug.replacedert(!string.IsNullOrEmpty(user));
			StringBuilder filter = new StringBuilder();
			filter.AppendFormat(" '{0:yyyy-MM-dd}'<=SessionDate AND SessionDate<='{1:yyyy-MM-dd}' ", start, end);
			filter.AppendFormat(" AND Domain='{0}'", user.Contains(@"\") ? user.Split('\\')[0] : Environment.MachineName);
			filter.AppendFormat(" AND UserName='{0}'", user.Contains(@"\") ? user.Split('\\')[1] : user);

			var groups = Database.Execute(db => db.ReadObjects<SnapGroup>("StatisticView", filter.ToString(), null, 4,
					"Domain", "UserName", "SessionDate", "ProcessName", "Sum(SnapCount) AS SnapCount"));

			List<object> array = new List<object>();
			foreach (var g in groups)
			{
				if (string.IsNullOrEmpty(g.ProcessName))
					continue;
				array.Add(new
				{
					User = g.User,
					Date = g.SessionDate,
					Prog = g.ProcessName,
					Count = g.SnapCount,
				});
			}
			return array.ToArray();
		}

19 Source : StatisticService.cs
with GNU General Public License v3.0
from aiportal

public object[] HostVisit(DateTime start, DateTime end, string user)
		{
			Debug.replacedert(!string.IsNullOrEmpty(user));
			StringBuilder filter = new StringBuilder();
			filter.AppendFormat(" '{0:yyyy-MM-dd}'<=SessionDate AND SessionDate<='{1:yyyy-MM-dd}' ", start, end);
			filter.AppendFormat(" AND Domain='{0}'", user.Contains(@"\") ? user.Split('\\')[0] : Environment.MachineName);
			filter.AppendFormat(" AND UserName='{0}'", user.Contains(@"\") ? user.Split('\\')[1] : user);
			filter.AppendFormat(" AND UrlHost NOT LIKE '_:'");

			var groups = Database.Execute(db => db.ReadObjects<SnapGroup>("StatisticView", filter.ToString(), null, 4,
					"Domain", "UserName", "SessionDate", "UrlHost", "Sum(SnapCount) AS SnapCount"));

			List<object> array = new List<object>();
			foreach (var g in groups)
			{
				if (string.IsNullOrEmpty(g.UrlHost))
					continue;
				array.Add(new
					{
						User = g.User,
						Date = g.SessionDate,
						Host = g.UrlHost,
						Count = g.SnapCount,
					});
			}
			return array.ToArray();
		}

19 Source : ConfigurationService.cs
with GNU General Public License v3.0
from aiportal

public object[] GetConfigurations()
		{
			List<object> objs = new List<object>();
			var dic = DataConverter.ToDictionary(Global.Config, false);
			foreach (var key in dic.Keys)
			{
				string val = DataConverter.Convert<string>(dic[key]);
				if (dic[key] != null && dic[key].GetType() == typeof(DateTime))
					val = ((DateTime)dic[key]).ToLongDateString();
				objs.Add(new
				{
					Name = key,
					Value = val,
				});
			}
			long freeSpace = new DriveInfo(AppDomain.CurrentDomain.BaseDirectory).AvailableFreeSpace / (1024 * 1024 * 1024);
			objs.Add(new { name = "DiskFree", value = freeSpace - 1 });

			return objs.ToArray();
		}

19 Source : DataQueryBase.cs
with GNU General Public License v3.0
from aiportal

public object[] GetHosts()
		{
			var hosts = Database.Execute(db => db.SelectArray<string>("HostInfo", "DISTINCT HostUrl", null));
			List<object> objs = new List<object>();
			_hosts.Clear();
			foreach (var host in hosts)
			{
				_hosts[host] = null;
				objs.Add(new { Name = host });
			}
			return objs.ToArray();
		}

19 Source : DataQueryBase.cs
with GNU General Public License v3.0
from aiportal

public object[] GetDrives()
		{
			var drvs = System.IO.DriveInfo.GetDrives();
			List<object> objs = new List<object>();
			_drives.Clear();
			foreach (var drv in drvs)
			{
				string name = drv.Name.TrimEnd('\\');
				_drives[name] = null;
				objs.Add(new { Name = name });
			}
			return objs.ToArray();
		}

19 Source : DataQueryService.cs
with GNU General Public License v3.0
from aiportal

public object[] GetSessions(DateTime start, DateTime end, string user)
		{
			StringBuilder sbFilter = new StringBuilder();
			sbFilter.AppendFormat(" '{0:yyyy-MM-dd}'<=date(CreateTime) AND date(CreateTime)<='{1:yyyy-MM-dd}' ", start, end);
			sbFilter.Append(" AND SnapshotCount>0 ");
			if (!string.IsNullOrEmpty(user) && ValidUser(user))
			{
				var domainUser = DomainUser.Create(user);
				if (domainUser != null)
					sbFilter.AppendFormat(" AND Domain='{0}' AND UserName='{1}'", domainUser.Domain, domainUser.UserName);
			}

			var sessions = Database.Execute(db => db.SelectObjects<SessionObj>("SessionView", sbFilter.ToString(),
				"SessionId", "CreateTime", "LastActiveTime", "UserName", "Domain", "ClientName", "ClientAddress", "IsEnd", "SnapshotCount", "DataLength"));

			List<object> objs = new List<object>();
			foreach (var s in sessions)
				objs.Add(new
				{
					SID = s.SID,
					Date = s.Date,
					User = s.User,
					Time = s.TimeRange,
					Count = s.SnapshotCount,
					Length = s.DataLength,
					Active = s.IsActive,
					Client = s.ClientName,
					Address = s.ClientAddress,
				});

			return objs.ToArray();
		}

19 Source : DataQueryService.cs
with GNU General Public License v3.0
from aiportal

public object[] GetSnapshots(Guid sid)
		{
			var segments = Database.Execute(db => db.SelectObjects<SnapshotGroup>("Searchreplacedle", new { SessionId = sid.ToString("n") },
				"SessionId", "ProcessName", "Windowreplacedle", "StartTime", "EndTime", "SnapshotCount"));

			List<object> objs = new List<object>();
			foreach (var sg in segments)
				objs.Add(new {
					SID = sg.SID,
					Prog = sg.ProcessName,
					replacedle = sg.Windowreplacedle,
					Time = sg.TimeRange,
					Count = sg.SnapshotCount,
				});

			return objs.ToArray();
		}

19 Source : StatisticService.cs
with GNU General Public License v3.0
from aiportal

public object[] ComputerUsage(DateTime start, DateTime end, string user)
		{
			Debug.replacedert(!string.IsNullOrEmpty(user));
			StringBuilder filter = new StringBuilder();
			filter.AppendFormat(" '{0:yyyy-MM-dd}'<=SnapDate AND SnapDate<='{1:yyyy-MM-dd}' ", start, end);
			filter.AppendFormat(" AND Domain='{0}'", user.Contains(@"\") ? user.Split('\\')[0] : Environment.MachineName);
			filter.AppendFormat(" AND UserName='{0}'", user.Contains(@"\") ? user.Split('\\')[1] : user);

			var groups = Database.Execute(db=>db.ReadObjects<SnapGroup>("HoursView", filter.ToString(), "SnapHour", 4,
				"Domain", "UserName", "SnapDate AS SessionDate", "SnapHour", "Sum(SnapCount) AS SnapCount"));

			List<object> array = new List<object>();
			foreach (var g in groups)
				array.Add(new
				{
					User = g.User,
					Date = g.SessionDate,
					Hour = g.SnapHour,
					Count = g.SnapCount,
				});
			return array.ToArray();
		}

19 Source : HttpRemoting.cs
with GNU General Public License v3.0
from aiportal

private object[] MakeInvokeParameters(MethodInfo mi, HttpListenerRequest Request, HttpListenerResponse Response)
		{
			List<object> ps = new List<object>();
			ps.Add(SerializeEngine.Deserialize(Request.InputStream));

			var prams = Request.GetParameters();
			foreach (var p in mi.GetParameters())
			{
				if (prams[p.Name] != null)
					ps.Add(DataConverter.ChangeType(prams[p.Name], p.ParameterType));
				else
					ps.Add(p.RawDefaultValue == DBNull.Value ? null : p.RawDefaultValue);
			};
			return ps.ToArray();
		}

19 Source : HttpRemoting.cs
with GNU General Public License v3.0
from aiportal

private object[] MakeInvokeParameters(MethodInfo mi, HttpListenerRequest Request, HttpListenerResponse Response)
		{
			List<object> ps = new List<object>();
			ps.Add(SerializeEngine.Deserialize(Request.InputStream));

			var prams = Request.GetParameters();
			foreach (var p in mi.GetParameters())
			{
				if (prams[p.Name] != null)
					ps.Add(DataConverter.ChangeType(prams[p.Name], p.ParameterType));
				else
					ps.Add(p.RawDefaultValue == DBNull.Value ? null : p.RawDefaultValue);
			};
			return ps.ToArray();
		}

19 Source : SubscriptionListener.cs
with Apache License 2.0
from ajuna-network

private void GenericCallBack<T>(string subscription, T result)
        {
            Logger.Debug($"{subscription}: {result}");

            if (_headerCallbacks.ContainsKey(subscription))
            {
                ((Action<string, T>) _headerCallbacks[subscription])(subscription, result);
            }
            else
            {
                if (!_pendingHeaders.ContainsKey(subscription)) _pendingHeaders.Add(subscription, new List<object>());
                _pendingHeaders[subscription].Add(result);
            }
        }

19 Source : LookupTest.cs
with Apache License 2.0
from akarnokd

[Test]
        public void Enumerate_NonGeneric()
        {
            var lookup = new Lookup<int, int>(EqualityComparer<int>.Default);
            lookup.Add(0, 1);
            lookup.Add(0, 2);

            var list = new List<object>();
            foreach (var g in (IEnumerable)lookup)
            {
                foreach (var i in (IEnumerable)g)
                {
                    list.Add(i);
                }
            }

            replacedert.AreEqual(new List<object>() { 1, 2 }, list);
        }

19 Source : DataTableConverter.cs
with MIT License
from akaskela

private static void CreateRow(JsonReader reader, DataTable dt, JsonSerializer serializer)
        {
            DataRow dr = dt.NewRow();
            reader.ReadAndreplacedert();

            while (reader.TokenType == JsonToken.PropertyName)
            {
                string columnName = (string)reader.Value;

                reader.ReadAndreplacedert();

                DataColumn column = dt.Columns[columnName];
                if (column == null)
                {
                    Type columnType = GetColumnDataType(reader);
                    column = new DataColumn(columnName, columnType);
                    dt.Columns.Add(column);
                }

                if (column.DataType == typeof(DataTable))
                {
                    if (reader.TokenType == JsonToken.StartArray)
                    {
                        reader.ReadAndreplacedert();
                    }

                    DataTable nestedDt = new DataTable();

                    while (reader.TokenType != JsonToken.EndArray)
                    {
                        CreateRow(reader, nestedDt, serializer);

                        reader.ReadAndreplacedert();
                    }

                    dr[columnName] = nestedDt;
                }
                else if (column.DataType.IsArray && column.DataType != typeof(byte[]))
                {
                    if (reader.TokenType == JsonToken.StartArray)
                    {
                        reader.ReadAndreplacedert();
                    }

                    List<object> o = new List<object>();

                    while (reader.TokenType != JsonToken.EndArray)
                    {
                        o.Add(reader.Value);
                        reader.ReadAndreplacedert();
                    }

                    Array destinationArray = Array.CreateInstance(column.DataType.GetElementType(), o.Count);
                    Array.Copy(o.ToArray(), destinationArray, o.Count);

                    dr[columnName] = destinationArray;
                }
                else
                {
                    dr[columnName] = (reader.Value != null) ? serializer.Deserialize(reader, column.DataType) : DBNull.Value;
                }

                reader.ReadAndreplacedert();
            }

            dr.EndEdit();
            dt.Rows.Add(dr);
        }

19 Source : JsonSerializerInternalWriter.cs
with MIT License
from akaskela

[SecuritySafeCritical]
#endif
        private void SerializeISerializable(JsonWriter writer, ISerializable value, JsonISerializableContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
        {
            if (!JsonTypeReflector.FullyTrusted)
            {
                string message = @"Type '{0}' implements ISerializable but cannot be serialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data." + Environment.NewLine +
                                 @"To fix this error either change the environment to be fully trusted, change the application to not deserialize the type, add JsonObjectAttribute to the type or change the JsonSerializer setting ContractResolver to use a new DefaultContractResolver with IgnoreSerializableInterface set to true." + Environment.NewLine;
                message = message.FormatWith(CultureInfo.InvariantCulture, value.GetType());

                throw JsonSerializationException.Create(null, writer.ContainerPath, message, null);
            }

            OnSerializing(writer, contract, value);
            _serializeStack.Add(value);

            WriteObjectStart(writer, value, contract, member, collectionContract, containerProperty);

            SerializationInfo serializationInfo = new SerializationInfo(contract.UnderlyingType, new FormatterConverter());
            value.GetObjectData(serializationInfo, Serializer._context);

            foreach (SerializationEntry serializationEntry in serializationInfo)
            {
                JsonContract valueContract = GetContractSafe(serializationEntry.Value);

                if (ShouldWriteReference(serializationEntry.Value, null, valueContract, contract, member))
                {
                    writer.WritePropertyName(serializationEntry.Name);
                    WriteReference(writer, serializationEntry.Value);
                }
                else if (CheckForCircularReference(writer, serializationEntry.Value, null, valueContract, contract, member))
                {
                    writer.WritePropertyName(serializationEntry.Name);
                    SerializeValue(writer, serializationEntry.Value, valueContract, null, contract, member);
                }
            }

            writer.WriteEndObject();

            _serializeStack.RemoveAt(_serializeStack.Count - 1);
            OnSerialized(writer, contract, value);
        }

19 Source : JsonSerializerInternalWriter.cs
with MIT License
from akaskela

private void SerializeDynamic(JsonWriter writer, IDynamicMetaObjectProvider value, JsonDynamicContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
        {
            OnSerializing(writer, contract, value);
            _serializeStack.Add(value);

            WriteObjectStart(writer, value, contract, member, collectionContract, containerProperty);

            int initialDepth = writer.Top;

            for (int index = 0; index < contract.Properties.Count; index++)
            {
                JsonProperty property = contract.Properties[index];

                // only write non-dynamic properties that have an explicit attribute
                if (property.HasMemberAttribute)
                {
                    try
                    {
                        object memberValue;
                        JsonContract memberContract;

                        if (!CalculatePropertyValues(writer, value, contract, member, property, out memberContract, out memberValue))
                        {
                            continue;
                        }

                        property.WritePropertyName(writer);
                        SerializeValue(writer, memberValue, memberContract, property, contract, member);
                    }
                    catch (Exception ex)
                    {
                        if (IsErrorHandled(value, contract, property.PropertyName, null, writer.ContainerPath, ex))
                        {
                            HandleError(writer, initialDepth);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }

            foreach (string memberName in value.GetDynamicMemberNames())
            {
                object memberValue;
                if (contract.TryGetMember(value, memberName, out memberValue))
                {
                    try
                    {
                        JsonContract valueContract = GetContractSafe(memberValue);

                        if (!ShouldWriteDynamicProperty(memberValue))
                        {
                            continue;
                        }

                        if (CheckForCircularReference(writer, memberValue, null, valueContract, contract, member))
                        {
                            string resolvedPropertyName = (contract.PropertyNameResolver != null)
                                ? contract.PropertyNameResolver(memberName)
                                : memberName;

                            writer.WritePropertyName(resolvedPropertyName);
                            SerializeValue(writer, memberValue, valueContract, null, contract, member);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (IsErrorHandled(value, contract, memberName, null, writer.ContainerPath, ex))
                        {
                            HandleError(writer, initialDepth);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }

            writer.WriteEndObject();

            _serializeStack.RemoveAt(_serializeStack.Count - 1);
            OnSerialized(writer, contract, value);
        }

19 Source : JsonSerializerInternalWriter.cs
with MIT License
from akaskela

private void SerializeObject(JsonWriter writer, object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
        {
            OnSerializing(writer, contract, value);

            _serializeStack.Add(value);

            WriteObjectStart(writer, value, contract, member, collectionContract, containerProperty);

            int initialDepth = writer.Top;

            for (int index = 0; index < contract.Properties.Count; index++)
            {
                JsonProperty property = contract.Properties[index];
                try
                {
                    object memberValue;
                    JsonContract memberContract;

                    if (!CalculatePropertyValues(writer, value, contract, member, property, out memberContract, out memberValue))
                    {
                        continue;
                    }

                    property.WritePropertyName(writer);
                    SerializeValue(writer, memberValue, memberContract, property, contract, member);
                }
                catch (Exception ex)
                {
                    if (IsErrorHandled(value, contract, property.PropertyName, null, writer.ContainerPath, ex))
                    {
                        HandleError(writer, initialDepth);
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            if (contract.ExtensionDataGetter != null)
            {
                IEnumerable<KeyValuePair<object, object>> extensionData = contract.ExtensionDataGetter(value);
                if (extensionData != null)
                {
                    foreach (KeyValuePair<object, object> e in extensionData)
                    {
                        JsonContract keyContract = GetContractSafe(e.Key);
                        JsonContract valueContract = GetContractSafe(e.Value);

                        bool escape;
                        string propertyName = GetPropertyName(writer, e.Key, keyContract, out escape);

                        if (ShouldWriteReference(e.Value, null, valueContract, contract, member))
                        {
                            writer.WritePropertyName(propertyName);
                            WriteReference(writer, e.Value);
                        }
                        else
                        {
                            if (!CheckForCircularReference(writer, e.Value, null, valueContract, contract, member))
                            {
                                continue;
                            }

                            writer.WritePropertyName(propertyName);

                            SerializeValue(writer, e.Value, valueContract, null, contract, member);
                        }
                    }
                }
            }

            writer.WriteEndObject();

            _serializeStack.RemoveAt(_serializeStack.Count - 1);

            OnSerialized(writer, contract, value);
        }

19 Source : JsonSerializerInternalWriter.cs
with MIT License
from akaskela

private void SerializeConvertable(JsonWriter writer, JsonConverter converter, object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
        {
            if (ShouldWriteReference(value, null, contract, collectionContract, containerProperty))
            {
                WriteReference(writer, value);
            }
            else
            {
                if (!CheckForCircularReference(writer, value, null, contract, collectionContract, containerProperty))
                {
                    return;
                }

                _serializeStack.Add(value);

                if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Info)
                {
                    TraceWriter.Trace(TraceLevel.Info, JsonPosition.FormatMessage(null, writer.Path, "Started serializing {0} with converter {1}.".FormatWith(CultureInfo.InvariantCulture, value.GetType(), converter.GetType())), null);
                }

                converter.WriteJson(writer, value, GetInternalSerializer());

                if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Info)
                {
                    TraceWriter.Trace(TraceLevel.Info, JsonPosition.FormatMessage(null, writer.Path, "Finished serializing {0} with converter {1}.".FormatWith(CultureInfo.InvariantCulture, value.GetType(), converter.GetType())), null);
                }

                _serializeStack.RemoveAt(_serializeStack.Count - 1);
            }
        }

19 Source : JsonSerializerInternalWriter.cs
with MIT License
from akaskela

private void SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
        {
            IWrappedCollection wrappedCollection = values as IWrappedCollection;
            object underlyingList = wrappedCollection != null ? wrappedCollection.UnderlyingCollection : values;

            OnSerializing(writer, contract, underlyingList);

            _serializeStack.Add(underlyingList);

            bool hasWrittenMetadataObject = WriteStartArray(writer, underlyingList, contract, member, collectionContract, containerProperty);

            writer.WriteStartArray();

            int initialDepth = writer.Top;

            int index = 0;
            // note that an error in the IEnumerable won't be caught
            foreach (object value in values)
            {
                try
                {
                    JsonContract valueContract = contract.FinalItemContract ?? GetContractSafe(value);

                    if (ShouldWriteReference(value, null, valueContract, contract, member))
                    {
                        WriteReference(writer, value);
                    }
                    else
                    {
                        if (CheckForCircularReference(writer, value, null, valueContract, contract, member))
                        {
                            SerializeValue(writer, value, valueContract, null, contract, member);
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (IsErrorHandled(underlyingList, contract, index, null, writer.ContainerPath, ex))
                    {
                        HandleError(writer, initialDepth);
                    }
                    else
                    {
                        throw;
                    }
                }
                finally
                {
                    index++;
                }
            }

            writer.WriteEndArray();

            if (hasWrittenMetadataObject)
            {
                writer.WriteEndObject();
            }

            _serializeStack.RemoveAt(_serializeStack.Count - 1);

            OnSerialized(writer, contract, underlyingList);
        }

19 Source : JsonSerializerInternalWriter.cs
with MIT License
from akaskela

private void SerializeDictionary(JsonWriter writer, IDictionary values, JsonDictionaryContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
        {
            IWrappedDictionary wrappedDictionary = values as IWrappedDictionary;
            object underlyingDictionary = wrappedDictionary != null ? wrappedDictionary.UnderlyingDictionary : values;

            OnSerializing(writer, contract, underlyingDictionary);
            _serializeStack.Add(underlyingDictionary);

            WriteObjectStart(writer, underlyingDictionary, contract, member, collectionContract, containerProperty);

            if (contract.ItemContract == null)
            {
                contract.ItemContract = Serializer._contractResolver.ResolveContract(contract.DictionaryValueType ?? typeof(object));
            }

            if (contract.KeyContract == null)
            {
                contract.KeyContract = Serializer._contractResolver.ResolveContract(contract.DictionaryKeyType ?? typeof(object));
            }

            int initialDepth = writer.Top;

            // Manual use of IDictionaryEnumerator instead of foreach to avoid DictionaryEntry box allocations.
            IDictionaryEnumerator e = values.GetEnumerator();
            try
            {
                while (e.MoveNext())
                {
                    DictionaryEntry entry = e.Entry;

                    bool escape;
                    string propertyName = GetPropertyName(writer, entry.Key, contract.KeyContract, out escape);

                    propertyName = (contract.DictionaryKeyResolver != null)
                        ? contract.DictionaryKeyResolver(propertyName)
                        : propertyName;

                    try
                    {
                        object value = entry.Value;
                        JsonContract valueContract = contract.FinalItemContract ?? GetContractSafe(value);

                        if (ShouldWriteReference(value, null, valueContract, contract, member))
                        {
                            writer.WritePropertyName(propertyName, escape);
                            WriteReference(writer, value);
                        }
                        else
                        {
                            if (!CheckForCircularReference(writer, value, null, valueContract, contract, member))
                            {
                                continue;
                            }

                            writer.WritePropertyName(propertyName, escape);

                            SerializeValue(writer, value, valueContract, null, contract, member);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (IsErrorHandled(underlyingDictionary, contract, propertyName, null, writer.ContainerPath, ex))
                        {
                            HandleError(writer, initialDepth);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
            finally
            {
                (e as IDisposable)?.Dispose();
            }

            writer.WriteEndObject();

            _serializeStack.RemoveAt(_serializeStack.Count - 1);

            OnSerialized(writer, contract, underlyingDictionary);
        }

19 Source : AnalysisJsGangAoCommandHandler.cs
with MIT License
from akinix

public async Task<bool> Handle(replacedysisJsGangAoCommand command, CancellationToken cancellationToken)
        {
            //将澳追加到A-G
            var array = JsonConvert.DeserializeObject<JArray>(_areaContextService.GangAoString);
            var aoCode = "820000";
            var ao = array.First(i => i[0].Value<string>() == aoCode);
            var pao = new List<object> { aoCode.ToInt(), ao[1][0].Value<string>(), AreaContextService.FirsreplacedemKey.ToInt() };
            (_areaContextService.GetFirstDicItem()[AreaContextService.KeyAg] as List<object>)?.Add(pao);
            RecursiveAdd(array, aoCode);

            //将香港追加到T-Z
            var gangCode = "810000";
            var gang = array.First(i => i[0].Value<string>() == gangCode);
            var pgang = new List<object> { gangCode.ToInt(), gang[1][0].Value<string>(), AreaContextService.FirsreplacedemKey.ToInt() };
            (_areaContextService.GetFirstDicItem()[AreaContextService.KeyTz] as List<object>)?.Add(pgang);
            RecursiveAdd(array, gangCode);
            return true;
        }

19 Source : AnalysisJsGangAoCommandHandler.cs
with MIT License
from akinix

private void RecursiveAdd(JArray ja, string pid)
        {
            var subs = ja.Where(i => i[2].Value<string>() == pid).ToList();
            if (subs.Count == 0)
                return;
            var rows = new List<object>();
            foreach (var sub in subs)
            {
                var subid = sub[0].Value<string>();
                var props = new List<object> { subid.ToInt(), sub[1][0].Value<string>(), pid.ToInt() };
                rows.Add(props);
                RecursiveAdd(ja, subid);
            }
            _areaContextService.MainDictionary.TryAdd(pid, rows);
        }

19 Source : AnalysisJsProvinceCommandHandler.cs
with MIT License
from akinix

public async Task<bool> Handle(replacedysisJsProvinceCommand command, CancellationToken cancellationToken)
        {
            var dicProvince = JsonConvert.DeserializeObject<Dictionary<string, JArray>>(_areaContextService.ProvinceString);
            var jaArea = JsonConvert.DeserializeObject<JArray>(_areaContextService.AreaString);

            foreach (var key in dicProvince.Keys)
            {
                var rows = new List<object>();
                foreach (var obj in dicProvince[key])
                {
                    var code = obj[0].Value<string>();
                    var props = new List<object> { code.ToInt(), obj[1][0].Value<string>(), AreaContextService.FirsreplacedemKey.ToInt() };
                    if (code == "110000")
                        rows.Insert(0, props);//确保北京在第一个
                    else
                        rows.Add(props);

                    RecursiveAdd(jaArea, code);
                }
                _areaContextService.GetFirstDicItem().TryAdd(key, rows);
            }
            return true;
        }

19 Source : AnalysisJsProvinceCommandHandler.cs
with MIT License
from akinix

private void RecursiveAdd(JArray ja, string pid)
        {
            var subs = ja.Where(i => i[2].Value<string>() == pid).ToList();

            if (subs.Count == 0)
            {
                //末级节点 触发 DistrictAddedEvent 事件
                try
                {
                    var districtCode = pid;
                    var p = ja.FirstOrDefault(i => i[0].Value<string>() == pid);//有些城市下无区县
                    if (p == null)
                        return;
                    var pId = p[2].Value<string>();
                    var pp = ja.FirstOrDefault(i => i[0].Value<string>() == pId);
                    if (pp == null)
                        return;
                    var ppId = pp[2].Value<string>();

                    _mediator.Publish(new DistrictAddedEvent(ppId, pId, districtCode));
                    return;
                }
                catch (Exception ex)
                {

                }
            }
            var rows = new List<object>();
            foreach (var sub in subs)
            {
                var subid = sub[0].Value<string>();
                var dataType = sub[3].Value<string>().ToInt();
                List<object> props;
                if (dataType == 0)
                {
                    props = new List<object> { subid.ToInt(), sub[1][0].Value<string>(), pid.ToInt() };
                }
                else if (dataType == 3)
                {
                    // 仿照淘宝 只取类型 = 3 属于/已合并到/已更名为
                    var fullname = sub[1][0].Value<string>();
                    var names = fullname.Split(" ");
                    props = new List<object> { subid.ToInt(), names[0], pid.ToInt(), 3, names[1], names[2] };
                }
                else
                {
                    continue;
                }
                rows.Add(props);
                // subid 可能为 "210211,210212" 这种格式 就无需处理
                if (subid.IndexOf(',') > 0)
                    continue;
                RecursiveAdd(ja, subid);
            }

            _areaContextService.MainDictionary.TryAdd(pid, rows);
        }

19 Source : AnalysisJsTaiwanCommandHandler.cs
with MIT License
from akinix

public async Task<bool> Handle(replacedysisJsTaiwanCommand command, CancellationToken cancellationToken)
        {
            //将台湾追加到T-Z
            var array = JsonConvert.DeserializeObject<JArray>(_areaContextService.TaiwanString);
            var twCode = "710000";
            var tw = array.First(i => i[0].Value<string>() == twCode);
            var ptw = new List<object> { twCode.ToInt(), tw[1][0].Value<string>(), AreaContextService.FirsreplacedemKey.ToInt() };
            (_areaContextService.GetFirstDicItem()[AreaContextService.KeyTz] as List<object>)?.Add(ptw);
            RecursiveAdd(array, twCode);

            return true;
        }

19 Source : JsonSerializerInternalWriter.cs
with MIT License
from akaskela

private void SerializeMultidimensionalArray(JsonWriter writer, Array values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
        {
            OnSerializing(writer, contract, values);

            _serializeStack.Add(values);

            bool hasWrittenMetadataObject = WriteStartArray(writer, values, contract, member, collectionContract, containerProperty);

            SerializeMultidimensionalArray(writer, values, contract, member, writer.Top, new int[0]);

            if (hasWrittenMetadataObject)
            {
                writer.WriteEndObject();
            }

            _serializeStack.RemoveAt(_serializeStack.Count - 1);

            OnSerialized(writer, contract, values);
        }

19 Source : EnumUtils.cs
with MIT License
from akaskela

public static IList<object> GetValues(Type enumType)
        {
            if (!enumType.IsEnum())
            {
                throw new ArgumentException("Type '" + enumType.Name + "' is not an enum.");
            }

            List<object> values = new List<object>();

            var fields = enumType.GetFields().Where(f => f.IsLiteral);

            foreach (FieldInfo field in fields)
            {
                object value = field.GetValue(enumType);
                values.Add(value);
            }

            return values;
        }

19 Source : ConstantExtractor.cs
with MIT License
from albyho

protected override Expression VisitConstant(ConstantExpression c)
        {
            _constants.Add(c.Value);
            return c;
        }

19 Source : dynamic.cs
with MIT License
from AlenToma

public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            if (_dictionary.TryGetValue(binder.Name, out result) == false)
                if (_dictionary.TryGetValue(binder.Name.ToLowerInvariant(), out result) == false)
                    return false;// throw new Exception("property not found " + binder.Name);

            if (result is IDictionary<string, object>)
            {
                result = new DynamicJson(result as IDictionary<string, object>);
            }
            else if (result is List<object>)
            {
                List<object> list = new List<object>();
                foreach (object item in (List<object>)result)
                {
                    if (item is IDictionary<string, object>)
                        list.Add(new DynamicJson(item as IDictionary<string, object>));
                    else
                        list.Add(item);
                }
                result = list;
            }

            return _dictionary.ContainsKey(binder.Name);
        }

19 Source : JSON.cs
with MIT License
from AlenToma

public object ToObject(string json, Type type)
        {
            //_params.FixValues();
            Type t = null;
            if (type != null && type.IsGenericType)
                t = Reflection.Instance.GetGenericTypeDefinition(type);
            _usingglobals = _params.UsingGlobalTypes;
            if (t == typeof(Dictionary<,>) || t == typeof(List<>))
                _usingglobals = false;

            object o = new JsonParser(json, _params.AllowNonQuotedKeys).Decode();
            if (o == null)
                return null;
#if !SILVERLIGHT
            if (type != null)
            {
                if (type == typeof(DataSet))
                    return CreateDataset(o as Dictionary<string, object>, null);
                else if (type == typeof(DataTable))
                    return CreateDataTable(o as Dictionary<string, object>, null);
            }
#endif
            if (o is IDictionary)
            {
                if (type != null && t == typeof(Dictionary<,>)) // deserialize a dictionary
                    return RootDictionary(o, type);
                else // deserialize an object
                    return ParseDictionary(o as Dictionary<string, object>, null, type, null);
            }
            else if (o is List<object>)
            {
                if (type != null)
                {
                    if (t == typeof(Dictionary<,>)) // kv format
                        return RootDictionary(o, type);
                    else if (t == typeof(List<>)) // deserialize to generic list
                        return RootList(o, type);
                    else if (type.IsArray)
                        return RootArray(o, type);
                    else if (type == typeof(Hashtable))
                        return RootHashTable((List<object>)o);
                }
                else //if (type == null)
                {
                    List<object> l = (List<object>)o;
                    if (l.Count > 0 && l[0].GetType() == typeof(Dictionary<string, object>))
                    {
                        Dictionary<string, object> globals = new Dictionary<string, object>();
                        List<object> op = new List<object>();
                        // try to get $types 
                        foreach (var i in l)
                            op.Add(ParseDictionary((Dictionary<string, object>)i, globals, null, null));
                        return op;
                    }
                    return l.ToArray();
                }
            }
            else if (type != null && o.GetType() != type)
                return ChangeType(o, type);

            return o;
        }

19 Source : JsonParser.cs
with MIT License
from AlenToma

private unsafe List<object> ParseArray(char* p)
        {
            List<object> array = new List<object>(10);
            ConsumeToken(); // [

            while (true)
            {
                switch (LookAhead(p))
                {
                    case Token.Comma:
                        ConsumeToken();
                        break;

                    case Token.Squared_Close:
                        ConsumeToken();
                        return array;

                    default:
                        array.Add(ParseValue(p, false));
                        break;
                }
            }
        }

19 Source : LightDataTableRow.cs
with MIT License
from AlenToma

internal void AddValue(LightDataTableColumn col, object value, ColumnsCollections<string> cols, ColumnsCollections<int> colsIndex)
        {
            ColumnsWithIndexKey = colsIndex;
            Columns = cols;
            ColumnLength = colsIndex.Count;
            var newList = _itemArray.ToList();
            newList.Add(value ?? ValueByType(col.DataType));
            _itemArray = newList.ToArray();
        }

19 Source : NetworkController.cs
with MIT License
from alerdenisov

private void SendHost()
        {
            byte error;
            List<object> logicData = new List<object>();

            foreach (var command in OutgoingCommands)
            {
                logicData.Add(command.CommandId);
                logicData.AddRange(command.Data());
            }

            OutgoingCommands.Flush();
            
            if (logicData.Count == 0) return;

            int size;
            var buffer = UnnyNetPacker.PackObject(out size, logicData.ToArray());

            foreach (var connectionId in Connections)
            {
                NetworkTransport.Send(hostId, connectionId, realiableChannel, buffer, size, out error);
            }            
        }

19 Source : EventRecorder.cs
with Apache License 2.0
from alexeyzimarev

public void Record(object @event)
        {
            if (@event == null) throw new ArgumentNullException(nameof(@event));
            _recorded.Add(@event);
        }

19 Source : NodeComboBox.cs
with MIT License
from AlexGyver

protected override void DoApplyChanges(TreeNodeAdv node, Control editor)
		{
			var combo = editor as ComboBox;
			if (combo != null)
			{
				if (combo.DropDownStyle == ComboBoxStyle.DropDown)
					SetValue(node, combo.Text);
				else
					SetValue(node, combo.SelectedItem);
			}
			else
			{
				var listBox = editor as CheckedListBox;
				Type type = GetEnumType(node);
				if (IsFlags(type))
				{
					int res = 0;
					foreach (object obj in listBox.CheckedItems)
						res |= (int)obj;
					object val = Enum.ToObject(type, res);
					SetValue(node, val);
				}
				else
				{
					List<object> list = new List<object>();
					foreach (object obj in listBox.CheckedItems)
						list.Add(obj);
					SetValue(node, list.ToArray());
				}
			}
		}

See More Examples