示例#1
0
        public void Load(IModuleContext context)
        {
            var settingsManager = context.ServiceLocator.GetInstance<ISettingsManager>();
            settingsManager.RegisterSettings<PathSettings>();

            context.ServiceLocator.RegisterSingleton<IDirectoryManager, DirectoryManager>();
        }
示例#2
0
        public static void Initialize()
        {
            ServerAddress = "localhost:11648";

            ObjectFactory.Configure(c =>
            {
                c.ForRequestedType<IFrameRateTimerFactory>().TheDefaultIsConcreteType<FrameRateTimerFactory>().CacheBy(StructureMap.Attributes.InstanceScope.Singleton);
                c.ForRequestedType<IEmulationRunner>().TheDefault.Is.OfConcreteType<EmulationRunner>();
                c.ForRequestedType<IEventAggregator>().TheDefaultIsConcreteType<EventAggregator>().CacheBy(StructureMap.Attributes.InstanceScope.Singleton);
            });

            _serviceLocator = new ServiceLocator();

            _serviceLocator.RegisterSingleton<IInputSourceAssembler, InputSourceAssembler>();
            _serviceLocator.RegisterSingleton<IEmulatorRegistry, EmulatorRegistry>();

            _loader = new ModuleLoader();
            _context = new ModuleContext()
                {
                    ServiceLocator = _serviceLocator,
                    InputSourceAssembler = _serviceLocator.GetInstance<IInputSourceAssembler>(),
                    EmulatorRegistry = _serviceLocator.GetInstance<IEmulatorRegistry>()
                };
            _loader.LoadModules(_context);        
        }
示例#3
0
 public void Imported(IModuleContext context) {
     if (Name == "clr") {
         ((IronPythonModuleContext)context).ShowClr = true;
     } else if (Name == "wpf") {
         AddWpfReferences();
     }
 }
示例#4
0
 public bool Load(IModuleContext context)
 {
     Should.NotBeNull(context, nameof(context));
     var mode = _supportedModes & context.Mode;
     if (_supportedModes.HasFlagEx(LoadMode.RuntimeDebug) || _supportedModes.HasFlagEx(LoadMode.RuntimeRelease))
     {
         if (mode != context.Mode)
             return false;
     }
     else
     {
         if (mode == 0)
             return false;
     }
     if (!_iocContainerCanBeNull && context.IocContainer == null)
         return false;
     lock (_locker)
     {
         _context = context;
         _iocContainer = context.IocContainer;
         _mode = context.Mode;
         try
         {
             return LoadInternal();
         }
         finally
         {
             _context = null;
             _iocContainer = null;
             _mode = default(LoadMode);
         }
     }
 }
示例#5
0
 public FunctionView(IModuleContext context, string name, IPythonFunction member, bool isMethod)
     : base(context, name, member)
 {
     _function = member;
     _isMethod = isMethod;
     _returnTypes = new Lazy<IEnumerable<IAnalysisItemView>>(CalculateReturnTypes);
 }
示例#6
0
 public ModuleView(IPythonInterpreter interpreter, IModuleContext context, string name, string idbPath) {
     _interpreter = interpreter;
     _context = context;
     Name = name;
     _idbPath = idbPath;
     _children = CalculateChildren().ToArray();
 }
示例#7
0
        public IMember GetMember(IModuleContext context, string name) {
            if (_attrs == null) {
                Interlocked.CompareExchange(ref _attrs, new Dictionary<string, MemberInfo>(), null);
            }
            bool showClr = context == null || ((IronPythonModuleContext)context).ShowClr;

            MemberInfo member;
            if (!_attrs.TryGetValue(name, out member) || member.Member == null) {
                var res = Interpreter.Remote.GetMember(Value, name);
                if (!res.Equals(Value)) {
                    _attrs[name] = member = new MemberInfo(_interpreter.MakeObject(res));
                }
            }

            if (!showClr) {
                if (!(this is IronPythonNamespace)) {   // namespaces always show all of their members...
                    switch (member.ClrOnly) {
                        case IsClrOnly.NotChecked:
                            CreateNonClrAttrs();
                            if (_attrs.ContainsKey(name) && 
                                _attrs[name].ClrOnly == IsClrOnly.Yes) {
                                return null;
                            }
                            break;
                        case IsClrOnly.No:
                            break;
                        case IsClrOnly.Yes:
                            return null;
                    }
                }
            }

            return member.Member;
        }
