本文整理汇总了C#中Set.AsReadOnly方法的典型用法代码示例。如果您正苦于以下问题:C# Set.AsReadOnly方法的具体用法?C# Set.AsReadOnly怎么用?C# Set.AsReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set.AsReadOnly方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadConfigurationPlatformNamesFromMSBuild
/// <summary>
/// Load available configurations and platforms from the project file
/// by looking at which conditions are used.
/// </summary>
void LoadConfigurationPlatformNamesFromMSBuild()
{
Set<string> configurationNames = new Set<string>();
Set<string> platformNames = new Set<string>();
foreach (MSBuild.BuildPropertyGroup g in project.PropertyGroups) {
if (g.IsImported) {
continue;
}
MSBuild.BuildProperty prop = MSBuildInternals.GetProperty(g, "Configuration");
if (prop != null && !string.IsNullOrEmpty(prop.FinalValue)) {
configurationNames.Add(prop.FinalValue);
}
prop = MSBuildInternals.GetProperty(g, "Platform");
if (prop != null && !string.IsNullOrEmpty(prop.FinalValue)) {
platformNames.Add(prop.FinalValue);
}
string gConfiguration, gPlatform;
MSBuildInternals.GetConfigurationAndPlatformFromCondition(g.Condition,
out gConfiguration,
out gPlatform);
if (gConfiguration != null) {
configurationNames.Add(gConfiguration);
}
if (gPlatform != null) {
platformNames.Add(gPlatform);
}
}
if (configurationNames.Count == 0) {
configurationNames.Add("Debug");
configurationNames.Add("Release");
}
if (platformNames.Count == 0) {
platformNames.Add("AnyCPU");
}
this.configurationNames = configurationNames.AsReadOnly();
this.platformNames = platformNames.AsReadOnly();
}
示例2: GetColors
protected override Set<Color> GetColors( System.IO.Stream iso )
{
using (Bitmap fullImage = GetFullImageFromIso( iso ))
{
Set<Color> result = new Set<Color>( ( a, b ) => a.ToArgb() == b.ToArgb() ? 0 : 1 );
for (int x = 0; x < fullImage.Width; x++)
{
for (int y = 0; y < fullImage.Height; y++)
{
result.Add( fullImage.GetPixel( x, y ) );
}
}
return result.AsReadOnly();
}
}
示例3: CreateItemsListFromMSBuild
/// <summary>
/// re-creates the list of project items and the list of available item types
/// </summary>
internal void CreateItemsListFromMSBuild()
{
WorkbenchSingleton.AssertMainThread();
lock (SyncRoot) {
foreach (ProjectItem item in items) {
item.Dispose();
}
items.Clear();
itemsReadOnly = null; // remove readonly variant of item list - will regenerate on next Items call
Set<ItemType> availableFileItemTypes = new Set<ItemType>();
availableFileItemTypes.AddRange(ItemType.DefaultFileItems);
foreach (MSBuild.BuildItem item in project.GetEvaluatedItemsByName("AvailableItemName")) {
availableFileItemTypes.Add(new ItemType(item.Include));
}
this.availableFileItemTypes = availableFileItemTypes.AsReadOnly();
foreach (MSBuild.BuildItem item in project.EvaluatedItems) {
if (item.IsImported) continue;
items.Add(CreateProjectItem(item));
}
}
ClearFindFileCache();
}
示例4: DeleteDangles
/// <summary>
/// Marks all edges from the graph which are "dangles".
/// Dangles are which are incident on a node with degree 1.
/// This process is recursive, since removing a dangling edge
/// may result in another edge becoming a dangle.
/// In order to handle large recursion depths efficiently,
/// an explicit recursion stack is used.
/// </summary>
/// <returns>A List containing the <see cref="ILineString"/>s that formed dangles.</returns>
public ICollection<ILineString> DeleteDangles()
{
var nodesToRemove = FindNodesOfDegree(1);
Set<ILineString> dangleLines = new Set<ILineString>();
Stack<Node> nodeStack = new Stack<Node>();
foreach (Node node in nodesToRemove)
nodeStack.Push(node);
while (nodeStack.Count != 0)
{
Node node = nodeStack.Pop();
DeleteAllEdges(node);
IList<DirectedEdge> nodeOutEdges = node.OutEdges.Edges;
foreach (PolygonizeDirectedEdge de in nodeOutEdges)
{
// delete this edge and its sym
de.Marked = true;
PolygonizeDirectedEdge sym = (PolygonizeDirectedEdge) de.Sym;
if (sym != null) sym.Marked = true;
// save the line as a dangle
PolygonizeEdge e = (PolygonizeEdge) de.Edge;
dangleLines.Add(e.Line);
Node toNode = de.ToNode;
// add the toNode to the list to be processed, if it is now a dangle
if (GetDegreeNonDeleted(toNode) == 1)
nodeStack.Push(toNode);
}
}
return dangleLines.AsReadOnly();
//new ArrayList(dangleLines.CastPlatform());
}
示例5: GetFileInfo
private static FileInfo GetFileInfo( Context context, XmlNode node )
{
string displayName = node.SelectSingleNode( "DisplayName" ).InnerText;
Guid guid = new Guid( node.SelectSingleNode( "Guid" ).InnerText );
int size = Int32.Parse( node.SelectSingleNode( "Size" ).InnerText );
FileType filetype = (FileType)Enum.Parse( typeof( FileType ), node.Name );
int sectionCount = Int32.Parse( node.SelectSingleNode( "Sections/@count" ).InnerText );
int[] sectionLengths = new int[sectionCount];
bool[] dteAllowed = new bool[sectionCount];
bool[] compressionAllowed = new bool[sectionCount];
bool[] hidden = new bool[sectionCount];
for ( int i = 0; i < sectionCount; i++ )
{
XmlNode sectionNode = node.SelectSingleNode( string.Format( "Sections/Section[@value='{0}']", i ) );
XmlAttribute hideAttribute = sectionNode.Attributes["hide"];
if ( hideAttribute != null )
{
hidden[i] = Boolean.Parse( hideAttribute.InnerText );
}
sectionLengths[i] = Int32.Parse( sectionNode.Attributes["entries"].InnerText );
dteAllowed[i] = Boolean.Parse( sectionNode.Attributes["dte"].InnerText );
if ( filetype == FileType.CompressedFile )
{
compressionAllowed[i] = Boolean.Parse( sectionNode.Attributes["compressible"].InnerText );
}
}
XmlNodeList sectors = node.SelectNodes( "Sectors/*" );
Dictionary<SectorType, IList<KeyValuePair<Enum, int>>> dict = new Dictionary<SectorType, IList<KeyValuePair<Enum, int>>>( 3 );
bool first = true;
KeyValuePair<Enum, int> primaryFile = new KeyValuePair<Enum, int>();
foreach ( XmlNode sectorNode in sectors )
{
SectorType sectorType = (SectorType)Enum.Parse( typeof( SectorType ), sectorNode.Name );
if ( !dict.ContainsKey( sectorType ) )
{
dict.Add( sectorType, new List<KeyValuePair<Enum, int>>() );
}
int offset = Int32.Parse( sectorNode.Attributes["offset"].InnerText );
Enum fileEnum = null;
switch ( sectorType )
{
case SectorType.BootBin:
dict[sectorType].Add( new KeyValuePair<Enum, int>( PatcherLib.Iso.PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, offset ) );
dict[sectorType].Add( new KeyValuePair<Enum, int>( PatcherLib.Iso.PspIso.Sectors.PSP_GAME_SYSDIR_EBOOT_BIN, offset ) );
fileEnum = PatcherLib.Iso.PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN;
break;
case SectorType.FFTPack:
FFTPack.Files fftPackFile = (FFTPack.Files)Enum.Parse( typeof( FFTPack.Files ), sectorNode.SelectSingleNode( "@index" ).InnerText );
dict[sectorType].Add( new KeyValuePair<Enum, int>( fftPackFile, offset ) );
fileEnum = fftPackFile;
break;
case SectorType.Sector:
PatcherLib.Iso.PsxIso.Sectors file = (PatcherLib.Iso.PsxIso.Sectors)Enum.Parse( typeof( PatcherLib.Iso.PsxIso.Sectors ), sectorNode.SelectSingleNode( "@filename" ).InnerText );
dict[sectorType].Add( new KeyValuePair<Enum, int>( file, offset ) );
fileEnum = file;
break;
}
if ( first )
{
//bytes = reader( iso, fileEnum, offset, size );
primaryFile = new KeyValuePair<Enum, int>( fileEnum, offset );
first = false;
}
}
IList<IList<string>> entryNames = GetEntryNames( node.SelectSingleNode( "Sections" ), node.SelectSingleNode( "//Templates" ) );
IList<string> sectionNames = GetSectionNames( node.SelectSingleNode( "Sections" ) );
IList<IList<int>> disallowedEntries;
IList<IDictionary<int,string>> staticEntries;
GetDisallowedEntries( node, sectionLengths.Length, out disallowedEntries, out staticEntries );
Set<byte> terminators = new Set<byte>( new byte[] { 0xFE } );
XmlNode terminatorNode = node.SelectSingleNode( "Terminators" );
if ( terminatorNode != null )
{
foreach ( XmlNode nnn in terminatorNode.SelectNodes( "Terminator" ) )
{
terminators.Add(
byte.Parse( nnn.InnerText, System.Globalization.NumberStyles.HexNumber ) );
}
}
FileInfo fi = new FileInfo
{
Context = context,
DisplayName = displayName,
DisallowedEntries = disallowedEntries.AsReadOnly(),
StaticEntries = staticEntries.AsReadOnly(),
EntryNames = entryNames.AsReadOnly(),
FileType = filetype,
Guid = guid,
Hidden = hidden.AsReadOnly(),
SectionLengths = sectionLengths.AsReadOnly(),
Sectors = new ReadOnlyDictionary<SectorType, IList<KeyValuePair<Enum, int>>>( dict ),
SectionNames = sectionNames,
//.........这里部分代码省略.........
示例6: GetColors
protected static Set<Color> GetColors( Bitmap bmp )
{
Set<Color> result = new Set<Color>( ( a, b ) => a.ToArgb() == b.ToArgb() ? 0 : 1 );
for ( int x = 0; x < bmp.Width; x++ )
{
for ( int y = 0; y < bmp.Height; y++ )
{
result.Add( bmp.GetPixel( x, y ) );
}
}
return result.AsReadOnly();
}
示例7: CreateItemsListFromMSBuild
/// <summary>
/// re-creates the list of project items and the list of available item types
/// </summary>
internal void CreateItemsListFromMSBuild()
{
WorkbenchSingleton.AssertMainThread();
lock (SyncRoot) {
foreach (ProjectItem item in items) {
item.Dispose();
}
items.Clear();
itemsReadOnly = null; // remove readonly variant of item list - will regenerate on next Items call
Set<ItemType> availableFileItemTypes = new Set<ItemType>();
availableFileItemTypes.AddRange(ItemType.DefaultFileItems);
foreach (MSBuild.BuildItem item in project.GetEvaluatedItemsByName("AvailableItemName")) {
availableFileItemTypes.Add(new ItemType(item.Include));
}
// HACK: MSBuild doesn't provide us with these because we don't specify BuildingInsideVisualStudio.
// This is not a problem for SD 4.0 as we're back to using BuildingInsideVisualStudio there (so don't merge this!).
availableFileItemTypes.Add(ItemType.ApplicationDefinition);
availableFileItemTypes.Add(ItemType.Page);
availableFileItemTypes.Add(ItemType.Resource);
availableFileItemTypes.Add(new ItemType("SplashScreen"));
this.availableFileItemTypes = availableFileItemTypes.AsReadOnly();
foreach (MSBuild.BuildItem item in project.EvaluatedItems) {
if (item.IsImported) continue;
items.Add(CreateProjectItem(item));
}
ClearFindFileCache();
}
}
示例8: LoadConfigurationPlatformNamesFromMSBuild
/// <summary>
/// Load available configurations and platforms from the project file
/// by looking at which conditions are used.
/// </summary>
void LoadConfigurationPlatformNamesFromMSBuild()
{
Set<string> configurationNames = new Set<string>();
Set<string> platformNames = new Set<string>();
LoadConfigurationPlatformNamesFromMSBuildInternal(project, configurationNames, platformNames);
LoadConfigurationPlatformNamesFromMSBuildInternal(userProject, configurationNames, platformNames);
if (configurationNames.Count == 0) {
configurationNames.Add("Debug");
configurationNames.Add("Release");
}
if (platformNames.Count == 0) {
platformNames.Add("AnyCPU");
}
this.configurationNames = configurationNames.AsReadOnly();
this.platformNames = platformNames.AsReadOnly();
}