public ParseInformation Parse(
			FileName fileName,
			ITextSource fileContent,
			TypeScriptProject project,
			IEnumerable<TypeScriptFile> files)
		{
			try {
				using (TypeScriptContext context = contextFactory.CreateContext()) {
					context.AddFile(fileName, fileContent.Text);
					context.RunInitialisationScript();
					
					NavigationBarItem[] navigation = context.GetNavigationInfo(fileName);
					var unresolvedFile = new TypeScriptUnresolvedFile(fileName);
					unresolvedFile.AddNavigation(navigation, fileContent);
					
					if (project != null) {
						context.AddFiles(files);
						var document = new TextDocument(fileContent);
						Diagnostic[] diagnostics = context.GetDiagnostics(fileName, project.GetOptions());
						TypeScriptService.TaskService.Update(diagnostics, fileName);
					}
					
					return new ParseInformation(unresolvedFile, fileContent.Version, true);
				}
			} catch (Exception ex) {
				Console.WriteLine(ex.ToString());
				LoggingService.Debug(ex.ToString());
			}
			
			return new ParseInformation(
				new TypeScriptUnresolvedFile(fileName),
				fileContent.Version,
				true);
		}
 protected void Init()
 {
     output_file_name = "";
     file = new FileName();
     type = InputFileTemplateType.UNKNOWN;
     replaceList = new Dictionary<string,string>();
 }
		public void ErrorListPadIsDisplayedWhenBuildCompleteEventIsFiredAfterStopMethodCalled()
		{
			FileName fileName = new FileName("test.cs");
			context.MockTaskService.Add(new Task(fileName, String.Empty, 1, 1, TaskType.Error));
			buildProjectBeforeTestRun.FireBuildCompleteEvent();
			Assert.IsTrue(context.MockUnitTestWorkbench.TypesPassedToGetPadMethod.Contains(typeof(ErrorListPad)));
		}
示例#4
0
 static Version GetTargetFrameworkVersionFrom(FileName fileName)
 {
     var project = SD.ProjectService.FindProjectContainingFile(fileName) as CompilableProject;
     if (project == null)
         return DotNet40;
     return ScanVersion(project.TargetFrameworkVersion);
 }
示例#5
0
		XamlContext TestContext(string xaml, int offset)
		{
			var fileName = new FileName("test.xaml");
			var textSource = new StringTextSource(xaml);
			SetUpWithCode(fileName, textSource);
			return XamlContextResolver.ResolveContext(fileName, textSource, offset);
		}
		public void IsMatchReturnsFalseWhenTaskTypesAreDifferent()
		{
			FileName fileName = new FileName(myTestFileName);
			lhs = new SDTask(fileName, description, column, line, TaskType.Warning);
			CreateTaskComparison();
			Assert.IsFalse(taskComparison.IsMatch);
		}
		public static void SetPosition(FileName fileName, IDocument document, int markerStartLine, int markerStartColumn, int markerEndLine, int markerEndColumn)
		{
			if (document == null)
				return;
			Remove();
			
			startLine   = markerStartLine;
			startColumn = markerStartColumn;
			endLine     = markerEndLine;
			endColumn   = markerEndColumn;
			
			if (startLine < 1 || startLine > document.LineCount)
				return;
			if (endLine < 1 || endLine > document.LineCount) {
				endLine = startLine;
				endColumn = int.MaxValue;
			}
			if (startColumn < 1)
				startColumn = 1;
			
			instance = new CurrentLineBookmark();
			instance.Location = new TextLocation(startLine, startColumn);
			instance.FileName = fileName;
			SD.BookmarkManager.AddMark(instance);
		}
 void AddTypeScriptFileToContext(IProject project, FileName fileName)
 {
     if (TypeScriptParser.IsTypeScriptFileName(fileName)) {
         var typeScriptProject = new TypeScriptProject(project);
         TypeScriptService.ContextProvider.AddFileToProjectContext(typeScriptProject, fileName);
     }
 }
		void RemoveTypeScriptFileFromContext(FileName fileName)
		{
			if (TypeScriptParser.IsTypeScriptFileName(fileName)) {
				TypeScriptContext context = TypeScriptService.ContextProvider.GetContext(fileName);
				context.RemoveFile(fileName);
			}
		}
		public void SomethingWentWrongReturnsTrueWhenErrorTaskAddedToTaskService()
		{
			FileName fileName = new FileName("test.cs");
			Task task = new Task(fileName, String.Empty, 1, 2, TaskType.Error);
			taskService.Add(task);
			Assert.IsTrue(taskService.SomethingWentWrong);
		}
 public DefaultAssemblySearcher(FileName mainAssemblyFileName)
 {
     if (mainAssemblyFileName == null)
         throw new ArgumentNullException("mainAssemblyFileName");
     this.mainAssemblyFileName = mainAssemblyFileName;
     this.baseDirectory = mainAssemblyFileName.GetParentDirectory();
 }
		public ChooseSaveErrorResult ChooseSaveError(FileName fileName, string message, string dialogName, Exception exceptionGot, bool chooseLocationEnabled)
		{
			writer.WriteLine(dialogName + ": " + message + " (" + fileName + ")");
			if (exceptionGot != null)
				writer.WriteLine(exceptionGot.ToString());
			return ChooseSaveErrorResult.Ignore;
		}