示例#8
0
 public void UnloadModules(IModuleContext context)
 {
     foreach (var m in _loadedModules)
     {
         m.Unload(context);
     }
 }
示例#9
0
 public FunctionOverloadView(IModuleContext context, string name, IPythonFunctionOverload overload) {
     _context = context;
     Name = name;
     _overload = overload;
     _prototype = new Lazy<string>(CalculatePrototype);
     _returnTypes = new Lazy<IEnumerable<IAnalysisItemView>>(CalculateReturnTypes);
     _parameters = new Lazy<IEnumerable<IAnalysisItemView>>(CalculateParameters);
 }
示例#10
0
        public void Load(IModuleContext context)
        {
            var persistenceManager = context.ServiceLocator.GetInstance<IPersistenceManager>();
            persistenceManager.RegiserPersistenceProvider(SettingsPersistenceProviderKey, () => new ApplicationDataXmlPersistenceProvider());

            context.ServiceLocator.RegisterSingleton<ISettingsManager, SettingsManager>();
            context.ServiceLocator.Register<ISettingsEntryKeyBuilder, SettingsEntryKeyBuilder>();
        }
示例#11
0
文件: SuperInfo.cs 项目: wenh123/PTVS
 public override IDictionary<string, IAnalysisSet> GetAllMembers(IModuleContext moduleContext) {
     var mro = ClassInfo._mro;
     if (!mro.IsValid) {
         return new Dictionary<string, IAnalysisSet>();
     }
     // First item in MRO list is always the class itself.
     return Values.Mro.GetAllMembersOfMro(mro.Skip(1), moduleContext);
 }
示例#12
0
        public void Load(IModuleContext context)
        {
            var settingsManager = context.ServiceLocator.GetInstance<ISettingsManager>();
            settingsManager.RegisterSettings<KeyboardBindingSettings>();
            settingsManager.RegisterSettings<GamepadBindingSettings>();
            settingsManager.RegisterSettings<InputSettings>();

            SetDefaults(settingsManager);

            InputManager inputManager = new InputManager();

            context.InputSourceAssembler.ConfigureInputSource((c) =>
                {
                    var settings = settingsManager.LoadSettings<InputSettings>(c);

                    if (settings.IsUserInputEnabled)
                    {
                        var bindings = settingsManager.LoadSettings<KeyboardBindingSettings>(c);
                        KeyboardInputSource keyboard = new KeyboardInputSource(inputManager.GetKeyboard(), bindings);
                        return keyboard;
                    }

                    return null;

                });


            context.InputSourceAssembler.ConfigureInputSource((c) =>
                {
                    var settings = settingsManager.LoadSettings<InputSettings>(c);

                    if (settings.IsUserInputEnabled)
                    {
                        CompositeInputSource cis = new CompositeInputSource();

                        for (Int32 i = 0; i < inputManager.GetJoystickCount(); i++)
                        {
                            var bindings = settingsManager.LoadSettings<GamepadBindingSettings>(c);

                            if (i == 0)
                            {
                                GamepadInputSource gamepad = new GamepadInputSource(inputManager.GetJoystick(i), bindings.Gamepad1Bindings);
                                cis.AddInputSource(gamepad);
                            }
                            else if (i == 1)
                            {
                                GamepadInputSource gamepad = new GamepadInputSource(inputManager.GetJoystick(i), bindings.Gamepad2Bindings);
                                cis.AddInputSource(gamepad);
                            }
                        }

                        return cis;
                    }

                    return null;
                });
        }
示例#13
0
        public void Load(IModuleContext context)
        {
            var settingsManager = context.ServiceLocator.GetInstance<ISettingsManager>();

            var keybindings = new List<Wren.Core.Input.KeyboardBindingSettings.KeyBinding>();
            keybindings.Add(new KeyboardBindingSettings.KeyBinding() { ButtonId = 100, Key = "Escape" });
            keybindings.Add(new KeyboardBindingSettings.KeyBinding() { ButtonId = 101, Key = "M" });
            var defaultKeybindings = new KeyboardBindingSettings() { Bindings = keybindings.ToArray() };
            settingsManager.ApplySettings(defaultKeybindings, new EmulationContext(Game.Empty, new EmulatedSystem("WrenGame")), SettingsScope.EmulatedSystem);
        }
