Esempio n. 1
0
        public void UpdatePrimitive(string propertyName)
        {
            MemoryMappedAttribute propMemMapping = ExtractMemoryMappedAttribute(propertyName);
            int finalAddress = GetFinalAddress() + propMemMapping.Offset;
            int value        = this.RootEntity.MemHandler.ReadInt32(new IntPtr(finalAddress));

            ExtractPropertyInfo(propertyName).SetMethod.Invoke(this, new object[] { value });
        }
Esempio n. 2
0
 public MemoryMapping(MemoryMappedAttribute attribute) : this()
 {
     Offset     = attribute.Offset;
     PreOffsets = new int[attribute.PreOffsets.Length];
     for (int i = 0; i < PreOffsets.Length; i++)
     {
         PreOffsets[i] = attribute.PreOffsets[i];
     }
     Module       = attribute.Module;
     StartAddress = attribute.StartAddress;
 }
 private MemoryMappedAttribute GetMemoryMappedAttribute(PropertyInfo property)
 {
     foreach (object attribute in property.GetCustomAttributes(true))
     {
         MemoryMappedAttribute memoryMappedAttribute = attribute as MemoryMappedAttribute;
         if (memoryMappedAttribute != null)
         {
             return(memoryMappedAttribute);
         }
     }
     return(null);
 }
        private void HandleProperty(PropertyInfo property)
        {
            MemoryMappedAttribute memoryMappedAttribute = GetMemoryMappedAttribute(property);

            if (memoryMappedAttribute == null)
            {
                return;
            }

            if (property.PropertyType == typeof(Entity))
            {
                property.PropertyType.GetMethod("Load").Invoke(null, null);
            }
            else
            {
                property.SetMethod.Invoke(this, null);
            }
        }
Esempio n. 5
0
        public MemoryMappedAttribute ExtractMemoryMappedAttribute(string propertyName)
        {
            PropertyInfo property = ExtractPropertyInfo(propertyName);

            if (property == null)
            {
                // Property not found
                return(null);
            }

            foreach (object attribute in property.GetCustomAttributes(true))
            {
                MemoryMappedAttribute memoryMappedAttribute = attribute as MemoryMappedAttribute;
                if (memoryMappedAttribute != null)
                {
                    // Attribute of property was found
                    return(memoryMappedAttribute);
                }
            }

            // Attribute not found
            return(null);
        }