示例#1
0
 private IEnumerable<string> GetResult(string text)
 {
     var mock = new Mock<IRunner>();
     mock.Setup(o => o.WorkingDirectory).Returns(Path.Combine(Environment.CurrentDirectory, "Test"));
     _argument = ArgumentFactory.Create(mock.Object, text);
     return _argument.Complete();
 }
		public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
		{
			if (input.Arguments.Count > 0)
			{
				var arguments = new Argument[input.Arguments.Count];

				for (int i = 0; i < input.Arguments.Count; i++)
				{
					arguments[i] = new Argument
					               	{
					              		Name = input.Arguments.ParameterName(i),
					              		Value = input.Arguments[i]
					              	};
				}

				_tape.RecordRequest(arguments, input.MethodBase.ReflectedType, input.MethodBase.Name);
			}

			Console.WriteLine("> Intercepting " + input.MethodBase.Name);
			Console.WriteLine("> Intercepting " + input.MethodBase.ReflectedType);

			IMethodReturn methodReturn = getNext()(input, getNext);

			Console.WriteLine("> Intercepted return value: " + methodReturn.ReturnValue.GetType().Name);

			if (methodReturn.ReturnValue != null)
			{
				_tape.RecordResponse(methodReturn.ReturnValue, input.MethodBase.ReflectedType, input.MethodBase.Name);
			}

			return methodReturn;
		}
示例#3
0
 public object GetValue(Argument arg, int size)
 {
     switch (Tag)
     {
     case TypeTag.Boolean:
     case TypeTag.Int8:
     case TypeTag.UInt8:
     case TypeTag.Int16:
     case TypeTag.UInt16:
     case TypeTag.Int32:
     case TypeTag.UInt32:
     case TypeTag.Int64:
     case TypeTag.UInt64:
     case TypeTag.Int:
     case TypeTag.UInt:
     case TypeTag.Long:
     case TypeTag.ULong:
     case TypeTag.SSize:
     case TypeTag.Size:
     case TypeTag.Float:
     case TypeTag.Double:
         return typeof(Argument).GetField(Tag.ToString()).GetValue(arg);
     case TypeTag.Utf8:
         return GObject.Marshaller.Utf8PtrToString((IntPtr) arg.Pointer);
     default:
         return null;
     }
 }
        protected override IEnumerable<string> Format(Argument[] arguments)
        {
            var list = new List<string>();
            string deferred = null;
            foreach (var argument in arguments)
            {
                if (deferred != null)
                {
                    deferred += ",";
                }

                foreach (var line in this.Format(argument))
                {
                    if (deferred != null)
                    {
                        list.Add(deferred);
                    }

                    deferred = line;
                }
            }

            if (deferred != null)
            {
                list.Add(deferred);
            }

            return list;
        }
        public void IArgumentInfo_DefaultValue_returns_same_as_typed_property()
        {
            var arg = new Argument<string>(_parser, "short", "long", "foo", false);
            arg.DefaultValue = "timmeh!";

            Assert.Equal("timmeh!", ((IArgument)arg).DefaultValue);
        }
示例#6
0
文件: Command.cs 项目: Mavtak/roomie
 public Command(Argument[] arguments, string description, string group, string name)
 {
     Arguments = arguments;
     Description = description;
     Group = group;
     Name = name;
 }
示例#7
0
	private void concat(StringBuilder buf, Argument arg) {
		Iterator<Token>	it = arg.iterator();
		while (it.hasNext()) {
			Token	tok = it.next();
			buf.append(tok.getText());
		}
	}
 public static SCode Make(Primitive2 rator, Argument rand0, SCode rand1)
 {
     return
         (rand0 is Argument0) ? PrimitiveIsCharEqA0.Make (rator, (Argument0) rand0, rand1)
         : (rand0 is Argument1) ? PrimitiveIsCharEqA1.Make (rator, (Argument1) rand0, rand1)
         : Unimplemented ();
 }
示例#9
0
 protected Action(Argument argument, IActionContainer container=null)
 {
     Argument = argument;
     Container = container;
     OptionStrings = new List<string>(Argument.OptionStrings ?? new string[] {});
     Destination = Argument.Destination;
     IsRequired = Argument.IsRequired;
 }
示例#10
0
 /// <summary>
 /// Constructor that forms the info from the argument's metadata.
 /// </summary>
 /// <param name="setAttribute">Argument set attribute.</param>
 /// <param name="arg">Argument metadata.</param>
 public ArgumentUsageInfo(ArgumentSetAttribute setAttribute, Argument arg)
 {
     Syntax = arg.GetSyntaxHelp(setAttribute);
     Description = arg.Attribute.HelpText;
     Required = arg.IsRequired;
     ShortName = arg.ShortName;
     DefaultValue = TryGetDefaultValueString(setAttribute, arg);
 }
        public void exception_is_thrown_when_argments_are_not_valid()
        {
            _parser.IsValid = false;

            var arg = new Argument<int>(_parser, "shortName", "longName", "description", true);
            int value;
            Assert.Throws<InvalidOperationException>(() => value = arg.Value);
        }
 public void Value_returns_default_value_when_IsMissing()
 {
     _parser.IsValid = true;
     var arg = new Argument<string>(_parser, "short", "long", "foo", false);
     arg.IsMissing = true;
     arg.DefaultValue = "gobbles!";
     Assert.Equal("gobbles!", arg.Value);
 }