示例#14
0
文件: ModuleInfo.cs 项目: borota/JTVS
 public ModuleInfo(string moduleName, ProjectEntry projectEntry, IModuleContext moduleContext)
 {
     _name = moduleName;
     _projectEntry = projectEntry;
     _sequences = new Dictionary<Node, INamespaceSet>();
     _scope = new ModuleScope(this);
     _weakModule = new WeakReference(this);
     _context = moduleContext;
     _scopes = new Dictionary<Node, InterpreterScope>();
 }
示例#15
0
 public ModuleInfo(string moduleName, ProjectEntry projectEntry, IModuleContext moduleContext) {
     _name = moduleName;
     _projectEntry = projectEntry;
     _sequences = new Dictionary<Node, IAnalysisSet>();
     _scope = new ModuleScope(this);
     _weakModule = new WeakReference(this);
     _context = moduleContext;
     _scopes = new Dictionary<Node, InterpreterScope>();
     _referencedModules = new HashSet<ModuleReference>();
     _unresolvedModules = new HashSet<string>(StringComparer.Ordinal);
 }
示例#16
0
        public ParameterView(IModuleContext context, IParameterInfo parameter) {
            _context = context;
            _parameter = parameter;
            _types = new Lazy<IEnumerable<IAnalysisItemView>>(CalculateTypes);

            Name = _parameter.Name;
            if (_parameter.IsParamArray) {
                Name = "*" + Name;
            } else if (_parameter.IsKeywordDict) {
                Name = "**" + Name;
            }
        }
示例#17
0
 public override IDictionary<string, IAnalysisSet> GetAllMembers(IModuleContext moduleContext, GetMemberOptions options = GetMemberOptions.None) {
     var res = new Dictionary<string, IAnalysisSet>();
     foreach (var kvp in _scope.AllVariables) {
         kvp.Value.ClearOldValues();
         if (kvp.Value._dependencies.Count > 0) {
             var types = kvp.Value.Types;
             if (types.Count > 0) {
                 res[kvp.Key] = types;
             }
         }
     }
     return res;
 }
示例#18
0
        public void Load(IModuleContext context)
        {
            var directoryManager = context.ServiceLocator.GetInstance<IDirectoryManager>();
            directoryManager.RegisterExtensionKey(RomExtensionKey, "nes");
            directoryManager.RegisterExtensionKey(RomExtensionKey, "bin");
            directoryManager.RegisterExtensionKey(RomExtensionKey, "sms");
            // directoryManager.RegisterExtensionKey(RomExtensionKey, "zip");
            
            var persistenceManager = context.ServiceLocator.GetInstance<IPersistenceManager>();
            persistenceManager.RegiserPersistenceProvider(GameLibraryPersistenceProviderKey, () => new ApplicationDataXmlPersistenceProvider());

            context.ServiceLocator.RegisterSingleton<IGameLibraryManager, GameLibraryManager>();
        }
示例#19
0
        public void LoadModules(IModuleContext context)
        {
            var moduleTypes = new List<Type>();

            String path = Environment.CurrentDirectory;
            foreach (var file in Directory.GetFiles(path, "*.Module.*.dll"))
            {
                var assembly = Assembly.LoadFile(file);

                foreach (var type in assembly.GetExportedTypes())
                {
                    if (typeof(IModule).IsAssignableFrom(type))
                    {
                        moduleTypes.Add(type);
                    }
                }
            }

            List<Type> _dependencyGraph = new List<Type>();
            List<Type> _invalidModules = new List<Type>();

            while (_dependencyGraph.Count + _invalidModules.Count < moduleTypes.Count)
            {
                foreach (var type in moduleTypes)
                {
                    if (_dependencyGraph.Contains(type))
                        continue;

                    if (_invalidModules.Contains(type))
                        continue;

                    var dependencies = type.GetCustomAttributes(typeof(ModuleDependencyAttribute), false).Cast<ModuleDependencyAttribute>();

                    if (dependencies.Count() == 0)
                    {
                        _dependencyGraph.Add(type);
                        continue;
                    }

                    CheckDependencies(moduleTypes, _invalidModules, type, dependencies, _dependencyGraph);
                }
            }

            foreach (var m in _dependencyGraph)
            {
                var module = (IModule)Activator.CreateInstance(m);
                module.Load(context);
                _loadedModules.Add(module);
            }
        }
