public void TestStripBrackets() { Assert.AreEqual("My Movie", ResolverHelper.StripBrackets("My Movie [boxset] [blah blah]")); Assert.AreEqual("file 01", ResolverHelper.StripBrackets("[tag1] file 01 [tvdbid=12345]")); Assert.AreEqual("file 01", ResolverHelper.StripBrackets("[tag1] file 01 [tmdbid=12345]")); Assert.AreEqual("file 01", ResolverHelper.StripBrackets("[tag1] file [boxset] [tvdbid=12345] 01 [tmdbid=12345]")); }
public Task <ItemUpdateType> FetchAsync(Game item, IDirectoryService directoryService, CancellationToken cancellationToken) { var result = _cachedResult; string platform = null; if (string.IsNullOrEmpty(item.DisplayMediaType)) { platform = ResolverHelper.AttemptGetGamePlatformTypeFromPath(_fileSystem, item.Path); if (!string.IsNullOrEmpty(platform)) { item.DisplayMediaType = ResolverHelper.GetDisplayMediaTypeFromPlatform(platform); result = _cachedResultWithUpdate; } } if (string.IsNullOrEmpty(item.GameSystem)) { platform = platform ?? ResolverHelper.AttemptGetGamePlatformTypeFromPath(_fileSystem, item.Path); if (!string.IsNullOrEmpty(platform)) { item.GameSystem = ResolverHelper.GetGameSystemFromPlatform(platform); result = _cachedResultWithUpdate; } } return(result); }
/// <summary> /// Resolves the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>BoxSet.</returns> protected override BoxSet Resolve(ItemResolveArgs args) { // It's a boxset if all of the following conditions are met: // Is a Directory // Contains [boxset] in the path if (args.IsDirectory) { var filename = Path.GetFileName(args.Path); if (string.IsNullOrEmpty(filename)) { return(null); } if (filename.IndexOf("[boxset]", StringComparison.OrdinalIgnoreCase) != -1 || args.ContainsFileSystemEntryByName("collection.xml")) { return(new BoxSet { Path = args.Path, Name = ResolverHelper.StripBrackets(Path.GetFileName(args.Path)) }); } } return(null); }
public static void Initialize(IKernel kernel) { kernel.Load(Assembly.GetExecutingAssembly()); kernel.Bind <IUnitOfWork>().To <UnitOfWork>(); kernel.Bind <ISqlGenerator <Author> >().To <SqlGenerator <Author> >(); ResolverHelper.SetProvider(kernel); }
private static T AdaptToHost <T>(AddInToken pipeline, IContract addInContract) { if (addInContract == null) { throw new ArgumentNullException("addInContract"); } System.Diagnostics.Contracts.Contract.EndContractBlock(); ContractComponent contract = pipeline._contract; HostAdapter hostAdapter = pipeline._hostAdapter; Type hostAdapterType; Type contractType; LoadContractAndHostAdapter(contract, hostAdapter, out contractType, out hostAdapterType); int?temporaryToken = null; try { temporaryToken = addInContract.AcquireLifetimeToken(); // This assembly resolve event exists to: // 1) To upgrade the contract assembly from the LoadFrom context to // the default loader context ResolverHelper resolver = new ResolverHelper(pipeline); ResolveEventHandler assemblyResolver = new ResolveEventHandler(resolver.ResolveAssemblyForHostAdapter); AppDomain.CurrentDomain.AssemblyResolve += assemblyResolver; // Create the Host Adapter, which is a subclass of the Host Add-In View. // Pass the contract implementation to this constructor, using a // transparent proxy to the real type. Detect common errors here. InvokerDelegate myInvokerDelegate = CreateConsInvoker(hostAdapterType, contractType); T hav; try { hav = (T)myInvokerDelegate(addInContract); } catch (ArgumentException e) { CheckForLoaderContextProblems(contract, pipeline._addinAdapter, e); throw; } finally { AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolver; } return(hav); } finally { if (temporaryToken != null && addInContract != null) { addInContract.RevokeLifetimeToken((int)temporaryToken); } } }
public static void Main() { IService s = new AirDiskService(81, "toto", string.Format("waMA={0}", ResolverHelper.GetMacAddresses().First().ToString()), string.Format("adVF=0x81,adVN=toto,adVU={0}", Guid.NewGuid())); s.Publish(); Console.ReadLine(); s.Stop(); }
public Task <ItemUpdateType> FetchAsync(GameSystem item, IDirectoryService directoryService, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(item.GameSystemName)) { item.GameSystemName = ResolverHelper.GetGameSystemFromPath(_fileSystem, item.Path); return(_cachedResultWithUpdate); } return(_cachedResult); }
public Task <ItemUpdateType> FetchAsync(GameSystem item, MetadataRefreshOptions options, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(item.GameSystemName)) { item.GameSystemName = ResolverHelper.GetGameSystemFromPath(_fileSystem, item.Path); return(_cachedResultWithUpdate); } return(_cachedResult); }
public void Resolver(IResolverContext context, IDependencyResolver resolver) { var args = context.HasImplementationType() && context.HasPublicConstructor() ? ResolverHelper.GetConstructorParameters( context.Dependency.GetImplementationType(), resolver) : ArrayExtends.Empty <object>(); context.Resolved = CompileCacheManager.GetCache(context.Dependency, resolver, args); context.Handled = context.Resolved != null && !PropertyCacheManager.Any(context.Dependency); }
public AirDiskService(ushort port, string diskName, string sys, params string[] dk) { HostName = Environment.MachineName + ".local."; Name = diskName; Protocol = "_adisk._tcp.local."; var ep = ResolverHelper.GetEndPoint(); ep.Port = port; this.addresses.Add(ep); this["sys"] = sys; for (int i = 0; i < dk.Length; i++) { this["dk" + i] = dk[i]; } }
internal static T ActivateHostAdapter <T>(PartialToken pipeline, IContract addIn) { if (pipeline == null) { throw new ArgumentNullException("pipeline"); } if (addIn == null) { throw new ArgumentNullException("addIn"); } System.Diagnostics.Contracts.Contract.EndContractBlock(); ContractComponent contract = pipeline._contract; HostAdapter hostAdapter = pipeline._hostAdapter; Type hostAdapterType; Type contractType; LoadContractAndHostAdapter(contract, hostAdapter, out contractType, out hostAdapterType); // This assembly resolve event exists to: // 1) To upgrade the contract assembly from the LoadFrom context to // the default loader context ResolverHelper resolver = new ResolverHelper(contract); ResolveEventHandler assemblyResolver = new ResolveEventHandler(resolver.ResolveAssemblyForHostAdapter); AppDomain.CurrentDomain.AssemblyResolve += assemblyResolver; T hav; InvokerDelegate myInvokerDelegate = CreateConsInvoker(hostAdapterType, contractType); try { hav = (T)myInvokerDelegate(addIn); } catch (ArgumentException e) { CheckForLoaderContextProblems(contract, pipeline._addinAdapter, e); throw; } finally { AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolver; } return(hav); }
public string FindPlatformId(GameSystemInfo console) { var platformSettings = Plugin.Instance.Configuration.GameSystems.FirstOrDefault(gs => console.Path.Equals(gs.Path)); if (platformSettings != null) { var id = ResolverHelper.GetTgdbId(platformSettings.ConsoleType); if (id != null) { return(id.ToString()); } } return(null); }
public Task <ItemUpdateType> FetchAsync(Game item, MetadataRefreshOptions options, CancellationToken cancellationToken) { var result = _cachedResult; string platform = null; if (string.IsNullOrEmpty(item.GameSystem)) { platform = platform ?? ResolverHelper.AttemptGetGamePlatformTypeFromPath(_fileSystem, item.Path); if (!string.IsNullOrEmpty(platform)) { item.GameSystem = ResolverHelper.GetGameSystemFromPlatform(platform); result = _cachedResultWithUpdate; } } return(result); }
/// <summary> /// /// </summary> /// <param name="kernel"></param> /// <param name="binding"></param> /// <param name="constructor"></param> /// <returns></returns> private static object[] ResolveParameters(IKernel kernel, IBinding binding, ConstructorMetadata constructor) { var parameters = constructor.Parameters; if (parameters.Length == 0) { return(null); } var arguments = new object[parameters.Length]; for (var i = 0; i < arguments.Length; i++) { var parameter = parameters[i]; var pi = parameter.Parameter; // Constructor argument var argument = binding.ConstructorArguments.GetParameter(pi.Name); if (argument != null) { arguments[i] = argument.Resolve(kernel); continue; } // Multiple if (parameter.ElementType != null) { arguments[i] = ResolverHelper.ConvertArray(parameter.ElementType, kernel.ResolveAll(parameter.ElementType, constructor.Constraints[i])); continue; } // Resolve bool resolve; var obj = kernel.TryResolve(pi.ParameterType, constructor.Constraints[i], out resolve); if (resolve) { arguments[i] = obj; } } return(arguments); }
public void Resolver(IResolverContext context, IDependencyResolver resolver) { try { var args = context.HasImplementationType() && context.HasPublicConstructor() ? ResolverHelper.GetConstructorParameters( context.Dependency.GetImplementationType(), resolver) : ArrayExtends.Empty <object>(); context.Resolved = CompileCacheManager.GetOrSetCache(context.Dependency, () => CreateDelegate(context.Resolved as Expression)). Invoke(resolver, args); CacheResolved(context, resolver); } catch (Exception ex) { throw new InvalidOperationException($"未能创建类型\"{context.Dependency.ServiceType}\"的实例。", ex); } }
public void Resolver(IResolverContext context, IDependencyResolver resolver) { var implType = context.IsDynamicProxy() ? DynamicTypeCacheManager.GetCache(context.Dependency.ImplementationType) : context.Dependency.ImplementationType; var constructor = ResolverHelper.GetBastConstructor(implType, resolver); if (constructor == null) { throw new InvalidOperationException($"{implType.FullName}不存在公共构造方法。"); } var parameter = Expression.Parameter(typeof(object[]), "args"); context.Resolved = Expression. Lambda <Func <IDependencyResolver, object[], object> >( Expression.New(constructor, GetConstructorParameters(constructor, parameter)), Expression.Parameter(typeof(IDependencyResolver)), parameter); }
public Airplay(ushort port) { HostName = Environment.MachineName + ".local."; Name = ResolverHelper.GetMacAddresses().First() + "@" + Environment.MachineName; Protocol = "_raop._tcp.local."; properties.Add("txtvers", "1"); properties.Add("vn", "3"); properties.Add("pw", "false"); properties.Add("sr", "44100"); properties.Add("ss", "16"); properties.Add("ch", "2"); properties.Add("cn", "0,1"); properties.Add("et", "0,1"); properties.Add("ek", "1"); properties.Add("sv", "false"); properties.Add("sm", "false"); properties.Add("tp", "TCP,UDP"); EndPoint ep = ResolverHelper.GetEndPoint(); ep.Port = port; this.addresses.Add(ep); }
/// <summary> /// Initializes a new instance of the <see cref="NinjectResolver"/> class. /// </summary> public NinjectResolver() { this.resolverHelper = new ResolverHelper(); }
private void InitRepository() { AuthorRepository = new GenericDataRepository <Author>(_connection, ResolverHelper.GetService <ISqlGenerator <Author> >()); }