示例#13
0
		public ParseInformation Parse(FileName fileName, ITextSource fileContent, bool fullParseInformationRequested,
		                              IProject parentProject, CancellationToken cancellationToken)
		{
			var csharpProject = parentProject as CSharpProject;
			
			CSharpParser parser = new CSharpParser(csharpProject != null ? csharpProject.CompilerSettings : null);
			parser.GenerateTypeSystemMode = !fullParseInformationRequested;
			
			SyntaxTree cu = parser.Parse(fileContent, fileName);
			cu.Freeze();
			
			CSharpUnresolvedFile file = cu.ToTypeSystem();
			ParseInformation parseInfo;
			
			if (fullParseInformationRequested)
				parseInfo = new CSharpFullParseInformation(file, fileContent.Version, cu);
			else
				parseInfo = new ParseInformation(file, fileContent.Version, fullParseInformationRequested);
			
			IDocument document = fileContent as IDocument;
			AddCommentTags(cu, parseInfo.TagComments, fileContent, parseInfo.FileName, ref document);
			if (fullParseInformationRequested) {
				if (document == null)
					document = new ReadOnlyDocument(fileContent, parseInfo.FileName);
				((CSharpFullParseInformation)parseInfo).newFoldings = CreateNewFoldings(cu, document);
			}
			
			return parseInfo;
		}
        protected bool CopyMeteoFiles(MohidRunEngineData mre)
        {
            FileName dest = new FileName();

             orig.FullPath = @"..\general.data\boundary.conditions\" + mre.sim.Start.ToString("yyyyMMdd.HHmmss") + "-" + mre.sim.End.ToString("yyyyMMdd.HHmmss") + @"\meteo.hdf5";
             dest.FullPath = mre.sim.SimDirectory.Path + @"local.data\boundary.conditions\meteo.hdf5";
             if (!Directory.Exists(orig.Path))
            Directory.CreateDirectory(orig.Path);

             if (File.Exists(orig.FullPath))
             {
            FileTools.CopyFile(orig, dest, CopyOptions.OVERWRIGHT);
             }
             else
             {
            if (!GenerateMeteoFiles(mre))
            {
               Console.WriteLine("Was not possible to create the meteo files.");
               return false;
            }
            FileTools.CopyFile(orig, dest, CopyOptions.OVERWRIGHT);
             }

             return true;
        }
示例#15
0
		public SolutionLoader(FileName fileName)
		{
			this.fileName = fileName;
			// read solution files using system encoding, but detect UTF8 if BOM is present
			this.textReader = new StreamReader(fileName, Encoding.Default, true);
			NextLine();
		}
		public void Run(ListViewPadItemModel item)
		{
			var bookmarkBase = (BookmarkPadBase)Owner;	
			
			if (item == null) return;
			
			// get current mark
			var mark = item.Mark as SDBookmark;
			int line = mark.LineNumber;
			var fileName = new FileName(mark.FileName);
			
			SDBookmark bookmark;
			if (item.Mark is BreakpointBookmark) {
				var bookmarks = DebuggerService.Breakpoints;
				bookmark = bookmarks.FirstOrDefault(b => b.LineNumber == line && b.FileName == fileName);
				if (bookmark == null && bookmarks.Count > 0) {
					bookmark = bookmarks[0]; // jump around to first bookmark
				}
			}
			else {
				var bookmarks = BookmarkManager.Bookmarks;
				bookmark = bookmarks.FirstOrDefault(b => b.LineNumber == line && b.FileName == fileName);
				if (bookmark == null && bookmarks.Count > 0) {
					bookmark = bookmarks[0]; // jump around to first bookmark
				}
			}			
			
			if (bookmark != null) {
				FileService.JumpToFilePosition(bookmark.FileName, bookmark.LineNumber, bookmark.ColumnNumber);
			}	

			// select in tree
			bookmarkBase.SelectItem(item);
		}
示例#17
0
        protected bool CopyMeteoFiles(MohidRunEngineData mre)
        {
            FileName orig = new FileName();
             FileName dest = new FileName();

             orig.FullPath = @"..\general.data\boundary.conditions\" + mre.sim.Start.ToString("yyyyMMdd.HHmmss") + "-" + mre.sim.End.ToString("yyyyMMdd.HHmmss") + @"\meteo.hdf5";
             dest.FullPath = mre.sim.SimDirectory.Path + @"local.data\boundary.conditions\meteo.hdf5";
             if (Directory.Exists(orig.Path))
             {
            if (File.Exists(orig.FullPath))
            {
               FileTools.CopyFile(orig, dest, CopyOptions.OVERWRIGHT);
            }
            else
            {
               //Console.WriteLine("File {0} does not exists.", orig.FullName);
               if (!GenerateMeteoFiles(mre))
                  return false;
               FileTools.CopyFile(orig, dest, CopyOptions.OVERWRIGHT);
            }
             }
             else
             {
            Console.WriteLine("Folder {0} does not exists.", orig.Path);
            return false;
             }

             return true;
        }
示例#18
0
        internal FileSignInfo(FileName name, SignInfo fileSignData)
        {
            Debug.Assert(name.IsAssembly || fileSignData.StrongName == null);

            FileName = name;
            FileSignData = fileSignData;
        }
示例#19
0
		public static void SetPosition(FileName fileName, IDocument document, int markerStartLine, int markerStartColumn, int markerEndLine, int markerEndColumn)
		{
			if (document == null)
				return;
			Remove();
			
			startLine   = markerStartLine;
			startColumn = markerStartColumn;
			endLine     = markerEndLine;
			endColumn   = markerEndColumn;
			
			if (startLine < 1 || startLine > document.TotalNumberOfLines)
				return;
			if (endLine < 1 || endLine > document.TotalNumberOfLines) {
				endLine = startLine;
				endColumn = int.MaxValue;
			}
			if (startColumn < 1)
				startColumn = 1;
			
			IDocumentLine line = document.GetLine(startLine);
			if (endColumn < 1 || endColumn > line.Length)
				endColumn = line.Length;
			instance = new CurrentLineBookmark(fileName, new Location(startColumn, startLine));
			BookmarkManager.AddMark(instance);
		}
		public void IsMatchReturnsFalseWhenFileNamesAreDifferent()
		{
			FileName fileName = new FileName(@"temp.cs");
			lhs = new SDTask(fileName, rhs.Description, rhs.Column, rhs.Line, rhs.TaskType);
			CreateTaskComparison();
			Assert.IsFalse(taskComparison.IsMatch);
		}
