public static void DataTemplate(IMerchItem item, IMerchItemHolderYahoo holder, int position) { var yahooItem = (YahooItem)item.Item; MerchItemHolderTemplate.CommonFeedItemTemplate(item, holder); holder.Title.Text = item.Item.Name; holder.DetailBids.SetText(GetYahooItemLabel("Bids:", yahooItem.BidsCount.ToString()), TextView.BufferType.Spannable); holder.DetailEndsIn.SetText(GetYahooItemLabel("Ends in:", SharedUtil.TimeDiffToString((DateTime.UtcNow - yahooItem.EndTime).Duration())), TextView.BufferType.Spannable); holder.DetailCondition.SetText(GetYahooItemLabel("Condition:", yahooItem.Condition.ToString()), TextView.BufferType.Spannable); //if (yahooItem.BuyoutPrice != 0) //{ // holder.PriceSubtitle.Text = $"{yahooItem.BuyoutPrice}¥"; //} if (yahooItem.Tax == 0) { holder.DetailsTax.Visibility = ViewStates.Gone; } else { holder.DetailsTax.Visibility = ViewStates.Visible; holder.DetailsTax.SetText(GetYahooItemLabel("Tax:", $"+{yahooItem.Tax}%"), TextView.BufferType.Spannable); } holder.DetailShipping.Visibility = BindingConverters.BoolToVisibility(yahooItem.IsShippingFree); }
internal static void SaveImage(Image image, Stream stream, ImageFormat imageFormat, int jpegQuality) { SharedUtil.ThrowIfEmpty(image, "image"); SharedUtil.ThrowIfEmpty(stream, "stream"); SharedUtil.ThrowIfEmpty(imageFormat, "imageFormat"); if (imageFormat == ImageFormat.Jpeg) { using (EncoderParameters parameters = new EncoderParameters(1)) { using (EncoderParameter parameter = new EncoderParameter(Encoder.Quality, (long)jpegQuality)) { parameters.Param[0] = parameter; image.Save(stream, JpegCodec, parameters); stream.Flush(); } return; } } using (MemoryStream stream2 = new MemoryStream()) { image.Save(stream2, imageFormat); stream2.Seek(0L, SeekOrigin.Begin); stream2.WriteTo(stream); stream.Flush(); stream2.Flush(); } }
public async Task <ChadderError> Login(string username, string password) { if (await DeviceExists() == false) { var temp = await CreateDevice(); if (temp != ChadderError.OK) { return(temp); } } password = await SharedUtil.GetPasswordHash(password); var devicePair = await KeyFactory.RefreshBook(db.LocalDevice.PrivateKeyBook); var devicePublic = await devicePair.GetPublicBook(); var request = new LoginParameter() { Username = username, Password = password, DeviceId = db.LocalDevice.DeviceId, PublicKey = devicePublic.Serialize(), RefreshToken = await CryptoHelper.CreateRandomData(32) }; await request.Sign(db.LocalDevice.PrivateKeyBook.GetMaster()); var response = await Session.PostRequestAPI <BasicResponse <string> >(Urls.Login, request); if (response.Error == ChadderError.OK) { var key = await CryptoHelper.CreateRandomData(32); sqlDB = await ChadderSQLUserDB.GetNewUserDatabase(response.Extra, key, InstanceId); db.LocalUser = new ChadderLocalUserInfo() { UserId = response.Extra, Name = username, RefreshToken = request.RefreshToken }; await sqlDB.InsertAsync(db.LocalUser); var keyPackage = new PlainBinary(key); var record = new ChadderLocalUserRecord() { UserId = response.Extra, Name = username, DatabaseKey = keyPackage.Serialize() }; var mainDB = await ChadderSQLMainDB.GetDatabase(InstanceId); await mainDB.InsertAsync(record); IsOnline = true; await FinishLoading(); } return(response.Error); }
internal static async Task <int> Go() { try { var client = SharedUtil.CreateGitHubClient(); var storageAccount = SharedUtil.CreateStorageAccount(); AzureUtil.EnsureAzureResources(storageAccount); // await DumpHooks(client); // await DumpMilestones(client); // await PrintRateLimits(client); // await TestRateLimits(client, storageAccount); await PopulateSince(); // await FixNulls(storageAccount); // await DumpSince(client); // await InitRepo(client, storageAccount, SharedUtil.RepoId); // await Misc(client, storageAccount); return(0); } catch (Exception ex) { Console.Write($"{ex.Message}"); return(1); } }
internal LocalDescriptionAttribute(string description) : base(description) { this.description = string.Empty; this.description = SharedUtil.Trim(description); this.memberName = string.Empty; this.type = null; }
private static void Authorize(RestRequest request) { var text = ConfigurationManager.AppSettings[SharedConstants.GithubConnectionStringName]; var values = text.Split(':'); SharedUtil.AddAuthorization(request, values[0], values[1]); }
/// <summary> /// Milestone information still does not come down as a part of events. This function catches these types of /// update by doing a 'since' query on GitHub and bulk updating all of the changed values. /// </summary> public static async Task GithubPopulateIssuesSince( [TimerTrigger("0 0/1 * * * *")] TimerInfo timerInfo, [Table(TableNames.RoachIssueTable)] CloudTable issueTable, [Table(TableNames.RoachMilestoneTable)] CloudTable milestoneTable, [Table(TableNames.RoachStatusTable)] CloudTable statusTable, TextWriter logger, CancellationToken cancellationToken) { var client = SharedUtil.CreateGitHubClient(); var storagePopulator = new StoragePopulator(client, issueTable, milestoneTable); // TODO: Need to make this adaptable to all repos, not just dotnet/roslyn var allRepos = new[] { SharedUtil.RepoId }; foreach (var repo in allRepos) { var statusEntity = await AzureUtil.QueryAsync <RoachStatusEntity>(statusTable, RoachStatusEntity.GetEntityKey(repo), cancellationToken); if (statusEntity == null || statusEntity.LastBulkUpdate.Value == null) { logger.WriteLine($"Repo {repo.Owner}/{repo.Name} does not have a status entry. Cannot do a since update."); return; } var before = DateTimeOffset.UtcNow; await storagePopulator.PopulateIssuesSince(repo, statusEntity.LastBulkUpdate.Value, cancellationToken); // Given there are no events for milestones need to do a bulk update here. await storagePopulator.PopulateMilestones(repo, cancellationToken); statusEntity.SetLastBulkUpdate(before); await statusTable.ExecuteAsync(TableOperation.Replace(statusEntity), cancellationToken); } }
internal static List <Assembly> GetAllAssemblies(ProgressBar progressBar) { if (allAssemblies.Count == 0) { Assembly[] assemblyArray; GetAllAssemblies(allAssemblies, Assembly.GetEntryAssembly()); if (!SharedUtil.IsEmpty((ICollection)(assemblyArray = AppDomain.CurrentDomain.GetAssemblies()))) { if (progressBar != null) { progressBar.Value = 0; progressBar.Maximum = assemblyArray.Length; Application.DoEvents(); } foreach (Assembly assembly in assemblyArray) { if (progressBar != null) { progressBar.Value++; Application.DoEvents(); } GetAllAssemblies(allAssemblies, assembly); } } } return(allAssemblies); }
internal static Assembly LoadAssembly(string filePath, bool forceReload) { Assembly[] assemblyArray; if (!forceReload && !SharedUtil.IsEmpty((ICollection)(assemblyArray = AppDomain.CurrentDomain.GetAssemblies()))) { foreach (Assembly assembly in assemblyArray) { if (((assembly != null) && !(assembly is AssemblyBuilder)) && (!SharedUtil.IsEmpty(assembly.CodeBase) && IOUtil.PathEquals(assembly.CodeBase, filePath))) { return(assembly); } } } lock (LoadedAssemblies.SyncRoot) { if (forceReload || !LoadedAssemblies.ContainsKey(filePath = IOUtil.NormalizePath(filePath))) { byte[] buffer; using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { buffer = new byte[stream.Length]; using (MemoryStream stream2 = new MemoryStream(buffer, true)) { IOUtil.CopyStream(stream, stream2); } } LoadedAssemblies[filePath] = Assembly.Load(buffer); } return(LoadedAssemblies[filePath] as Assembly); } }
internal static string[] GetQueryParameters(string queryString) { string[] strArray; ArrayList list = new ArrayList(); while (queryString.StartsWith("?")) { queryString = queryString.Substring(1); } if (!SharedUtil.IsEmpty((ICollection)(strArray = queryString.Split(new char[] { '&' })))) { foreach (string str in strArray) { string[] strArray2; if (!SharedUtil.IsEmpty((ICollection)(strArray2 = str.Split(new char[] { '=' })))) { foreach (string str2 in strArray2) { list.Add(str2); } } } } return(list.ToArray(typeof(string)) as string[]); }
internal static object Deserialize(RegistryKey key, string name, object defaultValue, StreamingContextStates streamingContext) { object obj2; BinaryFormatter formatter = new BinaryFormatter(null, new StreamingContext(streamingContext)); try { byte[] buffer; if (SharedUtil.IsEmpty((ICollection)(buffer = GetBytes(key, name, null)))) { return(defaultValue); } using (MemoryStream stream = new MemoryStream(buffer, false)) { object obj3; if (((obj3 = formatter.Deserialize(stream)) != null) && ((defaultValue == null) || defaultValue.GetType().IsAssignableFrom(obj3.GetType()))) { return(obj3); } obj2 = defaultValue; } } catch { obj2 = defaultValue; } return(obj2); }
public override bool Equals(object obj) { if (!SharedUtil.Equals(this, obj)) { return(SharedUtil.Equals(this.Value, obj)); } return(true); }
internal string Undo(string currentVersion) { Trio <Modification, int, string>[] trioArray; if ((this.undoStack.Count != 0) && !SharedUtil.IsEmpty((ICollection)(trioArray = this.undoStack.Pop()))) { return(this.Modify(currentVersion, true, trioArray)); } return(currentVersion); }
public void BuildMaze <T>(int x_size, int y_size) where T : IMazeCell { this.size_x = x_size; this.size_y = y_size; cells.Capacity = size_x * size_y; int group_id = 0; //FIRST PASS for (int iy = 0; iy < size_y; iy++) { for (int ix = 0; ix < size_x; ix++) { if (maze_mask_cells != null && maze_mask_cells.Contains(SharedUtil.PointHash(ix, iy))) { cells.Add(null); } else { T cell = System.Activator.CreateInstance <T>(); cell.X = ix; cell.Y = iy; cell.GroupID = group_id++; cells.Add(cell); } } } //SECOND PASS for (int iy = 0; iy < size_y; iy++) { for (int ix = 0; ix < size_x; ix++) { IMazeCell cell = GetAt(ix, iy); if (cell != null) { IMazeCell[] neighbours = new IMazeCell[4]; neighbours[(int)EMazeDirection.North] = GetAt(ix, iy + 1); neighbours[(int)EMazeDirection.South] = GetAt(ix, iy - 1); neighbours[(int)EMazeDirection.West] = GetAt(ix - 1, iy); neighbours[(int)EMazeDirection.East] = GetAt(ix + 1, iy); cell.SetNeighbours(neighbours); } } } Generate(); for (int i = 0; i < post_processer.Count; i++) { if (post_processer[i] != null) { post_processer[i].PostProcess(this); } } }
internal DisplayNameAttribute(Type type, string memberName) { this.type = type; if (this.type == null) { throw new ArgumentNullException("type"); } SharedUtil.ThrowIfEmpty(this.memberName = memberName, "memberName"); }
/// <summary> /// 方便的函数,直接遍历Rect内的所有值,并设置其Type。 /// </summary> /// <param name="save_data"></param> /// <param name="config"></param> /// <param name="target_type"></param> public static void SetMapTileType(this TileRect rect, TileMapData save_data, TileThemeConfig theme_config, string type) { for (int iy = rect.y; iy <= rect.y_end; iy++) { for (int ix = rect.x; ix <= rect.x_end; ix++) { save_data[SharedUtil.PointHash(ix, iy)] = theme_config.GetTilePrefabConfigIndex(type); } } }
internal static string Attribute(XmlNode node, string name, string defaultValue) { XmlAttribute attribute; if (((attribute = node.Attributes[name]) != null) && !SharedUtil.IsEmpty(attribute.Value)) { return(attribute.Value); } return(defaultValue); }
internal static string EnsureAttribute(XmlNode node, string attributeName, string defaultValue, bool overwrite) { XmlAttribute orCreateAttribute = GetOrCreateAttribute(node, attributeName); if (overwrite || SharedUtil.IsEmpty(orCreateAttribute.Value)) { orCreateAttribute.Value = defaultValue; } return(orCreateAttribute.Value); }
internal JenkinsConnection(Uri baseUrl, IRestClient restClient, string userName = null, string password = null) { _baseUrl = baseUrl; _restClient = restClient; if (userName != null || password != null) { _authorizationHeaderValue = SharedUtil.CreateAuthorizationHeader(userName, password); } }
internal static string GetLocalDescription(Enum member) { string description = new LocalDescriptionAttribute(member.GetType(), member.ToString()).Description; if (!SharedUtil.IsEmpty(ref description)) { return(description); } return(member.ToString()); }
internal LocalDescriptionAttribute(Type type, string memberName) { this.description = string.Empty; this.type = type; if (this.type == null) { throw new ArgumentNullException("type"); } this.memberName = SharedUtil.Trim(memberName); }
internal string GetSettingsName(IComponent provider) { string str; if (componentNames.TryGetValue(provider, out str) && !SharedUtil.IsEmpty(str)) { return(str); } return(null); }
private static async Task PopulateSince() { var storageAccount = SharedUtil.CreateStorageAccount(); var client = SharedUtil.CreateGitHubClient(); var populator = new StoragePopulator(client, storageAccount.CreateCloudTableClient()); await populator.PopulateIssuesSince( new RoachRepoId("dotnet", "roslyn"), new DateTimeOffset(year : 2015, month : 1, day : 1, hour : 0, minute : 0, second : 0, offset : TimeSpan.Zero)); }
private static async Task PopulateSince() { var storageAccount = SharedUtil.CreateStorageAccount(); var client = SharedUtil.CreateGitHubClient(); var populator = new StoragePopulator(client, storageAccount.CreateCloudTableClient()); await populator.PopulateIssuesSince( new RoachRepoId("dotnet", "roslyn"), DateTimeOffset.UtcNow.AddDays(-7)); }
internal static Duo <XmlNode, string> GetNodeAtPosition(XmlNode node, int selectionStart, int selectionLength, XmlNodeType moveUpTo, params XmlNodeType[] moveUpIf) { XmlNode parentNode = null; string str = null; string str2; if ((((node != null) && !SharedUtil.IsEmpty(str2 = node.OuterXml)) && ((selectionStart >= 0) && (selectionStart <= str2.Length))) && ((selectionLength >= 0) && ((selectionStart + selectionLength) <= str2.Length))) { str = str2.Substring(selectionStart, selectionLength); if (!node.HasChildNodes) { parentNode = node; } else { int num; string innerXml = node.InnerXml; int num2 = num = str2.IndexOf(innerXml, str2.IndexOf('>')); if (num2 < 0) { num2 = num = 0; } if (selectionStart >= num) { foreach (XmlNode node3 in node.ChildNodes) { if (((selectionStart >= num2) && (selectionStart < (num2 + node3.OuterXml.Length))) && ((parentNode = GetNodeAtPosition(node3, selectionStart - num2, selectionLength, moveUpTo, new XmlNodeType[0]).Value1) != null)) { break; } num2 += node3.OuterXml.Length; } } if (parentNode == null) { parentNode = node; } } if (moveUpTo != XmlNodeType.None) { while (((parentNode != null) && (parentNode.NodeType != moveUpTo)) && (parentNode.ParentNode != null)) { parentNode = parentNode.ParentNode; } } else if (!SharedUtil.IsEmpty((ICollection)moveUpIf)) { while (((parentNode != null) && SharedUtil.In <XmlNodeType>(parentNode.NodeType, moveUpIf)) && (parentNode.ParentNode != null)) { parentNode = parentNode.ParentNode; } } } return(new Duo <XmlNode, string>(parentNode, str)); }
internal static Pen GetPen(Color color, float width) { Pen pen; int hashCode = SharedUtil.GetHashCode(new object[] { color.ToArgb(), width }); if (!pens.TryGetValue(hashCode, out pen)) { pens[hashCode] = pen = new Pen(color, width); } return(pen); }
internal static Pen GetPen(Brush brush, float width) { Pen pen; int hashCode = SharedUtil.GetHashCode(new object[] { brush, width }); if (!pens.TryGetValue(hashCode, out pen)) { pens[hashCode] = pen = new Pen(brush, width); } return(pen); }
internal static LinearGradientBrush GetLinearGradientBrush(Rectangle rect, Color one, Color two, LinearGradientMode mode) { LinearGradientBrush brush; int hashCode = SharedUtil.GetHashCode(new object[] { rect, one.ToArgb(), two.ToArgb(), mode }); if (!lgBrushes.TryGetValue(hashCode, out brush)) { lgBrushes[hashCode] = brush = new LinearGradientBrush(rect, one, two, mode); } return(brush); }
public override void PaintValue(PaintValueEventArgs e) { bool flag; string str = e.Value as string; if ((flag = !SharedUtil.IsEmpty(str)) || (FilePathTypeEditor <T> .NoFileImage != null)) { e.Graphics.DrawImage(flag ? DrawingUtil.GetFileImage(str, false) : FilePathTypeEditor <T> .NoFileImage, new Rectangle(1, 2, e.Bounds.Width - 2, e.Bounds.Height - 2)); } base.PaintValue(e); }
internal void SetSettingsUserScope(IComponent provider, string[] settings) { if (SharedUtil.IsEmpty((ICollection)settings)) { this.userProviders.Remove(provider); } else { this.userProviders[provider] = settings; } }