public Project GetProject() { //Project project = FluorineContext.Current.Session[FluorineProjectSessionKey] as Project; Project project = HttpContext.Current.Application[FluorineProjectSessionKey] as Project; if( project == null ) { string[] lac = TypeHelper.GetLacLocations(); project = new Project(FluorineContext.Current.ApplicationPath, FluorineContext.Current.AbsoluteUri, HttpContext.Current.Server.MapPath(FluorineContext.Current.RequestApplicationPath), /*FluorineContext.Current.RequestApplicationPath,*/ lac); Type[] excludeTypes = new Type[] { typeof(System.Web.UI.Page), typeof(System.Web.HttpApplication) }; Type[] attributes = new Type[] { typeof(FluorineFx.RemotingServiceAttribute), typeof(FluorineFx.TransferObjectAttribute) }; project.Build(excludeTypes, attributes, false); string safeName = Management.Util.GetSafeString(FluorineContext.Current.RequestApplicationPath); project.Package = safeName; //If we have assemblies pick up the first namespace as the package foreach (AssemblyDescriptor assemblyDescriptor in project.Assemblies) { if( assemblyDescriptor.Namespaces.Count > 0 ) project.Package = assemblyDescriptor.Namespaces[0].Name; } project.Name = safeName; project.ContextRoot = FluorineContext.Current.RequestApplicationPath; project.Locked = true; string baseDirectory = Path.Combine(FluorineContext.Current.ApplicationBaseDirectory, "apps"); if (Directory.Exists(baseDirectory)) { foreach (string appDirectory in Directory.GetDirectories(baseDirectory)) { DirectoryInfo directoryInfo = new DirectoryInfo(appDirectory); string appName = directoryInfo.Name; string appConfigFile = Path.Combine(appDirectory, "app.config"); ApplicationConfiguration configuration = ApplicationConfiguration.Load(appConfigFile); Application application = new Application(); application.Name = appName; application.Directory = directoryInfo.Name; application.ApplicationHandler = configuration.ApplicationHandler.Type; project.AddApplication(application); } } //FluorineContext.Current.Session[FluorineProjectSessionKey] = project; HttpContext.Current.Application.Add(FluorineProjectSessionKey, project); } return project; }
public static ActionScriptType GetActionScriptType(TypeDescriptor typeDescriptor, Project project) { if (TypeMappingDictionary.Contains(typeDescriptor.FullName)) return TypeMappingDictionary[typeDescriptor.FullName] as ActionScriptType; if (typeDescriptor.IsArray) return TypeMapper.Array; if (typeDescriptor.FullName == typeof(IList).FullName) return new ActionScriptType("mx.collections", "ArrayCollection", true); if (typeDescriptor.FullName.StartsWith("System.Collections.Generic.IList`1")) return new ActionScriptType("mx.collections", "ArrayCollection", true); if (typeDescriptor.FullName.StartsWith("System.Collections.Generic.ICollection`1")) return new ActionScriptType("mx.collections", "ArrayCollection", true); if (typeDescriptor.FullName.StartsWith(typeof(IDictionary).FullName)) return TypeMapper.Object; if (typeDescriptor.Implements(typeof(IList).FullName)) { //TODO: add legacy collection support return new ActionScriptType("mx.collections", "ArrayCollection", true); } //Generic IList if (typeDescriptor.Implements("System.Collections.Generic.IList`1")) return new ActionScriptType("mx.collections", "ArrayCollection", true); if (typeDescriptor.Implements("System.Collections.Generic.ICollection`1")) return new ActionScriptType("mx.collections", "ArrayCollection", true); if (typeDescriptor.Implements(typeof(IDictionary).FullName)) return TypeMapper.Object; foreach (AssemblyDescriptor assemblyDescriptor in project.Assemblies) { foreach (TypeDescriptor typeDescriptorTmp in assemblyDescriptor.Types) { if (typeDescriptor.FullName == typeDescriptorTmp.FullName) return new ActionScriptType(typeDescriptor.Namespace, typeDescriptor.Name, false); } } return TypeMapper.Object; }