示例#13
0
 public ExecutionStackItem(Argument arg)
 {
     _variable = new VariableItem();
     _variable.Value = arg.Value;
     if(arg.Value.Type == HVMType.Variable)
     {
         _variable.Name = arg.Value.StringValue;
     }
 }
        protected IEnumerable<string> Format(Argument argument)
        {
            var type = argument.GetType();

            if (type == typeof(NamedArgument)) return Format((NamedArgument)argument);
            if (type == typeof(PositionalArgument)) return Format((PositionalArgument)argument);

            throw new ArgumentException("Unhandled type " + type.FullName, nameof(argument));
        }
 public static SCode Make(Primitive2 rator, Argument rand0, SCode rand1)
 {
     return
         (rand0 is Argument0) ? PrimitiveIsObjectEqA0.Make (rator, (Argument0) rand0, rand1)
         : (rand0 is Argument1) ? PrimitiveIsObjectEqA1.Make (rator, (Argument1) rand0, rand1)
         : (rand1 is LexicalVariable) ? Unimplemented()
         : (rand1 is Quotation) ? PrimitiveIsObjectEqAQ.Make (rator, rand0, (Quotation) rand1)
         : new PrimitiveIsObjectEqA (rator, rand0, rand1);
 }
示例#16
0
 internal void SetArgumentValue(IScriptExtent extent, object value)
 {
     if (this._argument == null)
     {
         this._argument = new Argument();
     }
     this._argument.value = value;
     this._argument.extent = extent;
 }
示例#17
0
        /// <summary>
        ///     Creates a new command line argument parser.
        /// </summary>
        /// <param name="argumentSpecification"> The type of object to parse. </param>
        /// <param name="reporter"> The destination for parse errors. </param>
        private Parser(Type argumentSpecification, ErrorReporter reporter)
        {
            this.reporter = reporter;
            this.reporter += Log.Error;
            this.arguments = new ArrayList();
            this.argumentMap = new Hashtable();

            foreach (FieldInfo field in argumentSpecification.GetFields())
            {
                if (!field.IsStatic && !field.IsInitOnly && !field.IsLiteral)
                {
                    ArgumentAttribute attribute = GetAttribute(field);
                    if (attribute is DefaultArgumentAttribute)
                    {
                        Debug.Assert(this.defaultArgument == null);
                        this.defaultArgument = new Argument(attribute, field, reporter);
                    }
                    else
                    {
                        this.arguments.Add(new Argument(attribute, field, reporter));
                    }
                }
            }

            // add explicit names to map
            foreach (Argument argument in this.arguments)
            {
                Debug.Assert(!this.argumentMap.ContainsKey(argument.LongName));
                this.argumentMap[argument.LongName] = argument;
                if (argument.ExplicitShortName)
                {
                    if (!string.IsNullOrEmpty(argument.ShortName))
                    {
                        Debug.Assert(!this.argumentMap.ContainsKey(argument.ShortName));
                        this.argumentMap[argument.ShortName] = argument;
                    }
                    else
                    {
                        argument.ClearShortName();
                    }
                }
            }

            // add implicit names which don't collide to map
            foreach (Argument argument in this.arguments)
            {
                if (!argument.ExplicitShortName)
                {
                    if (!string.IsNullOrEmpty(argument.ShortName) &&
                        !this.argumentMap.ContainsKey(argument.ShortName))
                        this.argumentMap[argument.ShortName] = argument;
                    else
                        argument.ClearShortName();
                }
            }
        }