示例#20
0
        public override IDictionary<string, IAnalysisSet> GetAllMembers(IModuleContext moduleContext, GetMemberOptions options = GetMemberOptions.None)
        {
            var mro = ClassInfo._mro;
            if (!mro.IsValid) {
                return new Dictionary<string, IAnalysisSet>();
            }

            if (options.HasFlag(GetMemberOptions.DeclaredOnly)) {
                return Values.Mro.GetAllMembersOfMro(mro.Skip(1).Take(1), moduleContext, options);
            }

            // First item in MRO list is always the class itself.
            return Values.Mro.GetAllMembersOfMro(mro.Skip(1), moduleContext, options);
        }
示例#21
0
        public override IDictionary<string, IAnalysisSet> GetAllMembers(IModuleContext moduleContext, GetMemberOptions options = GetMemberOptions.None) {
            var res = new Dictionary<string, IAnalysisSet>();
            if (_instanceAttrs != null) {
                foreach (var kvp in _instanceAttrs) {
                    var types = kvp.Value.TypesNoCopy;
                    var key = kvp.Key;
                    kvp.Value.ClearOldValues();
                    if (kvp.Value.VariableStillExists) {
                        MergeTypes(res, key, types);
                    }
                }
            }

            // check and see if it's defined in a base class instance as well...
            if (!options.HasFlag(GetMemberOptions.DeclaredOnly)) {
                foreach (var b in _classInfo.Bases) {
                    foreach (var ns in b) {
                        if (ns.Push()) {
                            try {
                                ClassInfo baseClass = ns as ClassInfo;
                                if (baseClass != null &&
                                    baseClass.Instance._instanceAttrs != null) {
                                    foreach (var kvp in baseClass.Instance._instanceAttrs) {
                                        kvp.Value.ClearOldValues();
                                        if (kvp.Value.VariableStillExists) {
                                            MergeTypes(res, kvp.Key, kvp.Value.TypesNoCopy);
                                        }
                                    }
                                }
                            } finally {
                                ns.Pop();
                            }
                        }
                    }
                }

                foreach (var classMem in _classInfo.GetAllMembers(moduleContext)) {
                    MergeTypes(res, classMem.Key, classMem.Value);
                }
            }
            return res;
        }
示例#22
0
        public void Load(IModuleContext context)
        {
            var persistenceManager = context.ServiceLocator.GetInstance<IPersistenceManager>();
            persistenceManager.RegiserPersistenceProvider(ReplayPersistenceProviderKey, () => new BinaryFilePersistenceProvider());

            persistenceManager.RegiserPersistenceProvider(ReplayManagerPersistenceProviderKey, () => new ApplicationDataXmlPersistenceProvider());

            var settingsManager = context.ServiceLocator.GetInstance<ISettingsManager>();
            settingsManager.RegisterSettings<ReplaySettings>();

            context.ServiceLocator.RegisterSingleton<IReplayManager, ReplayManager>();

            var directoryManager = context.ServiceLocator.GetInstance<IDirectoryManager>();
            
            context.InputSourceAssembler.ConfigurePipeline((c, i) =>
                {
                    var settings = settingsManager.LoadSettings<ReplaySettings>(c);
                    if (settings.IsRecording)
                    {
                        return new RecordingInputSourceDecorator(i, Path.Combine(GetPath(c, directoryManager), settings.FileName), persistenceManager, 8);
                    }
                    else
                    {
                        return i;
                    }
                });

            context.InputSourceAssembler.ConfigureInputSource((c) =>
                {
                    var settings = settingsManager.LoadSettings<ReplaySettings>(c);
                    if (settings.IsPlayingBack)
                    {
                        var pp = new BinaryFilePersistenceProvider();
                        var replay = pp.Load<ReplayData>(System.IO.Path.Combine(GetPath(c, directoryManager), settings.FileName));
                        return new PlaybackInputSource(replay, 8);
                    }

                    return null;
                    
                });
        }
