本文整理汇总了C#中System.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# System.GetName方法的具体用法?C# System.GetName怎么用?C# System.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System.GetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureResources
public static void EnsureResources(System.Reflection.Assembly assembly, string dataPath)
{
var contentIdentifier = assembly.GetName().Name + ".Content.";
var scriptIdentifier = assembly.GetName().Name + ".Scripts.";
var dataIdentifier = assembly.GetName().Name + ".App_Data.";
foreach (var resource in assembly.GetManifestResourceNames()) {
if (resource.StartsWith (contentIdentifier)) {
// Treat Content resources as though every "." except the last is a directory separator
var path = resource.Substring (contentIdentifier.Length);
var lastDot = path.LastIndexOf (".");
if (lastDot > -1)
path = path.Substring (0, lastDot).Replace ('.', Path.DirectorySeparatorChar) + "." + path.Substring (lastDot + 1);
else
path = path.Replace('.', Path.DirectorySeparatorChar);
path = Path.Combine (dataPath, path);
EnsureResource (assembly, path, resource);
} else if (resource.StartsWith (scriptIdentifier)) {
var path = Path.Combine (dataPath, resource.Substring (scriptIdentifier.Length));
EnsureResource (assembly, path, resource);
} else if (resource.StartsWith (dataIdentifier)) {
var path = Path.Combine (dataPath, resource.Substring (dataIdentifier.Length));
EnsureResource (assembly, path, resource);
}
}
}
示例2: TryReadValues
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
public static void TryReadValues(this CharacterInventoryTable source, System.Data.IDataRecord dataRecord)
{
for (int i = 0; i < dataRecord.FieldCount; i++)
{
switch (dataRecord.GetName(i))
{
case "character_id":
source.CharacterID = (DemoGame.CharacterID)(DemoGame.CharacterID)dataRecord.GetInt32(i);
break;
case "item_id":
source.ItemID = (DemoGame.ItemID)(DemoGame.ItemID)dataRecord.GetInt32(i);
break;
case "slot":
source.Slot = (NetGore.InventorySlot)(NetGore.InventorySlot)dataRecord.GetByte(i);
break;
}
}
}
示例3: TryReadValues
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
public static void TryReadValues(this ShopTable source, System.Data.IDataRecord dataRecord)
{
for (int i = 0; i < dataRecord.FieldCount; i++)
{
switch (dataRecord.GetName(i))
{
case "can_buy":
source.CanBuy = (System.Boolean)(System.Boolean)dataRecord.GetBoolean(i);
break;
case "id":
source.ID = (NetGore.Features.Shops.ShopID)(NetGore.Features.Shops.ShopID)dataRecord.GetUInt16(i);
break;
case "name":
source.Name = (System.String)(System.String)dataRecord.GetString(i);
break;
}
}
}
示例4: TryReadValues
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
public static void TryReadValues(this WorldStatsCountShopBuyTable source, System.Data.IDataRecord dataRecord)
{
for (int i = 0; i < dataRecord.FieldCount; i++)
{
switch (dataRecord.GetName(i))
{
case "count":
source.Count = (System.Int32)(System.Int32)dataRecord.GetInt32(i);
break;
case "last_update":
source.LastUpdate = (System.DateTime)(System.DateTime)dataRecord.GetDateTime(i);
break;
case "shop_id":
source.ShopID = (NetGore.Features.Shops.ShopID)(NetGore.Features.Shops.ShopID)dataRecord.GetUInt16(i);
break;
}
}
}
示例5: TryReadValues
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
public static void TryReadValues(this EventCountersItemTemplateTable source, System.Data.IDataRecord dataRecord)
{
for (int i = 0; i < dataRecord.FieldCount; i++)
{
switch (dataRecord.GetName(i))
{
case "counter":
source.Counter = (System.Int64)(System.Int64)dataRecord.GetInt64(i);
break;
case "item_template_event_counter_id":
source.ItemTemplateEventCounterId = (System.Byte)(System.Byte)dataRecord.GetByte(i);
break;
case "item_template_id":
source.ItemTemplateID = (DemoGame.ItemTemplateID)(DemoGame.ItemTemplateID)dataRecord.GetUInt16(i);
break;
}
}
}
示例6: TryReadValues
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
public static void TryReadValues(this EventCountersShopTable source, System.Data.IDataRecord dataRecord)
{
for (int i = 0; i < dataRecord.FieldCount; i++)
{
switch (dataRecord.GetName(i))
{
case "counter":
source.Counter = (System.Int64)(System.Int64)dataRecord.GetInt64(i);
break;
case "shop_event_counter_id":
source.ShopEventCounterId = (System.Byte)(System.Byte)dataRecord.GetByte(i);
break;
case "shop_id":
source.ShopID = (NetGore.Features.Shops.ShopID)(NetGore.Features.Shops.ShopID)dataRecord.GetUInt16(i);
break;
}
}
}
示例7: TryReadValues
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
public static void TryReadValues(this WorldStatsCountItemBuyTable source, System.Data.IDataRecord dataRecord)
{
for (int i = 0; i < dataRecord.FieldCount; i++)
{
switch (dataRecord.GetName(i))
{
case "count":
source.Count = (System.Int32)(System.Int32)dataRecord.GetInt32(i);
break;
case "item_template_id":
source.ItemTemplateID = (DemoGame.ItemTemplateID)(DemoGame.ItemTemplateID)dataRecord.GetUInt16(i);
break;
case "last_update":
source.LastUpdate = (System.DateTime)(System.DateTime)dataRecord.GetDateTime(i);
break;
}
}
}
示例8: TryReadValues
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
public static void TryReadValues(this AccountCharacterTable source, System.Data.IDataRecord dataRecord)
{
for (int i = 0; i < dataRecord.FieldCount; i++)
{
switch (dataRecord.GetName(i))
{
case "account_id":
source.AccountID = (DemoGame.AccountID)(DemoGame.AccountID)dataRecord.GetInt32(i);
break;
case "character_id":
source.CharacterID = (DemoGame.CharacterID)(DemoGame.CharacterID)dataRecord.GetInt32(i);
break;
case "time_deleted":
source.TimeDeleted = (System.Nullable<System.DateTime>)(System.Nullable<System.DateTime>)(dataRecord.IsDBNull(i) ? (System.Nullable<System.DateTime>)null : dataRecord.GetDateTime(i));
break;
}
}
}
示例9: TryReadValues
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
public static void TryReadValues(this EventCountersUserTable source, System.Data.IDataRecord dataRecord)
{
for (int i = 0; i < dataRecord.FieldCount; i++)
{
switch (dataRecord.GetName(i))
{
case "counter":
source.Counter = (System.Int64)(System.Int64)dataRecord.GetInt64(i);
break;
case "user_event_counter_id":
source.UserEventCounterId = (System.Byte)(System.Byte)dataRecord.GetByte(i);
break;
case "user_id":
source.UserID = (DemoGame.CharacterID)(DemoGame.CharacterID)dataRecord.GetInt32(i);
break;
}
}
}
示例10: buildTreeFromAssembly
public void buildTreeFromAssembly(System.Reflection.Assembly CurrentAsm)
{
//code from Platt's example
TreeNode BaseNode;
BaseNode = treeViewAssembly.Nodes.Add("Assy:" + CurrentAsm.GetName().ToString());
BaseNode.Tag = CurrentAsm;
// Enumerate each type contained in the assembly
foreach (System.Type ThisType in CurrentAsm.GetTypes())
{
TreeNode MyNode;
MyNode = BaseNode.Nodes.Add(ThisType.ToString() + " : " + ThisType.BaseType.ToString());
MyNode.Tag = ThisType;
// Enumerate all the members of this type
// Add each member to the tree
foreach (System.Reflection.MemberInfo Member in
ThisType.GetMembers(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static))
{
TreeNode typenode = MyNode.Nodes.Add(Member.MemberType.ToString() + " : " + Member.Name);
typenode.Tag = Member;
}
}
}
示例11: TryReadValues
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
public static void TryReadValues(this CharacterSkillTable source, System.Data.IDataRecord dataRecord)
{
for (int i = 0; i < dataRecord.FieldCount; i++)
{
switch (dataRecord.GetName(i))
{
case "character_id":
source.CharacterID = (DemoGame.CharacterID)(DemoGame.CharacterID)dataRecord.GetInt32(i);
break;
case "skill_id":
source.SkillID = (DemoGame.SkillType)(DemoGame.SkillType)dataRecord.GetByte(i);
break;
case "time_added":
source.TimeAdded = (System.DateTime)(System.DateTime)dataRecord.GetDateTime(i);
break;
}
}
}
示例12: TryReadValues
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
public static void TryReadValues(this QuestRequireStartItemTable source, System.Data.IDataRecord dataRecord)
{
for (int i = 0; i < dataRecord.FieldCount; i++)
{
switch (dataRecord.GetName(i))
{
case "amount":
source.Amount = (System.Byte)(System.Byte)dataRecord.GetByte(i);
break;
case "item_template_id":
source.ItemTemplateID = (DemoGame.ItemTemplateID)(DemoGame.ItemTemplateID)dataRecord.GetUInt16(i);
break;
case "quest_id":
source.QuestID = (NetGore.Features.Quests.QuestID)(NetGore.Features.Quests.QuestID)dataRecord.GetUInt16(i);
break;
}
}
}
示例13: GetVersion
///<summary>
///Version info.
///</summary>
/// <param name="assembly">Assembly</param>
/// <remarks><para>Version of this assembly.</para>
/// <para>0.0.0.0 if wrong.</para></remarks>
public static Version GetVersion(System.Reflection.Assembly assembly) {
if (assembly != null) {
Version version = assembly.GetName().Version;
if (version != null) {
return version;
}
}
return new Version(0, 0, 0, 0);
}
示例14: FormatApplicationName
private string FormatApplicationName(System.Reflection.Assembly asm)
{
object[] customAttributes = asm.GetCustomAttributes(typeof(ApplicationNameAttribute), true);
if (customAttributes.Length > 0)
{
return ((ApplicationNameAttribute) customAttributes[0]).Value;
}
return asm.GetName().Name;
}
示例15: GetName
///<summary>
///Name info.
///</summary>
/// <param name="assembly">Assembly</param>
/// <remarks>Unknown name if wrong.</remarks>
public static string GetName(System.Reflection.Assembly assembly) {
if (assembly != null) {
string name = assembly.GetName().Name;
if (name != null) {
return name;
}
}
return "Unknown name";
}