示例#18
0
文件: gzjs.cs 项目: akinomyoga/agh
  static void Process(Argument cmdline){
    if(cmdline.IsTest){
      Trans.Test(cmdline);
      return;
    }

    // 各ファイルに対する処理
    System.Text.StringBuilder bcontent=new System.Text.StringBuilder();
    foreach(string file in cmdline.FileNames){
      string content1=System.IO.File.ReadAllText(file,System.Text.Encoding.UTF8);
      if(cmdline.Verbose)
        cmdline.WriteLine("gzjs: read from {0}.",file);

      content1=Trans.ProcessSource(content1,cmdline);
      if(cmdline.TokenReplacing)
        content1=Trans.GenerateTokenReplacing2(content1,cmdline);
      bcontent.Append(content1);
    }

    // 全体に対する処理
    string content=bcontent.ToString();
    if(cmdline.IsSfx85)
      content=Trans.CreateSfx85(content);
    else if(cmdline.IsSfx)
      content=Trans.CreateSfx(content);

    content=content.Replace("\r\n","\n");

    // 書込
    if(cmdline.IsGzipCompress){
      string gzfile=cmdline.OutputFile;
      if(cmdline.OutputFile=="-"){
        using(System.IO.Stream stdout=System.Console.OpenStandardOutput())
          IO.SaveAsGzipFile(stdout,content);
      }else
        IO.SaveAsGzipFile(gzfile,content);

      // <gzip.exe を使う場合>
      // string tempfile=System.IO.Path.Combine(IO.path_temp,System.IO.Path.GetFileName(cmdline.OutputFile));
      // writeFile(tempfile,content);
      // string gzfile=cmdline.OutputFile+".gz";
      // IO.gzip(tempfile,gzfile,false);
      // </gzip>

      if(cmdline.Verbose)
        cmdline.WriteLine("gzjs: wrote to {0}.",gzfile);
    }else{
      string outfile=cmdline.OutputFile;
      if(outfile=="-")
        System.Console.Write(content);
      else
        writeFile(outfile,content);
      if(cmdline.Verbose)
        cmdline.WriteLine("gzjs: wrote to {0}.",outfile);
    }
  }
 private object evaluateArgument(Argument argument) {
     if (argument.style == Argument.Style.Constant) {
         return argument.value;
     } else if (argument.style == Argument.Style.Parameter) {
         return ((Parameter)argument.value).value;
     } else if (argument.style == Argument.Style.Filter) {
         return evaluateFilter((Method)argument.value);
     }
     return null;
 }
示例#20
0
 public Parser(Type argumentSpecification, ErrorReporter reporter)
 {
     this.reporter = reporter;
     arguments = new ArrayList();
     argumentMap = new Hashtable();
     FieldInfo[] fields = argumentSpecification.GetFields();
     for (int i = 0; i < fields.Length; i++)
     {
         FieldInfo field = fields[i];
         if (!field.IsStatic && !field.IsInitOnly && !field.IsLiteral)
         {
             ArgumentAttribute attribute = GetAttribute(field);
             if (attribute is DefaultArgumentAttribute)
             {
                 Debug.Assert(defaultArgument == null);
                 defaultArgument = new Argument(attribute, field, reporter);
             }
             else
             {
                 arguments.Add(new Argument(attribute, field, reporter));
             }
         }
     }
     foreach (Argument argument in arguments)
     {
         Debug.Assert(!argumentMap.ContainsKey(argument.LongName));
         argumentMap[argument.LongName] = argument;
         if (argument.ExplicitShortName)
         {
             if (argument.ShortName != null && argument.ShortName.Length > 0)
             {
                 Debug.Assert(!argumentMap.ContainsKey(argument.ShortName));
                 argumentMap[argument.ShortName] = argument;
             }
             else
             {
                 argument.ClearShortName();
             }
         }
     }
     foreach (Argument argument in arguments)
     {
         if (!argument.ExplicitShortName)
         {
             if (argument.ShortName != null && argument.ShortName.Length > 0 && !argumentMap.ContainsKey(argument.ShortName))
             {
                 argumentMap[argument.ShortName] = argument;
             }
             else
             {
                 argument.ClearShortName();
             }
         }
     }
 }
 /// <summary>
 /// Serializes a filter variable to an XML file.
 /// </summary>
 /// <param name="writer">XMLWriter where the argument is stored.</param>
 /// <param name="argument">Argument to serialize.</param>
 /// <returns>Returns the XMLWriter with the argument.</returns>
 public static XmlWriter Serialize(XmlWriter writer, Argument argument)
 {
     writer.WriteStartElement(DTD.Request.QueryRequest.QueryFilter.FilterVariables.TagFilterVariable);
     writer.WriteAttributeString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagName, argument.Name);
     ModelType modelType = Convert.StringTypeToMODELType(argument.Type);
     if (modelType == ModelType.Oid)
     {
         writer.WriteAttributeString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagType, argument.ClassName);
     }
     else
     {
         writer.WriteAttributeString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagType, argument.Type);
     }
     if (argument.Value == null)
     {
         writer.WriteElementString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagNull, string.Empty);
     }
     else
     {
         if (argument.Value is Oids.AlternateKey)
         {
             XMLAlternateKeySerializer.Serialize(writer, (Oids.AlternateKey)argument.Value);
         }
         else if (argument.Value is Oids.Oid)
         {
             XMLAdaptorOIDSerializer.Serialize(writer, argument.Value as Oids.Oid);
         }
         else // <Literal>
         {
             string lvalue = Convert.TypeToXml(argument.Type, argument.Value); //<-- Convert TypeToXML()!!!!
             if (lvalue.Length > 0)
             {
                 // Check White spaces.
                 string lvalueTrim = lvalue.Trim();
                 if (lvalueTrim.Length > 0)
                 {
                     writer.WriteStartElement(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagLiteral);
                     writer.WriteValue(lvalue);
                     writer.WriteEndElement();
                 }
                 else// if is White spaces is <NULL>
                 {
                     writer.WriteElementString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagNull, string.Empty);
                 }
             }
             else // Is <NULL>
             {
                 writer.WriteElementString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagNull, string.Empty);
             }
         }
     }
     writer.WriteEndElement();
     return writer;
 }
