示例#1
0
        private async Task GetCapabilitiesAsync(int capabilityLevel = 1)
        {
            var request  = PrepareCommand <CommandCameraCapabilities>();
            var response = await request.SendAsync(false);

            _capabilities = CameraCapabilities.Parse(response.RawResponse, capabilityLevel);
        }
        internal static CameraCapabilities Parse(byte[] bytes, int capabilityLevel=1)
        {
            if (bytes == null || bytes.Length == 0)
                return null;

            var status = bytes[bytes.Length - 1];
            if (status == 0)
                return null;

            var cameraCapabilities = new CameraCapabilities();
            var type = cameraCapabilities.GetType();

            var properties=type.GetProperties();

            foreach (var property in properties)
            {
                var attributes = property.GetCustomAttributes(typeof(CapabilityAttribute), true);
                if (attributes.Length == 0)
                    continue;

                var capability = attributes[0] as CapabilityAttribute;

                SetCapability(bytes, capabilityLevel, cameraCapabilities, property, capability);
            }

            return cameraCapabilities;
        }
示例#3
0
        internal static CameraCapabilities Parse(byte[] bytes, int capabilityLevel = 1)
        {
            if (bytes == null || bytes.Length == 0)
            {
                return(null);
            }

            var status = bytes[bytes.Length - 1];

            if (status == 0)
            {
                return(null);
            }

            var cameraCapabilities = new CameraCapabilities();
            var type = cameraCapabilities.GetType();

            var properties = type.GetProperties();

            foreach (var property in properties)
            {
                var attributes = property.GetCustomAttributes(typeof(CapabilityAttribute), true);
                if (attributes.Length == 0)
                {
                    continue;
                }

                var capability = attributes[0] as CapabilityAttribute;

                SetCapability(bytes, capabilityLevel, cameraCapabilities, property, capability);
            }

            return(cameraCapabilities);
        }
 private static void SetCapability
     (
         byte[] bytes, int capabilityLevel,
         CameraCapabilities cameraCapabilities,
         PropertyInfo property,
         CapabilityAttribute capability
     )
 {
     if (capabilityLevel + capability.LocalIndex < bytes.Length &&
         (bytes[capabilityLevel + capability.LocalIndex] & capability.Mask) == capability.Mask)
         property.SetValue(cameraCapabilities, true, null);
 }
示例#5
0
 private static void SetCapability
 (
     byte[] bytes, int capabilityLevel,
     CameraCapabilities cameraCapabilities,
     PropertyInfo property,
     CapabilityAttribute capability
 )
 {
     if (capabilityLevel + capability.LocalIndex < bytes.Length &&
         (bytes[capabilityLevel + capability.LocalIndex] & capability.Mask) == capability.Mask)
     {
         property.SetValue(cameraCapabilities, true, null);
     }
 }