示例#21
0
 public TemplateBase LoadTemplate(FileName fileName)
 {
     var fileSystem = SD.FileSystem;
     using (Stream stream = fileSystem.OpenRead(fileName)) {
         return LoadTemplate(stream, new ReadOnlyChrootFileSystem(fileSystem, fileName.GetParentDirectory()));
     }
 }
		public bool IsPreferredBindingForFile(FileName fileName)
		{
			string extension = Path.GetExtension(fileName);
			var fileFilter = ProjectService.GetFileFilters().FirstOrDefault(ff => ff.ContainsExtension(extension));
			
			return fileFilter != null && fileFilter.MimeType.StartsWith("text/", StringComparison.OrdinalIgnoreCase);
		}
示例#23
0
 internal DirectoryEntry(FatFileSystemOptions options, FileName name, FatAttributes attrs, FatType fatVariant)
 {
     _options = options;
     _fatVariant = fatVariant;
     _name = name;
     _attr = (byte)attrs;
 }
示例#24
0
            public Assembly Compile(FileName scriptFileName, ScriptLanguage language = ScriptLanguage.BYEXTENSION)
            {
                if (language == ScriptLanguage.BYEXTENSION)
                {
                   switch (scriptFileName.Extension)
                   {
                  case "cs":
                     language = ScriptLanguage.CSHARP;
                     break;
                  case "vb":
                     language = ScriptLanguage.VB;
                     break;
                  default:
                     throw new Exception("Unknown script extension: '" + scriptFileName.Extension + "'");
                   }
                }

                switch (language)
                {
                   case ScriptLanguage.VB:
                  throw new Exception("VB scripts are not yet implemented.");
                   case ScriptLanguage.CSHARP:
                  return CompileCSharpScript(LoadCSharpScript(scriptFileName));
                   default:
                  return null;
                }
            }
示例#25
0
		public PropertyService(DirectoryName configDirectory, DirectoryName dataDirectory, string propertiesName)
			: base(LoadPropertiesFromStream(configDirectory.CombineFile(propertiesName + ".xml")))
		{
			this.dataDirectory = dataDirectory;
			this.configDirectory = configDirectory;
			propertiesFileName = configDirectory.CombineFile(propertiesName + ".xml");
		}
		internal FileServiceOpenedFile(FileService fileService, FileName fileName)
		{
			this.fileService = fileService;
			this.FileName = fileName;
			IsUntitled = false;
			fileChangeWatcher = new FileChangeWatcher(this);
		}
示例#27
0
		public static SDTask Create(TestResult result, ITestProject project)
		{
			TaskType taskType = TaskType.Warning;
			FileLineReference lineRef = null;
			string message = String.Empty;
			
			if (result.IsFailure) {
				taskType = TaskType.Error;
				if (!result.StackTraceFilePosition.IsEmpty) {
					lineRef = new FileLineReference(result.StackTraceFilePosition.FileName, result.StackTraceFilePosition.BeginLine - 1, result.StackTraceFilePosition.BeginColumn - 1);
				}
				message = GetTestFailedMessage(result);
			} else if (result.IsIgnored) {
				message = GetTestIgnoredMessage(result);
			}
			if (lineRef == null) {
				lineRef = FindTest(result.Name, project);
			}
			FileName fileName = null;
			if (lineRef != null) {
				fileName = new FileName(Path.GetFullPath(lineRef.FileName));
				int line = lineRef.Line + 1;
				return new SDTask(fileName, message, lineRef.Column, line, taskType);
			}
			return new SDTask(fileName, message, 0, 0, taskType);
		}
 public void LoadFile(string fileName)
 {
     TextEditor.SyntaxHighlighting =
         HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(fileName));
     TextEditor.Load(fileName);
     this.fileName = new FileName(fileName);
 }
示例#29
0
		public PropertyService()
			: base(LoadPropertiesFromStream(GetConfigDirectory().CombineFile(PropertiesName + ".xml")))
		{
			this.configDirectory = GetConfigDirectory();
			this.dataDirectory = new DirectoryName(Environment.CurrentDirectory);
			propertiesFileName = configDirectory.CombineFile(PropertiesName + ".xml");
		}
		public IDocument GetDocument(FileName fileName)
		{
			foreach (var pair in viewContent.SourceFiles) {
				if (pair.Key.FileName == fileName)
					return pair.Value;
			}
			throw new InvalidOperationException("Designer file not found");
		}
