public Pkcs11Signature(string libraryPath, ulong slotId) { Pkcs11InteropFactories factories = new Pkcs11InteropFactories(); pkcs11Library = factories.Pkcs11LibraryFactory.LoadPkcs11Library(factories, libraryPath, AppType.MultiThreaded); slot = pkcs11Library.GetSlotList(SlotsType.WithOrWithoutTokenPresent).Find(slot => slot.SlotId == slotId); }
public void GetEdges(SlotReference s, List <IEdge> foundEdges) { var node = GetNodeFromGuid(s.nodeGuid); if (node == null) { return; } ISlot slot = node.FindSlot <ISlot>(s.slotId); List <IEdge> candidateEdges; if (!m_NodeEdges.TryGetValue(s.nodeGuid, out candidateEdges)) { return; } foreach (var edge in candidateEdges) { var cs = slot.isInputSlot ? edge.inputSlot : edge.outputSlot; if (cs.nodeGuid == s.nodeGuid && cs.slotId == s.slotId) { foundEdges.Add(edge); } } }
/// <summary> /// Drop the stacked item to defined location. /// </summary> public void ContainerToGround(ISlot slotSource, Location sqm) { #region " Packet Structure Analyze " //--------------------------------------------------------- //DROP ITEM //--------------------------------------------------------- //00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 //--------------------------------------------------------- //0F 00 78 FF FF 40 00 00 25 0B 00 34 7D CC 7D 07 01 //SZ ID BP ST ITEMD ST [ X ] [ Y ] ZZ QT //--------------------------------------------------------- #endregion var Builder = new PacketBuilder(0x78, Connection); Builder.Append(0xFF); Builder.Append(0xFF); Builder.Append(slotSource.Container.Position); Builder.Append(0x00); Builder.Append(slotSource.Position); Builder.Append(slotSource.Item.Id); Builder.Append(slotSource.Position); Builder.Append(sqm.X); Builder.Append(sqm.Y); Builder.Append(sqm.Z); Builder.Append(slotSource.Item.Count); Connection.Send(Builder.GetPacket()); }
public void _03_SetAttributeValueTest() { using (IPkcs11 pkcs11 = Settings.Factories.Pkcs11Factory.CreatePkcs11(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11); // Open RW session using (ISession session = slot.OpenSession(SessionType.ReadWrite)) { // Login as normal user session.Login(CKU.CKU_USER, Settings.NormalUserPin); // Create object IObjectHandle objectHandle = Helpers.CreateDataObject(session); // Prepare list of attributes we want to set List <IObjectAttribute> objectAttributes = new List <IObjectAttribute>(); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.CreateObjectAttribute(CKA.CKA_LABEL, Settings.ApplicationName + "_2")); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.CreateObjectAttribute(CKA.CKA_VALUE, "New data object content")); // Set attributes session.SetAttributeValue(objectHandle, objectAttributes); // Do something interesting with modified object session.DestroyObject(objectHandle); session.Logout(); } } }
public void RemoveItem(IGameItem itemToBeRemoved) { ISlot currentSlot = this.SlotList.FirstOrDefault(x => x.GameItem == itemToBeRemoved); currentSlot.GameItem = null; currentSlot.IsEmpty = true; }
public SlotList Append(ISlot slot) { if (slot == null) { return(this); } if (!nonEmpty) { return(new SlotList(slot)); } if (this.tail == NIL) { return(new SlotList(slot).Prepend(this.Head)); } SlotList wholeClone = new SlotList(this.Head); SlotList subClone = wholeClone; SlotList current = this.tail; while (current.nonEmpty) { subClone = subClone.tail = new SlotList(current.Head); current = current.tail; } subClone.tail = new SlotList(slot); return(wholeClone); }
public static void DrawBase(ISlot slot) { if (slot != null) { var image = new BitmapImage(new Uri(slot.SlotImageSource, UriKind.Relative)); var gif = new BitmapImage(new Uri(slot.SlotInfoGif, UriKind.Relative)); var header = slot.SlotHeader; var info = slot.SlotInfo; Type slotType = slot.GetType(); var imageField = slotType.GetField("SlotImage", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(slot); imageField.GetType().GetProperty("Source", BindingFlags.Public | BindingFlags.Instance).SetValue(imageField, image); var gifField = slotType.GetField("InfoGif", BindingFlags.NonPublic | BindingFlags.Instance); ImageBehavior.SetAnimatedSource((Image)gifField.GetValue(slot), gif); var nameField = slotType.GetField("SlotName", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(slot); nameField.GetType().GetProperty("Text", BindingFlags.Public | BindingFlags.Instance).SetValue(nameField, header); var infoField = slotType.GetField("TextInformation", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(slot); infoField.GetType().GetProperty("Text", BindingFlags.Public | BindingFlags.Instance).SetValue(infoField, info); } else { return; } }
/// <summary></summary> private void AddKeysToToken(ISlot Slot, PgpToken Token) { byte[] abExponent, abId, abModulus; bool isEncrypt, isVerify; ulong vKeyType; PgpKeyFlags.nFlags eKeyFlags; ISlotInfo SlotInfo; List <IObjectAttribute> ltAttributes, ltSearchTemplate; List <IObjectHandle> ltPublicKeys; if (Slot != null) { SlotInfo = Slot.GetSlotInfo(); using (ISession Session = Slot.OpenSession(SessionType.ReadOnly)) { ltSearchTemplate = new List <IObjectAttribute> { Session.Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, CKO.CKO_PUBLIC_KEY) }; ltPublicKeys = Session.FindAllObjects(ltSearchTemplate); foreach (IObjectHandle PublicKey in ltPublicKeys) { ltAttributes = Session.GetAttributeValue(PublicKey, new List <CKA> { CKA.CKA_ENCRYPT, CKA.CKA_ID, CKA.CKA_KEY_TYPE, CKA.CKA_MODULUS, CKA.CKA_PUBLIC_EXPONENT, CKA.CKA_VERIFY }); isEncrypt = ltAttributes[0].GetValueAsBool(); abId = ltAttributes[1].GetValueAsByteArray(); vKeyType = ltAttributes[2].GetValueAsUlong(); abModulus = ltAttributes[3].GetValueAsByteArray(); abExponent = ltAttributes[4].GetValueAsByteArray(); isVerify = ltAttributes[5].GetValueAsBool(); if ((CKK)vKeyType == CKK.CKK_RSA) { if (!isEncrypt && isVerify) { eKeyFlags = PgpKeyFlags.nFlags.Certify | PgpKeyFlags.nFlags.Sign; } else if (isEncrypt && !isVerify) { eKeyFlags = PgpKeyFlags.nFlags.Encrypt; } else if (isEncrypt && isVerify) { eKeyFlags = PgpKeyFlags.nFlags.Authenticate; } else { eKeyFlags = PgpKeyFlags.nFlags.None; } Token.AddPublicKey(SlotInfo, abId, eKeyFlags, abModulus, abExponent); } } } } }
public void _01_GetAttributeValueTest() { using (IPkcs11 pkcs11 = Settings.Factories.Pkcs11Factory.CreatePkcs11(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11); // Open RW session using (ISession session = slot.OpenSession(SessionType.ReadWrite)) { // Login as normal user session.Login(CKU.CKU_USER, Settings.NormalUserPin); // Create object IObjectHandle objectHandle = Helpers.CreateDataObject(session); // Prepare list of empty attributes we want to read List <CKA> attributes = new List <CKA>(); attributes.Add(CKA.CKA_LABEL); attributes.Add(CKA.CKA_VALUE); // Get value of specified attributes List <IObjectAttribute> objectAttributes = session.GetAttributeValue(objectHandle, attributes); // Do something interesting with attribute value Assert.IsTrue(objectAttributes[0].GetValueAsString() == Settings.ApplicationName); session.DestroyObject(objectHandle); session.Logout(); } } }
/// <summary> /// Send the ammount of stacked Item to defined Container Slot. /// </summary> public void ContainerToContainer(ISlot fromSlot, ISlot toSlot) { #region " Packet Structure Analyze " //--------------------------------------------------- // SZ ID BP ST ITM ST BP ST QT // 0F 00 78 FF FF 41 00 02 7E 0C 02 FF FF 40 00 02 01 //--------------------------------------------------- // 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 //--------------------------------------------------- #endregion var Builder = new PacketBuilder(0x78, Connection); Builder.Append(0xFF); Builder.Append(0xFF); Builder.Append(fromSlot.Container.Position); Builder.Append(0x00); Builder.Append(fromSlot.Position); Builder.Append(fromSlot.Item.Id); Builder.Append(fromSlot.Position); Builder.Append(0xFF); Builder.Append(0xFF); Builder.Append(toSlot.Container.Position); Builder.Append(0x00); Builder.Append(toSlot.Position); Builder.Append(fromSlot.Item.Count); Connection.Send(Builder.GetPacket()); }
public void _01_CreateDestroyObjectTest() { using (IPkcs11Library pkcs11Library = Settings.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11Library); // Open RW session using (ISession session = slot.OpenSession(SessionType.ReadWrite)) { // Login as normal user session.Login(CKU.CKU_USER, Settings.NormalUserPin); // Prepare attribute template of new data object List <IObjectAttribute> objectAttributes = new List <IObjectAttribute>(); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, CKO.CKO_DATA)); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.Create(CKA.CKA_TOKEN, true)); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.Create(CKA.CKA_APPLICATION, Settings.ApplicationName)); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.Create(CKA.CKA_LABEL, Settings.ApplicationName)); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.Create(CKA.CKA_VALUE, "Data object content")); // Create object IObjectHandle objectHandle = session.CreateObject(objectAttributes); // Do something interesting with new object // Destroy object session.DestroyObject(objectHandle); session.Logout(); } } }
private void OnItemDropped(ISlot from, List <GameObject> objectsHit) { // Outside inventory if (objectsHit.Count == 0) { OnItemRemove?.Invoke(from.StoredItem, from.SlotCount); from.DropAll(); return; } for (int i = 0, n = objectsHit.Count; i < n; i++) { // Dropped on the inventory grid if (objectsHit[i].TryGetComponent(out IInventorySystem _)) { return; } // Dropped on inventory slot if (objectsHit[i].TryGetComponent(out ISlot to)) { MoveItem(from, to); return; } } // Outside inventory from.DropAll(); OnItemRemove?.Invoke(from.StoredItem, from.SlotCount); }
public void L02TestLiteral_Connectivity() { //Create two literal nodes & Connect them string commands = @" ClearSelection CreateCodeBlockNode|d:335.0|d:169.0|s:100 CreateIdentifierNode|d:534.0|d:184.0 MouseDown|e:System.Windows.Input.MouseButton,Left|u:0x10000001|e:DesignScriptStudio.Graph.Core.NodePart,OutputSlot|i:0|e:System.Windows.Input.ModifierKeys,None MouseUp|e:System.Windows.Input.MouseButton,Left|u:0x10000002|e:DesignScriptStudio.Graph.Core.NodePart,InputSlot|i:0|e:System.Windows.Input.ModifierKeys,None"; GraphController controller = new GraphController(null, null); bool result = controller.RunCommands(commands); Assert.AreEqual(true, result); Assert.AreEqual(2, controller.GetVisualNodes().Count);//output slot IVisualNode node = controller.GetVisualNode(0x10000001); IVisualNode node2 = controller.GetVisualNode(0x10000002); Assert.NotNull(new object[] { node, node2 }); // check if node create Assert.AreEqual(NodeType.Literal, node.VisualType); // check if literal node Assert.AreEqual(null, node.GetInputSlots()); //output slot Assert.AreEqual(3, controller.GetSlots().Count); //output slot // get slots uint outputSlotId = node.GetOutputSlot(0); ISlot outputSlot = controller.GetSlot(outputSlotId); uint connectingSlotId = node2.GetInputSlot(0); ISlot connectingSlot = controller.GetSlot(connectingSlotId); uint[] connecting = connectingSlot.ConnectingSlots; Assert.AreEqual(connectingSlotId, outputSlot.ConnectingSlots[0]); }
public Alpha2(GameObject player) : base(player) { Performance.HealthPoints = 200f; Performance.MaxHealthPoints = 200f; Performance.UserAccelerating = 0.3f; Performance.Braking = 1.5f; Performance.Steering = 0.1f; Performance.Acceleration = 80.0f; Performance.MaxSpeed = 6f; Performance.Mass = 9; Performance.CenterOfMass = new Vector3(0, 0.5f); Slots = new ISlot[] { new WeaponSlot { Position = new Vector2(0, -0.4f) } }; //Handling = new FullRigidBodyCarPhysics(player, this); Handling = new ArcadeCarPhysics(player, this); Firing = new PlayerFiring(player.transform, this); Destroyer = new OverloadVehicleDestroyer(player, this, 7.0f); AddWeapon(ModulesController.Instance.Weapons.First(w => w is PistolA)); }
public static void AddSlot <T>(ISlot slot) where T : IEntityInventory { if (!Get <T>().Slots.ContainsKey(slot.ObjectId)) { Get <T>().Slots.Add(slot.ObjectId, slot); } }
public void TestGetSlotPosition() { IGraphController controller = new GraphController(null); controller.DoCreateFunctionNode(1, 1, "", "Function", "int,int"); List <IVisualNode> nodes = ((GraphController)controller).GetVisualNodes(); VisualNode node = ((VisualNode)nodes[0]); uint slotId = node.GetOutputSlot(0); ISlot slot = ((GraphController)controller).GetSlot(slotId); System.Windows.Point pt = node.GetSlotPosition((Slot)slot); bool result = false; if (pt != null) { result = true; } Assert.AreEqual(true, result); slot = null; Assert.Throws <ArgumentNullException>(() => { pt = node.GetSlotPosition((Slot)slot); }); }
public void _HL_20_01_EncryptAndDecrypt_Gost28147_89_ECB_Test() { using (var pkcs11 = Settings.Factories.RutokenPkcs11LibraryFactory.LoadRutokenPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11); // Open RW session using (ISession session = slot.OpenSession(SessionType.ReadWrite)) { // Login as normal user session.Login(CKU.CKU_USER, Settings.NormalUserPin); // Generate symetric key IObjectHandle generatedKey = Helpers.GenerateGost28147_89Key(session); var mechanism = Settings.Factories.MechanismFactory.Create(CKM.CKM_GOST28147_ECB); byte[] sourceData = TestData.Encrypt_Gost28147_89_ECB_SourceData; // Encrypt data byte[] encryptedData = session.Encrypt(mechanism, generatedKey, sourceData); // Decrypt data byte[] decryptedData = session.Decrypt(mechanism, generatedKey, encryptedData); Assert.IsTrue(Convert.ToBase64String(sourceData) == Convert.ToBase64String(decryptedData)); session.DestroyObject(generatedKey); session.Logout(); } } }
public TokenRSA(X509Certificate2 certificate, ISession session, ISlot slot, IObjectHandle privateKeyHandle) { _certificate = certificate; _session = session; _slot = slot; _privateKeyHandle = privateKeyHandle; }
private void UpdateNodesAndSlostWithResolveMissingSlotAfterAction(IStorage storage, List<IVisualNode> nodeList, List<uint> slotIdList) { DataHeader header = new DataHeader(); storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of slots stored foreach (uint slotId in slotIdList) { header.Deserialize(storage); if (this.graphController.ContainSlotKey(slotId)) { ISlot slot = this.graphController.GetSlot(slotId); slot.Deserialize(storage); } else { ISlot slot = Slot.Create(this.graphController, storage); this.graphController.AddSlot(slot); } } storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of nodes stored foreach (IVisualNode node in nodeList) { header.Deserialize(storage); node.Deserialize(storage); } }
public override void ApplySpecials(ISlot slot, ISlot otherSlot, IGameMessages messages) { foreach (var s in _specials) { s.ApplySpecials(slot, otherSlot, messages); } }
public void _03_DigestKeyTest() { using (IPkcs11Library pkcs11Library = Settings.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11Library); // Open RW session using (ISession session = slot.OpenSession(SessionType.ReadWrite)) { // Login as normal user session.Login(CKU.CKU_USER, Settings.NormalUserPin); // Generate symetric key IObjectHandle generatedKey = Helpers.GenerateKey(session); // Specify digesting mechanism IMechanism mechanism = Settings.Factories.MechanismFactory.Create(CKM.CKM_SHA_1); // Digest key byte[] digest = session.DigestKey(mechanism, generatedKey); // Do something interesting with digest value Assert.IsNotNull(digest); session.DestroyObject(generatedKey); session.Logout(); } } }
public void _02_DigestMultiPartTest() { using (IPkcs11Library pkcs11Library = Settings.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11Library); // Open RO session using (ISession session = slot.OpenSession(SessionType.ReadOnly)) { // Specify digesting mechanism IMechanism mechanism = Settings.Factories.MechanismFactory.Create(CKM.CKM_SHA_1); byte[] sourceData = ConvertUtils.Utf8StringToBytes("Hello world"); byte[] digest = null; // Multipart digesting can be used i.e. for digesting of streamed data using (MemoryStream inputStream = new MemoryStream(sourceData)) { // Digest data digest = session.Digest(mechanism, inputStream); } // Do something interesting with digest value Assert.IsTrue(ConvertUtils.BytesToBase64String(digest) == "e1AsOh9IyGCa4hLN+2Od7jlnP14="); } } }
public void _01_GenerateKeyTest() { using (IPkcs11 pkcs11 = Settings.Factories.Pkcs11Factory.CreatePkcs11(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11); // Open RW session using (ISession session = slot.OpenSession(SessionType.ReadWrite)) { // Login as normal user session.Login(CKU.CKU_USER, Settings.NormalUserPin); // Prepare attribute template of new key List <IObjectAttribute> objectAttributes = new List <IObjectAttribute>(); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.CreateObjectAttribute(CKA.CKA_CLASS, CKO.CKO_SECRET_KEY)); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.CreateObjectAttribute(CKA.CKA_KEY_TYPE, CKK.CKK_DES3)); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.CreateObjectAttribute(CKA.CKA_ENCRYPT, true)); objectAttributes.Add(Settings.Factories.ObjectAttributeFactory.CreateObjectAttribute(CKA.CKA_DECRYPT, true)); // Specify key generation mechanism IMechanism mechanism = Settings.Factories.MechanismFactory.CreateMechanism(CKM.CKM_DES3_KEY_GEN); // Generate key IObjectHandle objectHandle = session.GenerateKey(mechanism, objectAttributes); // Do something interesting with generated key // Destroy object session.DestroyObject(objectHandle); session.Logout(); } } }
private int GetStackWeight(ISlot containerSlot) { int newContainerWeigth = containerSlot.StackWeight - containerSlot.Stack[0].Weight; //Calculate stack weight on top of lowest positioned container of this slot return(newContainerWeigth); }
public void _03_GetObjectSizeTest() { using (IPkcs11Library pkcs11Library = Settings.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11Library); // Open RW session using (ISession session = slot.OpenSession(SessionType.ReadWrite)) { // Login as normal user session.Login(CKU.CKU_USER, Settings.NormalUserPin); // Create object IObjectHandle objectHandle = Helpers.CreateDataObject(session); // Determine object size ulong objectSize = session.GetObjectSize(objectHandle); // Do something interesting with object size Assert.IsTrue(objectSize > 0); session.DestroyObject(objectHandle); session.Logout(); } } }
public void _02_CopyObjectTest() { using (IPkcs11Library pkcs11Library = Settings.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11Library); // Open RW session using (ISession session = slot.OpenSession(SessionType.ReadWrite)) { // Login as normal user session.Login(CKU.CKU_USER, Settings.NormalUserPin); // Create object that can be copied IObjectHandle objectHandle = Helpers.CreateDataObject(session); // Copy object IObjectHandle copiedObjectHandle = session.CopyObject(objectHandle, null); // Do something interesting with new object session.DestroyObject(copiedObjectHandle); session.DestroyObject(objectHandle); session.Logout(); } } }
public void _01_BasicInitTokenAndPinTest() { using (IPkcs11Library pkcs11Library = Settings.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11Library); ITokenInfo tokenInfo = slot.GetTokenInfo(); // Check if token needs to be initialized if (!tokenInfo.TokenFlags.TokenInitialized) { // Initialize token and SO (security officer) pin slot.InitToken(Settings.SecurityOfficerPin, Settings.ApplicationName); // Open RW session using (ISession session = slot.OpenSession(SessionType.ReadWrite)) { // Login as SO (security officer) session.Login(CKU.CKU_SO, Settings.SecurityOfficerPin); // Initialize user pin session.InitPin(Settings.NormalUserPin); session.Logout(); } } } }
public T GetSlotValue <T>(ISlot inputSlot) { var edge = owner.GetEdge(inputSlot.slotReference); if (edge != null) { var fromSocketRef = edge.outputSlot; var fromNode = owner.GetNodeFromGuid <AbstractNode>(fromSocketRef.nodeGuid); if (fromNode == null) { return(default(T)); } var slot = fromNode.FindSlot <NodeSlot>(fromSocketRef.slotId) as IHasValue <T>; if (slot == null) { return(default(T)); } return(slot.value); } var hasValue = inputSlot as IHasValue <T>; return(hasValue != null ? hasValue.value : default(T)); }
public ActionContainer(ActionType actionType, string text, ISlot sourceSlot, ISlot targetSlot) { ActionType = actionType; Text = text; SourceSlot = sourceSlot; TargetSlot = targetSlot; }
internal ISlot GetSlot(uint slotId) { ISlot slot = null; this.slotCollection.TryGetValue(slotId, out slot); return(slot); }
public void SetStateForSlot(ISlot slot, EntityState modified) { Slot instance = ConvertToSlot(slot); Entry(instance).State = EntityState.Modified; }
public static void AddSlot(ISlot slot) { if (!SlotDatabase.Slots.ContainsKey(slot.ObjectId)) { SlotDatabase.Slots.Add(slot.ObjectId, slot); } }
public void _02_FindAllObjectsTest() { using (IPkcs11Library pkcs11Library = Settings.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11Library); // Open RW session using (ISession session = slot.OpenSession(SessionType.ReadWrite)) { // Login as normal user session.Login(CKU.CKU_USER, Settings.NormalUserPin); // Let's create two objects so we can find something IObjectHandle objectHandle1 = Helpers.CreateDataObject(session); IObjectHandle objectHandle2 = Helpers.CreateDataObject(session); // Prepare attribute template that defines search criteria List <IObjectAttribute> objectAttributes = new List <IObjectAttribute>(); objectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, CKO.CKO_DATA)); objectAttributes.Add(session.Factories.ObjectAttributeFactory.Create(CKA.CKA_TOKEN, true)); // Find all objects that match provided attributes List <IObjectHandle> foundObjects = session.FindAllObjects(objectAttributes); // Do something interesting with found objects Assert.IsTrue(foundObjects.Count >= 2); session.DestroyObject(objectHandle2); session.DestroyObject(objectHandle1); session.Logout(); } } }
public void _01_GetFunctionStatusTest() { using (IPkcs11Library pkcs11Library = Settings.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present ISlot slot = Helpers.GetUsableSlot(pkcs11Library); // Open RO (read-only) session using (ISession session = slot.OpenSession(SessionType.ReadOnly)) { // Legacy functions should always return CKR_FUNCTION_NOT_PARALLEL try { session.GetFunctionStatus(); } catch (Pkcs11Exception ex) { if (ex.RV != CKR.CKR_FUNCTION_NOT_PARALLEL) { throw; } } } } }
public void AddSlot(ISlot slot) { if (!(slot is MaterialSlot)) { throw new ArgumentException(string.Format("Trying to add slot {0} to Material node {1}, but it is not a {2}", slot, this, typeof(MaterialSlot))); } var addingSlot = (MaterialSlot)slot; var foundSlot = FindSlot <MaterialSlot>(slot.id); // this will remove the old slot and add a new one // if an old one was found. This allows updating values m_Slots.RemoveAll(x => x.id == slot.id); m_Slots.Add(slot); slot.owner = this; Dirty(ModificationScope.Topological); if (foundSlot == null) { return; } addingSlot.CopyValuesFrom(foundSlot); }
public SlotForResponse(ISlot slot) { Status = slot.Status; StartDateTime = slot.StartDateTime; EndDateTime = slot.EndDateTime; DayId = slot.DayId; Id = slot.Id; }
public override void Attack(ISlot attacker, ISlot attackee) { base.Attack(attacker, attackee); if (attackee.SlotIndex > 0) attackee.PlayerHand.DealDamageTo(attacker, attackee.PlayerHand[attackee.SlotIndex - 1], AttackAmount); if (attackee.SlotIndex < PlayerHandClass.NUM_SLOTS - 1) attackee.PlayerHand.DealDamageTo(attacker, attackee.PlayerHand[attackee.SlotIndex + 1], AttackAmount); }
public override void Attack(ISlot attacker, ISlot attackee) { base.Attack(attacker, attackee); for (int s = 0; s < PlayerHandClass.NUM_SLOTS; ++s) { if (s != attacker.SlotIndex && attacker.PlayerHand[s] != null) { attacker.PlayerHand.Heal(attacker, attacker.PlayerHand[s], HealingOnAttackAmount, true); } } }
private Slot ConvertToSlot(ISlot slot) { var instance = slot as Slot; if ( instance == null ) { throw new ArgumentException("Provided 'slot' instance is not a Slot!", "slot"); } Day day = DbSetDays.Find(slot.DayId); instance.Day = day; return instance; }
/// <summary> /// Use the Item stacked on defined Slot. /// e.g: Open Containers, Eat Food, etc. /// </summary> public void InContainer(ISlot slotSource, int openInPosition) { PacketBuilder Builder = new PacketBuilder(0x82, connection); if (slotSource.Id == InventoryID.Container) { #region " Packet Structure Analyze " //------------------------------------ //SZ ID BP ST [ ID] ST PS //------------------------------------ //0A 00 82 FF FF 40 00 00 26 0B 00 01 //------------------------------------ #endregion Builder.Append(0xFF); Builder.Append(0XFF); Builder.Append(slotSource.Container.Position); Builder.Append(0x00); Builder.Append(slotSource.Position); Builder.Append(slotSource.Item.Id); Builder.Append(slotSource.Position); } else { #region " Packet Structure Analyze " //------------------------------------ //SZ ID ST [ ID ] PS //------------------------------------ //0A 00 82 FF FF 03 00 00 25 0B 00 00 //------------------------------------ #endregion Builder.Append(0xFF); Builder.Append(0XFF); Builder.Append(slotSource.Id.GetHashCode()); Builder.Append(0x00); Builder.Append(0x00); Builder.Append(slotSource.Item.Id); Builder.Append(0x00); } Builder.Append(openInPosition); Connection.Send(Builder.GetPacket()); }
public abstract void ApplySpecials(ISlot slot, ISlot otherSlot, IGameMessages messages);
/// <summary> /// Use the Defined Item to the Ground. /// e.g: Rope on Ground, Obsidian Knife on Creature, Shovel on Role, etc. /// </summary> public void OnGround(ISlot slotSource, Location sqm, uint tileID, uint stackPosition) { #region " Packet Structure Analyze " //--------------------------------------------------------- //USE ROPE //--------------------------------------------------------- //00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 //--------------------------------------------------------- //11 00 83 FF FF 40 00 0D BB 0B 0D 64 7F C3 7B 0A 82 01 00 //SZ ID BP ST ROPE ST [ X ] [ Y ] ZZ [TID] ?? //--------------------------------------------------------- #endregion PacketBuilder Builder = new PacketBuilder(0x83, connection); Builder.Append(0xFF); Builder.Append(0xFF); Builder.Append(slotSource.Container.Position); Builder.Append(0x00); Builder.Append(slotSource.Position); Builder.Append(slotSource.Item.Id); Builder.Append(slotSource.Position); Builder.Append(sqm.X); Builder.Append(sqm.Y); Builder.Append(sqm.Z); Builder.Append(tileID); Builder.Append(stackPosition); Connection.Send(Builder.GetPacket()); }
/// <summary> /// Use the Defined Item on a Player in Defined SQM and Drop after use if needed. /// e.g: Use Fluids on Players, Use Runes on Players, etc. /// </summary> public void OnPlayer(ISlot slotSource, Location sqm, bool dropAfterUse) { #region " Packet Structure Analyze " // SZ ID BP SLOT HMM X Y Z ?? QD //---------------------------------------------------------------------- // 11 00 83 FF FF 40 00 00 7E 0C 00 15 7E ED 7B 07 63 00 01 //---------------------------------------------------------------------- // 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 #endregion PacketBuilder Builder = new PacketBuilder(0x83, connection); Builder.Append(0xFF); Builder.Append(0xFF); Builder.Append(slotSource.Container.Position); Builder.Append(0x00); Builder.Append(slotSource.Position); Builder.Append(slotSource.Item.Id); Builder.Append(slotSource.Position); Builder.Append(sqm.X); Builder.Append(sqm.Y); Builder.Append(sqm.Z); Builder.Append(0x63); Builder.Append(0x00); Builder.Append(0x01); //TODO: Test increase this ammount. Connection.Send(Builder.GetPacket()); if (dropAfterUse) { System.Threading.Thread.Sleep(300); new Stack(Connection).ContainerToGround(slotSource, sqm); } }
public override void RemoveSpecials(ISlot slot, IGameMessages messages) { messages.Add("Removing damage bonus of all {0} by {1}", categoryAffected, amountAttack); slot.PlayerHand.ApplyDamageModifierToAll(slot.SlotIndex, categoryAffected, -amountAttack); }
public override void ApplySpecials(ISlot slot, ISlot otherSlot, IGameMessages messages) { messages.Add("Increasing health of all {0} by {1}", categoryAffected, amountHealth); slot.PlayerHand.ApplyHealthModifier(slot.SlotIndex, otherSlot.SlotIndex, categoryAffected, amountHealth); }
public override void RemoveSpecials(ISlot slot, IGameMessages messages) { foreach (var s in _specials) { s.RemoveSpecials(slot, messages); } }
public override void ApplySpecials(ISlot slot, ISlot otherSlot, IGameMessages messages) { messages.Add("Increasing damage of all {0} by {1}", categoryAffected, amountAttack); slot.PlayerHand.ApplyDamageModifier(otherSlot.SlotIndex, categoryAffected, amountAttack); }
public virtual void Attack(ISlot attacker, ISlot attackee) { if (attackee == null) return; attacker.IsStunned.Should().BeFalse(); int actualAttackAmount = attackee.PlayerHand.DealDamageTo(attacker, attackee, attacker.card.attack + attacker.AttackModifier); }
public override void Attack(ISlot attacker, ISlot attackee) { for(int s = 0; s < PlayerHandClass.NUM_SLOTS; ++s) { base.Attack(attacker, attackee.PlayerHand[s]); } }
public override void Attack(ISlot attacker, ISlot target) { base.Attack(attacker, target); target.PlayerHand.Stun(attacker, target); }
internal void AddSlot(ISlot slot) { if (null == slot) throw new ArgumentNullException("slot"); this.slotCollection.Add(slot.SlotId, slot); }
public abstract void RemoveSpecials(ISlot slot, IGameMessages messages);
public void Add(ISlot slot) { Slot instance = ConvertToSlot(slot); DbSetSlots.Add(instance); }
public void Remove(ISlot slot) { Slot instance = ConvertToSlot(slot); DbSetSlots.Remove(instance); }
/// <summary> /// Send the ammount of stacked Item to defined Container Slot. /// </summary> public void GroundToContainer(IItem item, ISlot destiny, Location sqm, uint stackPosition) { var Builder = new PacketBuilder(0x78, Connection); Builder.Append(sqm.X); Builder.Append(sqm.Y); Builder.Append(sqm.Z); Builder.Append(item.Id); Builder.Append(stackPosition); Builder.Append(0xFF); Builder.Append(0xFF); Builder.Append(destiny.Container.Position); Builder.Append(0x00); Builder.Append(destiny.Position); Builder.Append(item.Count); Connection.Send(Builder.GetPacket()); }
/// <summary> /// Send the ammount of stacked Item to defined Container Slot. /// </summary> public void Stack(ISlot toSlot) { if (Id == InventoryID.Container && toSlot.Id == InventoryID.Container) { StackActions.ContainerToContainer(this, toSlot); } else if (Id != InventoryID.Container && toSlot.Id == InventoryID.Container) { StackActions.SlotToContainer(Item, toSlot); } else if (Id == InventoryID.Container && toSlot.Id != InventoryID.Container) { StackActions.ContainerToSlot(this, toSlot.Id); } else if (Id != InventoryID.Container && toSlot.Id != InventoryID.Container) { StackActions.SlotToSlot(Item, toSlot.Id); } }
/// <summary> /// Send the ammount of stacked Item to defined Inventory Slot. /// </summary> public void ContainerToSlot(ISlot fromSlot, InventoryID toSloT) { #region " Packet Structure Analyze " //--------------------------------------------------- // SZ ID BP ST ITM ST ST QT // 0F 00 78 FF FF 40 00 03 CD 0C 03 FF FF 06 00 00 04 //--------------------------------------------------- // 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 //--------------------------------------------------- #endregion var Builder = new PacketBuilder(0x78, Connection); Builder.Append(0xFF); Builder.Append(0xFF); Builder.Append(fromSlot.Container.Position); Builder.Append(0x00); Builder.Append(fromSlot.Position); Builder.Append(fromSlot.Item.Id); Builder.Append(fromSlot.Position); Builder.Append(0xFF); Builder.Append(0xFF); Builder.Append(toSloT.GetHashCode()); Builder.Append(0x00); Builder.Append(0x00); Builder.Append(fromSlot.Item.Count); Connection.Send(Builder.GetPacket()); }
/// <summary> /// Send the ammount of stacked Item to defined Container Slot. /// </summary> public void SlotToContainer(IItem item, ISlot toSlot) { #region " Packet Structure Analyze " //--------------------------------------------------- // SZ ID ST ITM BP ST QT // 0F 00 78 FF FF 0A 00 00 7E 0C 00 FF FF 40 00 01 01 //--------------------------------------------------- // 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 //--------------------------------------------------- #endregion var Builder = new PacketBuilder(0x78, Connection); Builder.Append(0xFF); Builder.Append(0XFF); Builder.Append(item.Slot.Id.GetHashCode()); Builder.Append(0x00); Builder.Append(0x00); Builder.Append(item.Id); Builder.Append(0x00); Builder.Append(0xFF); Builder.Append(0xFF); Builder.Append(toSlot.Container.Position); Builder.Append(0x00); Builder.Append(toSlot.Position); Builder.Append(item.Count); Connection.Send(Builder.GetPacket()); }