示例#23
0
        // public const String SettingsPersistenceName = "Settings.config";

        public void Load(IModuleContext context)
        {
            var persistenceManager = context.ServiceLocator.GetInstance<IPersistenceManager>();
            persistenceManager.RegiserPersistenceProvider(AchievementsPersistenceProviderKey, () => new RavenDbPersistenceProvider());

            var settingsManager = context.ServiceLocator.GetInstance<ISettingsManager>();
            settingsManager.RegisterSettings<AchievementSettings>();

            AchievementSettings settings = new AchievementSettings();
            settings.DefinitionsLastSynchronized = new DateTime(2000, 1, 1);
            settings.StateLastDownloaded = new DateTime(2000, 1, 1);
            settingsManager.ApplySettings(settings);
           
            AchievementsManager manager = 
                new AchievementsManager(
                    new AchievementsService(), 
                    settingsManager, 
                    persistenceManager,
                    context.ServiceLocator.GetInstance<IEventAggregator>());

            var gameLibraryManager = context.ServiceLocator.GetInstance<IGameLibraryManager>();
            gameLibraryManager.RegisterGameInfoProvider(new AchievementGameInfoProvider(manager));
        }
示例#24
0
 public IEnumerable <string> GetMemberNames(IModuleContext moduleContext) => DeclaringModule.GetMemberNames(moduleContext);
示例#25
0
 public IMember GetMember(IModuleContext context, string name) => DeclaringModule.GetMember(context, name);
示例#26
0
文件: CJType.cs 项目: borota/JTVS
 public IEnumerable<string> GetMemberNames(IModuleContext moduleContext)
 {
     foreach (var key in _members.Keys) {
         yield return key;
     }
     if (_mro != null) {
         foreach (var type in _mro) {
             foreach (var key in type._members.Keys) {
                 yield return key;
             }
         }
     } else if (_bases != null) {
         foreach (var type in _bases) {
             foreach (var key in type.GetMemberNames(moduleContext)) {
                 yield return key;
             }
         }
     }
 }
示例#27
0
 protected virtual IObserverProvider GetObserverProvider(IModuleContext context)
 {
     return(null);
 }
示例#28
0
 internal IEnumerable <string> GetMemberNames(IModuleContext moduleContext)
 {
     return(_type.GetMemberNames(moduleContext));
 }
        private static void InitializeDesignTimeModules(IList<Assembly> assemblies, bool allAssemblies)
        {
            var designTimeManager = _designTimeManager;
            if (assemblies.Count == 0 || designTimeManager == null || !designTimeManager.IsDesignMode)
                return;
            IList<IModule> modules = assemblies.GetModules(false);
            if (modules.Count == 0)
                return;

            var context = new ModuleContext(designTimeManager.Platform, LoadMode.Design, designTimeManager.IocContainer,
                designTimeManager.Context, allAssemblies ? assemblies : GetAssemblies(true));
            for (int i = 0; i < modules.Count; i++)
            {
                IModule module = modules[i];
                var fullName = module.GetType().AssemblyQualifiedName;
                IModule oldModule;
                if (LoadedModules.TryGetValue(fullName, out oldModule))
                {
                    LoadedModules.Remove(fullName);
                    oldModule.Unload(_lastContext);
                    oldModule.TraceModule(false);
                }
                if (module.Load(context))
                {
                    LoadedModules[fullName] = module;
                    module.TraceModule(true);
                }
            }
            _lastContext = context;
        }
示例#30
0
        internal IDictionary <string, IAnalysisSet> GetAllMembers(IMemberContainer container, IModuleContext moduleContext)
        {
            var names  = container.GetMemberNames(moduleContext);
            var result = new Dictionary <string, IAnalysisSet>();

            foreach (var name in names)
            {
                result[name] = GetAnalysisValueFromObjects(container.GetMember(moduleContext, name));
            }
            var children = (container as IModule)?.GetChildrenPackages(moduleContext);

            if (children?.Any() ?? false)
            {
                foreach (var child in children)
                {
                    IAnalysisSet existing;
                    if (result.TryGetValue(child.Key, out existing))
                    {
                        result[child.Key] = existing.Add(child.Value);
                    }
                    else
                    {
                        result[child.Key] = child.Value;
                    }
                }
            }

            return(result);
        }