示例#31
0
 internal void AddDefaultLibScript(FileName fileName, string text)
 {
     defaultLibScriptFileName = fileName;
     AddFile(fileName, text);
 }
        public HttpResponseMessage GetUploadedDocInfo(string clientId, string doctorId)
        {
            var    desiesTypeResultList = new List <DesiesTypeResult>();
            var    disease = _diseaseDetailRepo.GetAll().OrderBy(x => x.DiseaseType).ToList();
            string host    = constant.imgUrl;// ConfigurationManager.AppSettings.Get("ImageBaseUrl");//HttpContext.Current.Request.Url.Host;

            var quickUp       = _quickUploadRepo.GetAll().ToList();
            var quickUpAssign = _QuickUploadAssignRepo.GetAll().ToList();

            var appointDetail = (from a in quickUp
                                 join t in quickUpAssign on a.Id equals t.QuickUploadId
                                 where t.AssignId == doctorId && t.AssignBy == clientId && t.IsActive == true
                                 select a).ToList();
            var result = appointDetail;


            var list = result.ToList();
            var data = list.GroupBy(item => item.DesiesType)
                       .Select(group => new { diseaseType = group.Key, Items = group.ToList() })
                       .ToList();

            foreach (var x in data)
            {
                var desiesTypeResult = new DesiesTypeResult();
                var listYear         = x.Items.Select(xx => xx).ToList().GroupBy(p => p.AddedYear).
                                       Select(group => new { AddedYear = group.Key, Items = group.ToList() })
                                       .ToList();
                desiesTypeResult.Years = new List <int?>();
                if (x.diseaseType != 0)
                {
                    desiesTypeResult.DiseaseType = x.diseaseType;
                    desiesTypeResult.DesiesName  = disease.Where(c => c.Id == x.diseaseType).FirstOrDefault().DiseaseType;
                }
                desiesTypeResult.YearList = new List <YearList>();
                foreach (var it in listYear)
                {
                    desiesTypeResult.Years.Add(it.AddedYear);
                    var yearList = new YearList();
                    yearList.Year = it.AddedYear;

                    var listMonth = it.Items.Select(xxp => xxp).ToList().GroupBy(ppp => ppp.AddedMonth).
                                    Select(group => new { AddedMonth = group.Key, Items = group.ToList() })
                                    .ToList();
                    yearList.Month     = new List <int?>();
                    yearList.MonthList = new List <MonthList>();
                    foreach (var mo in listMonth)
                    {
                        yearList.Month.Add(mo.AddedMonth);
                        var monthList = new MonthList();
                        monthList.Month = mo.AddedMonth;

                        yearList.MonthList.Add(monthList);
                        //MonthList
                        // To get Files details
                        monthList.FileList = new List <FileName>();
                        foreach (var file in mo.Items)
                        {
                            var fileName = new FileName();
                            fileName.DocName    = file.FilePath;
                            fileName.HospitalId = file.HospitalId;
                            fileName.Id         = file.Id;
                            //baseURL/ClientDocument/ClientId/DesiseType/Year/Month/Files.jpg
                            fileName.DocUrl = host + "ClientDocument/" + clientId + "/" + desiesTypeResult.DiseaseType + "/" + it.AddedYear
                                              + "/" + mo.AddedMonth + "/" + file.FilePath;
                            monthList.FileList.Add(fileName);
                        }
                    }

                    desiesTypeResult.YearList.Add(yearList);
                }

                desiesTypeResultList.Add(desiesTypeResult);
            }

            return(Request.CreateResponse(HttpStatusCode.Accepted, desiesTypeResultList));
        }
