public TVpObject Get(TAvatar avatar, TVpObject vpObject) { if (File.Exists(GetPath(avatar, vpObject))) { return(SerializableExtensions.Deserialize <TVpObject>(GetPath(avatar, vpObject))); } return(null); }
private async Task Connect() { Cli.WriteLine(ConsoleMessageType.Information, "Connecting..."); try { await Vp.Connect(); Cli.WriteLine(ConsoleMessageType.Information, "Connected to universe.\n"); if (File.Exists(AutoLogin.LoginconfigurationXmlPath)) { Cli.WriteLine(ConsoleMessageType.Information, "Autologin configuration enabled, attempting auto logon."); var config = SerializableExtensions.Deserialize <InstanceConfiguration <World> >(AutoLogin.LoginconfigurationXmlPath); try { await Vp.Login(config.UserName, config.Password, config.BotName); await Vp.Enter(config.World.Name); _world = config.World.Name; Vp.UpdateAvatar(); ProceedAfterLogin(true); } catch (VpException ex) { if (ex.Reason == ReasonCode.NotInUniverse) { // strange native vpsdk bug, after reating a new native instance, upon first time // the sdk does not seem to connect properly. await Connect(); } Cli.WriteLine(ConsoleMessageType.Information, "Autologin failed. Reason" + ex.Reason.ToString() + " " + ex.Message); AutoReconnect(); } } else { Cli.GetPromptTarget = LoginPrompt; Cli.ParseCommandLine = ProcessUserName; Cli.ReadLine(); } } catch (VpException ex) { AutoReconnect(); } }
/// <summary> /// Add a single object to the collection also adding additional configuration. /// </summary> /// <param name="namespace">is the object's namespace</param> /// <param name="name">is the object's name</param> /// <param name="clazz">is the class the object resolves to</param> /// <param name="type">is the object type</param> /// <param name="configuration">config</param> public void AddObject( string @namespace, string name, Type clazz, PluggableObjectType type, object configuration) { SerializableExtensions.EnsureSerializable(configuration); var namespaceMap = Pluggables.Get(@namespace); if (namespaceMap == null) { namespaceMap = new Dictionary<string, Pair<Type, PluggableObjectEntry>>(); Pluggables.Put(@namespace, namespaceMap); } namespaceMap.Put( name, new Pair<Type, PluggableObjectEntry>(clazz, new PluggableObjectEntry(type, configuration))); }
private void HandleAddPluggableObject( string factoryClassName, string @namespace, string name, PluggableObjectType type, object optionalCustomConfig, ImportServiceCompileTime importService) { SerializableExtensions.EnsureSerializable(optionalCustomConfig); if (factoryClassName == null) { throw new ConfigurationException("Factory class name has not been supplied for object '" + name + "'"); } if (@namespace == null) { throw new ConfigurationException("Namespace name has not been supplied for object '" + name + "'"); } if (name == null) { throw new ConfigurationException( "Name has not been supplied for object in namespace '" + @namespace + "'"); } Type clazz; try { clazz = importService.ClassForNameProvider.ClassForName(factoryClassName); } catch (TypeLoadException) { throw new ConfigurationException("View factory class " + factoryClassName + " could not be loaded"); } var namespaceMap = Pluggables.Get(@namespace); if (namespaceMap == null) { namespaceMap = new Dictionary<string, Pair<Type, PluggableObjectEntry>>(); Pluggables.Put(@namespace, namespaceMap); } namespaceMap.Put( name, new Pair<Type, PluggableObjectEntry>(clazz, new PluggableObjectEntry(type, optionalCustomConfig))); }
public List <PluginDescription> LoadConfiguration(string path) { return(SerializableExtensions.Deserialize <List <PluginDescription> >(path)); }