public static ReswClassGenerator CreateGenerator(ResourceFileInfo resourceFileInfo, IErrorLogger logger) { ICodeGenerator codeGenerator = null; switch (resourceFileInfo.ParentProject.Language) { case ResourceInfo.Language.CSHARP: codeGenerator = new CSharpCodeGenerator(); break; case ResourceInfo.Language.VB: codeGenerator = new VBCodeGenerator(); break; case ResourceInfo.Language.CPPCX: codeGenerator = new CppCXCodeGenerator(); break; case ResourceInfo.Language.CPPWINRT: codeGenerator = new CppWinRTCodeGenerator(); break; } if (codeGenerator != null) { return(new ReswClassGenerator(resourceFileInfo, codeGenerator, logger)); } return(null); }
/// <summary> /// 保存系统头像 /// </summary> /// <param name="id">头像文件的Id</param> public void SaveSysAvatar(int id) { ResourceFileInfo file = new ResourceFileInfo(); file.Id = id; file.UserId = User.Identity.GetUserId(); _resourceFileService.SaveAvatar(file); }
public static string ShowFileDialog(ResourceFileInfo resourceFileInfo) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Multiselect = false; openFile.RestoreDirectory = true; openFile.Filter = resourceFileInfo.Filter; if (openFile.ShowDialog() == DialogResult.OK) { return openFile.FileName; } else { return null; } }
public void Init(SCIPackage package, ResType type, ushort number, byte resNum, ResourceFileInfo info) { Package = package; Type = type; Number = number; if (type == ResType.Message && package.ExternalMessages) { Volumes.Add(new VolumeOffset(resNum, -1, "RESOURCE.MSG")); } else { Volumes.Add(new VolumeOffset(resNum, -1)); } _info = info; }
public object Done(string actionName, string controllerName, string ids) { var controller = ControllerBuilder.Current.GetControllerFactory() .CreateController(this.Request.RequestContext, controllerName) as BaseController; controller.ControllerContext = this.ControllerContext; int[] idArr = CommOp.ToIntArray(ids, ','); ResourceFileInfo[] results = new ResourceFileInfo[idArr.Length]; int i = 0; foreach (int id in idArr) { //调用业务逻辑得到stream数组 var file = _resourceFileService.GetFile(id); results[i++] = file; } var obj = RefHelper.CallMethod(controller, actionName, new object[] { results }); results.Each(r => r.FileStream.Dispose()); return(obj); }
private UploadResult UploadFile() { string contentRange = Request.Headers["Content-Range"]; if (Request.Files.Count != 1 && !contentRange.IsEmpty()) { throw new HttpRequestValidationException("Attempt to upload chunked file containing more than one fragment per request"); } var file = Request.Files[0]; var inputStream = file.InputStream; //ie8会上传完整的带路径文件名 FileInfo fi = new FileInfo(file.FileName); string md5 = Request.Form["md5"]; int CatalogId = int.Parse(Request.Form["CatalogId"]); //在重复文件已经存在不必上传的情况下,会象征性上传一个字节数据, //并传重复的文件的ID int id = CommOp.ToInt(Request.Form["Id"]); int dup = CommOp.ToInt(Request.Form["dup"]); ResourceFileInfo retMess = null; if (dup == 1 && (id > 0 && inputStream.Length == 1)) { var model = new ResourceFileInfo { Id = id, UserId = User.Identity.GetUserId(), MD5Code = md5, FileStream = inputStream, FileName = fi.Name, CatalogId = CatalogId, ContentType = file.ContentType, }; var saved = _resourceFileService.SaveCatalogArticleInfo(model); retMess = _resourceFileService.GetFile(saved.Id); } else { //bytes 1048576-2097151/5455977 ChunkInfo chunk = GetBytesChunkInfo(contentRange); var model = new ResourceFileInfo { Id = id, UserId = User.Identity.GetUserId(), MD5Code = md5, FileStream = inputStream, FileName = fi.Name, CatalogId = CatalogId, FileSize = chunk.Size == 0 ? file.ContentLength : chunk.Size, ContentType = file.ContentType, EndPos = chunk.End, StartPos = chunk.Start }; retMess = _resourceFileService.SaveFile(model); } return(new UploadResult() { name = retMess.FileName, size = retMess.FileSize, type = retMess.ContentType, Id = retMess.Id, UserId = retMess.UserId, FileKey = retMess.FileKey, CatalogId = retMess.CatalogId, url = Url.Action("Download", "Files", new { id = retMess.Id }), deleteUrl = Url.Action("Delete", "Files", new { id = retMess.Id }), thumbnailUrl = "",//Url.Action("Thumbnail", "Files", new { id = file.FileName }), deleteType = "DELETE", }); }
private ReswClassGenerator(ResourceFileInfo resourceInfo, ICodeGenerator generator, IErrorLogger logger) { _resourceFileInfo = resourceInfo; _codeGenerator = generator; _logger = logger; }
public virtual IEnumerable <GeneratedFile> GeneratedFiles(string baseFilename, StronglyTypedClass info, ResourceFileInfo resourceInfo, IEnumerable <string> namespaceOverride) { var supportMultiNamespaceDeclaration = SupportMultiNamespaceDeclaration(); var namespacesToUse = namespaceOverride ?? info.Namespaces; var markupClassName = info.ClassName + "Extension"; var headerFileName = baseFilename + ".h"; var cppFileName = baseFilename + ".cpp"; var baseNamespace = namespacesToUse == null || !namespacesToUse.Any() ? "" : namespacesToUse.Aggregate((a, b) => a + "::" + b); var indentStr = resourceInfo.Project.GetIndentString(); var builderHeader = new CodeStringBuilder(indentStr); var builderCpp = new CodeStringBuilder(indentStr); var precompiledHeader = resourceInfo.Project.GetPrecompiledHeader(); var localNamespace = baseNamespace == "" ? "" : $"{LocalNamespaceName}::"; var namespaceResourceClass = $"{localNamespace}{info.ClassName}::"; var namespaceMarkupExtensionClass = $"{localNamespace}{markupClassName}::"; HeaderFileGenerateHeaders(builderHeader, info.ClassName, info.Namespaces, info.IsAdvanced); builderHeader.AppendEmptyLine(); HeaderOpenNamespace(builderHeader, namespacesToUse, supportMultiNamespaceDeclaration); HeaderOpenStronglyTypedClass(builderHeader, info.ResoureFile, info.ClassName); builderHeader.AppendEmptyLine(); CppFileGenerateHeaders(builderCpp, precompiledHeader, headerFileName, baseNamespace, info.ClassName, info.Namespaces, info.IsAdvanced); builderCpp.AppendEmptyLine(); CppGenerateStronglyTypedClassStaticFunc(builderCpp, namespaceResourceClass, info.ResoureFile); builderCpp.AppendEmptyLine(); var firstLocalization = true; foreach (var item in info.Localizations) { if (firstLocalization) { firstLocalization = false; } else { builderHeader.AppendEmptyLine(); builderCpp.AppendEmptyLine(); } HeaderOpenRegion(builderHeader, item.Key); HeaderCreateFormatMethod(builderHeader, item.Key, item.IsProperty, item.Parameters.OfType <FunctionFormatTagParameter>(), item.Summary, item.ExtraParameters); builderCpp.AppendEmptyLine(); CppCreateFormatMethod(builderCpp, namespaceResourceClass, item.Key, item.IsProperty, item.IsDotNetFormatting, item.Parameters, item.ExtraParameters, (item as PluralLocalization)?.ParameterToUseForPluralization, (item as PluralLocalization)?.SupportNoneState ?? false, (item as IVariantLocalization)?.ParameterToUseForVariant ); HeaderCloseRegion(builderHeader); } HeaderCloseStronglyTypedClass(builderHeader); builderHeader.AppendEmptyLine(); HeaderCreateMarkupExtension(builderHeader, info.ResoureFile, markupClassName, info.Localizations.Where(i => i is Localization).Select(s => s.Key), info.Namespaces); HeaderCloseNamespace(builderHeader, namespacesToUse, supportMultiNamespaceDeclaration); HeaderAddExtra(builderHeader, info); builderCpp.AppendEmptyLine(); CppCreateMarkupExtension(builderCpp, namespaceMarkupExtensionClass, info.ResoureFile, markupClassName, info.Localizations.Where(i => i is Localization).Select(s => s.Key)); yield return(new GeneratedFile() { Filename = headerFileName, Content = builderHeader.GetString() }); yield return(new GeneratedFile() { Filename = cppFileName, Content = builderCpp.GetString() }); }
public virtual IEnumerable <GeneratedFile> GetGeneratedFiles(string baseFilename, StronglyTypedClass info, ResourceFileInfo resourceFileInfo) { return(GeneratedFiles(baseFilename, info, resourceFileInfo, null)); }