示例#1
0
        private bool PopulateSubscriptionStateForProfile(SubscriptionState state, Profile profile)
        {
            var success = true;

            profile.PrepareProfile();

            if (profile.ParentProfile != null)
            {
                success &= PopulateSubscriptionStateForProfile(state, profile.ParentProfile);
            }

            // Output devices
            var profileOutputDevices = new List <DeviceSubscription>();
            var outputDeviceGroup    = _context.DeviceGroupsManager.GetDeviceGroup(DeviceIoType.Output, profile.OutputDeviceGroupGuid);

            foreach (var device in outputDeviceGroup.Devices)
            {
                profileOutputDevices.Add(state.AddOutputDevice(device, profile));
            }

            // Devices are inherited, load them for the subscription model
            if (outputDeviceGroup.Devices.Count == 0)
            {
                var deviceGroup = profile.GetDeviceGroup(DeviceIoType.Output);
                if (deviceGroup != null)
                {
                    foreach (var device in deviceGroup.Devices)
                    {
                        profileOutputDevices.Add(state.AddOutputDevice(device, profile));
                    }
                }
            }

            state.AddMappings(profile, profileOutputDevices);

            return(success);
        }