/// <summary> /// Elimina entidades (usuarios o grupos) a la regla con el id especificado /// </summary> /// <param name="rule"></param> /// <param name="entities"></param> public static IObservable<Rule> DeleteEntities(Rule rule, IList<IEntity> entities) { if (rule.Id == null) throw new InvalidDataException("The provided rule must have an Id"); if (entities == null || entities.IsEmpty()) return Observable.Defer(() => Observable.Return(rule)); return RestEndpointFactory .Create<IRulesEndpoint>(SessionManager.Instance.CurrentLoggedUser) .DeleteEntities(rule.Id, entities.IsEmpty() ? "0" : entities.ToString(e => e.Id)).ToObservable() .SubscribeOn(ThreadPoolScheduler.Instance) .InterpretingErrors(); }
/// <summary> /// Dient eenmalig uitgevoerd te worden /// </summary> private void InitializeTiles(ISessionFactory factory) { Random random = new Random(); int result = 0; var nhSession = factory.OpenSession(); MapTiles = nhSession.QueryOver<MapTile>().List(); if (MapTiles.IsEmpty()) { MapTiles = new List<MapTile>(); using (var transaction = nhSession.BeginTransaction()) { for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { result = random.Next(0, 10); var tile = new MapTile() {Name = "Wasteland", X = x, Y = y}; MapTiles.Add(tile); nhSession.Save(tile); } } transaction.Commit(); } } }
public IndexHint(IndexHintAction hintAction, IndexHintType hintType, IndexHintScope hintScope, IList<string> indexList) { if (hintAction == IndexHintAction.None) { throw new ArgumentException("index hint hintAction is null"); } if (hintType == IndexHintType.None) { throw new ArgumentException("index hint hintType is null"); } if (hintScope == IndexHintScope.None) { throw new ArgumentException("index hint hintScope is null"); } HintAction = hintAction; IndexType = hintType; HintScope = hintScope; if (indexList == null || indexList.IsEmpty()) { IndexList = new List<string>(0); } else if (indexList is List<string>) { IndexList = indexList; } else { IndexList = new List<string>(indexList); } }
public SignatureHelpItems( IList<SignatureHelpItem> items, TextSpan applicableSpan, int argumentIndex, int argumentCount, string argumentName, int? selectedItem = null) { Contract.ThrowIfNull(items); Contract.ThrowIfTrue(items.IsEmpty()); Contract.ThrowIfTrue(selectedItem.HasValue && selectedItem.Value > items.Count); if (argumentIndex < 0) { throw new ArgumentException($"{nameof(argumentIndex)} < 0", nameof(argumentIndex)); } if (argumentCount < argumentIndex) { throw new ArgumentException($"{nameof(argumentCount)} < {nameof(argumentIndex)}", nameof(argumentIndex)); } this.Items = items; this.ApplicableSpan = applicableSpan; this.ArgumentIndex = argumentIndex; this.ArgumentCount = argumentCount; this.SelectedItemIndex = selectedItem; this.ArgumentName = argumentName; }
public GroupConcat(bool distinct, IList<IExpression> exprList, IExpression orderBy, bool isDesc, IList<IExpression> appendedColumnNames, string separator) : base("GROUP_CONCAT", exprList) { IsDistinct = distinct; OrderBy = orderBy; IsDesc = isDesc; if (appendedColumnNames == null || appendedColumnNames.IsEmpty()) { AppendedColumnNames = new List<IExpression>(0); } else if (appendedColumnNames is List<IExpression>) { AppendedColumnNames = appendedColumnNames; } else { AppendedColumnNames = new List<IExpression>( appendedColumnNames); } Separator = separator ?? ","; }
/// <exception cref="System.SqlSyntaxErrorException" /> public TableReferences(IList<TableReference> list) { if (list == null || list.IsEmpty()) { throw new SqlSyntaxErrorException("at least one table reference"); } _list = EnsureListType(list); }
public ActionResult CommentColumns(string id, IList<Column> columns) { if (!columns.IsEmpty()) { foreach (var item in columns) { this.DynamicQuery.Provider.DbMetadata.CommentColumn(id, item.Name, item.Description); } } return CloseDialogWithAlert("修改成功!"); }
public IndexDefinition(IndexType indexType, IList<IndexColumnName> columns, IList<IndexOption> options) { IndexType = indexType; if (columns == null || columns.IsEmpty()) { throw new ArgumentException("columns is null or empty"); } Columns = columns; Options = options == null || options.IsEmpty() ? new List<IndexOption>(0) : options; }
public TableRuleConfig(string name, IList<RuleConfig> rules) { if (name == null) { throw new ArgumentException("name is null"); } this.name = name; if (rules == null || rules.IsEmpty()) { throw new ArgumentException("no rule is found"); } this.rules = new List<RuleConfig>(rules).AsReadOnly(); }
public DalSetStatement(IList<Pair<VariableExpression, IExpression>> assignmentList) { if (assignmentList == null || assignmentList.IsEmpty()) { AssignmentList = new List<Pair<VariableExpression, IExpression>>(0); } else if (assignmentList is List<Pair<VariableExpression, IExpression>>) { AssignmentList = assignmentList; } else { AssignmentList = new List<Pair<VariableExpression, IExpression>>(assignmentList); } }
public FunctionExpression(string functionName, IList<IExpression> arguments) { this.functionName = functionName; if (arguments == null || arguments.IsEmpty()) { this.arguments = new List<IExpression>(0); } else if (arguments is List<IExpression>) { this.arguments = arguments; } else { this.arguments = new List<IExpression>(arguments); } }
public SignatureHelpItems( IList<SignatureHelpItem> items, TextSpan applicableSpan, int argumentIndex, int argumentCount, string argumentName, int? selectedItem = null) { Contract.ThrowIfNull(items); Contract.ThrowIfTrue(items.IsEmpty()); Contract.ThrowIfTrue(selectedItem.HasValue && selectedItem.Value >= items.Count); if (argumentIndex < 0) { throw new ArgumentException($"{nameof(argumentIndex)} < 0. {argumentIndex} < 0", nameof(argumentIndex)); } if (argumentCount < argumentIndex) { throw new ArgumentException($"{nameof(argumentCount)} < {nameof(argumentIndex)}. {argumentCount} < {argumentIndex}", nameof(argumentIndex)); } // Adjust the `selectedItem` index if duplicates are able to be removed. var distinctItems = items.Distinct().ToList(); if (selectedItem.HasValue && items.Count != distinctItems.Count) { // `selectedItem` index has already been determined to be valid, it now needs to be adjusted to point // to the equivalent item in the reduced list to account for duplicates being removed // E.g., // items = {A, A, B, B, C, D} // selectedItem = 4 (index for item C) // ergo // distinctItems = {A, B, C, D} // actualItem = C // selectedItem = 2 (index for item C) var actualItem = items[selectedItem.Value]; selectedItem = distinctItems.IndexOf(actualItem); Debug.Assert(selectedItem.Value >= 0, "actual item was not part of the final list"); } this.Items = distinctItems; this.ApplicableSpan = applicableSpan; this.ArgumentIndex = argumentIndex; this.ArgumentCount = argumentCount; this.SelectedItemIndex = selectedItem; this.ArgumentName = argumentName; }
public DdlDropTableStatement(IList<Identifier> tableNames, bool temp, bool ifExists, DropTableMode dropTableMode) { if (tableNames == null || tableNames.IsEmpty()) { TableNames = new List<Identifier>(0); } else { TableNames = tableNames; } IsTemp = temp; IsIfExists = ifExists; Mode = dropTableMode; }
public TableRefFactor(Identifier table, string alias, IList<IndexHint> hintList) : base(alias) { this.table = table; if (hintList == null || hintList.IsEmpty()) { HintList = new List<IndexHint>(0); } else if (hintList is List<IndexHint>) { HintList = hintList; } else { HintList = new List<IndexHint>(hintList); } }
public ShowProfile(IList<ProfileType> types, IExpression forQuery, Limit limit) { if (types == null || types.IsEmpty()) { ProfileTypes = new List<ProfileType>(0); } else if (types is List<ProfileType>) { ProfileTypes = types; } else { ProfileTypes = new List<ProfileType>(types); } ForQuery = forQuery; Limit = limit; }
public RowExpression(IList<IExpression> rowExprList) { if (rowExprList == null || rowExprList.IsEmpty()) { RowExprList = new List<IExpression>(0); } else { if (rowExprList is List<IExpression>) { RowExprList = rowExprList; } else { RowExprList = new List<IExpression>(rowExprList); } } }
/// <summary> /// 数据查询操作。 /// </summary> /// <param name="id">表名称</param> /// <param name="conditions">查询条件配置信息</param> /// <param name="pageIndex">当前页</param> /// <returns>返回数据查询页面</returns> public ActionResult Index(string id, IList<ConditionInfo> conditions = null, int pageIndex = 1) { var model = new SearchModel { Table = this.DynamicQuery.Provider.DbMetadata.GetTable(id) }; if (model.Table != null) { model.Columns = this.DynamicQuery.Provider.DbMetadata.GetColumns(id); model.Search = this.DynamicQuery.Where<SearchInfo>(m => m.TableName, id).Single(); model.Conditions = this.DynamicQuery.Where<ConditionInfo>(m => m.TableName, id).List(); var showColumns = model.Search?.GetVisibleColumns(); var orders = this.DynamicQuery.Where<OrderInfo>(m => m.TableName, id).List().Select(o => (Order)o); int totalRecords; if (conditions.IsEmpty()) { model.DataSource = this.DynamicQuery.OrderBy(orders.ToArray()).PagedList(id, pageIndex < 1 ? 1 : pageIndex, SearchObject.DefalutPageSize, out totalRecords, showColumns); } else { var temps = conditions.Select(c => (Condition)c); model.Conditions = conditions.MergeDatas(model.Conditions, (i1, i2) => i1.Column == i2.Column, (i1, i2) => { i1.Id = i2.Id; i1.TableName = i2.TableName; i1.Op = i2.Op; i1.ValidateRule = i2.ValidateRule; i1.DictionaryKey = i2.DictionaryKey; }) as IList<ConditionInfo>; model.DataSource = this.DynamicQuery.Where(temps).OrderBy(orders.ToArray()).PagedList(id, pageIndex < 1 ? 1 : pageIndex, SearchObject.DefalutPageSize, out totalRecords, showColumns); } model.TotalRecords = totalRecords; } this.ViewBag.Model = model; return View(); }
public DmlCallStatement(Identifier procedure, IList<IExpression> arguments) { this.procedure = procedure; if (arguments == null || arguments.IsEmpty()) { this.arguments = new List<IExpression>(0); } else { if (arguments is List<IExpression>) { this.arguments = arguments; } else { this.arguments = new List<IExpression>(arguments); } } }
/// <param name="_matchModifier">never null</param> public MatchExpression(IList<IExpression> columns, IExpression pattern, MatchModifier _matchModifier) { if (columns == null || columns.IsEmpty()) { Columns = new List<IExpression>(0); } else { if (columns is List<IExpression>) { Columns = columns; } else { Columns = new List<IExpression>(columns); } } Pattern = pattern; Modifier = _matchModifier; }
/// <summary> /// Проверка, что выполнены все доступные миграции с номерами меньше текущей /// </summary> /// <param name="availableMigrations">Доступные миграции</param> /// <param name="appliedVersions">Выполненные миграции</param> public static void CheckMigrationNumbers(IList<long> availableMigrations, IList<long> appliedVersions) { long current = appliedVersions.IsEmpty() ? 0 : appliedVersions.Max(); var skippedMigrations = availableMigrations.Where(m => m <= current && !appliedVersions.Contains(m)); Require.AreEqual(skippedMigrations.Count(), 0, "The current database version is {0}, the migration {1} are available but not used".FormatWith(current, skippedMigrations.ToCommaSeparatedString())); }
/// <summary> /// Nodes the exist. /// </summary> /// <param name="updatedNodes">The updated nodes.</param> /// <param name="id">The identifier.</param> /// <returns> /// <c>true</c> if node exists; <c>false</c> otherwise. /// </returns> private bool NodeExist(IList<SaveSitemapNodeModel> updatedNodes, Guid id) { if (updatedNodes == null || updatedNodes.IsEmpty()) { return false; } foreach (var node in updatedNodes) { if (node.Id == id || NodeExist(node.Nodes, id)) { return true; } } return false; }
/// <summary> /// Saves the nodes. /// </summary> /// <param name="sitemap">The sitemap.</param> /// <param name="nodeModels">The node models.</param> /// <param name="currentNodes">The existing nodes.</param> /// <param name="createdNodes">The created nodes.</param> /// <param name="updatedNodes">The sitemap nodes.</param> /// <param name="deletedNodes">The deleted nodes.</param> private void SaveNodes(Module.Pages.Models.Sitemap sitemap, IList<SaveSitemapNodeModel> nodeModels, List<SitemapNode> currentNodes, ref IList<SitemapNode> createdNodes, ref IList<SitemapNode> updatedNodes, ref IList<SitemapNode> deletedNodes) { var removeAll = nodeModels.IsEmpty(); foreach (var existingNode in currentNodes) { if (removeAll || !NodeExist(nodeModels, existingNode.Id)) { repository.Delete(existingNode); deletedNodes.Add(existingNode); } } if (removeAll) { return; } SaveChildNodes(sitemap, null, nodeModels, currentNodes, ref createdNodes, ref updatedNodes, ref deletedNodes); }
private void PrepareUsersGenderCountModel(UsersGenderCountModel model, IList<UsersGenderCount> genders) { model = model ?? new UsersGenderCountModel(); if (!genders.IsEmpty()) { StringBuilder sbPie = new StringBuilder(@"["); foreach (UsersGenderCount g in genders) { g.Gender = HttpUtility.JavaScriptStringEncode(string.Format("{0} ({1})", g.Gender, g.Count)); sbPie.AppendFormat(@"['{0}', {1}],", g.Gender, g.Count); } sbPie.Append(@"]"); model.JsonPie = sbPie.ToString(); } }
private void PrepareNewsFromRegionModel(NewsFromRegionModel model, IList<String> regions) { model = model ?? new NewsFromRegionModel(); if (!regions.IsEmpty()) { model.AllRegions = regions.Select(x => { var m = new SelectListItem() { Text = x, Value = x, Selected = !String.IsNullOrEmpty(model.SelectedRegion) && model.SelectedRegion == x }; return m; }); } }
private void PrepareCategoryPostCountModel(CategoryPostCountModel model, IList<CategoryPostCount> categories) { model = model ?? new CategoryPostCountModel(); if (!categories.IsEmpty()) { StringBuilder sbPie = new StringBuilder(@"["); StringBuilder sbBarCount = new StringBuilder(@"["); StringBuilder sbBarCat = new StringBuilder(@"["); foreach (CategoryPostCount m in categories) { m.Category = HttpUtility.JavaScriptStringEncode(string.Format("{0} ({1})", m.Category, m.PostCount)); sbPie.AppendFormat(@"['{0}', {1}],", m.Category, m.PostCount); sbBarCount.AppendFormat(@"{0}, ", m.PostCount); sbBarCat.AppendFormat(@"'{0}', ", m.Category); } sbPie.Append(@"]"); sbBarCount.Append(@"]"); sbBarCat.Append(@"]"); model.JsonPie = sbPie.ToString(); model.JsonBarCount = sbBarCount.ToString(); model.JsonBarCategory = sbBarCat.ToString(); } }
/// <exception cref="System.IO.IOException"></exception> private ObjectId ProcessHaveLines(IList<ObjectId> peerHas, ObjectId last) { if (peerHas.IsEmpty()) { return last; } // If both sides have the same object; let the client know. // AsyncRevObjectQueue q = walk.ParseAny(peerHas.AsIterable(), false); try { for (; ; ) { RevObject obj; try { obj = q.Next(); } catch (MissingObjectException) { continue; } if (obj == null) { break; } last = obj; if (obj.Has(PEER_HAS)) { continue; } obj.Add(PEER_HAS); if (obj is RevCommit) { ((RevCommit)obj).Carry(PEER_HAS); } AddCommonBase(obj); switch (multiAck) { case BasePackFetchConnection.MultiAck.OFF: { if (commonBase.Count == 1) { pckOut.WriteString("ACK " + obj.Name + "\n"); } break; } case BasePackFetchConnection.MultiAck.CONTINUE: { pckOut.WriteString("ACK " + obj.Name + " continue\n"); break; } case BasePackFetchConnection.MultiAck.DETAILED: { pckOut.WriteString("ACK " + obj.Name + " common\n"); break; } } } } finally { q.Release(); } // If we don't have one of the objects but we're also willing to // create a pack at this point, let the client know so it stops // telling us about its history. // for (int i = peerHas.Count - 1; i >= 0; i--) { ObjectId id = peerHas[i]; if (walk.LookupOrNull(id) == null) { if (OkToGiveUp()) { switch (multiAck) { case BasePackFetchConnection.MultiAck.OFF: { break; } case BasePackFetchConnection.MultiAck.CONTINUE: { pckOut.WriteString("ACK " + id.Name + " continue\n"); break; } case BasePackFetchConnection.MultiAck.DETAILED: { pckOut.WriteString("ACK " + id.Name + " ready\n"); break; } } } break; } } peerHas.Clear(); return last; }
private bool ScavengeChunks(bool alwaysKeepScavenged, IList<TFChunk.TFChunk> oldChunks) { if (oldChunks.IsEmpty()) throw new ArgumentException("Provided list of chunks to scavenge and merge is empty."); var sw = Stopwatch.StartNew(); int chunkStartNumber = oldChunks.First().ChunkHeader.ChunkStartNumber; long chunkStartPosition = oldChunks.First().ChunkHeader.ChunkStartPosition; int chunkEndNumber = oldChunks.Last().ChunkHeader.ChunkEndNumber; var tmpChunkPath = Path.Combine(_db.Config.Path, Guid.NewGuid() + ".scavenge.tmp"); var oldChunksLogList = string.Join("\n", oldChunks.Select(x => string.Format("#{0}-{1} ({2})", x.ChunkHeader.ChunkStartNumber, x.ChunkHeader.ChunkEndNumber, Path.GetFileName(x.FileName)))); Log.Trace("SCAVENGING: started to scavenge & merge chunks: {0}\nResulting temp chunk file: {1}.", oldChunksLogList, Path.GetFileName(tmpChunkPath)); TFChunk.TFChunk newChunk; try { newChunk = TFChunk.TFChunk.CreateNew(tmpChunkPath, _db.Config.ChunkSize, chunkStartNumber, chunkEndNumber, isScavenged: true); } catch (IOException exc) { Log.ErrorException(exc, "IOException during creating new chunk for scavenging purposes. Ignoring..."); return false; } try { var commits = new Dictionary<long, CommitInfo>(); foreach (var oldChunk in oldChunks) { TraverseChunk(oldChunk, prepare => { /* NOOP */ }, commit => { if (commit.TransactionPosition >= chunkStartPosition) commits.Add(commit.TransactionPosition, new CommitInfo(commit)); }, system => { /* NOOP */ }); } var positionMapping = new List<PosMap>(); foreach (var oldChunk in oldChunks) { TraverseChunk(oldChunk, prepare => { if (ShouldKeepPrepare(prepare, commits)) positionMapping.Add(WriteRecord(newChunk, prepare)); }, commit => { if (ShouldKeepCommit(commit, commits)) positionMapping.Add(WriteRecord(newChunk, commit)); }, // we always keep system log records for now system => positionMapping.Add(WriteRecord(newChunk, system))); } var oldSize = oldChunks.Sum(x => (long)x.PhysicalDataSize + x.ChunkFooter.MapSize + ChunkHeader.Size + ChunkFooter.Size); var newSize = (long)newChunk.PhysicalDataSize + PosMap.FullSize * positionMapping.Count + ChunkHeader.Size + ChunkFooter.Size; if (!alwaysKeepScavenged && oldSize <= newSize) { Log.Trace("Scavenging of chunks:\n{0}\n" + "completed in {1}.\n" + "Old chunks' versions are kept as they are smaller.\n" + "Old chunk total size: {2}, scavenged chunk size: {3}.\n" + "Scavenged chunk removed.", oldChunksLogList, sw.Elapsed, oldSize, newSize); newChunk.MarkForDeletion(); return false; } else { newChunk.CompleteScavenge(positionMapping); var chunk = _db.Manager.SwitchChunk(newChunk, verifyHash: false, removeChunksWithGreaterNumbers: false); if (chunk != null) { Log.Trace("Scavenging of chunks:\n{0}\n" + "completed in {1}.\n" + "New chunk: {2} --> #{3}-{4} ({5}).\n" + "Old chunks total size: {6}, scavenged chunk size: {7}.", oldChunksLogList, sw.Elapsed, Path.GetFileName(tmpChunkPath), chunkStartNumber, chunkEndNumber, Path.GetFileName(chunk.FileName), oldSize, newSize); return true; } else { Log.Trace("Scavenging of chunks:\n{0}\n" + "completed in {1}.\n" + "But switching was prevented for new chunk: #{2}-{3} ({4}).\n" + "Old chunks total size: {5}, scavenged chunk size: {6}.", oldChunksLogList, sw.Elapsed, chunkStartNumber, chunkEndNumber, Path.GetFileName(tmpChunkPath), oldSize, newSize); return false; } } } catch (FileBeingDeletedException exc) { Log.Info("Got FileBeingDeletedException exception during scavenging, that probably means some chunks were re-replicated.\n" + "Scavenging of following chunks will be skipped:\n{0}\n" + "Stopping scavenging and removing temp chunk '{1}'...\n" + "Exception message: {2}.", oldChunksLogList, tmpChunkPath, exc.Message); Helper.EatException(() => { File.SetAttributes(tmpChunkPath, FileAttributes.Normal); File.Delete(tmpChunkPath); }); return false; } }
private static IList<string> EnsureListType(IList<string> list) { if (list == null) { return null; } if (list.IsEmpty()) { return new List<string>(0); } if (list is List<string>) { return list; } return new List<string>(list); }
/// <exception cref="System.IO.IOException"></exception> private ObjectId ProcessHaveLines(IList<ObjectId> peerHas, ObjectId last) { preUploadHook.OnBeginNegotiateRound(this, wantIds, peerHas.Count); if (peerHas.IsEmpty()) { return last; } IList<ObjectId> toParse = peerHas; HashSet<ObjectId> peerHasSet = null; bool needMissing = false; sentReady = false; if (wantAll.IsEmpty() && !wantIds.IsEmpty()) { // We have not yet parsed the want list. Parse it now. peerHasSet = new HashSet<ObjectId>(peerHas); int cnt = wantIds.Count + peerHasSet.Count; toParse = new AList<ObjectId>(cnt); Sharpen.Collections.AddAll(toParse, wantIds); Sharpen.Collections.AddAll(toParse, peerHasSet); needMissing = true; } ICollection<RevObject> notAdvertisedWants = null; int haveCnt = 0; AsyncRevObjectQueue q = walk.ParseAny(toParse.AsIterable(), needMissing); try { for (; ; ) { RevObject obj; try { obj = q.Next(); } catch (MissingObjectException notFound) { ObjectId id = notFound.GetObjectId(); if (wantIds.Contains(id)) { string msg = MessageFormat.Format(JGitText.Get().wantNotValid, id.Name); throw new PackProtocolException(msg, notFound); } continue; } if (obj == null) { break; } // If the object is still found in wantIds, the want // list wasn't parsed earlier, and was done in this batch. // if (wantIds.Remove(obj)) { if (!advertised.Contains(obj) && requestPolicy != UploadPack.RequestPolicy.ANY) { if (notAdvertisedWants == null) { notAdvertisedWants = new HashSet<RevObject>(); } notAdvertisedWants.AddItem(obj); } if (!obj.Has(WANT)) { obj.Add(WANT); wantAll.AddItem(obj); } if (!(obj is RevCommit)) { obj.Add(SATISFIED); } if (obj is RevTag) { RevObject target = walk.Peel(obj); if (target is RevCommit) { if (!target.Has(WANT)) { target.Add(WANT); wantAll.AddItem(target); } } } if (!peerHasSet.Contains(obj)) { continue; } } last = obj; haveCnt++; if (obj is RevCommit) { RevCommit c = (RevCommit)obj; if (oldestTime == 0 || c.CommitTime < oldestTime) { oldestTime = c.CommitTime; } } if (obj.Has(PEER_HAS)) { continue; } obj.Add(PEER_HAS); if (obj is RevCommit) { ((RevCommit)obj).Carry(PEER_HAS); } AddCommonBase(obj); switch (multiAck) { case BasePackFetchConnection.MultiAck.OFF: { // If both sides have the same object; let the client know. // if (commonBase.Count == 1) { pckOut.WriteString("ACK " + obj.Name + "\n"); } break; } case BasePackFetchConnection.MultiAck.CONTINUE: { pckOut.WriteString("ACK " + obj.Name + " continue\n"); break; } case BasePackFetchConnection.MultiAck.DETAILED: { pckOut.WriteString("ACK " + obj.Name + " common\n"); break; } } } } finally { q.Release(); } // If the client asked for non advertised object, check our policy. if (notAdvertisedWants != null && !notAdvertisedWants.IsEmpty()) { switch (requestPolicy) { case UploadPack.RequestPolicy.ADVERTISED: default: { throw new PackProtocolException(MessageFormat.Format(JGitText.Get().wantNotValid, notAdvertisedWants.Iterator().Next().Name)); } case UploadPack.RequestPolicy.REACHABLE_COMMIT: { CheckNotAdvertisedWants(notAdvertisedWants); break; } case UploadPack.RequestPolicy.ANY: { // Allow whatever was asked for. break; } } } int missCnt = peerHas.Count - haveCnt; // If we don't have one of the objects but we're also willing to // create a pack at this point, let the client know so it stops // telling us about its history. // bool didOkToGiveUp = false; if (0 < missCnt) { for (int i = peerHas.Count - 1; i >= 0; i--) { ObjectId id = peerHas[i]; if (walk.LookupOrNull(id) == null) { didOkToGiveUp = true; if (OkToGiveUp()) { switch (multiAck) { case BasePackFetchConnection.MultiAck.OFF: { break; } case BasePackFetchConnection.MultiAck.CONTINUE: { pckOut.WriteString("ACK " + id.Name + " continue\n"); break; } case BasePackFetchConnection.MultiAck.DETAILED: { pckOut.WriteString("ACK " + id.Name + " ready\n"); sentReady = true; break; } } } break; } } } if (multiAck == BasePackFetchConnection.MultiAck.DETAILED && !didOkToGiveUp && OkToGiveUp ()) { ObjectId id = peerHas[peerHas.Count - 1]; sentReady = true; pckOut.WriteString("ACK " + id.Name + " ready\n"); sentReady = true; } preUploadHook.OnEndNegotiateRound(this, wantAll, haveCnt, missCnt, sentReady); peerHas.Clear(); return last; }
private void PrepareGoogleMapsLocationsModel(GoogleMapsLocationsModel model, IList<LocationInfo> locations) { model = model ?? new GoogleMapsLocationsModel(); if (!locations.IsEmpty()) { /// filter only locations with coordinates locations = locations.Where(x => x.Longitude.HasValue && x.Latitude.HasValue).ToList(); foreach (LocationInfo li in locations) { li.Name = HttpUtility.JavaScriptStringEncode(li.Name); li.Description = HttpUtility.JavaScriptStringEncode(li.Description); } model.Locations = locations; } }