Perceived Class

Defines a file's perceived type based on its extension.

public sealed class Perceived

Example

// Get perceived type for a file
var perceived = Perceived.GetPerceivedType(".txt");
Assert.Equal(PerceivedType.Text, perceived.PerceivedType);
Assert.NotEqual(PerceivedTypeSource.Undefined, perceived.PerceivedTypeSource); // e.g. SoftCoded, NativeSupport

// Add custom perceived types
Perceived.AddPerceived(".myext", PerceivedType.Text);
Assert.Equal(PerceivedType.Text, Perceived.GetPerceivedType("file.myext").PerceivedType);

// Add default perceived types for common development file extensions
Perceived.AddDefaultPerceivedTypes();
Assert.Equal(PerceivedType.Text, Perceived.GetPerceivedType("Program.cs").PerceivedType);

Properties

NameDescription
ExtensionGets the file's extension.
PerceivedTypeIndicates the normalized perceived type.
PerceivedTypeSourceIndicates the source of the perceived type information.

Extension

Perceived.cs

Gets the file's extension.

public string Extension { get; }

Property value

string The file's extension.

PerceivedType

Perceived.cs

Indicates the normalized perceived type.

public PerceivedType PerceivedType { get; }

Property value

PerceivedType The normalized perceived type.

PerceivedTypeSource

Perceived.cs

Indicates the source of the perceived type information.

public PerceivedTypeSource PerceivedTypeSource { get; }

Property value

PerceivedTypeSource the source of the perceived type information.

Methods

NameDescription
AddDefaultPerceivedTypes()Adds default perceived types for common development file extensions such as .cs, .html, .xaml, .sln, etc.
AddPerceived(string, PerceivedType)Adds a perceived instance to the list.
GetPerceivedType(string)Gets a file's perceived type based on its extension.
ToString()Returns a String that represents the current Object.

AddDefaultPerceivedTypes()

Perceived.cs

Adds default perceived types for common development file extensions such as .cs, .html, .xaml, .sln, etc.

public static void AddDefaultPerceivedTypes()

AddPerceived(string, PerceivedType)

Perceived.cs

Adds a perceived instance to the list.

public static Perceived AddPerceived(string extension, PerceivedType type)

Parameters

extension string
The file extension. May not be null.
type PerceivedType
The perceived type.

Returns

Perceived

GetPerceivedType(string)

Perceived.cs
  • Supported on windows5.1.2600

Gets a file's perceived type based on its extension.

[SupportedOSPlatform("windows5.1.2600")]
public static Perceived GetPerceivedType(string fileName)

Parameters

fileName string
The file name. May not be null.

Returns

Perceived An instance of the PerceivedType type.

ToString()

Perceived.cs

Returns a String that represents the current Object.

public override string ToString()

Returns

string A String that represents the current Object.