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; } } }
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()); }
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()); }
public void ExceptionThrownInMethodEmergesIntact() { //Arrange var item = new Item(); var method = item.GetType().GetMethod("ThrowMethod"); //Act MethodInvoker.Invoke(method, item, new object[] { 55, "bob" }); }
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); } } }
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; }
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; }
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 }
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 }
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")); }
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"))); }
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 { } } }
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); } } }
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); } } }
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(); }
public void Equip(Item item) { //TODO: put equipment back into inventory switch(item.GetType().ToString()) { case "Weapon": equipement[(int)equip.Weapon] = item; weapon = (Weapon)item; break; case "Helmet": equipement[(int)equip.Helmet] = item; helmet = (Helmet)item; break; case "Chest": equipement[(int)equip.Chest] = item; chest = (Chest)item; break; case "Pants": equipement[(int)equip.Pants] = item; pants = (Pants)item; break; case "Boots": equipement[(int)equip.Boots] = item; boots = (Boots)item; break; } }
public override bool AttemptedDoubleItemUse(Item target) { if (target.GetType() == typeof (Jew)) { Room.ParseInput("stab jew"); return true; } if (target.GetType() == typeof (Inquisitor)) { Room.ParseInput("stab inquisitor"); return true; } return false; }
public override bool ShouldExecute(Item item, ItemEvent itemEvent) { var type = item.GetType(); if (type == typeof(ContentPropertyData)) { var propertyData = (ContentPropertyData)item; return propertyData.Data.Any(x => x.Value != null && x.DataTypeEditor == DataTypeId) && (itemEvent == ItemEvent.Extracting || itemEvent == ItemEvent.Packaging); } else { var dataType = (DataType)item; return (dataType.DataEditorId == DataTypeId); } }
public IFluentOpcHdaMonitor Monitor(Item opcHdaDataSource) { if (opcHdaDataSource.GetType().FullName == "Citect.Ampla.Connectors.OpcHdaConnector.OpcHdaConnection") { dataSourceFullName = opcHdaDataSource.FullName; } else { string message = string.Format("OpcHdaMonitor - Invalid connection - Monitor({0})", opcHdaDataSource.FullName); Diagnostics.Write(TraceLevel.Warning, message); } return this; }
public void OnMouseDown( UIElement element ) { ////////////////////////////////////////////////////// // ListButtons if ( element.GetType() == typeof( UIListButton ) ) { activeItem = ( ( UIListButton ) element ).Item; if ( activeItem.GetType() == typeof( Powerup ) ) { //aus der Liste in die Shortcuts btnOk.IsEnabled = true; } else { btnOk.IsEnabled = false; } btnCancel.IsEnabled = true; } ////////////////////////////////////////////////////// // OK & Cankel Buttons if ( activeItem != null ) if ( element == btnOk ) { if ( activeItem.GetType() == typeof( Powerup ) ) { //Fressen activeItem player.UsePowerup( ( Powerup ) activeItem ); filteredInventarList.RemoveActiveItem(); player.RemoveItemFromInventar(activeItem); activeItem = null; //Fressen activeItem } } else if ( element == btnCancel ) { Item dropedItem = Item.Get( activeItem.TypeId ); dropedItem.LocationBehavior.Position = player.LocationBehavior.Position; dropedItem.LocationSizing(); if ( dropedItem.GetType() == typeof( Munition ) ) { ( ( Munition ) dropedItem ).Count = player.Inventar[ activeItem.TypeId ]; } Main.MainObject.GameManager.GameState.QuadTreeItems.Add( dropedItem ); filteredInventarList.RemoveActiveItem(); activeItem = player.RemoveItemFromInventar( activeItem ); //filteredInventarList.GenerateFilteredLists( player.Inventar ); } ////////////////////////////////////////////////////// // Shortcut buttons if ( element.GetType() == typeof( UIShortcutButton ) ) { HandleShortcutButtonClick( ( UIShortcutButton ) element ); } }
/// <summary> /// Entfernt ein Item aus dem Inventar /// </summary> /// <param name="item"> Item, dass entfernt wird </param> /// <returns> Typ des Items wird zurückgegeben </returns> public Item RemoveItemFromInventar(Item item) { int anzahl = 1; if (item.GetType() == typeof(Munition)) anzahl = ((Munition)item).Count; return RemoveRangeItemFromInventar(item, anzahl); }
/// <summary> /// Item in das Inventar hinzufügen /// </summary> /// <param name="item"> Item, dass hinzugefügt wird </param> public void AddItemToInventar(Item item) { int anzahl = 1; if (item.GetType() == typeof(Munition)) anzahl = ((Munition)item).Count; AddRangeItemToInventar(item, anzahl); }
public bool historyEquals(Item item) { if (item.GetType() == typeof(FileItem)) { return (item.getItemPath() == this.getItemPath()); } return false; }
public static void RemoveStatus(PlayerMobile from, Item item) { for (int i = from.Quests.Count - 1; i >= 0; i --) { BaseQuest quest = from.Quests[i]; for (int j = quest.Objectives.Count - 1; j >= 0; j --) { if (quest.Objectives[j] is ObtainObjective) { ObtainObjective obtain = (ObtainObjective)quest.Objectives[j]; if (obtain.Obtain != null && obtain.Obtain.IsAssignableFrom(item.GetType())) { obtain.CurProgress -= item.Amount; item.QuestItem = false; from.SendLocalizedMessage(1074769); // An item must be in your backpack (and not in a container within) to be toggled as a quest item. return; } } else if (quest.Objectives[j] is DeliverObjective) { DeliverObjective deliver = (DeliverObjective)quest.Objectives[j]; if (deliver.Delivery != null && deliver.Delivery.IsAssignableFrom(item.GetType())) { from.SendLocalizedMessage(1074813); // You have failed to complete your delivery. DeleteItems(from, deliver.Delivery, deliver.MaxProgress, false); deliver.Fail(); item.Delete(); return; } } } } }
public bool search_for_item_of_subtype(Item iTyp, string subtype) { Weapon.Type weapon_subtype = Weapon.Type.Axe; Armor.Armor_Type armor_subtype = Armor.Armor_Type.Helmet; if (iTyp.GetType() == typeof(Weapon)) weapon_subtype = ((Weapon.Type)Enum.Parse(typeof(Weapon.Type), subtype)); else if (iTyp.GetType() == typeof(Armor)) armor_subtype = ((Armor.Armor_Type)Enum.Parse(typeof(Armor.Armor_Type), subtype)); for (int i = 0; i < inventory.Count; i++) { if (inventory[i].GetType() == iTyp.GetType()) { if (inventory[i] is Weapon && ((Weapon)inventory[i]).get_my_weapon_type() == weapon_subtype) return true; else if (inventory[i] is Armor && ((Armor)inventory[i]).what_armor_type() == armor_subtype) return true; } } if ((main_hand != null && main_hand.get_my_weapon_type() == weapon_subtype) || (off_hand != null && off_hand.get_my_weapon_type() == weapon_subtype)) return true; if ((helm != null && helm.what_armor_type() == armor_subtype) || (over_armor != null && over_armor.what_armor_type() == armor_subtype) || (under_armor != null && under_armor.what_armor_type() == armor_subtype)) return true; return false; }
private TreeNode addNode(TreeNode parentNode, Item child) { TreeNode tn = parentNode.Nodes.Add(child.Name, child.Name, child.GetType().Name.Replace("Item",""), child.GetType().Name.Replace("Item","")); tn.Tag = child; return tn; }
public virtual bool IsObjective(Item item) { if (this.m_Obtain == null) return false; if (this.m_Obtain.IsAssignableFrom(item.GetType())) return true; return false; }
/* Persistence */ public string SaveItem(Item item, string providerDirectory, string revisionAlias) { string itemPath = Helpers.LocalIO.ItemFilePath(item, providerDirectory, revisionAlias); //serialization of revision //ADDED for 2.1, if stripResourcesFromCourierFiles is true if (Core.Settings.stripResourcesFromCourierFiles) { foreach (var r in item.Resources) r.ResourceContents = null; } Helpers.LocalIO.SaveFile(itemPath, Umbraco.Courier.Core.Serialization.Serializer.Serialize(item, item.GetType())); return itemPath; }
ItemEditor convertItem( Item oldItem ) { if( oldItem is TextureItem ) { return convertTextureItem( oldItem as TextureItem ) ; } if( oldItem is RectangleItem ) { return convertRectangleItem( oldItem as RectangleItem ) ; } if( oldItem is CircleItem ) { return convertCircleItem( oldItem as CircleItem ) ; } if( oldItem is PathItem ) { return convertPathItem( oldItem as PathItem ) ; } throw new NotSupportedException( @"Cannot convert a legacy item of type '{0}' as it is not a supported (or recognised) type.".FormatWith( oldItem.GetType( ) ) ) ; }
public RepositoryActionResponse ExtractItem(Item item, bool overWrite) { byte[] obj = Umbraco.Courier.Core.Serialization.Serializer.Serialize(item, item.GetType()); JupiterWebservice jws = new JupiterWebservice(Url); var reply = jws.Extract(this.SessionKey, obj, item.ItemId, true, "user", "pass"); return reply; }