private static ResourceFactory SelectResourceFactoryFor(Resource resource, IRow row) { WindowsAzureActiveDirectoryGroup group = resource as WindowsAzureActiveDirectoryGroup; if (group != null) { ResourceFactory result = new GroupFactory(row); return(result); } Core2EnterpriseUser user = resource as Core2EnterpriseUser; if (user != null) { ResourceFactory result = new UserFactory(row); return(result); } DynamicUser dynamicUser = resource as DynamicUser; if (dynamicUser != null) { ResourceFactory result = new DynamicUserFactory(row); return(result); } string unsupportedSchema = string.Join( Environment.NewLine, resource.Schemas); throw new NotSupportedException(unsupportedSchema); }
private static ResourceFactory SelectResourceFactoryFor(string schemaIdentifier, IRow row) { if (string.IsNullOrWhiteSpace(schemaIdentifier)) { throw new ArgumentNullException(nameof(schemaIdentifier)); } ResourceFactory resourceFactory; switch (schemaIdentifier) { case SchemaIdentifiers.Core2EnterpriseUser: resourceFactory = new UserFactory(row); break; case SchemaIdentifiers.WindowsAzureActiveDirectoryGroup: resourceFactory = new GroupFactory(row); break; case DynamicConstants.SchemaIdentifierUser: resourceFactory = new DynamicUserFactory(row); break; default: throw new NotSupportedException(schemaIdentifier); } return(resourceFactory); }
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); }
public override async Task UpdateAsync(IPatch patch, string correlationIdentifier) { if (null == patch) { throw new ArgumentNullException(nameof(patch)); } if (null == patch.ResourceIdentifier) { throw new ArgumentException(FileProviderResources.ExceptionInvalidPatch); } if (string.IsNullOrWhiteSpace(patch.ResourceIdentifier.Identifier)) { throw new ArgumentException(FileProviderResources.ExceptionInvalidPatch); } if (null == patch.PatchRequest) { throw new ArgumentException(FileProviderResources.ExceptionInvalidPatch); } IInformationNotification notification = VerboseInformationNotificationFactory.Instance.FormatNotification( FileProviderResources.InformationPatching, correlationIdentifier, FileProvider.NotificationIdentifierUpdateStarting, patch.ResourceIdentifier.SchemaIdentifier, patch.ResourceIdentifier.Identifier); this.Monitor.Inform(notification); PatchRequest2 patchRequest = patch.PatchRequest as PatchRequest2; if (null == patchRequest) { string unsupportedPatchTypeName = patch.GetType().FullName; throw new NotSupportedException(unsupportedPatchTypeName); } IRow row = await this.file.ReadRow(patch.ResourceIdentifier.Identifier); string rowSchema = null; if ( !row.Columns.TryGetValue(AttributeNames.Schemas, out rowSchema) || !string.Equals(rowSchema, patch.ResourceIdentifier.SchemaIdentifier, StringComparison.Ordinal) ) { return; } IReadOnlyDictionary <string, string> columns = FileProvider.Apply(patchRequest, rowSchema, row); IRow rowReplacement = new Row(row.Key, columns); await this.file.ReplaceRow(rowReplacement); if (string.Equals(SchemaIdentifiers.WindowsAzureActiveDirectoryGroup, rowSchema, StringComparison.OrdinalIgnoreCase)) { WindowsAzureActiveDirectoryGroup group = new GroupFactory(row).Create(); await this.UpdateMembersAsync(group, patch); } }