Пример #1
0
        private static Pageable <GenericResource> ListAtContextInternal(
            ResourceOperationsBase resourceOperations,
            string scopeFilter = null,
            ResourceFilterCollection resourceFilters = null,
            int?top = null,
            CancellationToken cancellationToken = default)
        {
            var armOperations = GetResourcesClient(resourceOperations).Resources;
            Pageable <GenericResourceExpanded> result;

            if (scopeFilter == null)
            {
                result = armOperations.List(resourceFilters?.ToString(), null, top, cancellationToken);
            }
            else
            {
                result = armOperations.ListByResourceGroup(
                    scopeFilter,
                    resourceFilters?.ToString(),
                    null,
                    top,
                    cancellationToken);
            }

            return(ConvertResults(result, resourceOperations));
        }
Пример #2
0
        private static Pageable <GenericResourceExpanded> ListAtContextInternal(
            ResourceOperationsBase resourceOperations,
            string scopeFilter = null,
            ResourceFilterCollection resourceFilters = null,
            string expand = null,
            int?top       = null,
            CancellationToken cancellationToken = default)
        {
            var restClient = GetGenericResourceContainer(resourceOperations);
            Pageable <GenericResourceExpanded> result;

            if (scopeFilter == null)
            {
                result = restClient.List(resourceFilters?.ToString(), expand, top, cancellationToken);
            }
            else
            {
                result = restClient.ListByResourceGroup(
                    scopeFilter,
                    resourceFilters?.ToString(),
                    expand,
                    top,
                    cancellationToken);
            }

            return(result);
        }
Пример #3
0
 private static AsyncPageable <GenericResource> ConvertResultsAsync(
     AsyncPageable <GenericResourceExpanded> result,
     ResourceOperationsBase resourceOperations)
 {
     return(new PhWrappingAsyncPageable <GenericResourceExpanded, GenericResource>(
                result,
                CreateResourceConverter(resourceOperations)));
 }
Пример #4
0
        private static Func <GenericResourceExpanded, GenericResource> CreateResourceConverter(ResourceOperationsBase resourceOperations)
        {
            return(s =>
            {
                var args = new object[]
                {
                    resourceOperations,
                    Activator.CreateInstance(typeof(GenericResourceData), s as ResourceManager.Resources.Models.GenericResource) as GenericResourceData,
                };

                return Activator.CreateInstance(
                    typeof(GenericResource),
                    BindingFlags.Instance | BindingFlags.NonPublic,
                    null,
                    args,
                    CultureInfo.InvariantCulture) as GenericResource;
            });
        }
Пример #5
0
 private static ResourcesManagementClient GetResourcesClient(ResourceOperationsBase resourceOperations)
 {
     return(new ResourcesManagementClient(resourceOperations.BaseUri, resourceOperations.Id.Subscription, resourceOperations.Credential));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceContainerBase{TOperations, TData}"/> class.
 /// </summary>
 /// <param name="parent"> The resource representing the parent resource. </param>
 protected ResourceContainerBase(ResourceOperationsBase parent)
     : base(parent)
 {
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceGroup"/> class.
 /// </summary>
 /// <param name="operations"> The operations to copy the client options from. </param>
 /// <param name="resource"> The ResourceGroupData to use in these operations. </param>
 internal ResourceGroup(ResourceOperationsBase operations, ResourceGroupData resource)
     : base(operations, resource.Id)
 {
     Data = resource;
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GenericResource"/> class.
 /// </summary>
 /// <param name="operations"> The operations object to copy the client parameters from. </param>
 /// <param name="resource"> The data model representing the generic azure resource. </param>
 /// <exception cref="ArgumentNullException"> If <see cref="AzureResourceManagerClientOptions"/> or <see cref="TokenCredential"/> is null. </exception>
 internal GenericResource(ResourceOperationsBase operations, GenericResourceData resource)
     : base(operations, resource.Id)
 {
     Data = resource;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GenericResourceOperations"/> class.
 /// </summary>
 /// <param name="operations"> The resource operations to copy the options from. </param>
 /// <param name="id"> The identifier of the resource that is the target of operations. </param>
 internal GenericResourceOperations(ResourceOperationsBase operations, ResourceIdentifier id)
     : base(operations, id)
 {
     _apiVersion = "BAD VALUE";
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceGroupOperations"/> class.
 /// </summary>
 /// <param name="options"> The client parameters to use in these operations. </param>
 /// <param name="id"> The identifier of the resource that is the target of operations. </param>
 protected ResourceGroupOperations(ResourceOperationsBase options, ResourceIdentifier id)
     : base(options, id)
 {
 }
Пример #11
0
 private static GenericResourceContainer GetGenericResourceContainer(ResourceOperationsBase resourceOperations)
 {
     return(new GenericResourceContainer(new ClientContext(resourceOperations.ClientOptions, resourceOperations.Credential, resourceOperations.BaseUri, resourceOperations.Pipeline), resourceOperations.Id));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceOperationsBase"/> class.
 /// </summary>
 /// <param name="options"> The operations to copy options from. </param>
 /// <param name="resourceId">The resource that is the target of operations.</param>
 protected ResourceOperationsBase(ResourceOperationsBase options, ResourceIdentifier resourceId)
     : base(options.ClientOptions, resourceId, options.Credential, options.BaseUri)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceOperationsBase"/> class.
 /// </summary>
 /// <param name="operations"> The operations representing the resource. </param>
 protected ResourceOperationsBase(ResourceOperationsBase operations)
     : base(operations.ClientOptions, operations.Id, operations.Credential, operations.BaseUri)
 {
 }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ContainerBase{TOperations}"/> class.
 /// </summary>
 /// <param name="parent"> The resource representing the parent resource. </param>
 protected ContainerBase(ResourceOperationsBase parent)
     : base(parent.ClientOptions, parent.Id, parent.Credential, parent.BaseUri)
 {
     Parent = parent;
 }