public static bool isRoutedEventHandlerClass(this ITypeReference typeRef, IMetadataHost host)
        {
            Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;;
            IAssemblyReference systemAssembly             = getSystemWindowsAssemblyReference(host);
            ITypeReference     routedEvHandlerType        = platform.CreateReference(systemAssembly, "System", "Windows", "RoutedEventHandler");

            return(typeRef.isClass(routedEvHandlerType));
        }
        public static bool isMessageBoxClass(this ITypeReference typeRef, IMetadataHost host)
        {
            Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;;
            IAssemblyReference systemAssembly             = getSystemWindowsAssemblyReference(host);
            ITypeReference     mbType = platform.CreateReference(systemAssembly, "System", "Windows", "MessageBox");

            return(typeRef.isClass(mbType));
        }
        public static bool isPhoneApplicationClass(this ITypeReference typeRef, IMetadataHost host)
        {
            Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
            IAssemblyReference systemAssembly             = PhoneTypeHelper.getSystemWindowsAssemblyReference(host);
            ITypeReference     applicationClass           = platform.CreateReference(systemAssembly, "System", "Windows", "Application");

            return(typeRef.isClass(applicationClass));
        }
        public static bool isNavigationServiceClass(this ITypeReference typeRef, IMetadataHost host)
        {
            Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
            IAssemblyReference phoneAssembly = getPhoneAssemblyReference(host);
            ITypeReference     phoneApplicationPageTypeRef = platform.CreateReference(phoneAssembly, "System", "Windows", "Navigation", "NavigationService");

            return(typeRef.isClass(phoneApplicationPageTypeRef));
        }
        public static bool isPhoneApplicationPageClass(this ITypeReference typeRef, IMetadataHost host)
        {
            Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
            IAssemblyReference phoneAssembly = PhoneTypeHelper.getPhoneAssemblyReference(host);
            ITypeReference     phoneApplicationPageTypeRef = platform.CreateReference(phoneAssembly, "Microsoft", "Phone", "Controls", "PhoneApplicationPage");

            return(typeRef.isClass(phoneApplicationPageTypeRef));
        }
        public static bool isCancelEventArgsClass(this ITypeReference typeRef, IMetadataHost host)
        {
            Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
            IAssemblyReference systemAssembly             = getSystemAssemblyReference(host);
            ITypeReference     cancelEventArgsClass       = platform.CreateReference(systemAssembly, "System", "ComponentModel", "CancelEventArgs");

            return(typeRef.isClass(cancelEventArgsClass));
        }
