本文整理汇总了C#中Resource.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Resource.GetType方法的具体用法?C# Resource.GetType怎么用?C# Resource.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resource
的用法示例。
在下文中一共展示了Resource.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
public static JToken Format(this MediaTypeFormatter formatter, Resource resource)
{
var content = new StringContent(String.Empty);
var type = resource.GetType();
using (var stream = new MemoryStream())
{
formatter.WriteToStreamAsync(type, resource, stream, content, null);
stream.Seek(0, SeekOrigin.Begin);
var serialisedResult = new StreamReader(stream).ReadToEnd();
return JToken.Parse(serialisedResult);
}
}
示例2: LoadTopListForResource
public TopList LoadTopListForResource(Resource res)
{
TopList t = new TopList(this);
if (res.GetType() == typeof(Artist))
{
DataSet topTracks = MakeDataSet("SELECT TOP 5 * FROM track, artist, release WHERE track.artist = artist.id AND track.album = release.id AND artist.identifier = '" + res.Identifier + "' ORDER BY track.popularity DESC");
t.TopTracks = new TrackCollection(this, t, new List<Track>());
t.TopAlbums = new ReleaseCollection(this, new List<Release>());
foreach (DataRow row in topTracks.Tables[0].Rows)
{
Track _track = TrackFromDataRow(row);
t.TopTracks.Add(_track);
}
if (topTracks.Tables[0].Rows.Count == 0)
return null;
return t;
}
if (res.GetType() == typeof(Country))
{
DataSet topTracks = MakeDataSet("SELECT TOP 5 * FROM track, artist, release WHERE track.artist = artist.id AND track.album = release.id ORDER BY track.popularity DESC");
t.TopTracks = new TrackCollection(this, t, new List<Track>());
t.TopAlbums = new ReleaseCollection(this, new List<Release>());
foreach (DataRow row in topTracks.Tables[0].Rows)
{
Track _track = TrackFromDataRow(row);
t.TopTracks.Add(_track);
}
DataSet topAlbums= MakeDataSet("SELECT TOP 100 * FROM artist, release WHERE release.artist = artist.id ORDER BY release.popularity DESC");
foreach (DataRow row in topTracks.Tables[0].Rows)
{
Release _album = ReleaseFromDataRow(row);
t.TopAlbums.Add(_album);
}
if (topAlbums.Tables[0].Rows.Count == 0)
return null;
return t;
}
return null;
}
示例3: SetObjectToInspect
/// <summary>
/// Sets a resource whose GUI is to be displayed in the inspector. Clears any previous contents of the window.
/// </summary>
/// <param name="resourcePath">Resource path relative to the project of the resource to inspect.</param>
private void SetObjectToInspect(String resourcePath)
{
activeResource = ProjectLibrary.Load<Resource>(resourcePath);
if (activeResource == null)
return;
currentType = InspectorType.Resource;
inspectorScrollArea = new GUIScrollArea();
GUI.AddElement(inspectorScrollArea);
inspectorLayout = inspectorScrollArea.Layout;
GUIPanel titlePanel = inspectorLayout.AddPanel();
titlePanel.SetHeight(RESOURCE_TITLE_HEIGHT);
GUILayoutY titleLayout = titlePanel.AddLayoutY();
titleLayout.SetPosition(PADDING, PADDING);
string name = Path.GetFileNameWithoutExtension(resourcePath);
string type = activeResource.GetType().Name;
LocString title = new LocEdString(name + " (" + type + ")");
GUILabel titleLabel = new GUILabel(title);
titleLayout.AddFlexibleSpace();
GUILayoutX titleLabelLayout = titleLayout.AddLayoutX();
titleLabelLayout.AddElement(titleLabel);
titleLayout.AddFlexibleSpace();
GUIPanel titleBgPanel = titlePanel.AddPanel(1);
GUITexture titleBg = new GUITexture(null, EditorStyles.InspectorTitleBg);
titleBgPanel.AddElement(titleBg);
inspectorLayout.AddSpace(COMPONENT_SPACING);
inspectorResource = new InspectorResource();
inspectorResource.panel = inspectorLayout.AddPanel();
var persistentProperties = persistentData.GetProperties(activeResource.UUID);
inspectorResource.inspector = InspectorUtility.GetInspector(activeResource.GetType());
inspectorResource.inspector.Initialize(inspectorResource.panel, activeResource, persistentProperties);
inspectorLayout.AddFlexibleSpace();
}