会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
Advance
Keep it simple but not too simple!
ObjectSpace中说明文档的不足!
using
System;
using
Microsoft.ObjectSpaces;
//
//
ObjectSpaces object 'Customer'.
//
public
abstract
class
Customer
{
[UniqueId]
public
abstract
string
Id
{
get
;
set
; }
public
abstract
string
Name
{
get
;
set
; }
public
abstract
string
CompanyName
{
get
;
set
; }
public
abstract
string
Phone
{
get
;
set
; }
public
abstract
string
Fax
{
get
;
set
; }
public
void
OnCreate(
string
newId)
{
Id
=
newId;
}
}
//
//
ObjectSpaces Tutorial #1
//
public
class
Example2
{
public
static
void
Main()
{
try
{
//
//
Load in the Source.xml file (specifies the XmlObjectSpace to load in).
//
IObjectSpace os
=
ObjectSpaceFactory.CreateObjectSpace(
"
Source.xml
"
);
//
//
Create two new customers.
//
Customer myCustomer
=
(Customer) os.CreateObject(
typeof
(Customer),
"
1
"
);
myCustomer.Name
=
"
Mario Esprito
"
;
myCustomer.CompanyName
=
"
Infoltrix
"
;
myCustomer.Phone
=
"
(111) 345 6777
"
;
myCustomer.Fax
=
"
(222) 343 6744
"
;
myCustomer
=
(Customer) os.CreateObject(
typeof
(Customer),
"
2
"
);
myCustomer.Name
=
"
Frank Antuono
"
;
myCustomer.CompanyName
=
"
Infoltrix
"
;
myCustomer.Phone
=
"
(333) 345 6737
"
;
myCustomer.Fax
=
"
(444) 343 6244
"
;
//
//
Once you have specified values for the fields, commit the changes to
//
the underlying object storage.
//
os.UpdateAll();
//
//
Iterate through the newly created objects in the ObjectSpace and
//
print out object properties.
//
foreach
(Customer theCustomer
in
os.GetObjects(
typeof
(Customer),
""
))
{
Console.WriteLine(
"
Customer Id:
"
+
theCustomer.Id
+
"
Customer Name:
"
+
theCustomer.Name
+
"
Company:
"
+
theCustomer.CompanyName
+
"
Phone:
"
+
theCustomer.Phone
+
"
Fax:
"
+
theCustomer.Fax
+
"
"
);
}
}
//
//
Catch any exceptions that might occur.
//
catch
(Exception e)
{
Console.Write(e);
}
}
}
其中 Customer myCustomer
=
(Customer) os.CreateObject(
typeof
(Customer),
"
1
"
);
感觉文档中说得不太清楚!VS2003的ObjectSpace文档感觉写得太烂,很多细节都忽略了!
posted on
2004-08-05 17:11
Advance
阅读(
1227
) 评论(
1
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告
导航
博客园
首页
新随笔
联系
订阅
管理