예제 #7
0
 internal AsmMetaHostEnvironment(string[] libPaths, bool searchGAC)
     : base()
 {
     foreach (var p in libPaths)
     {
         this.AddLibPath(p);
     }
     this.SearchInGAC  = searchGAC;
     this.platformType = new Microsoft.Cci.Immutable.PlatformType(this);
 }
        public static IAssemblyReference getSystemWindowsAssemblyReference(IMetadataHost host)
        {
            Microsoft.Cci.Immutable.PlatformType platform     = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
            IAssemblyReference coreAssemblyRef                = platform.CoreAssemblyRef;
            AssemblyIdentity   MSPhoneSystemWindowsAssemblyId =
                new AssemblyIdentity(host.NameTable.GetNameFor("System.Windows"), coreAssemblyRef.Culture, coreAssemblyRef.Version,
                                     coreAssemblyRef.PublicKeyToken, "");

            return(host.FindAssembly(MSPhoneSystemWindowsAssemblyId));
        }
        private PhoneCodeHelper(IMetadataHost host)
        {
            if (host != null)
            {
                platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
                initializeKnownUIChangers();

                BackKeyCancellingOffenders      = new HashSet <Tuple <ITypeReference, string> >();
                BackKeyUnknownDelegateOffenders = new HashSet <ITypeReference>();
                BackKeyNavigatingOffenders      = new Dictionary <ITypeReference, ICollection <Tuple <IMethodReference, string> > >();
                KnownBackKeyHandlers            = new HashSet <IMethodReference>();
                KnownNavigatingMethods          = new HashSet <IMethodReference>();
                KnownEventCancellingMethods     = new HashSet <IMethodReference>();
            }
        }
        public static bool isURIClass(this ITypeReference typeRef, IMetadataHost host)
        {
            Microsoft.Cci.Immutable.PlatformType platformType = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
            if (platformType == null)
            {
                return(false);
            }

            IAssemblyReference coreRef          = platformType.CoreAssemblyRef;
            AssemblyIdentity   systemAssemblyId = new AssemblyIdentity(host.NameTable.GetNameFor("System"), "", coreRef.Version, coreRef.PublicKeyToken, "");
            IAssemblyReference systemAssembly   = host.FindAssembly(systemAssemblyId);

            ITypeReference uriTypeRef = platformType.CreateReference(systemAssembly, "System", "Uri");

            return(typeRef.isClass(uriTypeRef));
        }
        public bool isMethodInputHandlerOrFeedbackOverride(IMethodDefinition method)
        {
            // FEEDBACK TODO: This is extremely coarse. There must be quite a few non-UI routed/non-routed events
            Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;;
            IAssemblyReference coreAssembly  = PhoneTypeHelper.getCoreAssemblyReference(host);
            ITypeReference     eventArgsType = platform.CreateReference(coreAssembly, "System", "EventArgs");

            foreach (IParameterDefinition paramDef in method.Parameters)
            {
                if (paramDef.Type.isClass(eventArgsType))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #12
0
        public PhoneNavigationCodeTraverser(MetadataReaderHost host, IEnumerable <IAssemblyReference> assemblies) : base()
        {
            this.host = host;
            List <IAssembly> assembliesTraversed = new List <IAssembly>();

            foreach (IAssemblyReference asmRef in assemblies)
            {
                assembliesTraversed.Add(asmRef.ResolvedAssembly);
            }

            Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;

            // TODO obtain version, culture and signature data dynamically
            IAssemblyReference assembly = PhoneTypeHelper.getPhoneAssemblyReference(host);

            // TODO determine the needed types dynamically
            navigationSvcType = platform.CreateReference(assembly, "System", "Windows", "Navigation", "NavigationService");

            assembly            = PhoneTypeHelper.getSystemAssemblyReference(host);
            cancelEventArgsType = platform.CreateReference(assembly, "System", "ComponentModel", "CancelEventArgs");
            navigationCallers   = new HashSet <IMethodReference>();
        }
예제 #13
0
 internal ConsoleHostEnvironment(string[] libPaths, bool searchGAC)
     : base()
 {
     foreach (var p in libPaths)
     {
         this.AddLibPath(p);
     }
     this.SearchInGAC = searchGAC;
     this.platformType = new Microsoft.Cci.Immutable.PlatformType(this);
 }
 public static IAssemblyReference getCoreAssemblyReference(IMetadataHost host)
 {
     Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
     return(platform.CoreAssemblyRef);
 }
예제 #15
0
        private void InitializeTraverser()
        {
            Microsoft.Cci.Immutable.PlatformType platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
            coreAssemblyRef = platform.CoreAssemblyRef;

            // TODO obtain version, culture and signature data dynamically
            AssemblyIdentity MSPhoneAssemblyId =
                new AssemblyIdentity(host.NameTable.GetNameFor("Microsoft.Phone"), "", new Version("7.0.0.0"),
                                     new byte[] { 0x24, 0xEE, 0xC0, 0xD8, 0xC8, 0x6C, 0xDA, 0x1E }, "");
            AssemblyIdentity MSPhoneControlsAssemblyId =
                new AssemblyIdentity(host.NameTable.GetNameFor("Microsoft.Phone.Controls"), "", new Version("7.0.0.0"),
                                     new byte[] { 0x24, 0xEE, 0xC0, 0xD8, 0xC8, 0x6C, 0xDA, 0x1E }, "");

            AssemblyIdentity MSPhoneSystemWindowsAssemblyId =
                new AssemblyIdentity(host.NameTable.GetNameFor("System.Windows"), coreAssemblyRef.Culture, coreAssemblyRef.Version,
                                     coreAssemblyRef.PublicKeyToken, "");

            phoneAssembly = host.FindAssembly(MSPhoneAssemblyId);
            phoneSystemWindowsAssembly = host.FindAssembly(MSPhoneSystemWindowsAssemblyId);
            MSPhoneControlsAssembly    = host.FindAssembly(MSPhoneControlsAssemblyId);
            // TODO BUG / XAML DEPENDENCE If a control is declared in XAML, it may be one from a library *not* linked! So, assemblies could be dummy here

            // TODO determine the needed types dynamically
            if (phoneAssembly != Dummy.Assembly)
            {
                appBarIconButtonType = platform.CreateReference(phoneAssembly, "Microsoft", "Phone", "Shell", "ApplicationBarIconButton");
                appBarMenuItemType   = platform.CreateReference(phoneAssembly, "Microsoft", "Phone", "Shell", "ApplicationBarMenuItem");
            }
            else
            {
                appBarIconButtonType = host.PlatformType.SystemObject;
                appBarMenuItemType   = host.PlatformType.SystemObject;
            }

            if (phoneSystemWindowsAssembly != Dummy.Assembly)
            {
                checkBoxType     = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "CheckBox");
                radioButtonType  = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "RadioButton");
                buttonType       = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Button");
                buttonBaseType   = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Primitives", "ButtonBase");
                toggleButtonType = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Primitives", "ToggleButton");
                controlType      = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "Control");
                uiElementType    = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "UIElement");
                listBoxType      = platform.CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Controls", "ListBox");
            }
            else
            {
                checkBoxType     = host.PlatformType.SystemObject;
                radioButtonType  = host.PlatformType.SystemObject;
                buttonType       = host.PlatformType.SystemObject;
                buttonBaseType   = host.PlatformType.SystemObject;
                toggleButtonType = host.PlatformType.SystemObject;
                controlType      = host.PlatformType.SystemObject;
                uiElementType    = host.PlatformType.SystemObject;
                listBoxType      = host.PlatformType.SystemObject;
            }

            if (MSPhoneControlsAssembly != Dummy.Assembly)
            {
                pivotType = platform.CreateReference(MSPhoneControlsAssembly, "Microsoft", "Phone", "Controls", "Pivot");
            }
            else
            {
                pivotType = host.PlatformType.SystemObject;
            }



            trueConstant = new CompileTimeConstant()
            {
                Type  = platform.SystemBoolean,
                Value = true
            };
            falseConstant = new CompileTimeConstant()
            {
                Type  = platform.SystemBoolean,
                Value = false
            };

            IEnumerable <IPropertyDefinition> controlProperties      = controlType.ResolvedType.Properties;
            IEnumerable <IPropertyDefinition> toggleButtonProperties = toggleButtonType.ResolvedType.Properties;
            IEnumerable <IPropertyDefinition> uiElementProperties    = uiElementType.ResolvedType.Properties;

            IPropertyDefinition prop = controlProperties.Single(p => p.Name.Value == "IsEnabled");

            isEnabledSetter  = prop.Setter;
            isEnabledGetter  = prop.Getter;
            prop             = toggleButtonProperties.Single(p => p.Name.Value == "IsChecked");
            isCheckedSetter  = prop.Setter;
            isCheckedGetter  = prop.Getter;
            prop             = uiElementProperties.Single(p => p.Name.Value == "Visibility");
            visibilitySetter = prop.Setter;
            visibilityGetter = prop.Getter;

            IEnumerable <IEventDefinition> buttonBaseEvents   = buttonBaseType.ResolvedType.Events;
            IEnumerable <IEventDefinition> toggleButtonEvents = toggleButtonType.ResolvedType.Events;
            IEventDefinition evt = buttonBaseEvents.Single(e => e.Name.Value == "Click");

            clickHandlerAdder   = evt.Adder;
            clickHandlerRemover = evt.Remover;
            evt = toggleButtonEvents.Single(e => e.Name.Value == "Checked");
            checkedHandlerAdder   = evt.Adder;
            checkedHandlerRemover = evt.Remover;
            evt = toggleButtonEvents.Single(e => e.Name.Value == "Unchecked");
            uncheckedHandlerAdder   = evt.Adder;
            uncheckedHandlerRemover = evt.Remover;
        }
    private PhoneCodeHelper(IMetadataHost host) {
      if (host != null) {
        platform = host.PlatformType as Microsoft.Cci.Immutable.PlatformType;
        initializeKnownUIChangers();

        BackKeyCancellingOffenders= new HashSet<Tuple<ITypeReference,string>>();
        BackKeyUnknownDelegateOffenders = new HashSet<ITypeReference>();
        BackKeyNavigatingOffenders = new Dictionary<ITypeReference, ICollection<Tuple<IMethodReference,string>>>();
        KnownBackKeyHandlers = new HashSet<IMethodReference>();
        KnownNavigatingMethods = new HashSet<IMethodReference>();
        KnownEventCancellingMethods = new HashSet<IMethodReference>();
      }
    }