private static ColumnsFactory SelectColumnsFactoryFor(Resource resource)
        {
            WindowsAzureActiveDirectoryGroup group = resource as WindowsAzureActiveDirectoryGroup;

            if (group != null)
            {
                ColumnsFactory result = new GroupColumnsFactory(group);
                return(result);
            }

            Core2EnterpriseUser user = resource as Core2EnterpriseUser;

            if (user != null)
            {
                ColumnsFactory result = new UserColumnsFactory(user);
                return(result);
            }

            DynamicUser dynamicUser = resource as DynamicUser;

            if (dynamicUser != null)
            {
                ColumnsFactory result = new DynamicUserColumnsFactory(dynamicUser);
                return(result);
            }

            string unsupportedSchema =
                string.Join(
                    Environment.NewLine,
                    resource.Schemas);

            throw new NotSupportedException(unsupportedSchema);
        }
        private static IReadOnlyDictionary <string, string> PatchGroup(PatchRequest2 patch, IRow row)
        {
            ResourceFactory <WindowsAzureActiveDirectoryGroup> groupFactory = new GroupFactory(row);
            WindowsAzureActiveDirectoryGroup group = groupFactory.Create();

            group.Apply(patch);
            ColumnsFactory <WindowsAzureActiveDirectoryGroup> groupColumnsFactory = new GroupColumnsFactory(group);
            IReadOnlyDictionary <string, string> result = groupColumnsFactory.CreateColumns();

            return(result);
        }