public MapController([FromServices] IGet get, [FromServices] IPost post, [FromServices] IPut put, [FromServices] IDelete delete) { Get = get; Post = post; Put = put; Delete = delete; }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { this.Get = new Get(this); this.Post = new Post(this); this.Put = new Put(this); this.BaseUri = new Uri("http://petstore-api.herokuapp.com/my/pet"); SerializationSettings = new JsonSerializerSettings { Formatting = Formatting.Indented, DateFormatHandling = DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = DateTimeZoneHandling.Utc, NullValueHandling = NullValueHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = DateTimeZoneHandling.Utc, NullValueHandling = NullValueHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); }
public AdminController([FromServices] IGet get, [FromServices] IPost post, [FromServices] IPut put, [FromServices] IDelete delete) { this.Get = get; this.Post = post; this.Put = put; this.Delete = delete; }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { this.Get = new Get(this); this.Post = new Post(this); this.Put = new Put(this); this.BaseUri = new System.Uri("http://petstore-api.herokuapp.com/my/pet"); SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(), Converters = new System.Collections.Generic.List <Newtonsoft.Json.JsonConverter> { new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter() } }; DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(), Converters = new System.Collections.Generic.List <Newtonsoft.Json.JsonConverter> { new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter() } }; CustomInitialize(); }
/// <summary> /// Creates "count" circles and adds to "circles" list /// </summary> /// <param name="rects">list of circles to add to</param> /// <param name="count">how many circles will be created</param> static void CreateSomeCircles(IPut<Circle> circles, int count) { for (int index = 0; index < count; index++) { circles.Add(new Circle( rnd.NextDouble() * rnd.Next(MAX_DIMENSION))); } }
public virtual Task <HttpResponseMessage <T, M> > PutAsJsonAsync <T, M>(IPut <T, M> resource, params IHandlerParam[] metaData) { Task <HttpResponseMessage> response = SendAsJsonAsync(resource, HttpMethod.Put, resource.Uri, metaData); return(response.ContinueWith <HttpResponseMessage <T, M> >( t => new HttpResponseMessage <T, M>(t.Result), TaskContinuationOptions.ExecuteSynchronously )); }
public RestResponse Put(IPut put) { RestResponse restResponse = new RestResponse(); using (HttpClient httpClient = GetHttpClient(put.Headers)) { var response = httpClient.PutAsync(put.Url, new StringContent(JsonConvert.SerializeObject(put.Request), Encoding.UTF8, "application/json")).Result; restResponse.ResultStatus = response.IsSuccessStatusCode ? RestResultStatus.Success : RestResultStatus.Fail; restResponse.ResponseContent = response.Content.ReadAsStringAsync().Result; } return(restResponse); }
public Instruction(InteractionType type, GameObject im, Item item) { target = item; interactionType = type; switch (type) { case InteractionType.Get: getter = im.GetComponent <IGet>(); break; case InteractionType.Put: putter = im.GetComponent <IPut>(); break; case InteractionType.WorkAt: workStation = im.GetComponent <IOperate>(); break; default: break; } location = im.transform; }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='pet'> /// The pet JSON you want to post /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task PetsAsync(this IPut operations, Pet pet, CancellationToken cancellationToken = default(CancellationToken)) { (await operations.PetsWithHttpMessagesAsync(pet, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='pet'> /// The pet JSON you want to post /// </param> public static void Pets(this IPut operations, Pet pet) { operations.PetsAsync(pet).GetAwaiter().GetResult(); }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='pet'> /// The pet JSON you want to post /// </param> public static void Pets(this IPut operations, Pet pet) { Task.Factory.StartNew(s => ((IPut)s).PetsAsync(pet), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='pet'> /// The pet JSON you want to post /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async System.Threading.Tasks.Task PetsAsync(this IPut operations, Pet pet, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { await operations.PetsWithHttpMessagesAsync(pet, null, cancellationToken).ConfigureAwait(false); }
public static int Write(this IPut i, Exception ex, string _user = "") { return(i.Put(ex.Message + "\r\n" + ex.StackTrace, _user, ex.TargetSite.ReflectedType + "." + ex.TargetSite.Name)); }
public virtual Task <HttpResponseMessage> PutAsJsonAsync(IPut resource, params IHandlerParam[] metaData) { return(SendAsJsonAsync(resource, HttpMethod.Put, resource.Uri, metaData)); }
public virtual HttpResponseMessage <T, M> PutAsJson <T, M>(IPut <T, M> resource, params IHandlerParam[] metaData) { HttpResponseMessage response = SendAsJsonAsync(resource, HttpMethod.Put, resource.Uri, metaData).Result; return(new HttpResponseMessage <T, M>(response)); }
/// <summary> /// Creates "count" rectangles and adds to "rects" list /// </summary> /// <param name="rects">list of rectangles to add to</param> /// <param name="count">how many rectangles will be created</param> static void CreateSomeRectangles(IPut<Rectangle> rects, int count) { for (int index = 0; index < count; index++) { rects.Add(new Rectangle( rnd.NextDouble() * rnd.Next(MAX_DIMENSION), rnd.NextDouble() * rnd.Next(MAX_DIMENSION))); } }