示例#33
0
        private string BuildSqlCommand()
        {
            StringBuilder sql = new StringBuilder("LOAD DATA ");

            if (Priority == MySqlBulkLoaderPriority.Low)
            {
                sql.Append("LOW_PRIORITY ");
            }
            else if (Priority == MySqlBulkLoaderPriority.Concurrent)
            {
                sql.Append("CONCURRENT ");
            }

            if (Local)
            {
                sql.Append("LOCAL ");
            }
            sql.Append("INFILE ");
            if (Path.DirectorySeparatorChar == '\\')
            {
                sql.AppendFormat("'{0}' ", FileName.Replace(@"\", @"\\"));
            }
            else
            {
                sql.AppendFormat("'{0}' ", FileName);
            }

            if (ConflictOption == MySqlBulkLoaderConflictOption.Ignore)
            {
                sql.Append("IGNORE ");
            }
            else if (ConflictOption == MySqlBulkLoaderConflictOption.Replace)
            {
                sql.Append("REPLACE ");
            }

            sql.AppendFormat("INTO TABLE {0} ", TableName);

            if (CharacterSet != null)
            {
                sql.AppendFormat("CHARACTER SET {0} ", CharacterSet);
            }

            StringBuilder optionSql = new StringBuilder(String.Empty);

            if (FieldTerminator != defaultFieldTerminator)
            {
                optionSql.AppendFormat("TERMINATED BY '{0}' ", FieldTerminator);
            }
            if (FieldQuotationCharacter != Char.MinValue)
            {
                optionSql.AppendFormat("{0} ENCLOSED BY '{1}' ",
                                       FieldQuotationOptional ? "OPTIONALLY" : "", FieldQuotationCharacter);
            }
            if (EscapeCharacter != defaultEscapeCharacter &&
                EscapeCharacter != Char.MinValue)
            {
                optionSql.AppendFormat("ESCAPED BY '{0}' ", EscapeCharacter);
            }
            if (optionSql.Length > 0)
            {
                sql.AppendFormat("FIELDS {0}", optionSql.ToString());
            }

            optionSql = new StringBuilder(String.Empty);
            if (LinePrefix != null && LinePrefix.Length > 0)
            {
                optionSql.AppendFormat("STARTING BY '{0}' ", LinePrefix);
            }
            if (LineTerminator != defaultLineTerminator)
            {
                optionSql.AppendFormat("TERMINATED BY '{0}' ", LineTerminator);
            }
            if (optionSql.Length > 0)
            {
                sql.AppendFormat("LINES {0}", optionSql.ToString());
            }

            if (NumberOfLinesToSkip > 0)
            {
                sql.AppendFormat("IGNORE {0} LINES ", NumberOfLinesToSkip);
            }

            if (Columns.Count > 0)
            {
                sql.Append("(");
                sql.Append(Columns[0]);
                for (int i = 1; i < Columns.Count; i++)
                {
                    sql.AppendFormat(",{0}", Columns[i]);
                }
                sql.Append(") ");
            }

            if (Expressions.Count > 0)
            {
                sql.Append("SET ");
                sql.Append(Expressions[0]);
                for (int i = 1; i < Expressions.Count; i++)
                {
                    sql.AppendFormat(",{0}", Expressions[i]);
                }
            }

            return(sql.ToString());
        }
示例#34
0
 /// <inheritdoc cref="object.ToString" />
 public override string ToString()
 {
     return(FileName.ToVisibleString());
 }
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     return(FileName.GetHashCode());
 }
 public bool IsPreferredBindingForFile(FileName fileName)
 {
     return(CanCreateContentForFile(fileName));
 }
示例#37
0
 public override int GetHashCode()
 {
     return(FileName != null ? GetType().Name.GetHashCode() ^ FileName.GetHashCode() ^ FileETag.GetHashCode() : 0);
 }
 bool StandaloneTypeScriptFileOpened(FileName fileName)
 {
     return(TypeScriptParser.IsTypeScriptFileName(fileName) &&
            !TypeScriptFileInAnyProject(fileName));
 }
示例#39
0
 public override int GetHashCode()
 {
     return(FileName?.GetHashCode() ?? 0);
 }
示例#40
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Storage.Attachment" /> class.
            /// </summary>
            /// <param name="message"> The message. </param>
            /// <param name="storageName">The name of the <see cref="Storage.NativeMethods.IStorage"/> stream that containts this attachment</param>
            internal Attachment(Storage message, string storageName) : base(message._storage)
            {
                StorageName = storageName;

                GC.SuppressFinalize(message);
                _propHeaderSize = MapiTags.PropertiesStreamHeaderAttachOrRecip;

                CreationTime         = GetMapiPropertyDateTime(MapiTags.PR_CREATION_TIME);
                LastModificationTime = GetMapiPropertyDateTime(MapiTags.PR_LAST_MODIFICATION_TIME);

                ContentId = GetMapiPropertyString(MapiTags.PR_ATTACH_CONTENTID);
                IsInline  = ContentId != null;

                var isContactPhoto = GetMapiPropertyBool(MapiTags.PR_ATTACHMENT_CONTACTPHOTO);

                if (isContactPhoto == null)
                {
                    IsContactPhoto = false;
                }
                else
                {
                    IsContactPhoto = (bool)isContactPhoto;
                }

                var renderingPosition = GetMapiPropertyInt32(MapiTags.PR_RENDERING_POSITION);

                if (renderingPosition == null)
                {
                    RenderingPosition = -1;
                }
                else
                {
                    RenderingPosition = (int)renderingPosition;
                }

                var fileName = GetMapiPropertyString(MapiTags.PR_ATTACH_LONG_FILENAME);

                if (string.IsNullOrEmpty(fileName))
                {
                    fileName = GetMapiPropertyString(MapiTags.PR_ATTACH_FILENAME);
                }

                if (string.IsNullOrEmpty(fileName))
                {
                    fileName = GetMapiPropertyString(MapiTags.PR_DISPLAY_NAME);
                }

                FileName = fileName != null
                    ? FileManager.RemoveInvalidFileNameChars(fileName)
                    : LanguageConsts.NameLessFileName;

                var attachmentMethod = GetMapiPropertyInt32(MapiTags.PR_ATTACH_METHOD);

                switch (attachmentMethod)
                {
                case MapiTags.ATTACH_BY_REFERENCE:
                case MapiTags.ATTACH_BY_REF_RESOLVE:
                case MapiTags.ATTACH_BY_REF_ONLY:
                    ResolveAttachment();
                    break;

                case MapiTags.ATTACH_OLE:
                    var storage       = GetMapiProperty(MapiTags.PR_ATTACH_DATA_BIN) as NativeMethods.IStorage;
                    var attachmentOle = new Attachment(new Storage(storage), null);
                    _data = attachmentOle.GetStreamBytes("CONTENTS");
                    if (_data != null)
                    {
                        var fileTypeInfo = FileTypeSelector.GetFileTypeFileInfo(Data);

                        if (string.IsNullOrEmpty(FileName))
                        {
                            FileName = fileTypeInfo.Description;
                        }

                        string extension;
                        if (fileTypeInfo != null)
                        {
                            extension = fileTypeInfo.Extension.ToLower();
                        }
                        else
                        {
                            extension = ".dat";     //generic file type for those that can't be determined
                        }
                        FileName += extension;
                    }
                    else
                    {
                        // http://www.devsuperpage.com/search/Articles.aspx?G=10&ArtID=142729
                        _data = attachmentOle.GetStreamBytes("\u0002OlePres000");
                    }

                    if (_data != null && !FileName.EndsWith(".dat"))
                    {
                        try
                        {
                            SaveImageAsPng(40);
                        }
                        catch (ArgumentException)
                        {
                            SaveImageAsPng(0);
                        }
                    }

                    OleAttachment = true;
                    IsInline      = true;
                    break;
                }
            }
 bool TypeScriptFileInAnyProject(FileName fileName)
 {
     return(TypeScriptService.ContextProvider.IsFileInsideProject(fileName));
 }
    public Python(ReadOnlyTargetRules Target) : base(Target)
    {
        Type = ModuleType.External;

        var EngineDir = Path.GetFullPath(Target.RelativeEnginePath);

        PythonSDKPaths PythonSDK = null;

        if (Target.Platform == UnrealTargetPlatform.Win32 || Target.Platform == UnrealTargetPlatform.Win64 || Target.Platform == UnrealTargetPlatform.Mac || Target.Platform == UnrealTargetPlatform.Linux)
        {
            // Check for an explicit version before using the auto-detection logic
            var PythonRoot = System.Environment.GetEnvironmentVariable("UE_PYTHON_DIR");
            if (PythonRoot != null)
            {
                PythonSDK = DiscoverPythonSDK(PythonRoot);
            }
        }

        // Perform auto-detection to try and find the Python SDK
        if (PythonSDK == null)
        {
            var PythonBinaryTPSDir = Path.Combine(EngineDir, "Binaries", "ThirdParty", "Python");
            var PythonSourceTPSDir = Path.Combine(EngineDir, "Source", "ThirdParty", "Python");

            var PotentialSDKs = new List <PythonSDKPaths>();

            // todo: This isn't correct for cross-compilation, we need to consider the host platform too
            if (Target.Platform == UnrealTargetPlatform.Win32 || Target.Platform == UnrealTargetPlatform.Win64)
            {
                var PlatformDir = Target.Platform == UnrealTargetPlatform.Win32 ? "Win32" : "Win64";

                PotentialSDKs.AddRange(
                    new PythonSDKPaths[] {
                    new PythonSDKPaths(Path.Combine(PythonBinaryTPSDir, PlatformDir), new List <string>()
                    {
                        Path.Combine(PythonSourceTPSDir, PlatformDir, "include")
                    }, Path.Combine(PythonSourceTPSDir, PlatformDir, "libs"), "python27.lib"),
                    //DiscoverPythonSDK("C:/Program Files/Python36"),
                    DiscoverPythonSDK("C:/Python27"),
                }
                    );
            }
            else if (Target.Platform == UnrealTargetPlatform.Mac)
            {
                PotentialSDKs.AddRange(
                    new PythonSDKPaths[] {
                    new PythonSDKPaths(Path.Combine(PythonBinaryTPSDir, "Mac"), new List <string>()
                    {
                        Path.Combine(PythonSourceTPSDir, "Mac", "include")
                    }, Path.Combine(PythonBinaryTPSDir, "Mac"), "libpython2.7.dylib")
                }
                    );
            }
            else if (Target.IsInPlatformGroup(UnrealPlatformGroup.Unix))
            {
                if (Target.Architecture.StartsWith("x86_64"))
                {
                    var PlatformDir = Target.Platform.ToString();

                    PotentialSDKs.AddRange(
                        new PythonSDKPaths[] {
                        new PythonSDKPaths(
                            Path.Combine(PythonBinaryTPSDir, PlatformDir),
                            new List <string>()
                        {
                            Path.Combine(PythonSourceTPSDir, PlatformDir, "include", "python2.7"),
                            Path.Combine(PythonSourceTPSDir, PlatformDir, "include", Target.Architecture)
                        },
                            Path.Combine(PythonSourceTPSDir, PlatformDir, "lib"), "libpython2.7.a"),
                    });
                    PublicAdditionalLibraries.Add("util");                      // part of libc
                }
            }

            foreach (var PotentialSDK in PotentialSDKs)
            {
                if (PotentialSDK.IsValid())
                {
                    PythonSDK = PotentialSDK;
                    break;
                }
            }
        }

        // Make sure the Python SDK is the correct architecture
        if (PythonSDK != null)
        {
            string ExpectedPointerSizeResult = Target.Platform == UnrealTargetPlatform.Win32 ? "4" : "8";

            // Invoke Python to query the pointer size of the interpreter so we can work out whether it's 32-bit or 64-bit
            // todo: We probably need to do this for all platforms, but right now it's only an issue on Windows
            if (Target.Platform == UnrealTargetPlatform.Win32 || Target.Platform == UnrealTargetPlatform.Win64)
            {
                string Result = InvokePython(PythonSDK.PythonRoot, "-c \"import struct; print(struct.calcsize('P'))\"");
                Result = Result != null?Result.Replace("\r", "").Replace("\n", "") : null;

                if (Result == null || Result != ExpectedPointerSizeResult)
                {
                    PythonSDK = null;
                }
            }
        }

        if (PythonSDK == null)
        {
            PublicDefinitions.Add("WITH_PYTHON=0");
            Console.WriteLine("Python SDK not found");
        }
        else
        {
            // If the Python install we're using is within the Engine directory, make the path relative so that it's portable
            string EngineRelativePythonRoot = PythonSDK.PythonRoot;
            if (EngineRelativePythonRoot.StartsWith(EngineDir))
            {
                // Strip the Engine directory and then combine the path with the placeholder to ensure the path is delimited correctly
                EngineRelativePythonRoot = EngineRelativePythonRoot.Remove(0, EngineDir.Length);
                foreach (string FileName in Directory.EnumerateFiles(PythonSDK.PythonRoot, "*", SearchOption.AllDirectories))
                {
                    if (!FileName.EndsWith(".pyc", System.StringComparison.OrdinalIgnoreCase))
                    {
                        RuntimeDependencies.Add(FileName);
                    }
                }
                EngineRelativePythonRoot = Path.Combine("{ENGINE_DIR}", EngineRelativePythonRoot);                 // Can't use $(EngineDir) as the placeholder here as UBT is eating it
            }

            PublicDefinitions.Add("WITH_PYTHON=1");
            PublicDefinitions.Add(string.Format("UE_PYTHON_DIR=\"{0}\"", EngineRelativePythonRoot.Replace('\\', '/')));

            // Some versions of Python need this define set when building on MSVC
            if (Target.Platform == UnrealTargetPlatform.Win32 || Target.Platform == UnrealTargetPlatform.Win64)
            {
                PublicDefinitions.Add("HAVE_ROUND=1");
            }

            PublicSystemIncludePaths.AddRange(PythonSDK.PythonIncludePath);
            if (Target.Platform == UnrealTargetPlatform.Mac)
            {
                // Mac doesn't understand PublicLibraryPaths
                PublicAdditionalLibraries.Add(Path.Combine(PythonSDK.PythonLibPath, PythonSDK.PythonLibName));
            }
            else if (Target.Platform == UnrealTargetPlatform.Linux)
            {
                PublicAdditionalLibraries.Add(Path.Combine(PythonSDK.PythonLibPath, PythonSDK.PythonLibName));
                RuntimeDependencies.Add("$(EngineDir)/Binaries/ThirdParty/Python/Linux/lib/libpython2.7.so.1.0");
            }
            else
            {
                PublicLibraryPaths.Add(PythonSDK.PythonLibPath);
                PublicAdditionalLibraries.Add(PythonSDK.PythonLibName);
            }
        }
    }
示例#43
0
 public AvalonEditSearchResultMatch(FileName fileName, Location startLocation, Location endLocation, int offset, int length, HighlightedInlineBuilder builder, ICSharpCode.AvalonEdit.Search.ISearchResult match)
     : base(fileName, startLocation, endLocation, offset, length, builder)
 {
     this.match = match;
 }
示例#44
0
        private void UpdateFileList()
        {
            fileList.BeginUpdate();
            fileList.Clear();
            fileList.EndUpdate();

            currentFiles.Clear();

            // return, we haven't populated anything yet
            if (roots.Count == 0 || RemoteFailed)
            {
                return;
            }

            DirectoryFileTreeNode node = GetNode(Directory);

            if (node == null)
            {
                return;
            }

            string match = ".*";

            if (FileName.IndexOf('*') != -1 || FileName.IndexOf('?') != -1)
            {
                match = Regex.Escape(FileName).Replace(@"\*", ".*").Replace(@"\?", ".");
            }

            fileList.BeginUpdate();

            foreach (var child in node.children)
            {
                if (child.IsHidden && !showHidden.Checked)
                {
                    continue;
                }

                var res = Regex.Match(child.Filename, match);

                // always display directories even if they don't match a glob
                if (!res.Success && !child.IsDirectory)
                {
                    continue;
                }

                int imgidx = ICON_FILE;
                if (child.IsDirectory)
                {
                    imgidx = ICON_DIRECTORY;
                }
                else if (child.IsExecutable)
                {
                    imgidx = ICON_EXECUTABLE;
                }

                // skip non-executables
                if (imgidx == ICON_FILE && fileType.SelectedIndex == 0)
                {
                    continue;
                }

                if (child.IsHidden)
                {
                    imgidx = ICON_FILE_FADED;
                    if (child.IsDirectory)
                    {
                        imgidx = ICON_DIRECTORY_FADED;
                    }
                    else if (child.IsExecutable)
                    {
                        imgidx = ICON_EXECUTABLE_FADED;
                    }
                }

                ListViewItem item = new ListViewItem(child.Filename, imgidx);
                item.Tag = child;

                fileList.Items.Add(item);

                currentFiles.Add(child);
            }

            fileList.EndUpdate();
        }
示例#45
0
 public bool IsMatch(string fileName, string sheetName)
 {
     return(FileName.IsMatch(fileName) && SheetName == sheetName);
 }
示例#46
0
        public MediaInfo Analyse(bool logIt = true)
        {
            if (Info == null)
            {
                return(this);
            }

            Title = Info.Name;

            if (IsRussianSoccerGame())
            {
                IsSoccer = true;
                return(this);
            }

            if (Title.ToUpper().Contains("SAMPLE"))
            {
                return(this);
            }

            if (Title.ToUpper().Contains("TEST"))
            {
                return(this);
            }

            if (FileName.ToUpper().Contains("INPROGRESS"))
            {
                return(this);
            }

            if (FileName.ToUpper().Contains("RARBG.COM"))
            {
                return(this);
            }

            IsNfl = DetermineNfl();

            Format = DetermineFormat();
            if (Format.Equals("ZIP"))
            {
                AnalyseZip();
            }

            if (!IsNfl)
            {
                IsBook = DetermineBook();
                if (IsBook)
                {
                    DetemineMagazine();
                }

                Title = DetermineTitle();

                if (Title.ToUpper().StartsWith("JUDGE JUDY"))
                {
                    Title   = "Judge Judy";
                    Season  = 21;
                    Episode = 1;
                    IsTV    = true;
                }
                else
                {
                    if (!IsBook && !IsMagazine && !IsSoccer)
                    {
                        Season = DetermineSeason();
                        if (Season > 0)
                        {
                            Episode = DeterminEpisode();
                        }
                        if (Season > 0)
                        {
                            IsTV = true;
                        }

                        IsMovie = DetermineMovie();

                        if (IsMovie)
                        {
                            FixTitle();
                        }
                    }
                }
            }
            if (IsTV)
            {
                TvTitle = Title;
            }

            OutputToConsole(logIt);
            return(this);
        }
 public double AutoDetectFileContent(FileName fileName, System.IO.Stream fileContent, string detectedMimeType)
 {
     return(1);
 }
示例#48
0
        private string ToFile()
        {
            string _stage = "";
            string _filePath, _fullFilePath = "";

            // Check file name null
            try
            {
                _stage    = "Preparing temp path";
                _filePath = Path.GetTempPath();

                if (!FileName.ToUpper().EndsWith($".{FileType}"))
                {
                    FileName += $".{FileType.ToString().ToLower()}";
                }

                _fullFilePath = $"{_filePath}{FileName}";
                if (File.Exists(_fullFilePath))
                {
                    //
                    _stage = $"Deleting {_fullFilePath}";
                    File.Delete(_fullFilePath);
                }
                //
                _stage = $"Saving to {FileType} file";
                switch (FileType)
                {
                case cMiscFunctions.eFileType.XLS:
                case cMiscFunctions.eFileType.TXT:
                    using (FileStream _fs = File.Create(_fullFilePath))
                    {
                        byte[] _info = new UTF8Encoding(true).GetBytes(Contents);
                        // Add some information to the file.
                        _fs.Write(_info, 0, _info.Length);
                    }
                    break;

                case cMiscFunctions.eFileType.PDF:
                    var config = new PdfGenerateConfig();
                    if (Orientation.ToString().ToUpper() == "LANDSCAPE")
                    {
                        config.PageOrientation = PdfSharpCore.PageOrientation.Landscape;
                    }
                    else
                    {
                        config.PageOrientation = PdfSharpCore.PageOrientation.Portrait;
                    }
                    config.PageSize = PdfSharpCore.PageSize.A4;
                    PdfDocument pdfDocument = PdfGenerator.GeneratePdf(Contents, config);
                    pdfDocument.Save(_fullFilePath);
                    break;

                default:
                    throw new Exception("Non supported format");
                }
                return(_fullFilePath);
            }
            catch (Exception ex)
            {
                throw new Exception($"[cProcess/ToFile#{_stage}] {ex.Message}.");
            }
        }
示例#49
0
 public override bool ContainsText(string text) => (Name.ToLowerInvariant().Contains(text) || FileName.ToLowerInvariant().Contains(text));
示例#50
0
 public override string ToString()
 {
     return(FileName.ToString() + ", " + TimeStamp.ToString() + ", " + FileID.ToString());
 }
示例#51
0
 string GetLegacyPreferencesFileName()
 {
     return(FileName.ChangeExtension(".userprefs"));
 }
示例#52
0
        private void Close_Click(object sender, RoutedEventArgs e)
        {
            // MessageBox.Show(sender.ToString() + "    "+e.ToString());
            if (this.EditPnl.SaveState && this.imageOn.Source != null /* && this.EditPnl.Angle != 0*/)
            {
                BitmapEncoder encoder;
                string        tmp         = FileName;
                string        imageFormat = tmp.Substring(tmp.LastIndexOf('.') + 1);
                MessageBox.Show(imageFormat);
                for (int i = 1; ; i++)
                {
                    if (!File.Exists(FileName))
                    {
                        break;
                    }
                    try
                    {
                        FileName = FileName.Remove(this.FileName.LastIndexOf('('));
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        FileName = FileName.Remove(this.FileName.LastIndexOf('.'));
                    }
                    FileName += '(' + i.ToString() + ")." + imageFormat;
                }
                switch (imageFormat)
                {
                case "jpeg":
                    encoder = new JpegBitmapEncoder();
                    break;

                case "png":
                    encoder = new PngBitmapEncoder();
                    break;

                case "bmp":
                    encoder = new BmpBitmapEncoder();
                    break;

                case "tiff":
                    encoder = new TiffBitmapEncoder();
                    break;

                case "wmp":
                    encoder = new WmpBitmapEncoder();
                    break;

                case "gif":
                    encoder = new GifBitmapEncoder();
                    break;

                default:
                    encoder = new PngBitmapEncoder();
                    break;
                }
                CachedBitmap      cache = new CachedBitmap((BitmapSource)this.imageOn.Source, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                TransformedBitmap tb    = new TransformedBitmap(cache, new RotateTransform(EditPnl.Angle));
                encoder.Frames.Add(BitmapFrame.Create(tb));
                using (FileStream file = File.Create(this.FileName))
                {
                    encoder.Save(file);
                }
            }
            this.Close();
        }
        public bool FileExistsInProject(string path)
        {
            string fullPath = GetFullPath(path);

            return(project.IsFileInProject(FileName.Create(fullPath)));
        }
 public bool CanCreateContentForFile(FileName fileName)
 {
     return(string.Equals(Path.GetExtension(fileName), FileExtension, StringComparison.OrdinalIgnoreCase));
 }
示例#55
0
 public OpeningFromForm EnterFileName(string fileName)
 {
     FileName.Enter(fileName);
     return(this);
 }
 public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
 {
     return(double.NegativeInfinity);
 }
示例#57
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(FileName))
     {
         bool isImageFile = FileName.Contains("jpg") || FileName.Contains("jpeg") || FileName.Contains("png");
         if (isImageFile)
         {
             if (FileName.Contains(Configuration.ImagesVisualizationPath))
             {
                 uploadLink.HRef = FileName;
             }
             else
             {
                 uploadLink.HRef = Configuration.ImagesVisualizationPath + FileName;
             }
         }
         else
         {
             if (FileName.Contains(Configuration.DocsPath))
             {
                 uploadLink.HRef = FileName;
             }
             else
             {
                 uploadLink.HRef = Configuration.DocsPath + FileName;
             }
         }
         if (FileName.Contains(Configuration.UploadSeparator))
         {
             string file = FileName.Substring(FileName.LastIndexOf(Configuration.UploadSeparator) + 2);
             uploadLink.InnerHtml = file;
         }
         else
         {
             uploadLink.InnerHtml = FileName;
         }
     }
 }
 public bool IsPreferredBindingForFile(FileName fileName)
 {
     return(false);
 }
示例#59
0
 internal void RemoveFile(FileName fileName)
 {
     scripts.Remove(fileName);
 }
示例#60
0
 internal void UpdateFileName(FileName fileName)
 {
     this.fileName = fileName;
 }