當前位置: 首頁>>代碼示例>>C#>>正文


C# Item.GetType方法代碼示例

本文整理匯總了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;
                }

            }
        }
開發者ID:jayvin,項目名稱:Courier,代碼行數:25,代碼來源:MacroParameters.cs

示例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());
 }
開發者ID:linzhixiong,項目名稱:.net,代碼行數:8,代碼來源:TaxedRuleTest.cs

示例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());
 }
開發者ID:linzhixiong,項目名稱:.net,代碼行數:8,代碼來源:TaxedRuleTest.cs

示例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" });
        }
開發者ID:jamie-davis,項目名稱:ConsoleTools,代碼行數:9,代碼來源:MethodInvoker.cs

示例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);
         }
     }
 }
開發者ID:jayvin,項目名稱:Courier,代碼行數:9,代碼來源:Images.cs

示例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;
 }
開發者ID:jayvin,項目名稱:Courier,代碼行數:10,代碼來源:Images.cs

示例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;
        }
開發者ID:bartonnen,項目名稱:MediaBrowser.Classic,代碼行數:12,代碼來源:Chapter.cs

示例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
        }
開發者ID:jamie-davis,項目名稱:ConsoleTools,代碼行數:12,代碼來源:MethodInvoker.cs

示例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
        }
開發者ID:jamie-davis,項目名稱:ConsoleTools,代碼行數:12,代碼來源:MethodInvoker.cs

示例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"));
        }
開發者ID:jamie-davis,項目名稱:ConsoleTools,代碼行數:12,代碼來源:MethodInvoker.cs

示例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")));
        }
開發者ID:jamie-davis,項目名稱:ConsoleTools,代碼行數:12,代碼來源:MethodInvoker.cs

示例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
				{
				}
			}
		}
開發者ID:greeduomacro,項目名稱:last-wish,代碼行數:16,代碼來源:CloneMe.cs

示例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);
                }
            }
        }
開發者ID:jayvin,項目名稱:Courier,代碼行數:21,代碼來源:MultiPropertyDataResolverProvider.cs

示例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);
                }
            }
        }
開發者ID:jayvin,項目名稱:Courier,代碼行數:21,代碼來源:PropertyDataResolverProvider.cs

示例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();
 }
開發者ID:FreeReign,項目名稱:aosredux,代碼行數:36,代碼來源:GenScriptv1_2.cs


注:本文中的System.Item.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。