diff options
author | Unknown <t-espave@A3479886.redmond.corp.microsoft.com> | 2011-07-15 11:11:46 -0700 |
---|---|---|
committer | Unknown <t-espave@A3479886.redmond.corp.microsoft.com> | 2011-07-15 11:11:46 -0700 |
commit | 7dea3ce2cd43af0f3a7efc6ef57136d5a2fd8099 (patch) | |
tree | 869e979464433fa5c208d7f05e73166f42836b74 /BCT/BytecodeTranslator/Phone | |
parent | 4c0b3cd19f6259d4b7f644497212f639c1e07706 (diff) |
initial page detection and init
Diffstat (limited to 'BCT/BytecodeTranslator/Phone')
-rw-r--r-- | BCT/BytecodeTranslator/Phone/PhoneCodeHelper.cs | 9 | ||||
-rw-r--r-- | BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs | 15 |
2 files changed, 17 insertions, 7 deletions
diff --git a/BCT/BytecodeTranslator/Phone/PhoneCodeHelper.cs b/BCT/BytecodeTranslator/Phone/PhoneCodeHelper.cs index 411fc819..74ad2140 100644 --- a/BCT/BytecodeTranslator/Phone/PhoneCodeHelper.cs +++ b/BCT/BytecodeTranslator/Phone/PhoneCodeHelper.cs @@ -126,8 +126,13 @@ namespace BytecodeTranslator.Phone { /// <param name="uri"></param>
/// <returns></returns>
public static string getURIBase(string uri) {
- // TODO
- return uri;
+ // I need to build an absolute URI just to call getComponents() ...
+ Uri mockBaseUri = new Uri("mock://mock/", UriKind.RelativeOrAbsolute);
+ Uri realUri = new Uri(mockBaseUri, uri);
+
+ string str= realUri.GetComponents(UriComponents.Path|UriComponents.StrongAuthority|UriComponents.Scheme, UriFormat.UriEscaped);
+ Uri mockStrippedUri = new Uri(str);
+ return mockBaseUri.MakeRelativeUri(mockStrippedUri).ToString();
}
}
}
diff --git a/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs b/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs index 5f08f1c7..b702e78b 100644 --- a/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs +++ b/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs @@ -4,18 +4,21 @@ using System.Linq; using System.Text;
using Microsoft.Cci;
using Microsoft.Cci.MutableCodeModel;
+using TranslationPlugins;
namespace BytecodeTranslator.Phone {
public class PhoneNavigationCodeTraverser : BaseCodeTraverser {
private MetadataReaderHost host;
private ITypeReference navigationSvcType;
private ITypeReference typeTraversed;
+ private PhoneControlsPlugin phonePlugin;
private static readonly string[] NAV_CALLS = { "GoBack", "GoForward", "Navigate", "StopLoading" };
- public PhoneNavigationCodeTraverser(MetadataReaderHost host, ITypeReference typeTraversed) : base() {
+ public PhoneNavigationCodeTraverser(PhoneControlsPlugin plugin, MetadataReaderHost host, ITypeReference typeTraversed) : base() {
this.host = host;
this.typeTraversed = typeTraversed;
+ this.phonePlugin = plugin;
Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
// TODO obtain version, culture and signature data dynamically
@@ -33,7 +36,7 @@ namespace BytecodeTranslator.Phone { if (method.IsConstructor && PhoneCodeHelper.isPhoneApplicationClass(typeTraversed, host)) {
// TODO initialize current navigation URI to mainpage, using a placeholder for now.
// TODO BUG doing this is generating a fresh variable definition somewhere that the BCT then translates into two different (identical) declarations
- string URI_placeholder="URI_PLACEHOLDER";
+ string mainPageUri = phonePlugin.getMainPageXAML();
SourceMethodBody sourceBody = method.Body as SourceMethodBody;
if (sourceBody != null) {
BlockStatement bodyBlock = sourceBody.Block as BlockStatement;
@@ -41,7 +44,7 @@ namespace BytecodeTranslator.Phone { Assignment uriInitAssign = new Assignment() {
Source = new CompileTimeConstant() {
Type = host.PlatformType.SystemString,
- Value = URI_placeholder,
+ Value = mainPageUri,
},
Type = host.PlatformType.SystemString,
Target = new TargetExpression() {
@@ -230,10 +233,12 @@ namespace BytecodeTranslator.Phone { public class PhoneNavigationMetadataTraverser : BaseMetadataTraverser {
private MetadataReaderHost host;
private ITypeDefinition typeBeingTraversed;
+ private PhoneControlsPlugin phonePlugin;
- public PhoneNavigationMetadataTraverser(MetadataReaderHost host)
+ public PhoneNavigationMetadataTraverser(PhoneControlsPlugin plugin, MetadataReaderHost host)
: base() {
this.host = host;
+ this.phonePlugin = plugin;
}
public override void Visit(IModule module) {
@@ -267,7 +272,7 @@ namespace BytecodeTranslator.Phone { // TODO same here. Are there specific methods (and ways to identfy those) that can perform navigation?
public override void Visit(IMethodDefinition method) {
- PhoneNavigationCodeTraverser codeTraverser = new PhoneNavigationCodeTraverser(host, typeBeingTraversed);
+ PhoneNavigationCodeTraverser codeTraverser = new PhoneNavigationCodeTraverser(phonePlugin, host, typeBeingTraversed);
codeTraverser.Visit(method);
}
|