本文整理汇总了C#中System.Item.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Item.GetType方法的具体用法?C# Item.GetType怎么用?C# Item.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Extracting
public override void Extracting(Item item) {
if (item.GetType() == typeof(ContentPropertyData)) {
ContentPropertyData cpd = (ContentPropertyData)item;
foreach (var prop in cpd.Data.Where(x => x.Value != null && macroDataTypes.Contains(x.DataTypeEditor.ToString().ToLower()))) {
string templateText = prop.Value.ToString();
Helpers.MacroResolver resolver = new Helpers.MacroResolver();
resolver.RegisterMacroDependencies = true;
resolver.RegisterNodeDependencies = true;
resolver.context = this.ExecutionContext;
if (templateText.IndexOf("umbraco:macro", StringComparison.OrdinalIgnoreCase) > 0)
templateText = resolver.ReplaceMacroElements(templateText, false, item);
if (templateText.IndexOf("UMBRACO_MACRO", StringComparison.OrdinalIgnoreCase) > 0)
templateText = resolver.ReplaceOldMacroElements(templateText, false, item);
prop.Value = templateText;
}
}
}
示例2: ApplyTest_Four
public void ApplyTest_Four()
{
AbstractItem item = new Item(Category.MEDICAL, true, 11.28m);
Type resultType = typeof(ImportedItem);
item = rule.Apply(item);
Assert.IsNotNull(item);
Assert.AreEqual(resultType, item.GetType());
}
示例3: ApplyTest_Two
public void ApplyTest_Two()
{
AbstractItem item = new Item(Category.OTHERS, false, 11.28m);
Type resultType = typeof(TaxedItem);
item = rule.Apply(item);
Assert.IsNotNull(item);
Assert.AreEqual(resultType, item.GetType());
}
示例4: ExceptionThrownInMethodEmergesIntact
public void ExceptionThrownInMethodEmergesIntact()
{
//Arrange
var item = new Item();
var method = item.GetType().GetMethod("ThrowMethod");
//Act
MethodInvoker.Invoke(method, item, new object[] { 55, "bob" });
}
示例5: Packaging
public override void Packaging(Item item)
{
if (item.GetType() == typeof(ContentPropertyData)) {
ContentPropertyData cpd = (ContentPropertyData)item;
foreach (var prop in cpd.Data.Where(x => x.Value != null && macroDataTypes.Contains(x.DataTypeEditor.ToString().ToLower()))) {
FindResoucesInString(prop.Value.ToString(), item);
}
}
}
示例6: ShouldExecute
public override bool ShouldExecute(Item item, Core.Enums.ItemEvent itemEvent)
{
if (item.GetType() == typeof(ContentPropertyData)) {
ContentPropertyData cpd = (ContentPropertyData)item;
foreach (var cp in cpd.Data)
if (cp.Value != null && macroDataTypes.Contains(cp.DataTypeEditor.ToString().ToLower()))
return true;
}
return false;
}
示例7: PlayAction
public override bool PlayAction(Item item)
{
var chapterItem = item as ChapterItem;
if (chapterItem == null)
{
Logging.Logger.ReportError("Attempt to play invaild chapter item {0}", item.GetType().Name);
return false;
}
Application.CurrentInstance.Play(chapterItem.ParentItem, PositionTicks);
return true;
}
示例8: VoidMethodCanBeCalled
public void VoidMethodCanBeCalled()
{
//Arrange
var item = new Item();
var method = item.GetType().GetMethod("VoidMethod");
//Act
MethodInvoker.Invoke(method, item, new object[] { 55, "bob" });
//Assert
//We expect no assertion
}
示例9: StaticMethodCanBeCalled
public void StaticMethodCanBeCalled()
{
//Arrange
var item = new Item();
var method = item.GetType().GetMethod("StaticStringMethod", BindingFlags.Static | BindingFlags.Public);
//Act
MethodInvoker.Invoke(method, null, new object[] { 55, "bob" });
//Assert
//We expect no assertion
}
示例10: NoParamMethodCanBeCalledWithNoParameterArray
public void NoParamMethodCanBeCalledWithNoParameterArray()
{
//Arrange
var item = new Item();
var method = item.GetType().GetMethod("NoParamMethod");
//Act
var result = MethodInvoker.Invoke(method, item, null) as string;
//Assert
Assert.That(result, Is.EqualTo("No params"));
}
示例11: MemberMethodCanBeCalled
public void MemberMethodCanBeCalled()
{
//Arrange
var item = new Item();
var method = item.GetType().GetMethod("StringMethod");
//Act
var result = MethodInvoker.Invoke(method, item, new object[] { 55, "bob" }) as string;
//Assert
Assert.That(result, Is.EqualTo(item.StringMethod(55, "bob")));
}
示例12: CopyProperties
private static void CopyProperties ( Item dest, Item src )
{
PropertyInfo[] props = src.GetType().GetProperties();
for ( int i = 0; i < props.Length; i++ )
{
try
{
if ( props[i].CanRead && props[i].CanWrite )
props[i].SetValue( dest, props[i].GetValue( src, null ), null );
}
catch
{
}
}
}
示例13: Extracting
public override void Extracting(Item item)
{
if (item != null)
{
var type = item.GetType();
if (type == typeof(ContentPropertyData))
{
var propertyData = (ContentPropertyData)item;
foreach (var property in propertyData.Data.Where(x => DataTypeIds.Contains(x.DataTypeEditor)))
{
if (property != null && property.Value != null)
ExtractingProperty(item, property);
}
}
else
{
ExtractingDataType((DataType)item);
}
}
}
示例14: Packaging
public override void Packaging(Item item)
{
if (item != null)
{
var type = item.GetType();
if (type == typeof(ContentPropertyData))
{
var propertyData = (ContentPropertyData)item;
foreach (var property in propertyData.Data.Where(x => x.DataTypeEditor == DataTypeId))
{
if (property != null && property.Value != null)
PackagingProperty(item, property);
}
}
else
{
PackagingDataType((DataType)item);
}
}
}
示例15: WriteItem
public void WriteItem(StreamWriter op, Item it)
{
op.WriteLine("using System;");
op.WriteLine(" ");
op.WriteLine("namespace Server.Items");
op.WriteLine("{");
op.WriteLine(String.Format(" public class {0} : {1}", ClassName, it.GetType().Name));
op.WriteLine(" {");
op.WriteLine(" [Constructable]");
op.WriteLine(String.Format(" public {0}() : base( {1} )", ClassName, it.ItemID.ToString()));
op.WriteLine(" {");
op.WriteLine(String.Format(" this.Name = \"{0}\";", it.Name));
op.WriteLine(String.Format(" this.Hue = {0};", it.Hue.ToString()));
op.WriteLine(" }");
op.WriteLine(" ");
op.WriteLine(String.Format(" public {0}( Serial serial ) : base( serial )", ClassName));
op.WriteLine(" {");
op.WriteLine(" }");
op.WriteLine(" ");
op.WriteLine(" public override void Serialize( GenericWriter writer )");
op.WriteLine(" {");
op.WriteLine(" base.Serialize( writer );");
op.WriteLine(" ");
op.WriteLine(" writer.Write( (int) 0 ); // version");
op.WriteLine(" }");
op.WriteLine(" ");
op.WriteLine(" public override void Deserialize( GenericReader reader )");
op.WriteLine(" {");
op.WriteLine(" base.Deserialize( reader );");
op.WriteLine(" ");
op.WriteLine(" int version = reader.ReadInt();");
op.WriteLine(" }");
op.WriteLine(" }");
op.WriteLine("}");
op.Flush();
}