Cache









How do I use Cache
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: crBaoCao.cs Copy
103         public CachedcrBaoCao() {
104         }
File name: crBaoCao.cs Copy
108         public virtual bool IsCacheable {
109             get {
110                 return true;
111             }
112             set {
113                 //
114             }
115         }
File name: crBaoCao.cs Copy
130         public virtual System.TimeSpan CacheTimeOut {
131             get {
132                 return CachedReportConstants.DEFAULT_TIMEOUT;
133             }
134             set {
135                 //
136             }
137         }
File name: crBaoCao.cs Copy
145         public virtual string GetCustomizedCacheKey(RequestContext request) {
146             String key = null;
147             // // The following is the code used to generate the default
148             // // cache key for caching report jobs in the ASP.NET Cache.
149             // // Feel free to modify this code to suit your needs.
150             // // Returning key == null causes the default cache key to
151             // // be generated.
152             //
153             // key = RequestContext.BuildCompleteCacheKey(
154             // request,
155             // null, // sReportFilename
156             // this.GetType(),
157             // this.ShareDBLogonInfo );
158             return key;
159         }
File name: rptThisinh.cs Copy
95         public CachedrptThisinh() {
96         }
File name: rptThisinh.cs Copy
100         public virtual bool IsCacheable {
101             get {
102                 return true;
103             }
104             set {
105                 //
106             }
107         }
File name: rptThisinh.cs Copy
122         public virtual System.TimeSpan CacheTimeOut {
123             get {
124                 return CachedReportConstants.DEFAULT_TIMEOUT;
125             }
126             set {
127                 //
128             }
129         }
File name: rptThisinh.cs Copy
137         public virtual string GetCustomizedCacheKey(RequestContext request) {
138             String key = null;
139             // // The following is the code used to generate the default
140             // // cache key for caching report jobs in the ASP.NET Cache.
141             // // Feel free to modify this code to suit your needs.
142             // // Returning key == null causes the default cache key to
143             // // be generated.
144             //
145             // key = RequestContext.BuildCompleteCacheKey(
146             // request,
147             // null, // sReportFilename
148             // this.GetType(),
149             // this.ShareDBLogonInfo );
150             return key;
151         }
File name: ChatGui.cs Copy
103     public void OnGUI()
104     {
105         if (!this.IsVisible)
106         {
107             return;
108         }
109
110         GUI.skin.label.wordWrap = true;
111         //GUI.skin.button.richText = true; // this allows toolbar buttons to have bold/colored text. nice to indicate new msgs
112         //GUILayout.Button("lala"); // as richText, html tags could be in text
113
114
115         if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
116         {
117             if ("ChatInput".Equals(GUI.GetNameOfFocusedControl()))
118             {
119                 // focus on input -> submit it
120                 GuiSendsMsg();
121                 return; // showing the now modified list would result in an error. to avoid this, we just skip this single frame
122             }
123             else
124             {
125                 // assign focus to input
126                 GUI.FocusControl("ChatInput");
127             }
128         }
129
130         GUI.SetNextControlName("");
131         GUILayout.BeginArea(this.GuiRect);
132
133         GUILayout.FlexibleSpace();
134
135         if (this.chatClient.State != ChatState.ConnectedToFrontEnd)
136         {
137             GUILayout.Label("Not in chat yet.");
138         }
139         else
140         {
141             List channels = new List(this.chatClient.PublicChannels.Keys); // this could be cached
142             int countOfPublicChannels = channels.Count;
143             channels.AddRange(this.chatClient.PrivateChannels.Keys);
144
145             if (channels.Count > 0)
146             {
147                 int previouslySelectedChannelIndex = this.selectedChannelIndex;
148                 int channelIndex = channels.IndexOf(this.selectedChannelName);
149                 this.selectedChannelIndex = (channelIndex >= 0) ? channelIndex : 0;
150
151                 this.selectedChannelIndex = GUILayout.Toolbar(this.selectedChannelIndex, channels.ToArray(), GUILayout.ExpandWidth(false));
152                 this.scrollPos = GUILayout.BeginScrollView(this.scrollPos);
153
154                 this.doingPrivateChat = (this.selectedChannelIndex >= countOfPublicChannels);
155                 this.selectedChannelName = channels[this.selectedChannelIndex];
156
157                 if (this.selectedChannelIndex != previouslySelectedChannelIndex)
158                 {
159                     // changed channel -> scroll down, if private: pre-fill "to" field with target user's name
160                     this.scrollPos.y = float.MaxValue;
161                     if (this.doingPrivateChat)
162                     {
163                         string[] pieces = this.selectedChannelName.Split(new char[] {':'}, 3);
164                         this.userIdInput = pieces[1];
165                     }
166                 }
167
168                 GUILayout.Label(ChatGui.WelcomeText);
169
170                 if (this.chatClient.TryGetChannel(selectedChannelName, this.doingPrivateChat, out this.selectedChannel))
171                 {
172                     for (int i = 0; i < this.selectedChannel.Messages.Count; i++)
173                     {
174                         string sender = this.selectedChannel.Senders[i];
175                         object message = this.selectedChannel.Messages[i];
176                         GUILayout.Label(string.Format("{0}: {1}", sender, message));
177                     }
178                 }
179
180                 GUILayout.EndScrollView();
181             }
182         }
183
184
185         GUILayout.BeginHorizontal();
186         if (doingPrivateChat)
187         {
188             GUILayout.Label("to:", GUILayout.ExpandWidth(false));
189             GUI.SetNextControlName("WhisperTo");
190             this.userIdInput = GUILayout.TextField(this.userIdInput, GUILayout.MinWidth(100), GUILayout.ExpandWidth(false));
191             string focussed = GUI.GetNameOfFocusedControl();
192             if (focussed.Equals("WhisperTo"))
193             {
194                 if (this.userIdInput.Equals("username"))
195                 {
196                     this.userIdInput = "";
197                 }
198             }
199             else if (string.IsNullOrEmpty(this.userIdInput))
200             {
201                 this.userIdInput = "username";
202             }
203
204         }
205         GUI.SetNextControlName("ChatInput");
206         inputLine = GUILayout.TextField(inputLine);
207         if (GUILayout.Button("Send", GUILayout.ExpandWidth(false)))
208         {
209             GuiSendsMsg();
210         }
211         GUILayout.EndHorizontal();
212         GUILayout.EndArea();
213     }
File name: ReorderableListResources.cs Copy
75         {
76             get { return s_Cached[ (int)ResourceName.add_button ]; }
77         }

Download file with original file name:Cache

Cache 2.772 lượt xem

Gõ tìm kiếm nhanh...