示例#31
0
 public IEnumerable <string> GetModuleMemberNames(IModuleContext context)
 {
     return(GetMemberNames(context));
 }
示例#32
0
 public void Unload(IModuleContext context)
 {
     OnUnloaded(context);
 }
示例#33
0
 protected virtual IBindingMemberProvider GetBindingMemberProvider(IModuleContext context)
 {
     return(null);
 }
示例#34
0
 protected virtual bool CanLoad(IModuleContext context)
 {
     return(true);
 }
示例#35
0
 public AccountManager(IModuleContext context)
 {
     this.context = context;
 }
示例#36
0
 public void Load(IModuleContext context)
 {
     context.EmulatorRegistry.RegisterEmulator<SmsEmulator>(new EmulatedSystem("SMS"));
 }
示例#37
0
        internal IDictionary <string, IAnalysisSet> GetAllMembers(IMemberContainer container, IModuleContext moduleContext)
        {
            var names  = container.GetMemberNames(moduleContext);
            var result = new Dictionary <string, IAnalysisSet>();

            foreach (var name in names)
            {
                result[name] = GetAnalysisValueFromObjects(container.GetMember(moduleContext, name));
            }

            return(result);
        }
示例#38
0
 public IEnumerable <string> GetMemberNames(IModuleContext moduleContext) => null;
示例#39
0
 public void Unload(IModuleContext context)
 {
 }
示例#40
0
 public IMember GetMember(IModuleContext context, string name) => null;
示例#41
0
 public IEnumerable <KeyValuePair <string, AnalysisValue> > GetChildrenPackages(IModuleContext context)
 {
     foreach (var name in _type.GetChildrenModules())
     {
         yield return(new KeyValuePair <string, AnalysisValue>(name, ProjectState.GetAnalysisValueFromObjects(_type.GetMember(context, name))));
     }
 }
 /// <summary>
 ///     Gets the <see cref="IBindingErrorProvider" /> that will be used by default.
 /// </summary>
 protected override IBindingErrorProvider GetBindingErrorProvider(IModuleContext context)
 {
     return new BindingErrorProvider();
 }
示例#43
0
 public override IDictionary<string, INamespaceSet> GetAllMembers(IModuleContext moduleContext)
 {
     return _original.GetAllMembers(moduleContext);
 }
示例#44
0
 protected virtual IBindingManager GetBindingManager(IModuleContext context)
 {
     return(null);
 }
示例#45
0
文件: CJType.cs 项目: borota/JTVS
 public IMember GetMember(IModuleContext context, string name)
 {
     IMember res;
     if (_members.TryGetValue(name, out res)) {
         return res;
     }
     if (_mro != null) {
         foreach (var mroType in _mro) {
             if (mroType._members.TryGetValue(name, out res)) {
                 return res;
             }
         }
     } else if (_bases != null) {
         foreach (var baseType in _bases) {
             res = baseType.GetMember(context, name);
             if (res != null) {
                 return res;
             }
         }
     }
     return null;
 }
示例#46
0
 public IMember GetMember(IModuleContext context, string name) => new UnionType(
     Types.Select(t => t.GetMember(context, name)).OfType <IPythonType>().ToArray()
     );
示例#47
0
 IEnumerable <KeyValuePair <string, AnalysisValue> > IModule.GetChildrenPackages(IModuleContext context)
 {
     foreach (var member in _members.OfType <IModule>())
     {
         foreach (var keyValue in member.GetChildrenPackages(context))
         {
             yield return(keyValue);
         }
     }
 }
示例#48
0
 protected virtual void OnUnloaded(IModuleContext context)
 {
 }
示例#49
0
 public IEnumerable <string> GetMemberNames(IModuleContext moduleContext) => Types.SelectMany(t => t.GetMemberNames(moduleContext));
示例#50
0
 protected virtual IBindingErrorProvider GetBindingErrorProvider(IModuleContext context)
 {
     return(new BindingErrorProviderBase());
 }
示例#51
0
 public void Unload(IModuleContext context)
 {
     
 }
示例#52
0
 public ManageModelQueryHandler(ILogger <ManageModelQueryHandler> logger, IModuleContext ctx)
 {
     _logger = logger;
     _ctx    = ctx;
 }