示例#22
0
 internal static CommandParameterInternal CreateArgument(IScriptExtent extent, object value, bool splatted = false)
 {
     CommandParameterInternal internal2 = new CommandParameterInternal();
     Argument argument = new Argument {
         extent = extent,
         value = value,
         splatted = splatted
     };
     internal2._argument = argument;
     return internal2;
 }
示例#23
0
 public static SCode Make(Argument rator, SCode rand0, SCode rand1)
 {
     return
         (rator is Argument0) ? Combination2A0.Make ((Argument0) rator, rand0, rand1) :
         (rand0 is Argument) ? Combination2AA.Make (rator, (Argument) rand0, rand1) :
         (rand0 is Quotation) ? Combination2AQ.Make (rator, (Quotation) rand0, rand1) :
         (rand0 is StaticVariable) ? Combination2AS.Make (rator, (StaticVariable) rand0, rand1) :
         (rand1 is Argument) ? Combination2AXA.Make (rator, rand0, (Argument) rand1):
         (rand1 is Quotation) ? new Combination2AXQ (rator, rand0, (Quotation) rand1) :
         (rand1 is StaticVariable) ? new Combination2AXS (rator, rand0, (StaticVariable) rand1) :
         new Combination2A (rator, rand0, rand1);
 }
示例#24
0
        private static IEnumerable<string> EnumerableFor(Argument fixedInVersions)
        {
            if (!fixedInVersions.IsPresent)
            {
                yield break;
            }

            foreach (var version in fixedInVersions.Values)
            {
                yield return version;
            }
        }
示例#25
0
	private Token stringify(Token pos, Argument arg) {
		StringBuilder	buf = new StringBuilder();
		concat(buf, arg);
		// System.out.println("Concat: " + arg + " -> " + buf);
		StringBuilder	str = new StringBuilder("\"");
		escape(str, buf.ToString());
		str.append("\"");
		// System.out.println("Escape: " + buf + " -> " + str);
		return new Token(Token.STRING,
				pos.getLine(), pos.getColumn(),
				str.toString(), buf.toString());
	}
示例#26
0
        public override Expression VisitMethodCall(MethodCallExpression expression)
        {
            methodInfo = expression.Method;

            arguments = new Argument[expression.Arguments.Count];

            for (int index = 0; index < arguments.Length; index++)
            {
                arguments[index] = new Argument(expression.Arguments[index]);
            }

            return expression;
        }
示例#27
0
 public static Argument Get(string name, params string[] defaultValue)
 {
     Argument retVal = null;
     if (!_ArgumentsBySwitch.TryGetValue(name, out retVal))
     {
         retVal = new Argument(name);
         if (defaultValue != null && defaultValue.Length > 0)
         {
             retVal.Values.AddRange(defaultValue);
         }
     }
     return retVal;
 }
示例#28
0
        public List<Argument> getOutlineArgs()
        {
            List<Argument> result = new List<Argument>();
            Regex p = new Regex("<[^<]*>");
            var matches = p.Matches(getName());
            foreach (System.Text.RegularExpressions.Match match in matches)
            {
                var argument = new Argument(match.Index, match.Value);
                result.Add(argument);
            }

            return result;
        }
示例#29
0
        public void ParsingWorks()
        {
            var a = new Argument("value1", new Parameter("a"));
            var b = new Argument("123", new Parameter("b"));
            var c = new Argument("Sunday", new Parameter("c"));

            this
                .Given(s => Task.FromResult(0))
                .Then(s => a.Value.Should().Be("value1", null))
                .Then(s => b.AsInt32().Should().Be(123, null))
                .Then(s => c.AsEnum<DayOfWeek>().Should().Be(DayOfWeek.Sunday, null))
                .BDDfy();
        }
