当前位置: 首页>>代码示例>>C#>>正文


C# List.AsReadOnly方法代码示例

本文整理汇总了C#中List.AsReadOnly方法的典型用法代码示例。如果您正苦于以下问题:C# List.AsReadOnly方法的具体用法?C# List.AsReadOnly怎么用?C# List.AsReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在List的用法示例。


在下文中一共展示了List.AsReadOnly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PopulateProperties

 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();
 }
开发者ID:Glain,项目名称:FFTPatcher,代码行数:7,代码来源:WldTex2.cs

示例2: GetLogsForRoom

        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();
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:26,代码来源:ModerationLogs.cs

示例3: Create

		/// <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();
		}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:31,代码来源:VerificationErrorCollectionCreator.cs

示例4: GetCodeDefinitions

        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();
        }
开发者ID:nick-randal,项目名称:UsefulCSharp,代码行数:26,代码来源:CodeGenerator.cs

示例5: PdfContents

 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");
         }
     }
 }
开发者ID:jdehaan,项目名称:SafeRapidPdf,代码行数:28,代码来源:PdfContents.cs

示例6: Parse

		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();
		}
开发者ID:snowinmars,项目名称:pdf2abc,代码行数:35,代码来源:MorphemeLogic.cs

示例7: MinimalResolveContext

		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();
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:31,代码来源:MinimalResolveContext.cs

示例8: FallbackKeyProcessorTest

        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());
        }
开发者ID:honeyhoneywell,项目名称:VsVim,代码行数:26,代码来源:FallbackKeyProcessorTest.cs

示例9: View

		public View (LayoutSpec spec) {
			_spec = spec ?? LayoutSpec.Empty;
			_children = new List<View>();
			this.Transform = Matrix4.Identity;
			this.Children = _children.AsReadOnly();
			this.ZDepth = 0.1f;
		}
开发者ID:jpernst,项目名称:GameStack,代码行数:7,代码来源:View.cs

示例10: Read

        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;
                }
            }
        }
开发者ID:ShaneCastle,项目名称:TeaFiles.Net,代码行数:29,代码来源:TimeSectionFormatter.cs

示例11: GetAuthorizationPolicies

        // 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();
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:29,代码来源:ServiceAuthorizationManager.cs

示例12: GetPositionalArguments

		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();
		}
开发者ID:95ulisse,项目名称:ILEdit,代码行数:30,代码来源:CSharpAttribute.cs

示例13: InsertImages

		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();
		}
开发者ID:nhannd,项目名称:Xian,代码行数:7,代码来源:StudyComposerComponent.cs

示例14: GetPages

		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();
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:7,代码来源:PresetVoiLutConfigurationPageProvider.cs

示例15: PerfMetadata

        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();
        }
开发者ID:modulexcite,项目名称:Tx,代码行数:27,代码来源:PerfMetadata.cs


注:本文中的List.AsReadOnly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。