private void PopulateProperties( GraphicStructure paletteStructure, IList<GraphicStructure> pixelStructures ) { Palette = new Palette( paletteStructure.Pixels, Palette.ColorDepth._16bit ); List<byte> pix = new List<byte>(); pixelStructures.ForEach( p => pix.AddRange( p.Pixels ) ); Pixels = pix.AsReadOnly(); }
/// <summary> /// Creates a <see cref="ReadOnlyCollection<VerificationError>" /> based /// on the output of peverify. /// </summary> /// <param name="peVerifyOutput">The output from peverify.</param> /// <returns>A collection of errors.</returns> public static ReadOnlyCollection<VerificationError> Create(TextReader peVerifyOutput) { var errors = new List<VerificationError>(); if (peVerifyOutput == null) return errors.AsReadOnly(); var peOutputLine = peVerifyOutput.ReadLine(); while (peOutputLine != null) { peOutputLine = peOutputLine.Replace("\0", string.Empty); if (peOutputLine.Length > 0) { var error = VerificationError.Create(peOutputLine); if (error != null) errors.Add(error); } peOutputLine = peVerifyOutput.ReadLine(); } return errors.AsReadOnly(); }
public static ReadOnlyCollection<ModerationChatlogEntry> GetLogsForRoom(uint RoomId, double FromTimestamp, double ToTimestamp) { List<ModerationChatlogEntry> Entries = new List<ModerationChatlogEntry>(); if (!(bool)ConfigManager.GetValue("moderation.chatlogs.enabled")) { return Entries.AsReadOnly(); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { MySqlClient.SetParameter("roomid", RoomId); MySqlClient.SetParameter("timestamp_from", FromTimestamp); MySqlClient.SetParameter("timestamp_to", ToTimestamp); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT user_id,room_id,timestamp,message FROM moderation_chatlogs WHERE room_id = @roomid AND timestamp >= @timestamp_from AND timestamp <= @timestamp_to ORDER BY timestamp DESC"); foreach (DataRow Row in Table.Rows) { Entries.Add(new ModerationChatlogEntry((uint)Row["user_id"], (uint)Row["room_id"], (double)Row["timestamp"], (string)Row["message"])); } } return Entries.AsReadOnly(); }
public IReadOnlyList<DbCodeDefinition> GetCodeDefinitions(string commandText, CommandType commandType) { var codes = new List<DbCodeDefinition>(); using (var connection = OpenConnection()) using (var command = new SqlCommand(commandText, connection) { CommandType = commandType }) using (var reader = command.ExecuteReader()) { if (reader.HasRows == false) return codes.AsReadOnly(); if(reader.FieldCount < 4) throw new InvalidDataException("SQL command provided must have at least 4 fields but returned " + reader.FieldCount); while (reader.Read()) { var isObsolete = reader.FieldCount > 4 ? reader.GetValue(4) : null; codes.Add( new DbCodeDefinition(reader.GetValue(0), reader.GetValue(1), reader.GetValue(2), reader.GetValue(3), isObsolete) ); } } return codes.AsReadOnly(); }
public View (LayoutSpec spec) { _spec = spec ?? LayoutSpec.Empty; _children = new List<View>(); this.Transform = Matrix4.Identity; this.Children = _children.AsReadOnly(); this.ZDepth = 0.1f; }
public void TestAddingListOfSongs() { EZPlaylist playlist = new EZPlaylist("My Awesome Playlist"); MediaLibrary lib = new MediaLibrary(); if (lib.Songs.Count > 1) { List<SongInfo> list = new List<SongInfo>(); Song song = lib.Songs[0]; SongInfo si1 = new SongInfo(song.Artist.Name, song.Album.Name, song.Name, song.Duration, song.TrackNumber); list.Add(si1); song = lib.Songs[1]; SongInfo si2 = new SongInfo(song.Artist.Name, song.Album.Name, song.Name, song.Duration, song.TrackNumber); list.Add(si2); playlist.AddList(list.AsReadOnly()); Assert.IsTrue(playlist.Count == 2); Assert.IsTrue(playlist.Songs.Contains(si1)); Assert.IsTrue(playlist.Songs.Contains(si2)); } else { Assert.Fail("Can't test adding a song because there are no songs to add or there is only one song."); } }
public IEnumerable<Morpheme> Parse(string input) { List<Morpheme> morphemes = new List<Morpheme>(128); Regex regex = new Regex(@".* rg"); Regex ReplaceRegex = new Regex(@"\r\n"); string lastItem = default(string); foreach (var item in regex.Split(input)) { if ((item == String.Empty) || (item == "\r\n")) { continue; } string str = ReplaceRegex.Replace(item, String.Empty); // Размер пишется двумя морфемами. Я считываю одну и вторую и для удобства записываю их в одну общую. if (Common.singatureRegex.Match(str).Success) { if (Common.singatureRegex.Match(lastItem).Success) { morphemes.Add(new Morpheme(lastItem + str)); } lastItem = str; continue; } morphemes.Add(new Morpheme(str)); lastItem = str; } return morphemes.AsReadOnly(); }
private MinimalResolveContext() { List<ITypeDefinition> types = new List<ITypeDefinition>(); types.Add(systemObject = new DefaultTypeDefinition(this, "System", "Object") { Accessibility = Accessibility.Public }); types.Add(systemValueType = new DefaultTypeDefinition(this, "System", "ValueType") { Accessibility = Accessibility.Public, BaseTypes = { systemObject } }); types.Add(CreateStruct("System", "Boolean")); types.Add(CreateStruct("System", "SByte")); types.Add(CreateStruct("System", "Byte")); types.Add(CreateStruct("System", "Int16")); types.Add(CreateStruct("System", "UInt16")); types.Add(CreateStruct("System", "Int32")); types.Add(CreateStruct("System", "UInt32")); types.Add(CreateStruct("System", "Int64")); types.Add(CreateStruct("System", "UInt64")); types.Add(CreateStruct("System", "Single")); types.Add(CreateStruct("System", "Double")); types.Add(CreateStruct("System", "Decimal")); types.Add(new DefaultTypeDefinition(this, "System", "String") { Accessibility = Accessibility.Public, BaseTypes = { systemObject } }); types.Add(new VoidTypeDefinition(this)); foreach (ITypeDefinition type in types) type.Freeze(); this.types = types.AsReadOnly(); }
public static IList<Subprogram> GetCallsRec(Subprogram sp) { List<Subprogram> splist = new List<Subprogram>(); foreach (Subprogram callee in sp.GetCalls()) Enumerate(callee, (x => { }), splist); return splist.AsReadOnly(); }
public IEnumerable<IConfigurationPage> GetPages() { List<IConfigurationPage> listPages = new List<IConfigurationPage>(); if (PermissionsHelper.IsInRole(AuthorityTokens.ViewerVisible)) listPages.Add(new ConfigurationPage<PresetVoiLutConfigurationComponent>("TitleTools/TitleWindowLevel")); return listPages.AsReadOnly(); }
protected virtual ReadOnlyCollection <Expression> VisitExpressionList(ReadOnlyCollection <Expression> original) { List <Expression> list = null; for (int i = 0, n = original.Count; i < n; i++) { Expression p; if (original[i] == _oldParameter) { p = Expression.MakeMemberAccess(_newParameter, _referenceProperty); } else { p = this.Visit(original[i]); } if (p != original[i] && list == null) { list = original.Take(i).ToList(); } if (list != null) { list.Add(p); } } return(list?.AsReadOnly() ?? original); }
/// <summary> /// Initializes a new instance of the <see cref="ChatMessageEventArgs"/> class. /// </summary> /// <param name="client">The <see cref="ClientInfo"/> object representing the client that sent the message.</param> /// <param name="type">The type of chat message.</param> /// <param name="message">The message text.</param> /// <param name="recipientEntityIds">The list of entity IDs receiving the message.</param> internal ChatMessageEventArgs(ClientInfo client, EChatType type, string message, List <int> recipientEntityIds) { this.Client = (client == null) ? SMClient.Console : new SMClient(client); this.Type = (SMChatType)type; this.Message = message; this.RecipientEntityIds = recipientEntityIds?.AsReadOnly(); }
public Shipment(Address originAddress, Address destinationAddress, List <Package> packages, ShipmentOptions?options = null) { OriginAddress = originAddress ?? throw new ArgumentNullException(nameof(originAddress)); DestinationAddress = destinationAddress ?? throw new ArgumentNullException(nameof(destinationAddress)); Packages = packages?.AsReadOnly() ?? throw new ArgumentNullException(nameof(packages)); Options = options ?? new ShipmentOptions(); }
protected FallbackKeyProcessorTest(bool useVimBuffer = false) { _keyboardDevice = new MockKeyboardDevice(); _commands = new Mock<Commands>(MockBehavior.Strict); _dte = new Mock<_DTE>(MockBehavior.Loose); _dte.SetupGet(x => x.Commands).Returns(_commands.Object); _vsShell = new Mock<IVsShell>(MockBehavior.Loose); _removedBindingList = new List<CommandKeyBinding>(); _vimApplicationSettings = new Mock<IVimApplicationSettings>(MockBehavior.Loose); _vimApplicationSettings .SetupGet(x => x.RemovedBindings) .Returns(() => _removedBindingList.AsReadOnly()); var textView = CreateTextView(""); _vimBuffer = useVimBuffer ? Vim.GetOrCreateVimBuffer(textView) : null; _keyProcessor = new FallbackKeyProcessor( _vsShell.Object, _dte.Object, CompositionContainer.GetExportedValue<IKeyUtil>(), _vimApplicationSettings.Object, textView, _vimBuffer, new ScopeData()); }
public IEnumerable<string> Wrap(string input) { var builder = new StringBuilder(); int pos = 0; var result = new List<string>(); foreach (var chr in input) { if (!(chr == ' ' && pos == 0)) { builder.Append(chr); ++pos; if (pos == rowLength) { result.Add(builder.ToString()); builder.Clear(); pos = 0; } } } if(builder.Length > 0) result.Add(builder.ToString()); return result.AsReadOnly(); }
public void SelectItems(IEnumerable<ListViewItem> items) { List<ListViewItem> newSelection = new List<ListViewItem>(SelectedItems.Count); foreach (ListViewItem item in items) newSelection.Add(item); List<ListViewItem> selected = new List<ListViewItem>(newSelection.GetRange(0, newSelection.Count)); foreach (ListViewItem item in selectedItems) selected.Remove(item); List<ListViewItem> deselected = new List<ListViewItem>(selectedItems.GetRange(0, selectedItems.Count)); foreach (ListViewItem item in newSelection) deselected.Remove(item); foreach (ListViewItem item in selected) item.Selected = true; foreach (ListViewItem item in deselected) item.Selected = false; selectedItems = newSelection; if (selected.Count > 0 || deselected.Count > 0) { OnListSelectionChanged(new CustomListViewSelectionChangedEventArgs(deselected.AsReadOnly(), selected.AsReadOnly())); } }
public PerfMetadata(string logFileName) { List<string> machines = PdhUtils.GetMachineList(logFileName); var machineInfos = new List<MachineInfo>(); foreach (string m in machines) { var objects = PdhUtils.GetObjectList(logFileName, m); var objectInfos = new List<ObjectInfo>(); foreach (string o in objects) { var counters = new List<string>(); var instances = new List<string>(); PdhUtils.GetCounterAndInstanceList(logFileName, m, o, out counters, out instances); ObjectInfo info = new ObjectInfo(o, counters, instances); objectInfos.Add(info); } machineInfos.Add(new MachineInfo(m, objectInfos)); } _machines = machineInfos.AsReadOnly(); }
/// <summary> /// Gets information about the files contained in the archive. /// </summary> /// <returns>A list of <see cref="CabFileInfo"/> objects, each /// containing information about a file in the archive.</returns> public new IList<CabFileInfo> GetFiles() { IList<ArchiveFileInfo> files = base.GetFiles(); List<CabFileInfo> cabFiles = new List<CabFileInfo>(files.Count); foreach (CabFileInfo cabFile in files) cabFiles.Add(cabFile); return cabFiles.AsReadOnly(); }
/// <summary> /// Initializes a new instance of the <see cref="SequenceExpression"/> class. /// </summary> /// <param name="sequence">The sequence of expressions to match.</param> public SequenceExpression(IEnumerable<Expression> sequence) { if (sequence == null) { throw new ArgumentNullException(nameof(sequence)); } var flattened = new List<Expression>(); foreach (var e in sequence) { SequenceExpression sequenceExpression; LiteralExpression literalExpression; if ((sequenceExpression = e as SequenceExpression) != null) { var last = sequenceExpression.Sequence.LastOrDefault() as CodeExpression; if (last == null || last.CodeType == CodeType.State || last.CodeType == CodeType.Error) { flattened.AddRange(sequenceExpression.Sequence); continue; } } else if ((literalExpression = e as LiteralExpression) != null) { if (string.IsNullOrEmpty(literalExpression.Value)) { continue; } } flattened.Add(e); } this.Sequence = flattened.AsReadOnly(); }
/// <summary> /// Gets information about the certain files contained in the archive file. /// </summary> /// <param name="searchPattern">The search string, such as /// "*.txt".</param> /// <returns>A list of <see cref="ZipFileInfo"/> objects, each containing /// information about a file in the archive.</returns> public new IList<ZipFileInfo> GetFiles(string searchPattern) { IList<ArchiveFileInfo> files = base.GetFiles(searchPattern); List<ZipFileInfo> zipFiles = new List<ZipFileInfo>(files.Count); foreach (ZipFileInfo zipFile in files) zipFiles.Add(zipFile); return zipFiles.AsReadOnly(); }
// Define the set of policies taking part in chaining. We will provide // the safe default set (primary token + all supporting tokens except token with // with SecurityTokenAttachmentMode.Signed + transport token). Implementor // can override and provide different selection of policies set. protected virtual ReadOnlyCollection<IAuthorizationPolicy> GetAuthorizationPolicies(OperationContext operationContext) { SecurityMessageProperty security = operationContext.IncomingMessageProperties.Security; if (security == null) { return EmptyReadOnlyCollection<IAuthorizationPolicy>.Instance; } ReadOnlyCollection<IAuthorizationPolicy> externalPolicies = security.ExternalAuthorizationPolicies; if (security.ServiceSecurityContext == null) { return externalPolicies ?? EmptyReadOnlyCollection<IAuthorizationPolicy>.Instance; } ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies = security.ServiceSecurityContext.AuthorizationPolicies; if (externalPolicies == null || externalPolicies.Count <= 0) { return authorizationPolicies; } // Combine List<IAuthorizationPolicy> policies = new List<IAuthorizationPolicy>(authorizationPolicies); policies.AddRange(externalPolicies); return policies.AsReadOnly(); }
public IEnumerable<IConfigurationPage> GetPages() { List<IConfigurationPage> listPages = new List<IConfigurationPage>(); if (PermissionsHelper.IsInRole(ImageViewer.AuthorityTokens.ViewerVisible)) listPages.Add(new ConfigurationPage<MonitorConfigurationApplicationComponent>("MonitorConfiguration")); return listPages.AsReadOnly(); }
static NewTestament() { List<Book> booksList = new List<Book>(); booksList.Add(NewTestament.Mathew); booksList.Add(Mark); booksList.Add(Luke); booksList.Add(John); booksList.Add(Acts); booksList.Add(Romans); booksList.Add(Corinthians1); booksList.Add(Corinthians2); booksList.Add(Galatians); booksList.Add(Ephesians); booksList.Add(Philippians); booksList.Add(Colossians); booksList.Add(Thessalonians1); booksList.Add(Thessalonians2); booksList.Add(Timoth1); booksList.Add(Timothy2); booksList.Add(Titus); booksList.Add(Philemon); booksList.Add(Hebrews); booksList.Add(James); booksList.Add(Peter1); booksList.Add(Peter2); booksList.Add(John1); booksList.Add(John2); booksList.Add(John3); booksList.Add(Jude); booksList.Add(Revelation); NewTestament.Books = booksList.AsReadOnly(); }
public DesktopServiceHostPermissionAttribute(params string[] authorityTokens) { List<string> viewerTokens = new List<string>(); viewerTokens.Add(ImageViewer.AuthorityTokens.ViewerVisible); viewerTokens.AddRange(authorityTokens); AuthorityTokens = viewerTokens.AsReadOnly(); }
public static IList<HtmlWord> GetWords(this HtmlNode node, HtmlNode top) { var words = new List<HtmlWord>(); if (node.HasChildNodes) { foreach (var child in node.ChildNodes) words.AddRange(child.GetWords(top)); } else { var textNode = node as HtmlTextNode; if (textNode != null && !string.IsNullOrEmpty(textNode.Text)) { string[] singleWords = textNode.Text.Split( new string[] {" "}, StringSplitOptions.RemoveEmptyEntries ); words.AddRange( singleWords .Select(w => new HtmlWord(w, node.ParentNode, top) ) ); } } return words.AsReadOnly(); }
public IList<Subprogram> GetSubprograms() { List<Subprogram> splist = new List<Subprogram>(); foreach (Subprogram kernel in Kernels) Enumerate(kernel, (x => { }), splist); return splist.AsReadOnly(); }
public void Read(ReadContext c) { // time scale var epoch = c.Reader.ReadInt64(); var ticksPerDay = c.Reader.ReadInt64(); c.Description.Timescale = Timescale.FromEpoch(epoch, ticksPerDay); // time fields var timeFieldsCount = c.Reader.ReadInt32(); var offsets = new List<int>(); timeFieldsCount.Times(() => offsets.Add(c.Reader.ReadInt32())); c.Description.TimeFieldOffsets = offsets.AsReadOnly(); // adorn item description with time aspects, if available var id = c.Description.ItemDescription; if (id != null) { bool isFirstTimeField = true; foreach (var offset in offsets) { var f = id.FindFieldByOffset(offset); if (f == null) throw new FileFormatException("Time format section contains an entry for a field at offset {0} but no such field was found in the item description."); f.IsTime = true; f.IsEventTime = isFirstTimeField; isFirstTimeField = false; } } }
public IList<KeyValuePair<string, string>> GetValues(string section) { if (String.IsNullOrEmpty(section)) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "section"); } try { var sectionElement = _config.Root.Element(section); if (sectionElement == null) { return null; } var kvps = new List<KeyValuePair<string, string>>(); foreach (var e in sectionElement.Elements("add")) { var key = e.GetOptionalAttributeValue("key"); var value = e.GetOptionalAttributeValue("value"); if (!String.IsNullOrEmpty(key) && value != null) { kvps.Add(new KeyValuePair<string, string>(key, value)); } } return kvps.AsReadOnly(); } catch (Exception e) { throw new InvalidOperationException(NuGetResources.UserSettings_UnableToParseConfigFile, e); } }
public IList<IConstantValue> GetPositionalArguments(ITypeResolveContext context) { if (namedCtorArguments == null || namedCtorArguments.Count == 0) { // no namedCtorArguments: just return the positionalArguments if (positionalArguments != null) return new ReadOnlyCollection<IConstantValue>(positionalArguments); else return EmptyList<IConstantValue>.Instance; } // we do have namedCtorArguments, which need to be re-ordered and appended to the positional arguments List<IConstantValue> result = new List<IConstantValue>(this.positionalArguments); IMethod method = ResolveConstructor(context); if (method != null) { for (int i = result.Count; i < method.Parameters.Count; i++) { IParameter p = method.Parameters[i]; bool found = false; foreach (var pair in namedCtorArguments) { if (pair.Key == p.Name) { result.Add(pair.Value); found = true; } } if (!found) { // add the parameter's default value: result.Add(p.DefaultValue ?? new SimpleConstantValue(p.Type, CSharpResolver.GetDefaultValue(p.Type.Resolve(context)))); } } } return result.AsReadOnly(); }
public IList<ImageItem> InsertImages(IEnumerable<IPresentationImage> images) { List<ImageItem> list = new List<ImageItem>(); foreach (IPresentationImage image in images) { list.Add(DoInsertImage(image)); } return list.AsReadOnly(); }
/// <summary> /// Returns a list of Dates that are the next fire times of a /// <see cref="ITrigger" />. /// The input trigger will be cloned before any work is done, so you need /// not worry about its state being altered by this method. /// </summary> /// <param name="trigg">The trigger upon which to do the work</param> /// <param name="cal">The calendar to apply to the trigger's schedule</param> /// <param name="numTimes">The number of next fire times to produce</param> /// <returns>List of java.util.Date objects</returns> public static IList<DateTimeOffset> ComputeFireTimes(IOperableTrigger trigg, ICalendar cal, int numTimes) { List<DateTimeOffset> lst = new List<DateTimeOffset>(); IOperableTrigger t = (IOperableTrigger) trigg.Clone(); if (t.GetNextFireTimeUtc() == null || !t.GetNextFireTimeUtc().HasValue) { t.ComputeFirstFireTimeUtc(cal); } for (int i = 0; i < numTimes; i++) { DateTimeOffset? d = t.GetNextFireTimeUtc(); if (d.HasValue) { lst.Add(d.Value); t.Triggered(cal); } else { break; } } return lst.AsReadOnly(); }
public PdfContents(IPdfObject obj) : base(PdfObjectType.Contents) { IsContainer = true; if (obj is PdfIndirectReference) { obj = (obj as PdfIndirectReference).ReferencedObject.Object; } PdfArray array = obj as PdfArray; PdfStream stream = obj as PdfStream; if (array != null) { Streams = array.Items; } else { if (stream != null) { var list = new List<IPdfObject>(); list.Add(stream); Streams = list.AsReadOnly(); } else { throw new Exception("Contents must be either a stream or an array of streams"); } } }
/// <summary> /// creates a SerializerProvider /// The constructor accesses the registry to find all installed plug-ins /// </summary> /// <remarks> /// Create a SerializerProvider listing all installed serializers (from the registry) /// /// This method currently requires full trust to run. /// </remarks> ///<SecurityNote> /// The DemandPlugInSerializerPermissions() ensures that this method only works in full trust. /// Full trust is required, so that partial trust applications do not load or use potentially /// unsafe serializer plug ins ///</SecurityNote> public SerializerProvider() { SecurityHelper.DemandPlugInSerializerPermissions(); SerializerDescriptor sd = null; List<SerializerDescriptor> installedSerializers = new List<SerializerDescriptor>(); sd = CreateSystemSerializerDescriptor(); if (sd != null) { installedSerializers.Add(sd); } RegistryKey plugIns = _rootKey.CreateSubKey(_registryPath); if ( plugIns != null ) { foreach ( string keyName in plugIns.GetSubKeyNames()) { sd = SerializerDescriptor.CreateFromRegistry(plugIns, keyName); if (sd != null) { installedSerializers.Add(sd); } } plugIns.Close(); } _installedSerializers = installedSerializers.AsReadOnly(); }
public static IReadOnlyList <string> GetLogMessages(this DependencyObject source) { lock (LogProperty) { List <string> logs = (List <string>)source.GetValue(LogProperty); return(logs?.AsReadOnly() ?? (IReadOnlyList <string>)Array.Empty <string>()); } }
public IReadOnlyCollection <IMatcher <JobKey> > GetJobListenerMatchers(string listenerName) { lock (globalJobListeners) { List <IMatcher <JobKey> > matchers = globalJobListenersMatchers.TryGetAndReturn(listenerName); return(matchers?.AsReadOnly()); } }
public TranslatedSub(DynamicMethod method, List <Register> subArgs) { Method = method ?? throw new ArgumentNullException(nameof(method));; SubArgs = subArgs?.AsReadOnly() ?? throw new ArgumentNullException(nameof(subArgs)); _callers = new HashSet <long>(); PrepareDelegate(); }
public ProjectDeploymentSettings( List <DeploymentScript> scripts, Dictionary <string, ServiceDeploymentSettings> services, string serviceScriptsRootPath = "") { Scripts = scripts?.AsReadOnly(); Services = new ReadOnlyDictionary <string, ServiceDeploymentSettings>(services); ServiceScriptsRootPath = serviceScriptsRootPath; }
public TestRun(long total, long passed, long failed, long inconclusive, long skipped, List <TestCase> testCases) { Total = total; Passed = passed; Failed = failed; Inconclusive = inconclusive; Skipped = skipped; TestCases = testCases?.AsReadOnly(); }
public Scope(int id, int depth, int parentId, int startAddress, int endAddress, List <Identifier> identifiers) { Id = id; Depth = depth; ParentId = parentId; StartAddress = startAddress; EndAddress = endAddress; Identifiers = identifiers?.AsReadOnly(); }
public ReadOnlyCollection <Node <T> > DepthFirstTraversal() { var result = new List <Node <T> >(); DFSImplementation(Nodes[0], new bool[Nodes.Count], result, (nextNode) => { result.Add(nextNode); // Move to next node return(false); }); return(result?.AsReadOnly()); }
public SquadTemplate(int id, string name, WeaponSet defaultWeapons, List <SquadWeaponOption> weaponOptions, ArmorTemplate armor, List <SquadTemplateElement> elements, SquadTypes squadType) { Id = id; Name = name; Elements = elements.AsReadOnly(); DefaultWeapons = defaultWeapons; WeaponOptions = weaponOptions?.AsReadOnly(); Armor = armor; SquadType = squadType; }
internal ClusterNode(ClusterConfiguration configuration, string raw, EndPoint origin) { // https://redis.io/commands/cluster-nodes this.configuration = configuration; Raw = raw; var parts = raw.Split(StringSplits.Space); var flags = parts[2].Split(StringSplits.Comma); // redis 4 changes the format of "cluster nodes" - adds @... to the endpoint var ep = parts[1]; int at = ep.IndexOf('@'); if (at >= 0) { ep = ep.Substring(0, at); } EndPoint = Format.TryParseEndPoint(ep); if (flags.Contains("myself")) { IsMyself = true; if (EndPoint == null) { // Unconfigured cluster nodes might report themselves as endpoint ":{port}", // hence the origin fallback value to make sure that we can address them EndPoint = origin; } } NodeId = parts[0]; IsReplica = flags.Contains("slave") || flags.Contains("replica"); IsNoAddr = flags.Contains("noaddr"); ParentNodeId = string.IsNullOrWhiteSpace(parts[3]) ? null : parts[3]; List <SlotRange> slots = null; for (int i = 8; i < parts.Length; i++) { if (SlotRange.TryParse(parts[i], out SlotRange range)) { (slots ??= new List <SlotRange>(parts.Length - i)).Add(range); } } Slots = slots?.AsReadOnly() ?? (IList <SlotRange>)Array.Empty <SlotRange>(); IsConnected = parts[7] == "connected"; // Can be "connected" or "disconnected" }
private IReadOnlyCollection <FieldDeclaration> VisitFieldDeclarations( IReadOnlyCollection <FieldDeclaration> fields) { // Todo: where is alternate used?!? List <FieldDeclaration> alternate = null; foreach (var(field, index) in fields.WithIndex()) { var e = Visit(field.Expression); if (alternate is null && e != field.Expression) { alternate = fields.Take(index).ToList(); } alternate?.Add(new FieldDeclaration(field.Name, e)); } return(alternate?.AsReadOnly() ?? fields); }
public static TResponse ConvertToDto <TEntity, TResponse>(this TEntity entity, List <BacklogItemCustomFieldValue>?customFieldValues) where TEntity : BacklogItem where TResponse : BacklogItemGetResponseBase, new() { var response = new TResponse { Title = entity.Title, State = entity.State, EstimatedSize = entity.EstimatedSize, Assignee = entity.Assignee is null ? null : (entity.Assignee with { }).RemoveEntityPrefixFromId(), HistoryDescOrder = entity.ModifiedBy.OrderByDescending(i => i.Timestamp).ToList(), Tags = entity.Tags, Comments = GetCommentsList(entity.Comments), RelatedItems = entity.RelatedItems.AsReadOnly(), CustomFields = customFieldValues?.AsReadOnly(), Type = entity.Type }; switch (entity) { case BacklogItemBug entityBug when response is BugGetResponse responseBug: responseBug.Priority = entityBug.Priority; responseBug.Severity = entityBug.Severity; responseBug.StepsToReproduce = entityBug.StepsToReproduce; break; case BacklogItemUserStory entityUserStory when response is UserStoryGetResponse responseUserStory: responseUserStory.AcceptanceCriteria = entityUserStory.AcceptanceCriteria; break; case BacklogItemTask entityTask when response is TaskGetResponse responseTask: responseTask.Description = entityTask.Description; break; case BacklogItemFeature entityFeature when response is FeatureGetResponse responseFeature: responseFeature.Description = entityFeature.Description; break; } return(response); }
public async Task <IEnumerable <Depense> > Handle(GetAllDepensesQuery query, CancellationToken cancellationToken) { if (!(query.OrderByDateOrMontant == "Date" || query.OrderByDateOrMontant == "Montant" || string.IsNullOrEmpty(query.OrderByDateOrMontant))) { throw new ArgumentException("OrderBy must be Date , Montant or null"); } List <Depense> DepenseList = null; if (!string.IsNullOrEmpty(query.OrderByDateOrMontant)) { DepenseList = await _context.Depenses .OrderByPropertyName(query.OrderByDateOrMontant) .ToListAsync(); } else { DepenseList = await _context.Depenses .ToListAsync(); } return(DepenseList?.AsReadOnly()); }
public virtual IList <Party> GetUserParties() { List <Party> userPartiesAsList = UserParties as List <Party>; return(userPartiesAsList?.AsReadOnly()); }
public IReadOnlyList <DomainEvent> GetDomainEvents() { return(domainEvents?.AsReadOnly()); }
public IList <ConversationReference> GetBotInstances() { List <ConversationReference> botPartiesAsList = BotInstances as List <ConversationReference>; return(botPartiesAsList?.AsReadOnly()); }
public IList <Connection> GetConnections() { List <Connection> connectionsAsList = Connections as List <Connection>; return(connectionsAsList?.AsReadOnly()); }
public async Task <IReadOnlyCollection <T> > GetByIdsAsync(IEnumerable <string> ids, bool useCache = false, TimeSpan?expiresIn = null) { var idList = ids?.Distinct().Where(i => !String.IsNullOrEmpty(i)).ToList(); if (idList == null || idList.Count == 0) { return(EmptyList); } if (!HasIdentity) { throw new NotSupportedException("Model type must implement IIdentity."); } var hits = new List <T>(); if (IsCacheEnabled && useCache) { var cacheHits = await Cache.GetAllAsync <T>(idList).AnyContext(); hits.AddRange(cacheHits.Where(kvp => kvp.Value.HasValue).Select(kvp => kvp.Value.Value)); } var itemsToFind = idList.Except(hits.OfType <IIdentity>().Select(i => i.Id)).ToList(); if (itemsToFind.Count == 0) { return(hits.AsReadOnly()); } var multiGet = new MultiGetDescriptor(); if (!HasParent) { itemsToFind.ForEach(id => multiGet.Get <T>(f => f.Id(id).Index(GetIndexById(id)).Type(ElasticType.Name))); var multiGetResults = await _client.MultiGetAsync(multiGet).AnyContext(); _logger.Trace(() => multiGetResults.GetRequest()); foreach (var doc in multiGetResults.Documents) { if (!doc.Found) { continue; } hits.Add(((IMultiGetHit <T>)doc).ToFindHit().Document); itemsToFind.Remove(doc.Id); } } // fallback to doing a find if (itemsToFind.Count > 0 && (HasParent || HasMultipleIndexes)) { hits.AddRange((await FindAsync(NewQuery().WithIds(itemsToFind)).AnyContext()).Hits.Where(h => h.Document != null).Select(h => h.Document)); } if (IsCacheEnabled && useCache) { foreach (var item in hits.OfType <IIdentity>()) { await Cache.SetAsync(item.Id, item, expiresIn.HasValue?SystemClock.UtcNow.Add(expiresIn.Value) : SystemClock.UtcNow.AddSeconds(ElasticType.DefaultCacheExpirationSeconds)).AnyContext(); } } return(hits.AsReadOnly()); }
public cNamespaceNames(List <cNamespaceName> pPersonal, List <cNamespaceName> pOtherUsers, List <cNamespaceName> pShared) { Personal = pPersonal?.AsReadOnly(); OtherUsers = pOtherUsers?.AsReadOnly(); Shared = pShared?.AsReadOnly(); }
public IReadOnlyCollection <INotification> GetDomainEvents() => _domainEvents?.AsReadOnly();
public IReadOnlyCollection <DomainEvent> GetDomainEvents() => _domainEvents?.AsReadOnly();
public IList <ConversationReference> GetAggregationChannels() { List <ConversationReference> aggregationPartiesAsList = AggregationChannels as List <ConversationReference>; return(aggregationPartiesAsList?.AsReadOnly()); }
public IList <ConnectionRequest> GetConnectionRequests() { List <ConnectionRequest> connectionRequestsAsList = ConnectionRequests as List <ConnectionRequest>; return(connectionRequestsAsList?.AsReadOnly()); }
public virtual IList <Party> GetBotParties() { List <Party> botPartiesAsList = BotParties as List <Party>; return(botPartiesAsList?.AsReadOnly()); }
public IList <ConversationReference> GetUsers() { List <ConversationReference> userPartiesAsList = Users as List <ConversationReference>; return(userPartiesAsList?.AsReadOnly()); }
public virtual IList <Party> GetAggregationParties() { List <Party> aggregationPartiesAsList = AggregationParties as List <Party>; return(aggregationPartiesAsList?.AsReadOnly()); }
public virtual IList <Party> GetPendingRequests() { List <Party> pendingRequestsAsList = PendingRequests as List <Party>; return(pendingRequestsAsList?.AsReadOnly()); }
public Branch(List <Expression> conditions, BlockExpression block) { Conditions = conditions?.AsReadOnly(); Block = block; }