📄 definitions.cs
字号:
/*
Copyright 2006 Christian Gross http://www.devspace.com
From the book Ajax Patterns and Best Practices
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.Collections.Generic;
using Devspace.Commons;
using Devspace.Commons.Automaters;
namespace Devspace.Ajax.CacheController.Books {
public interface Librarian {
Book CheckOutBook( String isbn);
void CheckInBook( Book book);
}
public class Book {
private String _ISBN;
private String _author;
private String _title;
private List< Comment> _comments = new List< Comment>();
private int _staticHashCode;
private bool _isHashCodeAssigned = false;
public String ISBN {
set {
_ISBN = value;
}
get {
return _ISBN;
}
}
public String Author {
set {
_author = value;
}
get {
return _author;
}
}
public String Title {
set {
_title = value;
}
get {
return _title;
}
}
public void AddComment(Comment comment) {
_comments.Add(comment);
}
public override int GetHashCode() {
if( _isHashCodeAssigned) {
return _staticHashCode;
}
else {
return new HashCodeAutomater()
.Append( _ISBN)
.Append( _author)
.Append( _title)
.Append( _comments).toHashCode();
}
}
public void AssignHashCode( int hashcode) {
_staticHashCode = GetHashCode();
_isHashCodeAssigned = true;
}
public void ResetAssignedHashCode() {
_isHashCodeAssigned = false;
}
}
public class Comment {
private String _id;
private String _text;
private String _whoMadeComment;
public String Id {
set {
_id = value;
}
get {
return _id;
}
}
public String Text {
set {
_text = value;
}
get {
return _text;
}
}
public String WhoMadeComment {
set {
_whoMadeComment = value;
}
get {
return _whoMadeComment;
}
}
}
public class User {
private String _username;
private byte[] _password;
private List<string> _books = new List<string>();
private List<string> _wishList = new List<string>();
public String Username {
set {
_username = value;
}
get {
return _username;
}
}
public byte[] Password {
set {
_password = value;
}
get {
return _password;
}
}
public void AddBook(String book) {
_books.Add(book);
}
public IEnumerator< string> GetBooks() {
return _books.GetEnumerator();
}
public void AddWishList(String book) {
_wishList.Add(book);
}
public IEnumerator<string> GetWishLists() {
return _wishList.GetEnumerator();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -