static void Main(string[] args) { ResourceManager localManager = new LocalResourceManager(@"E:\UTM\Teoria Sistemelor"); Console.WriteLine("Local Files"); foreach (var item in localManager.GetFiles()) { Console.WriteLine(item); Console.WriteLine("File Size : " + localManager.GetFileSize(item)); Console.WriteLine("Last modified date :" + localManager.GetLastModifiedDate(item)); Console.WriteLine(); } Console.WriteLine("Remote Files"); ResourceManager remoteManager = new RemoteResourceManager("vlad", "alexei"); foreach (var item in localManager.GetFiles()) { Console.WriteLine(item); Console.WriteLine("File Size : " + localManager.GetFileSize(item)); Console.WriteLine("Last modified date :" + localManager.GetLastModifiedDate(item)); Console.WriteLine(); } }
/// <summary> /// Creates and returns local ResourceManager for this page. /// </summary> /// <remarks> /// <para> /// In ASP.NET 1.1, this method loads local resources from the web application assembly. /// </para> /// <para> /// However, in ASP.NET 2.0, local resources are compiled into the dynamic assembly, /// so we need to find that assembly instead and load the resources from it. /// </para> /// </remarks> /// <returns>Local ResourceManager instance.</returns> private ResourceManager GetLocalResourceManager() { #if !NET_2_0 return(new ResourceManager(GetType().BaseType)); #else return(LocalResourceManager.GetLocalResourceManager(this)); #endif }
/// <summary> /// 取得游戏资源全目录 /// </summary> /// <param name="strRelativePath">相对路径</param> /// <param name="bIsWWW">是否用www来加载</param> /// <returns>dataPath+小写格式的相对地址</returns> public static string GetFullPath(string strRelativePath, bool bIsWWW) { string result = LocalResourceManager.FormatPath(strRelativePath);//小写格式的相对地址 RuntimePlatform platform = Application.platform; switch (platform) { case RuntimePlatform.OSXEditor: case RuntimePlatform.WindowsEditor: if (bIsWWW) { result = string.Format("file:///{0}/bin/{1}", Application.dataPath, strRelativePath); } else { result = string.Format("{0}/bin/{1}", Application.dataPath, strRelativePath); } break; case RuntimePlatform.OSXPlayer: case RuntimePlatform.OSXWebPlayer: case RuntimePlatform.OSXDashboardPlayer: case (RuntimePlatform)6: break; case RuntimePlatform.WindowsPlayer: if (bIsWWW) { result = string.Format("file:///{0}/../{1}", Application.dataPath, strRelativePath); } else { result = string.Format("{0}/../{1}", Application.dataPath, strRelativePath); } break; case RuntimePlatform.WindowsWebPlayer: result = string.Format("{0}/../{1}", Application.dataPath, strRelativePath); break; case RuntimePlatform.IPhonePlayer: if (bIsWWW) { result = string.Format("file://{0}/{1}", PluginTool.Singleton.GetResPath(), strRelativePath); } else { result = string.Format("{0}/{1}", PluginTool.Singleton.GetResPath(), strRelativePath); } break; default: if (platform == RuntimePlatform.Android) { if (bIsWWW) { result = string.Format("file://{0}/{1}", PluginTool.Singleton.GetResPath(), strRelativePath); } else { result = string.Format("{0}/{1}", PluginTool.Singleton.GetResPath(), strRelativePath); } } break; } return(result); }
/// <summary> /// 取得本地资源管理器 /// </summary> /// <returns></returns> public static IResourceManager GetResourceManager() { return(LocalResourceManager.GetInstance()); }
/// <summary> /// Creates and returns local ResourceManager for this page. /// </summary> /// <remarks> /// <para> /// In ASP.NET 1.1, this method loads local resources from the web application assembly. /// </para> /// <para> /// However, in ASP.NET 2.0, local resources are compiled into the dynamic assembly, /// so we need to find that assembly instead and load the resources from it. /// </para> /// </remarks> /// <returns>Local ResourceManager instance.</returns> private ResourceManager GetLocalResourceManager() { return(LocalResourceManager.GetLocalResourceManager(this)); }
private ICollection Deserialize(IServiceProvider provider, IContainer container, bool recycleInstances, bool validateRecycledTypes, bool applyDefaults) { PassThroughSerializationManager manager = new PassThroughSerializationManager(new LocalDesignerSerializationManager(this, new LocalServices(this, provider))); if (container != null) { manager.Manager.Container = container; } DesignerSerializationManager service = provider.GetService(typeof(IDesignerSerializationManager)) as DesignerSerializationManager; if (service != null) { foreach (IDesignerSerializationProvider provider2 in service.SerializationProviders) { ((IDesignerSerializationManager) manager.Manager).AddSerializationProvider(provider2); } } manager.Manager.RecycleInstances = recycleInstances; manager.Manager.PreserveNames = recycleInstances; manager.Manager.ValidateRecycledTypes = validateRecycledTypes; ArrayList list = null; if (this._resourceStream != null) { BinaryFormatter formatter = new BinaryFormatter(); this._resourceStream.Seek(0L, SeekOrigin.Begin); Hashtable data = formatter.Deserialize(this._resourceStream) as Hashtable; this._resources = new LocalResourceManager(data); } if (!recycleInstances) { list = new ArrayList(this._objectNames.Count); } using (manager.Manager.CreateSession()) { if (this._shimObjectNames.Count > 0) { List<string> list2 = this._shimObjectNames; IDesignerSerializationManager manager3 = manager; if ((manager3 != null) && (container != null)) { foreach (string str in list2) { object instance = container.Components[str]; if ((instance != null) && (manager3.GetInstance(str) == null)) { manager3.SetName(instance, str); } } } } ComponentListCodeDomSerializer.Instance.Deserialize(manager, this._objectState, this._objectNames, applyDefaults); if (!recycleInstances) { foreach (string str2 in this._objectNames) { object obj3 = ((IDesignerSerializationManager) manager.Manager).GetInstance(str2); if (obj3 != null) { list.Add(obj3); } } } this._errors = manager.Manager.Errors; } return list; }
private CodeDomSerializationStore(SerializationInfo info, StreamingContext context) { this._objectState = (Hashtable) info.GetValue("State", typeof(Hashtable)); this._objectNames = (ArrayList) info.GetValue("Names", typeof(ArrayList)); this._assemblies = (AssemblyName[]) info.GetValue("Assemblies", typeof(AssemblyName[])); this._shimObjectNames = (List<string>) info.GetValue("Shim", typeof(List<string>)); Hashtable data = (Hashtable) info.GetValue("Resources", typeof(Hashtable)); if (data != null) { this._resources = new LocalResourceManager(data); } }