/// <summary> /// Read both algorithm and config properties. /// </summary> /// <param name="algReader">From where to read algorithm and config properties.</param> /// <exception cref="IOException">If there is a low-level I/O error.</exception> public Config(TextReader algReader) { // read alg file to array of lines IList <string> lines = new List <string>(); int lastConfigLine = 0; string line; while ((line = algReader.ReadLine()) != null) { lines.Add(line); if (line.IndexOf('=') > 0) { lastConfigLine = lines.Count; } } algReader.Dispose(); // copy props lines to string MemoryStream ms = new MemoryStream(); TextWriter writer = new StreamWriter(ms); for (int i = 0; i < lastConfigLine; i++) { writer.WriteLine(lines[i]); } // read props from string this.props = new Dictionary <string, string>(); writer.Flush(); ms.Position = 0; props.LoadProperties(ms); // make sure work dir is set properly string temp; if (!props.TryGetValue("work.dir", out temp) || temp == null) { // LUCENENET specific - reformatted with : props["work.dir"] = SystemProperties.GetProperty("benchmark:work:dir", "work"); } if (props.TryGetValue("print.props", out temp)) { if (temp.Equals("true", StringComparison.OrdinalIgnoreCase)) { PrintProps(); } } else if (DEFAULT_PRINT_PROPS) { PrintProps(); } // copy algorithm lines var sb = new StringBuilder(); for (int i = lastConfigLine; i < lines.Count; i++) { sb.Append(lines[i]); sb.Append(NEW_LINE); } algorithmText = sb.ToString(); }
static async Task ConvertFile(string filename) { try { await Task.CompletedTask; filename = System.IO.Path.GetFullPath(filename); var imagingFactory = new WIC.WICImagingFactory(); var decoder = imagingFactory.CreateDecoderFromFilename(filename, Guid.Empty, WIC.StreamAccessMode.GENERIC_READ, WIC.WICDecodeOptions.WICDecodeMetadataCacheOnLoad); //ShowMetadata(decoder.GetFrame(0)); if (decoder.GetDecoderInfo().GetCLSID() == WIC.Decoder.Jpeg) { Console.WriteLine($"'{filename}' is already a JPEG file."); return; } var output = imagingFactory.CreateStream(); output.InitializeFromFilename(System.IO.Path.ChangeExtension(filename, ".jpg"), WIC.StreamAccessMode.GENERIC_WRITE); var encoder = imagingFactory.CreateEncoder(ContainerFormat.Jpeg); encoder.Initialize(output, WICBitmapEncoderCacheOption.WICBitmapEncoderNoCache); for (int i = 0; i < decoder.GetFrameCount(); i++) { var frame = decoder.GetFrame(i); encoder.CreateNewFrame(out var frameJpg, null); frameJpg.Initialize(null); frameJpg.SetSize(frame.GetSize()); frameJpg.SetResolution(frame.GetResolution()); frameJpg.SetPixelFormat(frame.GetPixelFormat()); var reader = frame.AsMetadataBlockReader(); var count = reader.GetCount(); //Get the EXIF data from the original photo. var metadataReader = frame.GetMetadataQueryReader(); var metadataWriter = frameJpg.GetMetadataQueryWriter(); foreach (var name in metadataReader.GetNamesRecursive()) { try { var val = metadataReader.GetMetadataByName(name); if (name.StartsWith("/ifd/")) { metadataWriter.SetMetadataByName("/app1" + name.Replace("/ifd/{ushort=34665}/", "/ifd/exif/").Replace("/ifd/{ushort=34853}/", "/ifd/gps/"), val); } else if (name.StartsWith("/xmp/")) { metadataWriter.SetMetadataByName(name, val); } } catch { System.Diagnostics.Trace.WriteLine($"Error setting '{name}'"); } } var photoProperties = SystemProperties.Concat(SystemPhotoProperties.Concat(SystemGpsProperties)); foreach (var photoProp in photoProperties) { var action = "getting"; try { var val = metadataReader.GetMetadataByName(photoProp); //System.Diagnostics.Trace.WriteLine($"{photoProp} = {val}"); action = "setting"; metadataWriter.SetMetadataByName(photoProp, val); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine($"Error {action} '{photoProp}': " + ex.Message); } } frameJpg.WriteSource(frame); frameJpg.Commit(); frame = null; frameJpg = null; } encoder.Commit(); output.Commit(WIC.STGC.STGC_DEFAULT); encoder = null; output = null; } catch (Exception ex) { Console.WriteLine($"Error converting file '{filename}': {ex.Message}"); System.Diagnostics.Trace.WriteLine($"Error converting file '{filename}': {ex.ToString()}"); } }
public virtual void TestXMLConfiguration() { // TODO - not working with XML. Assert.AreEqual("0x00000010", ConfigurationSettings.CurrentConfiguration["tests:seed"]); Assert.AreEqual("0x00000010", SystemProperties.GetProperty("tests:seed")); }
/// <summary> /// (仅适用于<see cref="BuildVersionCodes.O"/>)判断设备为 Notch 机型 /// <para><see langword="true"/>:是刘海屏;<see langword="false"/>:非刘海屏。</para> /// </summary> /// <returns></returns> public static bool IsNotch() { SystemProperties.TryGet("ro.miui.notch", out var value); return(value == "1"); }
protected void AddSystemProperty(ImportProperty systemProperty) { SystemProperties.Add(systemProperty); }
void btnDelete_Click(object sender, EventArgs e) { Delete(); MsgReturned = ""; SystemProperties.Cleared(this, false, true, true); }
void btnCancel_Click(object sender, EventArgs e) { LoadInstructor(); SystemProperties.Cleared(this, false, true, true); MsgReturned = ""; }
void SetProperties() { ObjEnable(false); GetRoomType(); SystemProperties.Cleared(this, false, true, true); }
void btnCancel_Click(object sender, EventArgs e) { GetRoomType(); SystemProperties.Cleared(this, false, true, true); MsgReturned = ""; }
void SetProperties() { LoadSMS(); ObjEnable(false); SystemProperties.Cleared(this, false, true, true); }
/// <summary> /// Entry point to the Compile application. /// <para/> /// This program takes any number of arguments: the first is the name of the /// desired stemming algorithm to use (a list is available in the package /// description) , all of the rest should be the path or paths to a file or /// files containing a stemmer table to compile. /// </summary> /// <param name="args">the command line arguments</param> public static void Main(string[] args) { if (args.Length < 1) { return; } // LUCENENET NOTE: This line does nothing in .NET // and also does nothing in Java...what? //args[0].ToUpperInvariant(); // Reads the first char of the first arg backward = args[0][0] == '-'; int qq = (backward) ? 1 : 0; bool storeorig = false; if (args[0][qq] == '0') { storeorig = true; qq++; } multi = args[0][qq] == 'M'; if (multi) { qq++; } // LUCENENET specific - reformatted with : and changed "charset" to "encoding" string charset = SystemProperties.GetProperty("egothor:stemmer:encoding", "UTF-8"); var stemmerTables = new JCG.List <string>(); // LUCENENET specific // command line argument overrides environment variable or default, if supplied for (int i = 1; i < args.Length; i++) { if ("-e".Equals(args[i], StringComparison.Ordinal) || "--encoding".Equals(args[i], StringComparison.Ordinal)) { charset = args[i]; } else { stemmerTables.Add(args[i]); } } char[] optimizer = new char[args[0].Length - qq]; for (int i = 0; i < optimizer.Length; i++) { optimizer[i] = args[0][qq + i]; } foreach (var stemmerTable in stemmerTables) { // System.out.println("[" + args[i] + "]"); Diff diff = new Diff(); //int stems = 0; // not used int words = 0; AllocTrie(); Console.WriteLine(stemmerTable); using (TextReader input = new StreamReader( new FileStream(stemmerTable, FileMode.Open, FileAccess.Read), Encoding.GetEncoding(charset))) { string line; while ((line = input.ReadLine()) != null) { line = line.ToLowerInvariant(); using StringTokenizer st = new StringTokenizer(line); if (st.MoveNext()) { string stem = st.Current; if (storeorig) { trie.Add(stem, "-a"); words++; } while (st.MoveNext()) { string token = st.Current; if (token.Equals(stem, StringComparison.Ordinal) == false) { trie.Add(token, diff.Exec(token, stem)); words++; } } } else // LUCENENET: st.MoveNext() will return false rather than throwing a NoSuchElementException { // no base token (stem) on a line } } } Optimizer o = new Optimizer(); Optimizer2 o2 = new Optimizer2(); Lift l = new Lift(true); Lift e = new Lift(false); Gener g = new Gener(); for (int j = 0; j < optimizer.Length; j++) { string prefix; switch (optimizer[j]) { case 'G': trie = trie.Reduce(g); prefix = "G: "; break; case 'L': trie = trie.Reduce(l); prefix = "L: "; break; case 'E': trie = trie.Reduce(e); prefix = "E: "; break; case '2': trie = trie.Reduce(o2); prefix = "2: "; break; case '1': trie = trie.Reduce(o); prefix = "1: "; break; default: continue; } trie.PrintInfo(Console.Out, prefix + " "); } using DataOutputStream os = new DataOutputStream( new FileStream(stemmerTable + ".out", FileMode.OpenOrCreate, FileAccess.Write)); os.WriteUTF(args[0]); trie.Store(os); } }
void SetProperties() { ObjEnable(false); LoadSubject(); SystemProperties.Cleared(this, false, true, true); }
public override ACPropertyValidationResult ValidateProperties(IEnumerable <ACProperty> properties) { return(SystemProperties.ValidateProperties(properties)); }
// https://github.com/ejohnson-dotnet/heic2jpg/blob/master/Program.cs public static async Task Convert(string input, Format format) { try { var wInputFile = await StorageFile.GetFileFromPathAsync(input); using (var wInputStream = await wInputFile.OpenReadAsync()) { var wDecoder = await BitmapDecoder.CreateAsync(wInputStream); var wBitmap = await wDecoder.GetSoftwareBitmapAsync(); var wOutputName = Path.GetFileName(Path.ChangeExtension(input, $".{format}".ToLower())); var wParentFolder = await wInputFile.GetParentAsync(); var wOutputFile = await wParentFolder.CreateFileAsync(wOutputName, CreationCollisionOption.ReplaceExisting); using (var wOutputStream = await wOutputFile.OpenAsync(FileAccessMode.ReadWrite)) { var wEncoder = await BitmapEncoder.CreateAsync(Encoders[format], wOutputStream); wEncoder.SetSoftwareBitmap(wBitmap); wEncoder.IsThumbnailGenerated = true; try { await wEncoder.FlushAsync(); } catch (Exception e) { const int WINCODEC_ERR_UNSUPPORTEDOPERATION = unchecked ((int)0x88982F81); switch (e.HResult) { case WINCODEC_ERR_UNSUPPORTEDOPERATION: // If the encoder does not support writing a thumbnail, then try again // but disable thumbnail generation. wEncoder.IsThumbnailGenerated = false; break; default: throw; } } if (wEncoder.IsThumbnailGenerated == false) { await wEncoder.FlushAsync(); } } var wPropertiesToRetrieve = SystemProperties.Union(SystemGpsProperties).Union(SystemImageProperties).Union(SystemPhotoProperties).ToList(); var wProperties = await wInputFile.Properties.RetrievePropertiesAsync(wPropertiesToRetrieve); foreach (var wProperty in wProperties) { try { await wOutputFile.Properties.SavePropertiesAsync(new[] { wProperty }); } catch (Exception e) { Console.WriteLine($"Key: {wProperty.Key}, Value: {wProperty.Value}"); Console.WriteLine(e.ToString()); } } } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public static void EvtRenderBufferWithContextSystem(EventLogHandle contextHandle, EventLogHandle eventHandle, Microsoft.Win32.UnsafeNativeMethods.EvtRenderFlags flag, SystemProperties systemProperties, int SYSTEM_PROPERTY_COUNT) { IntPtr zero = IntPtr.Zero; IntPtr ptr = IntPtr.Zero; EventLogPermissionHolder.GetEventLogPermission().Demand(); try { int num; int num2; if (!Microsoft.Win32.UnsafeNativeMethods.EvtRender(contextHandle, eventHandle, flag, 0, IntPtr.Zero, out num, out num2)) { int num3 = Marshal.GetLastWin32Error(); if (num3 != 0x7a) { EventLogException.Throw(num3); } } zero = Marshal.AllocHGlobal(num); bool flag2 = Microsoft.Win32.UnsafeNativeMethods.EvtRender(contextHandle, eventHandle, flag, num, zero, out num, out num2); int errorCode = Marshal.GetLastWin32Error(); if (!flag2) { EventLogException.Throw(errorCode); } if (num2 != SYSTEM_PROPERTY_COUNT) { throw new InvalidOperationException("We do not have " + SYSTEM_PROPERTY_COUNT + " variants given for the UnsafeNativeMethods.EvtRenderFlags.EvtRenderEventValues flag. (System Properties)"); } ptr = zero; for (int i = 0; i < num2; i++) { Microsoft.Win32.UnsafeNativeMethods.EvtVariant val = (Microsoft.Win32.UnsafeNativeMethods.EvtVariant) Marshal.PtrToStructure(ptr, typeof(Microsoft.Win32.UnsafeNativeMethods.EvtVariant)); switch (i) { case 0: systemProperties.ProviderName = (string) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeString); break; case 1: systemProperties.ProviderId = (Guid?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeGuid); break; case 2: systemProperties.Id = (short?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeInt16); break; case 3: systemProperties.Qualifiers = (short?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeInt16); break; case 4: systemProperties.Level = (byte?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeByte); break; case 5: systemProperties.Task = (short?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeInt16); break; case 6: systemProperties.Opcode = (byte?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeByte); break; case 7: systemProperties.Keywords = (long?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeHexInt64); break; case 8: systemProperties.TimeCreated = (DateTime?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeFileTime); break; case 9: systemProperties.RecordId = (long?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeInt64); break; case 10: systemProperties.ActivityId = (Guid?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeGuid); break; case 11: systemProperties.RelatedActivityId = (Guid?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeGuid); break; case 12: systemProperties.ProcessId = (int?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeInt32); break; case 13: systemProperties.ThreadId = (int?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeInt32); break; case 14: systemProperties.ChannelName = (string) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeString); break; case 15: systemProperties.ComputerName = (string) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeString); break; case 0x10: systemProperties.UserId = (SecurityIdentifier) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeSid); break; case 0x11: systemProperties.Version = (byte?) ConvertToObject(val, Microsoft.Win32.UnsafeNativeMethods.EvtVariantType.EvtVarTypeByte); break; } ptr = new IntPtr(((long) ptr) + Marshal.SizeOf(val)); } } finally { if (zero != IntPtr.Zero) { Marshal.FreeHGlobal(zero); } } }
public static void EvtRenderBufferWithContextSystem(EventLogHandle contextHandle, EventLogHandle eventHandle, UnsafeNativeMethods.EvtRenderFlags flag, SystemProperties systemProperties, int SYSTEM_PROPERTY_COUNT) { IntPtr buffer = IntPtr.Zero; IntPtr pointer = IntPtr.Zero; int bufferNeeded; int propCount; EventLogPermissionHolder.GetEventLogPermission().Demand(); try { bool status = UnsafeNativeMethods.EvtRender(contextHandle, eventHandle, flag, 0, IntPtr.Zero, out bufferNeeded, out propCount); if (!status) { int error = Marshal.GetLastWin32Error(); if (error != UnsafeNativeMethods.ERROR_INSUFFICIENT_BUFFER) EventLogException.Throw(error); } buffer = Marshal.AllocHGlobal((int)bufferNeeded); status = UnsafeNativeMethods.EvtRender(contextHandle, eventHandle, flag, bufferNeeded, buffer, out bufferNeeded, out propCount); int win32Error = Marshal.GetLastWin32Error(); if (!status) EventLogException.Throw(win32Error); if (propCount != SYSTEM_PROPERTY_COUNT) throw new InvalidOperationException("We do not have " + SYSTEM_PROPERTY_COUNT + " variants given for the UnsafeNativeMethods.EvtRenderFlags.EvtRenderEventValues flag. (System Properties)"); pointer = buffer; //read each Variant structure for (int i = 0; i < propCount; i++) { UnsafeNativeMethods.EvtVariant varVal = (UnsafeNativeMethods.EvtVariant)Marshal.PtrToStructure(pointer, typeof(UnsafeNativeMethods.EvtVariant)); switch (i) { case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemProviderName: systemProperties.ProviderName = (string)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeString); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemProviderGuid: systemProperties.ProviderId = (Guid?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeGuid); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemEventID: systemProperties.Id = (ushort?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeUInt16); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemQualifiers: systemProperties.Qualifiers = (ushort?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeUInt16); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemLevel: systemProperties.Level = (byte?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeByte); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemTask: systemProperties.Task = (ushort?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeUInt16); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemOpcode: systemProperties.Opcode = (byte?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeByte); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemKeywords: systemProperties.Keywords = (ulong?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeHexInt64); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemTimeCreated: systemProperties.TimeCreated = (DateTime?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeFileTime); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemEventRecordId: systemProperties.RecordId = (ulong?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeUInt64); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemActivityID: systemProperties.ActivityId = (Guid?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeGuid); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemRelatedActivityID: systemProperties.RelatedActivityId = (Guid?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeGuid); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemProcessID: systemProperties.ProcessId = (uint?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeUInt32); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemThreadID: systemProperties.ThreadId = (uint?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeUInt32); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemChannel: systemProperties.ChannelName = (string)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeString); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemComputer: systemProperties.ComputerName = (string)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeString); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemUserID: systemProperties.UserId = (SecurityIdentifier)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeSid); break; case (int) UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemVersion: systemProperties.Version = (byte?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeByte); break; } pointer = new IntPtr(((Int64)pointer + Marshal.SizeOf(varVal))); } } finally { if (buffer != IntPtr.Zero) Marshal.FreeHGlobal(buffer); } }
// LUCENENET specific - changed the logic here to leave the // ANALYSIS_DATA_DIR an empty string if it is not found. This // allows us to skip loading files from disk if there are no files // to load (and fixes LUCENE-1817 that prevents the on-disk files // from ever being loaded). private static void Init() { #if NETSTANDARD // Support for GB2312 encoding. See: https://docs.microsoft.com/en-us/dotnet/api/system.text.codepagesencodingprovider?view=netcore-2.0 var encodingProvider = System.Text.CodePagesEncodingProvider.Instance; System.Text.Encoding.RegisterProvider(encodingProvider); #endif string dirName = "analysis-data"; //string propName = "analysis.properties"; // Try the system property:-Danalysis.data.dir=/path/to/analysis-data //ANALYSIS_DATA_DIR = System.getProperty("analysis.data.dir", ""); ANALYSIS_DATA_DIR = SystemProperties.GetProperty("analysis.data.dir", ""); if (ANALYSIS_DATA_DIR.Length != 0) { return; } #if NETSTANDARD1_6 string currentPath = System.AppContext.BaseDirectory; #else string currentPath = AppDomain.CurrentDomain.BaseDirectory; #endif //FileInfo[] cadidateFiles = new FileInfo[] { new FileInfo(currentPath + "/" + dirName), // new FileInfo(currentPath + "/bin/" + dirName)/*, new FileInfo("./" + propName), // new FileInfo("./lib/" + propName)*/ }; //for (int i = 0; i < cadidateFiles.Length; i++) //{ // FileInfo file = cadidateFiles[i]; // if (file.Exists) // { // ANALYSIS_DATA_DIR = file.FullName; // //if (file.isDirectory()) // //{ // // ANALYSIS_DATA_DIR = file.getAbsolutePath(); // //} // //else if (file.isFile() && GetAnalysisDataDir(file).Length != 0) // //{ // // ANALYSIS_DATA_DIR = GetAnalysisDataDir(file); // //} // break; // } //} string candidatePath = System.IO.Path.Combine(currentPath, dirName); if (Directory.Exists(candidatePath)) { ANALYSIS_DATA_DIR = candidatePath; return; } try { while (new DirectoryInfo(currentPath).Parent != null) { candidatePath = System.IO.Path.Combine(new DirectoryInfo(currentPath).Parent.FullName, dirName); if (Directory.Exists(candidatePath)) { ANALYSIS_DATA_DIR = candidatePath; return; } currentPath = new DirectoryInfo(currentPath).Parent.FullName; } } catch (SecurityException) { // ignore security errors } //for (int i = 0; i < cadidateDirectories.Count; i++) //{ // DirectoryInfo dir = cadidateDirectories[i]; // if (dir.Exists) // { // ANALYSIS_DATA_DIR = dir.FullName; // break; // } //} //if (ANALYSIS_DATA_DIR.Length == 0) //{ // // Dictionary directory cannot be found. // throw new Exception("WARNING: Can not find lexical dictionary directory!" // + " This will cause unpredictable exceptions in your application!" // + " Please refer to the manual to download the dictionaries."); //} }
private void SetInfo() { if (properties == null) { properties = new SystemProperties(); } properties.Info.Add("User Name", Environment.UserName); properties.Info.Add("Machine Name", Environment.MachineName); properties.Info.Add("Domain", Environment.UserDomainName); properties.Info.Add("OS", Environment.OSVersion.Platform + " " + Environment.OSVersion.Version); }