//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ // None //------------------------------------------------------ // // Internal Events // //------------------------------------------------------ // None //------------------------------------------------------ // // Protected Constructors // //------------------------------------------------------ // None //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods // <summary> // This method creates a part containing the name of the resource and // the resource manager that should contain it. If the resource manager // does not contain the requested part then when GetStream() is called on // the part it will return null. // </summary> // <param name="uri"></param> // <returns></returns> protected override PackagePart GetPartCore(Uri uri) { string partName; bool isContentFile; // AppDomain.AssemblyLoad event handler for standalone apps. This is added specifically for designer (Sparkle) scenario. // We use the assembly name to fetch the cached resource manager. With this mechanism we will still get resource from the // old version dll when a newer one is loaded. So whenever the AssemblyLoad event is fired, we will need to update the cache // with the newly loaded assembly. This is currently only for designer so not needed for browser hosted apps. // Attach the event handler before the first time we get the ResourceManagerWrapper. if (!assemblyLoadhandlerAttached) { AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(OnAssemblyLoadEventHandler); assemblyLoadhandlerAttached = true; } ResourceManagerWrapper rmWrapper = GetResourceManagerWrapper(uri, out partName, out isContentFile); // If the part name was specified as Content at compile time then we will try to load // the file directly. Otherwise we assume the user is looking for a resource. if (isContentFile) { return(new ContentFilePart(this, uri)); } else { // Uri mapps to a resource stream. // Make sure the resource id is exactly same as the one we used to create Resource // at compile time. partName = ResourceIDHelper.GetResourceIDFromRelativePath(partName); return(new ResourcePart(this, uri, partName, rmWrapper)); } }
// <summary> // Searches the available ResourceManagerWrapper list for one that matches the given Uri. // It could be either ResourceManagerWrapper for specific libary assembly or Application // main assembly. Package enforces that all Uri will be correctly formated. // </summary> // <param name="uri">Assumed to be relative</param> // <param name="partName">The name of the file in the resource manager</param> // <param name="isContentFile">A flag to indicate that this path is a known loose file at compile time</param> // <returns></returns> private ResourceManagerWrapper GetResourceManagerWrapper(Uri uri, out string partName, out bool isContentFile) { string assemblyName; string assemblyVersion; string assemblyKey; ResourceManagerWrapper rmwResult = ApplicationResourceManagerWrapper; isContentFile = false; BaseUriHelper.GetAssemblyNameAndPart(uri, out partName, out assemblyName, out assemblyVersion, out assemblyKey); if (!String.IsNullOrEmpty(assemblyName)) { string key = assemblyName + assemblyVersion + assemblyKey; _registeredResourceManagers.TryGetValue(key.ToLowerInvariant(), out rmwResult); // first time. Add this to the hash table if (rmwResult == null) { Assembly assembly; assembly = BaseUriHelper.GetLoadedAssembly(assemblyName, assemblyVersion, assemblyKey); if (assembly.Equals(Application.ResourceAssembly)) { // This Uri maps to Application Entry assembly even though it has ";component". rmwResult = ApplicationResourceManagerWrapper; } else { rmwResult = new ResourceManagerWrapper(assembly); } _registeredResourceManagers[key.ToLowerInvariant()] = rmwResult; } } if ((rmwResult == ApplicationResourceManagerWrapper)) { if (rmwResult != null) { // If this is not a resource from a component then it might be // a content file and not an application resource. if (ContentFileHelper.IsContentFile(partName)) { isContentFile = true; rmwResult = null; } } else { // Throw when Application.ResourceAssembly is null. throw new IOException(SR.Get(SRID.EntryAssemblyIsNull)); } } return(rmwResult); }
public static void StorageAccountTestInit(TestContext testContext) { TestBase.TestClassInitialize(testContext); if (isResourceMode) { NodeJSAgent.AgentConfig.UseEnvVar = false; AzureEnvironment environment = Utility.GetTargetEnvironment(); managementClient = new ManagementClient(Utility.GetCertificateCloudCredential(), environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement)); accountUtils = new AccountUtils(lang, isResourceMode); accountName = accountUtils.GenerateAccountName(); resourceLocation = isMooncake ? Constants.MCLocation.ChinaEast : allowedLocation; resourceManager = new ResourceManagerWrapper(); resourceGroupName = accountUtils.GenerateResourceGroupName(); resourceManager.CreateResourceGroup(resourceGroupName, resourceLocation); var parameters = new SRPModel.StorageAccountCreateParameters(new SRPModel.Sku(SRPModel.SkuName.StandardGRS), SRPModel.Kind.StorageV2, isMooncake ? Constants.MCLocation.ChinaEast : allowedLocation); accountUtils.SRPStorageClient.StorageAccounts.CreateAsync(resourceGroupName, accountName, parameters, CancellationToken.None).Wait(); //resourceGroupName = "weitest"; //accountName = "weitesttemp"; } }
public ResourcePart(Package container, Uri uri, string name, ResourceManagerWrapper rmWrapper) : base(container, uri) { if (rmWrapper == null) { throw new ArgumentNullException("rmWrapper"); } this._rmWrapper.Value = rmWrapper; this._name = name; }
protected override PackagePart GetPartCore(Uri uri) { if (!ResourceContainer.assemblyLoadhandlerAttached && !BrowserInteropHelper.IsBrowserHosted) { AppDomain.CurrentDomain.AssemblyLoad += this.OnAssemblyLoadEventHandler; ResourceContainer.assemblyLoadhandlerAttached = true; } string resourceIDFromRelativePath; bool flag; ResourceManagerWrapper resourceManagerWrapper = this.GetResourceManagerWrapper(uri, out resourceIDFromRelativePath, out flag); if (flag) { return(new ContentFilePart(this, uri)); } resourceIDFromRelativePath = ResourceIDHelper.GetResourceIDFromRelativePath(resourceIDFromRelativePath); return(new ResourcePart(this, uri, resourceIDFromRelativePath, resourceManagerWrapper)); }
// Token: 0x06007A52 RID: 31314 RVA: 0x0022AA1C File Offset: 0x00228C1C private ResourceManagerWrapper GetResourceManagerWrapper(Uri uri, out string partName, out bool isContentFile) { ResourceManagerWrapper resourceManagerWrapper = ResourceContainer.ApplicationResourceManagerWrapper; isContentFile = false; string text; string text2; string text3; BaseUriHelper.GetAssemblyNameAndPart(uri, out partName, out text, out text2, out text3); if (!string.IsNullOrEmpty(text)) { string text4 = text + text2 + text3; ResourceContainer._registeredResourceManagers.TryGetValue(text4.ToLowerInvariant(), out resourceManagerWrapper); if (resourceManagerWrapper == null) { Assembly loadedAssembly = BaseUriHelper.GetLoadedAssembly(text, text2, text3); if (loadedAssembly.Equals(Application.ResourceAssembly)) { resourceManagerWrapper = ResourceContainer.ApplicationResourceManagerWrapper; } else { resourceManagerWrapper = new ResourceManagerWrapper(loadedAssembly); } ResourceContainer._registeredResourceManagers[text4.ToLowerInvariant()] = resourceManagerWrapper; } } if (resourceManagerWrapper == ResourceContainer.ApplicationResourceManagerWrapper) { if (resourceManagerWrapper == null) { throw new IOException(SR.Get("EntryAssemblyIsNull")); } if (ContentFileHelper.IsContentFile(partName)) { isContentFile = true; resourceManagerWrapper = null; } } return(resourceManagerWrapper); }
private static void ConstructFontResourceCache(Assembly entryAssembly, Dictionary <string, List <string> > folderResourceMap) { // For entryAssembly build a set of mapping from paths to entries that describe each resource. Dictionary <string, string> contentFiles = ContentFileHelper.GetContentFiles(entryAssembly); if (contentFiles != null) { foreach (string contentFile in contentFiles.Keys) { AddResourceToFolderMap(folderResourceMap, contentFile); } } IList resourceList = new ResourceManagerWrapper(entryAssembly).ResourceList; if (resourceList != null) { foreach (string resource in resourceList) { AddResourceToFolderMap(folderResourceMap, resource); } } }