Ejemplo n.º 1
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, string, TargetInstance, CallSettings)
            // Additional: InsertAsync(string, string, TargetInstance, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            string         project = "";
            string         zone    = "";
            TargetInstance targetInstanceResource = new TargetInstance();
            // Make the request
            lro::Operation <Operation, Operation> response = await targetInstancesClient.InsertAsync(project, zone, targetInstanceResource);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Operation result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            lro::Operation <Operation, Operation> retrievedResponse = await targetInstancesClient.PollOnceInsertAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Ejemplo n.º 2
0
        public void Get()
        {
            moq::Mock <TargetInstances.TargetInstancesClient> mockGrpcClient = new moq::Mock <TargetInstances.TargetInstancesClient>(moq::MockBehavior.Strict);
            GetTargetInstanceRequest request = new GetTargetInstanceRequest
            {
                Zone           = "zone255f4ea8",
                Project        = "projectaa6ff846",
                TargetInstance = "target_instance1017fe07",
            };
            TargetInstance expectedResponse = new TargetInstance
            {
                Id                = "id74b70bb8",
                Kind              = "kindf7aa39d9",
                Name              = "name1c9368b0",
                Zone              = "zone255f4ea8",
                Instance          = "instance99a62371",
                CreationTimestamp = "creation_timestamp235e59a1",
                Description       = "description2cf9da67",
                SelfLink          = "self_link7e87f12d",
                NatPolicy         = TargetInstance.Types.NatPolicy.NoNat,
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TargetInstancesClient client   = new TargetInstancesClientImpl(mockGrpcClient.Object, null);
            TargetInstance        response = client.Get(request.Project, request.Zone, request.TargetInstance);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetRequestObject()
        {
            moq::Mock <TargetInstances.TargetInstancesClient> mockGrpcClient = new moq::Mock <TargetInstances.TargetInstancesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForZoneOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTargetInstanceRequest request = new GetTargetInstanceRequest
            {
                Zone           = "zone255f4ea8",
                Project        = "projectaa6ff846",
                TargetInstance = "target_instance1017fe07",
            };
            TargetInstance expectedResponse = new TargetInstance
            {
                Id                = 11672635353343658936UL,
                Kind              = "kindf7aa39d9",
                Name              = "name1c9368b0",
                Zone              = "zone255f4ea8",
                Instance          = "instance99a62371",
                CreationTimestamp = "creation_timestamp235e59a1",
                Network           = "networkd22ce091",
                Description       = "description2cf9da67",
                SelfLink          = "self_link7e87f12d",
                NatPolicy         = "nat_policy8dd30c47",
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TargetInstancesClient client   = new TargetInstancesClientImpl(mockGrpcClient.Object, null);
            TargetInstance        response = client.Get(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 4
0
        public async stt::Task GetAsync()
        {
            moq::Mock <TargetInstances.TargetInstancesClient> mockGrpcClient = new moq::Mock <TargetInstances.TargetInstancesClient>(moq::MockBehavior.Strict);
            GetTargetInstanceRequest request = new GetTargetInstanceRequest
            {
                Zone           = "zone255f4ea8",
                Project        = "projectaa6ff846",
                TargetInstance = "target_instance1017fe07",
            };
            TargetInstance expectedResponse = new TargetInstance
            {
                Id                = "id74b70bb8",
                Kind              = "kindf7aa39d9",
                Name              = "name1c9368b0",
                Zone              = "zone255f4ea8",
                Instance          = "instance99a62371",
                CreationTimestamp = "creation_timestamp235e59a1",
                Description       = "description2cf9da67",
                SelfLink          = "self_link7e87f12d",
                NatPolicy         = TargetInstance.Types.NatPolicy.NoNat,
            };

            mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <TargetInstance>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            TargetInstancesClient client = new TargetInstancesClientImpl(mockGrpcClient.Object, null);
            TargetInstance        responseCallSettings = await client.GetAsync(request.Project, request.Zone, request.TargetInstance, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            TargetInstance responseCancellationToken = await client.GetAsync(request.Project, request.Zone, request.TargetInstance, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>
 /// Creates a TargetInstance resource in the specified project and zone using the data included in the request.
 /// </summary>
 /// <param name="project">
 /// Project ID for this request.
 /// </param>
 /// <param name="zone">
 /// Name of the zone scoping this request.
 /// </param>
 /// <param name="targetInstanceResource">
 /// The body resource for this request
 /// </param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual Operation Insert(string project, string zone, TargetInstance targetInstanceResource, gaxgrpc::CallSettings callSettings = null) =>
 Insert(new InsertTargetInstanceRequest
 {
     Project = gax::GaxPreconditions.CheckNotNullOrEmpty(project, nameof(project)),
     TargetInstanceResource = gax::GaxPreconditions.CheckNotNull(targetInstanceResource, nameof(targetInstanceResource)),
     Zone = gax::GaxPreconditions.CheckNotNullOrEmpty(zone, nameof(zone)),
 }, callSettings);
Ejemplo n.º 6
0
        public void Execute(object parameter)
        {
            var command = TargetInstance.GetType().GetProperty("Instance").GetValue(TargetInstance) as ICommand;
            var result  = _commandCoordinator.Handle(command);
            var process = Proxy as ICanProcessCommandProcess;

            process.Process(command, result);
        }
Ejemplo n.º 7
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = OriginGenericParameter != null?OriginGenericParameter.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (TargetInstance != null ? TargetInstance.GetHashCode() : 0);
                return(hashCode);
            }
        }
Ejemplo n.º 8
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + AddAccessor?.GetHashCode() ?? 0;
         hash = hash * 23 + RemoveAccessor?.GetHashCode() ?? 0;
         hash = hash * 23 + TargetInstance?.GetHashCode() ?? 0;
         return(hash);
     }
 }
Ejemplo n.º 9
0
 /// <summary>Snippet for Insert</summary>
 public void Insert()
 {
     // Snippet: Insert(string, string, TargetInstance, CallSettings)
     // Create client
     TargetInstancesClient targetInstancesClient = TargetInstancesClient.Create();
     // Initialize request argument(s)
     string         project = "";
     string         zone    = "";
     TargetInstance targetInstanceResource = new TargetInstance();
     // Make the request
     Operation response = targetInstancesClient.Insert(project, zone, targetInstanceResource);
     // End snippet
 }
Ejemplo n.º 10
0
 /// <summary>Snippet for Get</summary>
 public void Get()
 {
     // Snippet: Get(string, string, string, CallSettings)
     // Create client
     TargetInstancesClient targetInstancesClient = TargetInstancesClient.Create();
     // Initialize request argument(s)
     string project        = "";
     string zone           = "";
     string targetInstance = "";
     // Make the request
     TargetInstance response = targetInstancesClient.Get(project, zone, targetInstance);
     // End snippet
 }
Ejemplo n.º 11
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetAsync()
        {
            // Snippet: GetAsync(string, string, string, CallSettings)
            // Additional: GetAsync(string, string, string, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            string project        = "";
            string zone           = "";
            string targetInstance = "";
            // Make the request
            TargetInstance response = await targetInstancesClient.GetAsync(project, zone, targetInstance);

            // End snippet
        }
Ejemplo n.º 12
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, string, TargetInstance, CallSettings)
            // Additional: InsertAsync(string, string, TargetInstance, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            string         project = "";
            string         zone    = "";
            TargetInstance targetInstanceResource = new TargetInstance();
            // Make the request
            Operation response = await targetInstancesClient.InsertAsync(project, zone, targetInstanceResource);

            // End snippet
        }
Ejemplo n.º 13
0
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetTargetInstanceRequest, CallSettings)
     // Create client
     TargetInstancesClient targetInstancesClient = TargetInstancesClient.Create();
     // Initialize request argument(s)
     GetTargetInstanceRequest request = new GetTargetInstanceRequest
     {
         Zone           = "",
         TargetInstance = "",
         Project        = "",
     };
     // Make the request
     TargetInstance response = targetInstancesClient.Get(request);
     // End snippet
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            IActivatedEventArgs activatedArgs = AppInstance.GetActivatedEventArgs();

            if (activatedArgs is ToastNotificationActivatedEventArgs)
            {
                return;
            }

            if (activatedArgs is CommandLineActivatedEventArgs CmdActivate)
            {
                if (CmdActivate.Operation.Arguments.StartsWith("RX-Explorer.exe"))
                {
                    if (AppInstance.RecommendedInstance != null)
                    {
                        AppInstance.RecommendedInstance.RedirectActivationTo();
                    }
                    else if (ApplicationData.Current.LocalSettings.Values["LastActiveGuid"] is string LastGuid &&
                             !string.IsNullOrWhiteSpace(LastGuid) &&
                             AppInstance.FindOrRegisterInstanceForKey(LastGuid) is AppInstance TargetInstance &&
                             !TargetInstance.IsCurrentInstance)
                    {
                        TargetInstance.RedirectActivationTo();
                    }
                    else if (AppInstance.GetInstances().FirstOrDefault() is AppInstance ExistInstance)
                    {
                        ExistInstance.RedirectActivationTo();
                    }
                    else
                    {
                        string      InstanceId = Guid.NewGuid().ToString();
                        AppInstance Instance   = AppInstance.FindOrRegisterInstanceForKey(InstanceId);
                        ApplicationData.Current.LocalSettings.Values["LastActiveGuid"] = InstanceId;

                        Application.Start((p) => new App());
                    }
                }
                else
                {
                    string      InstanceId = Guid.NewGuid().ToString();
                    AppInstance Instance   = AppInstance.FindOrRegisterInstanceForKey(InstanceId);
                    ApplicationData.Current.LocalSettings.Values["LastActiveGuid"] = InstanceId;

                    Application.Start((p) => new App());
                }
            }
Ejemplo n.º 15
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetTargetInstanceRequest, CallSettings)
            // Additional: GetAsync(GetTargetInstanceRequest, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            GetTargetInstanceRequest request = new GetTargetInstanceRequest
            {
                Zone           = "",
                TargetInstance = "",
                Project        = "",
            };
            // Make the request
            TargetInstance response = await targetInstancesClient.GetAsync(request);

            // End snippet
        }
        //  public Boolean DoCreateNewIfNotExist { get; set; } = true;

        public Boolean Load()
        {
            if (File.Exists(Filepath))
            {
                LoadedXml = File.ReadAllText(Filepath);


                LoadedInstance = objectSerialization.ObjectOfTypeFromXML(LoadedXml, TargetType);

                TargetInstance.setObjectBySource(LoadedInstance);

                TargetXml = objectSerialization.ObjectToXML(TargetInstance);

                if (DoVerifyDataDeployement)
                {
                    XmlDocument loadedXmlDoc = new XmlDocument();
                    loadedXmlDoc.LoadXml(LoadedXml);

                    XmlDocument targetXmlDoc = new XmlDocument();
                    targetXmlDoc.LoadXml(TargetXml);

                    if (loadedXmlDoc.DocumentElement.OuterXml.Equals(targetXmlDoc.DocumentElement.OuterXml))
                    {
                        return(true);
                    }
                    else
                    {
                        //  throw new objectSerializationTaskException("Deployement of loaded XML [" + Filepath + "] is not verified", this, null);
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 17
0
        private object InvokeMethod(MethodBase method, Type[] parameterTypes, object[] parameters)
        {
            if (TargetInstance != null)
            {
                if (TargetType == null)
                {
                    TargetType = TargetInstance.GetType();
                }

                MethodBase underlyingMethod = TargetType.GetMethod(method.Name, parameterTypes);
                if (method == null)
                {
                    // Look for method definition in ancestor interfaces
                    foreach (Type interfaceType in TargetType.GetInterfaces())
                    {
                        underlyingMethod = interfaceType.GetMethod(method.Name, parameterTypes);
                        if (underlyingMethod != null)
                        {
                            break;
                        }
                    }
                }

                //MethodInfo underlyingMethod = underlyingType.GetMethod(method.Name);

                if (underlyingMethod == null)
                {
                    Debug.WriteLine("No underlying method found for " + method.Name);
                    throw new NotImplementedException(String.Format("Method {0} not found in underlying object", method.Name));
                }
                else
                {
                    return(underlyingMethod.Invoke(TargetInstance, parameters));
                }
            }

            return(null);
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            IActivatedEventArgs activatedArgs = AppInstance.GetActivatedEventArgs();

            if (AppInstance.GetInstances().Count == 0)
            {
                AppInstanceIdContainer.ClearAll();
            }

            switch (activatedArgs)
            {
            case ToastNotificationActivatedEventArgs ToastActivate:
            {
                switch (ToastActivate.Argument)
                {
                case "EnterBackgroundTips":
                {
                    if (AppInstance.RecommendedInstance != null)
                    {
                        AppInstance.RecommendedInstance.RedirectActivationTo();
                    }
                    else if (!string.IsNullOrWhiteSpace(AppInstanceIdContainer.LastActiveId))
                    {
                        do
                        {
                            if (AppInstance.GetInstances().Any((Ins) => Ins.Key == AppInstanceIdContainer.LastActiveId))
                            {
                                if (AppInstance.FindOrRegisterInstanceForKey(AppInstanceIdContainer.LastActiveId) is AppInstance TargetInstance)
                                {
                                    TargetInstance.RedirectActivationTo();
                                }

                                break;
                            }
                            else
                            {
                                AppInstanceIdContainer.UngisterId(AppInstanceIdContainer.LastActiveId);
                            }
                        }while (!string.IsNullOrEmpty(AppInstanceIdContainer.LastActiveId));
                    }

                    break;
                }

                case "Restart":
                {
                    string      InstanceId = Guid.NewGuid().ToString();
                    AppInstance Instance   = AppInstance.FindOrRegisterInstanceForKey(InstanceId);
                    AppInstanceIdContainer.RegisterId(InstanceId);

                    Application.Start((p) => new App());
                    break;
                }
                }

                break;
            }

            case CommandLineActivatedEventArgs CmdActivate:
            {
                if (CmdActivate.Operation.Arguments.StartsWith("RX-Explorer.exe", StringComparison.OrdinalIgnoreCase))
                {
                    if (AppInstance.RecommendedInstance != null)
                    {
                        AppInstance.RecommendedInstance.RedirectActivationTo();
                    }
                    else if (!string.IsNullOrWhiteSpace(AppInstanceIdContainer.LastActiveId))
                    {
                        do
                        {
                            if (AppInstance.GetInstances().Any((Ins) => Ins.Key == AppInstanceIdContainer.LastActiveId))
                            {
                                if (AppInstance.FindOrRegisterInstanceForKey(AppInstanceIdContainer.LastActiveId) is AppInstance TargetInstance)
                                {
                                    TargetInstance.RedirectActivationTo();
                                }

                                break;
                            }
                            else
                            {
                                AppInstanceIdContainer.UngisterId(AppInstanceIdContainer.LastActiveId);
                            }
                        }while (!string.IsNullOrEmpty(AppInstanceIdContainer.LastActiveId));
                    }
                    else
                    {
                        string      InstanceId = Guid.NewGuid().ToString();
                        AppInstance Instance   = AppInstance.FindOrRegisterInstanceForKey(InstanceId);
                        AppInstanceIdContainer.RegisterId(InstanceId);

                        Application.Start((p) => new App());
                    }
                }
                else
                {
                    if (!ApplicationData.Current.LocalSettings.Values.ContainsKey("AlwaysStartNew"))
                    {
                        ApplicationData.Current.LocalSettings.Values["AlwaysStartNew"] = true;
                    }

                    bool AlwaysStartNew = Convert.ToBoolean(ApplicationData.Current.LocalSettings.Values["AlwaysStartNew"]);

                    if (AlwaysStartNew)
                    {
                        string      InstanceId = Guid.NewGuid().ToString();
                        AppInstance Instance   = AppInstance.FindOrRegisterInstanceForKey(InstanceId);
                        AppInstanceIdContainer.RegisterId(InstanceId);

                        Application.Start((p) => new App());
                    }
                    else
                    {
                        if (!string.IsNullOrWhiteSpace(AppInstanceIdContainer.LastActiveId))
                        {
                            do
                            {
                                if (AppInstance.GetInstances().Any((Ins) => Ins.Key == AppInstanceIdContainer.LastActiveId))
                                {
                                    if (AppInstance.FindOrRegisterInstanceForKey(AppInstanceIdContainer.LastActiveId) is AppInstance TargetInstance)
                                    {
                                        TargetInstance.RedirectActivationTo();
                                    }

                                    break;
                                }
                                else
                                {
                                    AppInstanceIdContainer.UngisterId(AppInstanceIdContainer.LastActiveId);
                                }
                            }while (!string.IsNullOrEmpty(AppInstanceIdContainer.LastActiveId));
                        }
                        else
                        {
                            string      InstanceId = Guid.NewGuid().ToString();
                            AppInstance Instance   = AppInstance.FindOrRegisterInstanceForKey(InstanceId);
                            AppInstanceIdContainer.RegisterId(InstanceId);

                            Application.Start((p) => new App());
                        }
                    }
                }

                break;
            }

            case LaunchActivatedEventArgs LaunchArg:
            {
                if (!ApplicationData.Current.LocalSettings.Values.ContainsKey("AlwaysStartNew"))
                {
                    ApplicationData.Current.LocalSettings.Values["AlwaysStartNew"] = true;
                }

                bool AlwaysStartNew = Convert.ToBoolean(ApplicationData.Current.LocalSettings.Values["AlwaysStartNew"]);

                if (AlwaysStartNew)
                {
                    string      InstanceId = Guid.NewGuid().ToString();
                    AppInstance Instance   = AppInstance.FindOrRegisterInstanceForKey(InstanceId);
                    AppInstanceIdContainer.RegisterId(InstanceId);

                    Application.Start((p) => new App());
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(AppInstanceIdContainer.LastActiveId))
                    {
                        do
                        {
                            if (AppInstance.GetInstances().Any((Ins) => Ins.Key == AppInstanceIdContainer.LastActiveId))
                            {
                                if (AppInstance.FindOrRegisterInstanceForKey(AppInstanceIdContainer.LastActiveId) is AppInstance TargetInstance)
                                {
                                    TargetInstance.RedirectActivationTo();
                                }

                                break;
                            }
                            else
                            {
                                AppInstanceIdContainer.UngisterId(AppInstanceIdContainer.LastActiveId);
                            }
                        }while (!string.IsNullOrEmpty(AppInstanceIdContainer.LastActiveId));
                    }
                    else
                    {
                        string      InstanceId = Guid.NewGuid().ToString();
                        AppInstance Instance   = AppInstance.FindOrRegisterInstanceForKey(InstanceId);
                        AppInstanceIdContainer.RegisterId(InstanceId);

                        Application.Start((p) => new App());
                    }
                }

                break;
            }

            case FileActivatedEventArgs _:
            {
                if (!string.IsNullOrWhiteSpace(AppInstanceIdContainer.LastActiveId))
                {
                    do
                    {
                        if (AppInstance.GetInstances().Any((Ins) => Ins.Key == AppInstanceIdContainer.LastActiveId))
                        {
                            if (AppInstance.FindOrRegisterInstanceForKey(AppInstanceIdContainer.LastActiveId) is AppInstance TargetInstance)
                            {
                                TargetInstance.RedirectActivationTo();
                            }

                            break;
                        }
                        else
                        {
                            AppInstanceIdContainer.UngisterId(AppInstanceIdContainer.LastActiveId);
                        }
                    }while (!string.IsNullOrEmpty(AppInstanceIdContainer.LastActiveId));
                }
                else
                {
                    string      InstanceId = Guid.NewGuid().ToString();
                    AppInstance Instance   = AppInstance.FindOrRegisterInstanceForKey(InstanceId);
                    AppInstanceIdContainer.RegisterId(InstanceId);

                    Application.Start((p) => new App());
                }

                break;
            }

            default:
            {
                string      InstanceId = Guid.NewGuid().ToString();
                AppInstance Instance   = AppInstance.FindOrRegisterInstanceForKey(InstanceId);
                AppInstanceIdContainer.RegisterId(InstanceId);

                Application.Start((p) => new App());
                break;
            }
            }
        }
        /// <summary>
        /// Creates a TargetInstance resource in the specified project and zone using the data included in the request.
        /// Documentation https://developers.google.com/compute/v1/reference/targetInstances/insert
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="zone">Name of the zone scoping this request.</param>
        /// <param name="body">A valid Compute v1 body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Insert(ComputeService service, string project, string zone, TargetInstance body, TargetInstancesInsertOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (zone == null)
                {
                    throw new ArgumentNullException(zone);
                }

                // Building the initial request.
                var request = service.TargetInstances.Insert(body, project, zone);

                // Applying optional parameters to the request.
                request = (TargetInstancesResource.InsertRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request TargetInstances.Insert failed.", ex);
            }
        }
 /// <summary>
 /// Creates a TargetInstance resource in the specified project and zone using the data included in the request.
 /// </summary>
 /// <param name="project">
 /// Project ID for this request.
 /// </param>
 /// <param name="zone">
 /// Name of the zone scoping this request.
 /// </param>
 /// <param name="targetInstanceResource">
 /// The body resource for this request
 /// </param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <Operation> InsertAsync(string project, string zone, TargetInstance targetInstanceResource, st::CancellationToken cancellationToken) =>
 InsertAsync(project, zone, targetInstanceResource, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
Ejemplo n.º 21
0
        /// <summary>
        /// Creates the JavaScript client side object that matches the
        /// server side method signature. The JScript function maps
        /// to a CallMethod() call on the client.
        /// </summary>
        private void GenerateClassWrapperForCallbackMethods()
        {
            if (ServiceType != AjaxMethodCallbackServiceTypes.AjaxMethodCallback)
            {
                GenerateClassWrapperForWcfAndAsmx();
                return;
            }

            StringBuilder sb = new StringBuilder();

            if (GenerateClientProxyClass == ProxyClassGenerationModes.jsdebug)
            {
                ClientScriptProxy.Current.RegisterClientScriptInclude(this, typeof(ControlResources), ServerUrl.ToLower() + "/jsdebug", ScriptRenderModes.Script);
                return;
            }
            if (GenerateClientProxyClass == ProxyClassGenerationModes.Inline)
            {
                Type objectType = null;

                if (ClientProxyTargetType != null)
                {
                    objectType = ClientProxyTargetType;
                }
                else if (TargetInstance != null)
                {
                    objectType = TargetInstance.GetType();
                }
                // assume Page as default
                else
                {
                    objectType = Page.GetType();
                }

                sb.Append("var " + ID + " = { ");

                MethodInfo[] Methods = objectType.GetMethods(BindingFlags.Instance | BindingFlags.Public);
                foreach (MethodInfo Method in Methods)
                {
                    if (Method.GetCustomAttributes(typeof(CallbackMethodAttribute), false).Length > 0)
                    {
                        sb.Append("\r\n    " + Method.Name + ": function " + "(");

                        string ParameterList = "";
                        foreach (ParameterInfo Parm in Method.GetParameters())
                        {
                            ParameterList += Parm.Name + ",";
                        }
                        sb.Append(ParameterList + "completed,errorHandler)");

                        sb.AppendFormat(
                            @"
    {{
        var _cb = {0}_GetProxy();
        _cb.callMethod(""{1}"",[{2}],completed,errorHandler);
        return _cb;           
    }},", ID, Method.Name, ParameterList.TrimEnd(','));
                    }
                }

                if (sb.Length > 0)
                {
                    sb.Length--; // strip trailing ,
                }
                // End of class
                sb.Append("\r\n}\r\n");
            }
            string Url = null;

            if (string.IsNullOrEmpty(ServerUrl))
            {
                Url = Context.Request.Path;
            }
            else
            {
                Url = ResolveUrl(ServerUrl);
            }

            sb.Append(
                "function " + ID + @"_GetProxy() {
    var _cb = new AjaxMethodCallback('" + ID + "','" + Url + @"',
                                    { timeout: " + Timeout.ToString() + @",
                                      postbackMode: '" + PostBackMode.ToString() + @"',
                                      formName: '" + PostBackFormName + @"' 
                                    });
    return _cb;
}
");
            ClientScriptProxy.RegisterStartupScript(this, GetType(), ID + "_ClientProxy", sb.ToString(), true);
        }
        /// <summary>
        /// Creates a TargetInstance resource in the specified project and zone using the data included in the request.
        /// Documentation https://developers.google.com/compute/beta/reference/targetInstances/insert
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="zone">Name of the zone scoping this request.</param>
        /// <param name="body">A valid compute beta body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Insert(computeService service, string project, string zone, TargetInstance body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (zone == null)
                {
                    throw new ArgumentNullException(zone);
                }

                // Make the request.
                return(service.TargetInstances.Insert(body, project, zone).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request TargetInstances.Insert failed.", ex);
            }
        }