本文整理汇总了C#中IBlock.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IBlock.GetType方法的具体用法?C# IBlock.GetType怎么用?C# IBlock.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBlock
的用法示例。
在下文中一共展示了IBlock.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Invoke
public override void Invoke(IBlock block)
{
Block = block;
if (DateTime.Now > _readyTime)
{
PerformRandomAction();
if (_actionWasPerformed)
{
try
{
VerifyState();
}
catch
{
Logs.Add("Monkey Verification failed at " + Block.GetType());
throw;
}
Probability = _baseProbability;
_readyTime = DateTime.Now + _interval;
}
else
{
Probability += _baseProbability < 0.1 ? 0 : (1 - Probability) / 3;
}
}
}
示例2: AddFaceIfSolid
private void AddFaceIfSolid(IBlock block, IntVector3 direction)
{
if (block.GetType() == typeof(AirBlock)) return;
if (!block.GetAdjacentBlockIn(direction).Info.IsSolidIn(-direction))
{
var offsets = block.Info.GetFaceVertexOffsets(direction);
if (offsets != null)
{
AddFaceVertices(block, offsets);
AddFaceTriangles();
AddFaceUvs(block, direction);
}
}
}
示例3: GetServices
internal static Dictionary<string, MethodBase> GetServices(IBlock instance, string name)
{
Dictionary<string, MethodBase> serviceMethods = new Dictionary<string, MethodBase>();
foreach (MethodBase method in instance.GetType().GetMethods())
{
object[] attrs = method.GetCustomAttributes(typeof(BlockServiceAttribute), true);
if (attrs.Length == 1 && (method.Name == name || name == null))
{
if ( serviceMethods.ContainsKey(method.Name) ) throw new Exception("Invalid Service: Repeated name: "+method.Name);
serviceMethods.Add(method.Name, method);
}
}
return serviceMethods;
}
示例4: GetBlockInfo
internal static string GetBlockInfo(IBlock blockBase)
{
//[BlockComments("Some comments")]
//[BlockCompany("mahdix")]
//[BlockFriendlyName("Friend")]
//[BlockReleaseDate("121212")]
object[] attributes = blockBase.GetType().GetCustomAttributes(true);
BlockHandle blockId = null;
string comments = null;
string company = null;
string friendlyName = null;
string releaseDate = null;
foreach (object item in attributes)
{
if (item is BlockHandleAttribute) blockId = (item as BlockHandleAttribute).BlockId;
if (item is BlockCommentsAttribute) comments = (item as BlockCommentsAttribute).Text;
if (item is BlockCompanyAttribute) company = (item as BlockCompanyAttribute).Text;
if (item is BlockFriendlyNameAttribute) friendlyName = (item as BlockFriendlyNameAttribute).Text;
if (item is BlockReleaseDateAttribute) releaseDate = (item as BlockReleaseDateAttribute).Date;
}
StringBuilder sb = new StringBuilder();
sb.Append("Unique Handle: ");
sb.Append(blockBase.Id);
sb.Append("\r\n");
sb.Append("Identifier: ");
if(blockId != null ) sb.Append(blockId.ToString());
sb.Append("\r\n");
sb.Append("Friendly Name: ");
if (friendlyName != null) sb.Append(friendlyName);
sb.Append("\r\n");
sb.Append("Comments: ");
if (comments != null) sb.Append(comments);
sb.Append("\r\n");
sb.Append("Company: ");
if (company != null) sb.Append(company);
sb.Append("\r\n");
sb.Append("Release Date: ");
if (releaseDate != null) sb.Append(releaseDate);
sb.Append("\r\n");
return sb.ToString();
}
示例5: getBlockId
private BlockHandle getBlockId(IBlock block)
{
object[] result = block.GetType().GetCustomAttributes(typeof(BlockHandleAttribute), true);
if (result.Length == 1)
{
return (result[0] as BlockHandleAttribute).BlockId;
}
throw new Exception("BlockId has problem");
}