示例#30
0
        /// <summary>
        /// Extends the specific method for a particular array of arguments to be used with the container.
        /// </summary>
        public IMethod Create(System.Reflection.MethodInfo methodInfo, Argument[] arguments)
        {
            var methodHash = new MethodHash(methodInfo);

            if (!methods.ContainsKey(methodHash))
                methods.Add(methodHash, new List<IMethod>());

            var methodMetaData = new MethodMetaData(methodHash, arguments);

            methods[methodHash].Add(methodMetaData);

            return methodMetaData;
        }
        public virtual async Task <ArmOperation <PrivateEndpointConnectionResource> > UpdateAsync(WaitUntil waitUntil, PrivateEndpointConnectionData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _privateEndpointConnectionClientDiagnostics.CreateScope("PrivateEndpointConnectionResource.Update");
            scope.Start();
            try
            {
                var response = await _privateEndpointConnectionRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false);

                var operation = new EventHubsArmOperation <PrivateEndpointConnectionResource>(Response.FromValue(new PrivateEndpointConnectionResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual ArmOperation <AvailabilitySetResource> CreateOrUpdate(WaitUntil waitUntil, string availabilitySetName, AvailabilitySetData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(availabilitySetName, nameof(availabilitySetName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _availabilitySetClientDiagnostics.CreateScope("AvailabilitySetCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _availabilitySetRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, availabilitySetName, data, cancellationToken);
                var operation = new ComputeArmOperation <AvailabilitySetResource>(Response.FromValue(new AvailabilitySetResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#33
0
        public virtual async Task <ArmOperation <GalleryImageVersionResource> > UpdateAsync(WaitUntil waitUntil, PatchableGalleryImageVersionData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _galleryImageVersionClientDiagnostics.CreateScope("GalleryImageVersionResource.Update");
            scope.Start();
            try
            {
                var response = await _galleryImageVersionRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false);

                var operation = new ComputeArmOperation <GalleryImageVersionResource>(new GalleryImageVersionOperationSource(Client), _galleryImageVersionClientDiagnostics, Pipeline, _galleryImageVersionRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#34
0
        public virtual async Task <ArmOperation <ServiceRegistryResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string serviceRegistryName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(serviceRegistryName, nameof(serviceRegistryName));

            using var scope = _serviceRegistryResourceServiceRegistriesClientDiagnostics.CreateScope("ServiceRegistryResourceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _serviceRegistryResourceServiceRegistriesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, serviceRegistryName, cancellationToken).ConfigureAwait(false);

                var operation = new AppPlatformArmOperation <ServiceRegistryResource>(new ServiceRegistryResourceOperationSource(Client), _serviceRegistryResourceServiceRegistriesClientDiagnostics, Pipeline, _serviceRegistryResourceServiceRegistriesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, serviceRegistryName).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#35
0
        public virtual async Task <ArmOperation <VirtualMachineRunCommandResource> > UpdateAsync(WaitUntil waitUntil, VirtualMachineRunCommandUpdate runCommand, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(runCommand, nameof(runCommand));

            using var scope = _virtualMachineRunCommandClientDiagnostics.CreateScope("VirtualMachineRunCommandResource.Update");
            scope.Start();
            try
            {
                var response = await _virtualMachineRunCommandRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, runCommand, cancellationToken).ConfigureAwait(false);

                var operation = new ComputeArmOperation <VirtualMachineRunCommandResource>(new VirtualMachineRunCommandOperationSource(Client), _virtualMachineRunCommandClientDiagnostics, Pipeline, _virtualMachineRunCommandRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, runCommand).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async virtual Task <ArmOperation <FtpSiteSlotBasicPublishingCredentialsPolicy> > CreateOrUpdateAsync(bool waitForCompletion, CsmPublishingCredentialsPoliciesEntityData csmPublishingAccessPoliciesEntity, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(csmPublishingAccessPoliciesEntity, nameof(csmPublishingAccessPoliciesEntity));

            using var scope = _ftpSiteSlotBasicPublishingCredentialsPolicyWebAppsClientDiagnostics.CreateScope("FtpSiteSlotBasicPublishingCredentialsPolicy.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _ftpSiteSlotBasicPublishingCredentialsPolicyWebAppsRestClient.UpdateFtpAllowedSlotAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, csmPublishingAccessPoliciesEntity, cancellationToken).ConfigureAwait(false);

                var operation = new AppServiceArmOperation <FtpSiteSlotBasicPublishingCredentialsPolicy>(Response.FromValue(new FtpSiteSlotBasicPublishingCredentialsPolicy(Client, response), response.GetRawResponse()));
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#37
0
        public async virtual Task <ArmOperation> ValidateMoveResourcesAsync(bool waitForCompletion, ResourcesMoveInfo parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroup.ValidateMoveResources");
            scope.Start();
            try
            {
                var response = await _resourceGroupRestClient.ValidateMoveResourcesAsync(Id.SubscriptionId, Id.ResourceGroupName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new ResourcesArmOperation(_resourceGroupClientDiagnostics, Pipeline, _resourceGroupRestClient.CreateValidateMoveResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, parameters).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#38
0
        public virtual ArmOperation <ClusterResource> CreateOrUpdate(WaitUntil waitUntil, string clusterName, ClusterResourceData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(clusterName, nameof(clusterName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _clusterResourceCassandraClustersClientDiagnostics.CreateScope("ClusterResourceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _clusterResourceCassandraClustersRestClient.CreateUpdate(Id.SubscriptionId, Id.ResourceGroupName, clusterName, data, cancellationToken);
                var operation = new CosmosDBArmOperation <ClusterResource>(new ClusterResourceOperationSource(Client), _clusterResourceCassandraClustersClientDiagnostics, Pipeline, _clusterResourceCassandraClustersRestClient.CreateCreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, clusterName, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#39
0
        public virtual ArmOperation <SiteDomainOwnershipIdentifierResource> CreateOrUpdate(WaitUntil waitUntil, string domainOwnershipIdentifierName, IdentifierData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(domainOwnershipIdentifierName, nameof(domainOwnershipIdentifierName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _siteDomainOwnershipIdentifierWebAppsClientDiagnostics.CreateScope("SiteDomainOwnershipIdentifierCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _siteDomainOwnershipIdentifierWebAppsRestClient.CreateOrUpdateDomainOwnershipIdentifier(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, domainOwnershipIdentifierName, data, cancellationToken);
                var operation = new AppServiceArmOperation <SiteDomainOwnershipIdentifierResource>(Response.FromValue(new SiteDomainOwnershipIdentifierResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#40
0
        public virtual ArmOperation <LocalUser> CreateOrUpdate(WaitUntil waitUntil, string username, LocalUserData properties, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(username, nameof(username));
            Argument.AssertNotNull(properties, nameof(properties));

            using var scope = _localUserClientDiagnostics.CreateScope("LocalUserCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _localUserRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, username, properties, cancellationToken);
                var operation = new StorageArmOperation <LocalUser>(Response.FromValue(new LocalUser(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async Task <Response> CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string galleryName, string galleryApplicationName, string galleryApplicationVersionName, GalleryApplicationVersionData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(galleryName, nameof(galleryName));
            Argument.AssertNotNullOrEmpty(galleryApplicationName, nameof(galleryApplicationName));
            Argument.AssertNotNullOrEmpty(galleryApplicationVersionName, nameof(galleryApplicationVersionName));
            Argument.AssertNotNull(data, nameof(data));

            using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, data);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            case 201:
            case 202:
                return(message.Response);

            default:
                throw new RequestFailedException(message.Response);
            }
        }
示例#42
0
        /// <summary>
        /// Closes the document in the main shell with the specified view model.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="tag">The tag.</param>
        public void CloseDocument(IViewModel viewModel, object tag = null)
        {
            Argument.IsNotNull(() => viewModel);

            Log.Debug("Closing document for view model '{0}'", viewModel.UniqueIdentifier);

            var viewLocator = GetService <IViewLocator>();
            var viewType    = viewLocator.ResolveView(viewModel.GetType());

            var document = AvalonDockHelper.FindDocument(viewType, tag);

            if (document == null)
            {
                Log.Warning("Cannot find document belonging to view model '{0}' with id '{1}' thus cannot close the document",
                            ObjectToStringHelper.ToTypeString(viewModel), viewModel.UniqueIdentifier);
            }
            else
            {
                AvalonDockHelper.CloseDocument(document);
            }

            Log.Debug("Closed document for view model '{0}'", viewModel.UniqueIdentifier);
        }
        public async virtual Task <ArmOperation <ExpressRouteCircuitsRoutesTableListResult> > GetRoutesTableExpressRouteCrossConnectionAsync(bool waitForCompletion, string devicePath, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(devicePath, nameof(devicePath));

            using var scope = _expressRouteCrossConnectionClientDiagnostics.CreateScope("ExpressRouteCrossConnectionPeering.GetRoutesTableExpressRouteCrossConnection");
            scope.Start();
            try
            {
                var response = await _expressRouteCrossConnectionRestClient.ListRoutesTableAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, devicePath, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkArmOperation <ExpressRouteCircuitsRoutesTableListResult>(new ExpressRouteCircuitsRoutesTableListResultOperationSource(), _expressRouteCrossConnectionClientDiagnostics, Pipeline, _expressRouteCrossConnectionRestClient.CreateListRoutesTableRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, devicePath).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual async Task <ArmOperation <SharedPrivateLinkResource> > UpdateAsync(WaitUntil waitUntil, SharedPrivateLinkData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _sharedPrivateLinkWebPubSubSharedPrivateLinkResourcesClientDiagnostics.CreateScope("SharedPrivateLinkResource.Update");
            scope.Start();
            try
            {
                var response = await _sharedPrivateLinkWebPubSubSharedPrivateLinkResourcesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false);

                var operation = new WebPubSubArmOperation <SharedPrivateLinkResource>(new SharedPrivateLinkOperationSource(Client), _sharedPrivateLinkWebPubSubSharedPrivateLinkResourcesClientDiagnostics, Pipeline, _sharedPrivateLinkWebPubSubSharedPrivateLinkResourcesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#45
0
        public async virtual Task <Response <ResourceGroup> > RemoveTagAsync(string key, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(key, nameof(key));

            using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroup.RemoveTag");
            scope.Start();
            try
            {
                var originalTags = await TagResource.GetAsync(cancellationToken).ConfigureAwait(false);

                originalTags.Value.Data.Properties.TagsValue.Remove(key);
                await TagResource.CreateOrUpdateAsync(true, originalTags.Value.Data, cancellationToken : cancellationToken).ConfigureAwait(false);

                var originalResponse = await _resourceGroupRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(new ResourceGroup(Client, originalResponse.Value), originalResponse.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#46
0
        /// <summary>
        ///   Creates a consumer strongly aligned with the active protocol and transport, responsible
        ///   for reading <see cref="ServiceBusMessage" /> from a specific Service Bus entity.
        /// </summary>
        /// <param name="entityPath"></param>
        ///
        /// <param name="retryPolicy">The policy which governs retry behavior and try timeouts.</param>
        /// <param name="receiveMode">The <see cref="ReceiveMode"/> used to specify how messages are received. Defaults to PeekLock mode.</param>
        /// <param name="prefetchCount">Controls the number of events received and queued locally without regard to whether an operation was requested.  If <c>null</c> a default will be used.</param>
        /// <param name="identifier"></param>
        /// <param name="sessionId"></param>
        /// <param name="isSessionReceiver"></param>
        ///
        /// <returns>A <see cref="TransportReceiver" /> configured in the requested manner.</returns>
        ///
        public override TransportReceiver CreateReceiver(
            string entityPath,
            ServiceBusRetryPolicy retryPolicy,
            ReceiveMode receiveMode,
            uint prefetchCount,
            string identifier,
            string sessionId,
            bool isSessionReceiver)
        {
            Argument.AssertNotClosed(_closed, nameof(AmqpClient));

            return(new AmqpReceiver
                   (
                       entityPath,
                       receiveMode,
                       prefetchCount,
                       ConnectionScope,
                       retryPolicy,
                       identifier,
                       sessionId,
                       isSessionReceiver
                   ));
        }
示例#47
0
        public async virtual Task <ArmOperation <AfdSecurityPolicy> > UpdateAsync(bool waitForCompletion, AfdSecurityPolicyUpdateOptions options, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(options, nameof(options));

            using var scope = _afdSecurityPolicyClientDiagnostics.CreateScope("AfdSecurityPolicy.Update");
            scope.Start();
            try
            {
                var response = await _afdSecurityPolicyRestClient.PatchAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options, cancellationToken).ConfigureAwait(false);

                var operation = new CdnArmOperation <AfdSecurityPolicy>(new AfdSecurityPolicyOperationSource(Client), _afdSecurityPolicyClientDiagnostics, Pipeline, _afdSecurityPolicyRestClient.CreatePatchRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options).Request, response, OperationFinalStateVia.OriginalUri);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual ArmOperation <SiteSlotFunction> CreateOrUpdate(bool waitForCompletion, string functionName, FunctionEnvelopeData functionEnvelope, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(functionName, nameof(functionName));
            Argument.AssertNotNull(functionEnvelope, nameof(functionEnvelope));

            using var scope = _siteSlotFunctionWebAppsClientDiagnostics.CreateScope("SiteSlotFunctionCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _siteSlotFunctionWebAppsRestClient.CreateInstanceFunctionSlot(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, functionName, functionEnvelope, cancellationToken);
                var operation = new AppServiceArmOperation <SiteSlotFunction>(new SiteSlotFunctionOperationSource(Client), _siteSlotFunctionWebAppsClientDiagnostics, Pipeline, _siteSlotFunctionWebAppsRestClient.CreateCreateInstanceFunctionSlotRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, functionName, functionEnvelope).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual ArmOperation <SiteHybridConnection> CreateOrUpdate(bool waitForCompletion, string entityName, RelayServiceConnectionEntityData connectionEnvelope, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(entityName, nameof(entityName));
            Argument.AssertNotNull(connectionEnvelope, nameof(connectionEnvelope));

            using var scope = _siteHybridConnectionWebAppsClientDiagnostics.CreateScope("SiteHybridConnectionCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _siteHybridConnectionWebAppsRestClient.CreateOrUpdateRelayServiceConnection(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, entityName, connectionEnvelope, cancellationToken);
                var operation = new AppServiceArmOperation <SiteHybridConnection>(Response.FromValue(new SiteHybridConnection(Client, response), response.GetRawResponse()));
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#50
0
        public virtual ArmOperation <Disk> CreateOrUpdate(WaitUntil waitUntil, string diskName, DiskData disk, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(diskName, nameof(diskName));
            Argument.AssertNotNull(disk, nameof(disk));

            using var scope = _diskClientDiagnostics.CreateScope("DiskCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _diskRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, diskName, disk, cancellationToken);
                var operation = new ComputeArmOperation <Disk>(new DiskOperationSource(Client), _diskClientDiagnostics, Pipeline, _diskRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, diskName, disk).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async virtual Task <Response <DdosProtectionPlan> > AddTagAsync(string key, string value, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrWhiteSpace(key, nameof(key));

            using var scope = _ddosProtectionPlanClientDiagnostics.CreateScope("DdosProtectionPlan.AddTag");
            scope.Start();
            try
            {
                var originalTags = await TagResource.GetAsync(cancellationToken).ConfigureAwait(false);

                originalTags.Value.Data.Properties.TagsValue[key] = value;
                await TagResource.CreateOrUpdateAsync(true, originalTags.Value.Data, cancellationToken : cancellationToken).ConfigureAwait(false);

                var originalResponse = await _ddosProtectionPlanRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(new DdosProtectionPlan(ArmClient, originalResponse.Value), originalResponse.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#52
0
        public virtual async Task <ArmOperation <VMwareClusterResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string clusterName, VMwareClusterData data = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(clusterName, nameof(clusterName));

            using var scope = _vMwareClusterClustersClientDiagnostics.CreateScope("VMwareClusterCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _vMwareClusterClustersRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, clusterName, data, cancellationToken).ConfigureAwait(false);

                var operation = new ConnectedVMwarevSphereArmOperation <VMwareClusterResource>(new VMwareClusterOperationSource(Client), _vMwareClusterClustersClientDiagnostics, Pipeline, _vMwareClusterClustersRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, clusterName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual ArmOperation <EventHubsPrivateEndpointConnectionResource> CreateOrUpdate(WaitUntil waitUntil, string privateEndpointConnectionName, EventHubsPrivateEndpointConnectionData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _eventHubsPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("EventHubsPrivateEndpointConnectionCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _eventHubsPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data, cancellationToken);
                var operation = new EventHubsArmOperation <EventHubsPrivateEndpointConnectionResource>(Response.FromValue(new EventHubsPrivateEndpointConnectionResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#54
0
        public virtual async Task <ArmOperation <ScVmmVirtualNetworkResource> > UpdateAsync(WaitUntil waitUntil, ResourcePatch patch, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(patch, nameof(patch));

            using var scope = _scVmmVirtualNetworkVirtualNetworksClientDiagnostics.CreateScope("ScVmmVirtualNetworkResource.Update");
            scope.Start();
            try
            {
                var response = await _scVmmVirtualNetworkVirtualNetworksRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false);

                var operation = new ArcScVmmArmOperation <ScVmmVirtualNetworkResource>(new ScVmmVirtualNetworkOperationSource(Client), _scVmmVirtualNetworkVirtualNetworksClientDiagnostics, Pipeline, _scVmmVirtualNetworkVirtualNetworksRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#55
0
        public virtual ArmOperation <P2SVpnGateway> CreateOrUpdate(WaitUntil waitUntil, string gatewayName, P2SVpnGatewayData p2SVpnGatewayParameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName));
            Argument.AssertNotNull(p2SVpnGatewayParameters, nameof(p2SVpnGatewayParameters));

            using var scope = _p2SVpnGatewayP2sVpnGatewaysClientDiagnostics.CreateScope("P2SVpnGatewayCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _p2SVpnGatewayP2sVpnGatewaysRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, p2SVpnGatewayParameters, cancellationToken);
                var operation = new NetworkArmOperation <P2SVpnGateway>(new P2SVpnGatewayOperationSource(Client), _p2SVpnGatewayP2sVpnGatewaysClientDiagnostics, Pipeline, _p2SVpnGatewayP2sVpnGatewaysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, p2SVpnGatewayParameters).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual ArmOperation <RouteResource> CreateOrUpdate(WaitUntil waitUntil, string routeName, RouteData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(routeName, nameof(routeName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _routeClientDiagnostics.CreateScope("RouteCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _routeRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeName, data, cancellationToken);
                var operation = new NetworkArmOperation <RouteResource>(new RouteOperationSource(Client), _routeClientDiagnostics, Pipeline, _routeRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual async Task <Response <VirtualNetworkResource> > RemoveTagAsync(string key, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(key, nameof(key));

            using var scope = _virtualNetworkClientDiagnostics.CreateScope("VirtualNetworkResource.RemoveTag");
            scope.Start();
            try
            {
                var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false);

                originalTags.Value.Data.TagValues.Remove(key);
                await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false);

                var originalResponse = await _virtualNetworkRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(new VirtualNetworkResource(Client, originalResponse.Value), originalResponse.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#58
0
        public virtual ArmOperation <MsixPackageResource> CreateOrUpdate(WaitUntil waitUntil, string msixPackageFullName, MsixPackageData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(msixPackageFullName, nameof(msixPackageFullName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _msixPackageMSIXPackagesClientDiagnostics.CreateScope("MsixPackageCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _msixPackageMSIXPackagesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, msixPackageFullName, data, cancellationToken);
                var operation = new DesktopVirtualizationArmOperation <MsixPackageResource>(Response.FromValue(new MsixPackageResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#59
0
        public async virtual Task <ArmOperation <SyncMember> > UpdateAsync(bool waitForCompletion, SyncMemberData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _syncMemberClientDiagnostics.CreateScope("SyncMember.Update");
            scope.Start();
            try
            {
                var response = await _syncMemberRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new SqlArmOperation <SyncMember>(new SyncMemberOperationSource(Client), _syncMemberClientDiagnostics, Pipeline, _syncMemberRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, parameters).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#60
0
        public virtual async Task <ArmOperation <FirewallPolicyRuleCollectionGroupResource> > UpdateAsync(WaitUntil waitUntil, FirewallPolicyRuleCollectionGroupData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _firewallPolicyRuleCollectionGroupClientDiagnostics.CreateScope("FirewallPolicyRuleCollectionGroupResource.Update");
            scope.Start();
            try
            {
                var response = await _firewallPolicyRuleCollectionGroupRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkArmOperation <FirewallPolicyRuleCollectionGroupResource>(new FirewallPolicyRuleCollectionGroupOperationSource(Client), _firewallPolicyRuleCollectionGroupClientDiagnostics, Pipeline, _firewallPolicyRuleCollectionGroupRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }