Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(239)

Side by Side Diff: Src/GoogleApis/Apis/Util/LazyResult.cs

Issue 12020043: Issue 325 - Remove discovery and codegen (Closed) Base URL: https://google-api-dotnet-client.googlecode.com/hg/
Patch Set: Sir miceli comment Created 10 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Src/GoogleApis/Apis/Services/IClientService.cs ('k') | Src/GoogleApis/Apis/Util/Utilities.cs » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 Copyright 2010 Google Inc
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 using System;
18
19 namespace Google.Apis.Util
20 {
21 /// <summary>
22 /// Lazily returns the result of an operation. Can be used to pass Exception s along asynchronous methods.
23 /// </summary>
24 /// <typeparam name="T">Type of the result.</typeparam>
25 public class LazyResult<T>
26 {
27 private T result;
28 private bool resultFetched;
29 private readonly Func<T> fetchFunction;
30
31 internal LazyResult(Func<T> resultFetcher)
32 {
33 resultFetcher.ThrowIfNull("resultFetcher");
34 fetchFunction = resultFetcher;
35 }
36
37 /// <summary>
38 /// Returns the result associated with this object. Might throw an excep tion.
39 /// </summary>
40 public T GetResult()
41 {
42 if (!resultFetched)
43 {
44 resultFetched = true;
45 result = fetchFunction();
46 }
47
48 return result;
49 }
50 }
51 }
OLDNEW
« no previous file with comments | « Src/GoogleApis/Apis/Services/IClientService.cs ('k') | Src/GoogleApis/Apis/Util/Utilities.cs » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b