本文整理汇总了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();
}
示例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();
}
示例3: Create
/// <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();
}
示例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();
}
示例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");
}
}
}
示例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();
}
示例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();
}
示例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());
}
示例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;
}
示例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;
}
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}