Example #1
1
 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();
 }
Example #2
0
        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();
        }
		/// <summary>
		/// Creates a <see cref="ReadOnlyCollection&lt;VerificationError&gt;" /> 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 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();
        }
Example #5
0
 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");
         }
     }
 }
Example #6
0
		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();
		}
        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());
        }
Example #9
0
		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 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;
                }
            }
        }
        // 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();
        }
Example #12
0
		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();
		}
Example #13
0
		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();
		}
		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();
		}
Example #15
0
        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();
        }
Example #16
0
        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()));
            }
        }
 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();
 }
Example #18
0
        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);
            }
        }
Example #19
0
        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();
        }
Example #20
0
		public IList<Subprogram> GetSubprograms()
		{
			List<Subprogram> splist = new List<Subprogram>();
			foreach (Subprogram kernel in Kernels)
				Enumerate(kernel, (x => { }), splist);
			return splist.AsReadOnly();
		}
Example #21
0
        /// <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();
        }
Example #22
0
 /// <summary>
 /// Gets information about the certain files contained in the archive file.
 /// </summary>
 /// <param name="searchPattern">The search string, such as
 /// &quot;*.txt&quot;.</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();
 }
Example #23
0
        /// <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();
        }
Example #24
0
        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.");
            }
        }
Example #25
0
		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();
		}
Example #26
0
        /// <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();
        } 
Example #27
0
 /// <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();
 }
		public DesktopServiceHostPermissionAttribute(params string[] authorityTokens)
		{
			List<string> viewerTokens = new List<string>();
			viewerTokens.Add(ImageViewer.AuthorityTokens.ViewerVisible);
			viewerTokens.AddRange(authorityTokens);
			AuthorityTokens = viewerTokens.AsReadOnly();
		}
Example #29
0
        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 IEnumerable<IConfigurationPage> GetPages()
		{
			List<IConfigurationPage> listPages = new List<IConfigurationPage>();
			if (PermissionsHelper.IsInRole(ImageViewer.AuthorityTokens.ViewerVisible))
				listPages.Add(new ConfigurationPage<MonitorConfigurationApplicationComponent>("MonitorConfiguration"));
			return listPages.AsReadOnly();
		}