1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
18 using System
.Collections
;
20 using System
.Globalization
;
22 public class SimpleHelper
24 public String
FileSizeInKBytes(String basePath
, String file
)
26 FileInfo info
= new FileInfo(Path
.Combine(basePath
, file
));
30 return String
.Format(CultureInfo
.InvariantCulture
,"{0:#.##}", info
.Length
/ 1024f
).ToString();
33 throw new Exception("File " + info
.FullName
+ " was not found");
36 public String
RemoveOffset(String offset
, String path
)
38 return path
.Substring(offset
.Length
);
41 public String
Relativize(String offset
, String path
, String page
)
45 if (offset
.Length
>= path
.Length
)
47 return String
.Format("./{0}", page
);
51 String newPath
= path
.Substring(offset
.Length
);
52 return String
.Format(".{0}/{1}", newPath
, page
);
61 public String
GetShortTypeName(String typeName
)
63 String
[] parts
= typeName
.Split('.');
65 return parts
[parts
.Length
- 1];
68 public int GetLevels(String path
)
70 return path
.Split('/').Length
- 1;
73 public Stack
CreateStack()
78 public int Push(Stack stack
)
80 stack
.Push(String
.Empty
);
84 public int Pop(Stack stack
)