private void btnView_Click(object sender, EventArgs e) { long FileSize; byte[] Context; string SourcePath, FileName, FileSuffix; OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "选择文件"; ofd.Filter = "图纸(*.cut)|*.cut|所有文件(*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { SourcePath = ofd.FileName; FileStream fs = new FileStream(SourcePath, FileMode.Open); BinaryReader br = new BinaryReader(fs); Context = br.ReadBytes(Convert.ToInt32(fs.Length)); FileName = SourcePath.Substring(SourcePath.LastIndexOf("\\") + 1); FileSuffix = FileName.Substring(FileName.IndexOf(".") + 1); FileSize = fs.Length; fs.Close(); _Entry = new DrawingInfo(_PID, 0, "", SourcePath, FileName, FileSuffix, FileSize, UserSetting.UserInf.UserName, DateTime.Now, false, false, "修改-图纸替换", Context); } }
public override int GetHashCode() { unchecked { return(SourcePath.GetHashCode() + DestinationSubDirectory.GetHashCode()); } }
/// <summary> /// Serves as a hash function for a <see cref="Binding"/> object. /// </summary> /// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a /// hash table.</returns> public override int GetHashCode() { int targetHash = Target == null ? 0 : Target.GetHashCode(); int sourceHash = Source == null ? 0 : Source.GetHashCode(); return(targetHash ^ TargetPath.GetHashCode() ^ sourceHash ^ SourcePath.GetHashCode()); }
public bool Compatible(PathMatch match) // The specified match is compatible with (does not contradicts to) this match { // Main rule: if a coverage condition holds for one path (in one or another direction) then it must hold for the other path (in the same direction) // SourcePath -> TargetPath if (match.SourcePath.StartsWith(SourcePath)) // The specified match continues this path { return(match.TargetPath.StartsWith(TargetPath)); // The same must be true for the other paths } else if (SourcePath.StartsWith(match.SourcePath)) // Opposite { return(TargetPath.StartsWith(match.TargetPath)); // The same must be true for the other paths } // TargetPath -> SourcePath if (match.TargetPath.StartsWith(TargetPath)) { return(match.SourcePath.StartsWith(SourcePath)); } else if (TargetPath.StartsWith(match.TargetPath)) { return(SourcePath.StartsWith(match.SourcePath)); } // Neither source path nor target paths cover. // This means they have some intersection (meet table they both continue). // This meet point defines an implicit match which we do not check but it might contradict to other matches. return(true); }
public override void UpdateSource() { if (SourcePath.IsNotReadyToUpdate) { return; } var targetValue = GetTargetValue(); var sourceValueType = SourcePath.GetPropertyValue()?.GetType(); if (sourceValueType == null) { sourceValueType = _sourceValueType; } else { _sourceValueType = sourceValueType; } if (targetValue != null && sourceValueType?.IsNumeric() == true) { targetValue = Cast.To(targetValue, sourceValueType, CultureInfo.CurrentCulture); } SourcePath.SetPropertyValue(targetValue); }
public override void UpdateTarget() { var value = SourcePath.GetPropertyValue(); var path = TargetPath.Path.ToUpperCase(); if (path == "INNERHTML") { if (Target.Get(0).NodeType == NodeType.Text) { Target.Get(0).NodeValue = value + ""; return; } Target.Html(value + ""); return; } if (path == "VALUE") { Target.Val(value + "").Change(); return; } Target.Attr(TargetPath.Path, value + ""); }
/// <summary> /// Recognizes values from one or more business cards. /// <para>See <a href="https://aka.ms/formrecognizer/businesscardfields"/> for a list of available fields on a business card.</para> /// </summary> /// <param name="businessCardUri">The absolute URI of the remote file to recognize values from.</param> /// <param name="recognizeBusinessCardsOptions">A set of options available for configuring the recognize request.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>A <see cref="RecognizeBusinessCardsOperation"/> to wait on this long-running operation. Its <see cref="RecognizeBusinessCardsOperation.Value"/> upon successful /// completion will contain the extracted business cards.</returns> public virtual async Task <RecognizeBusinessCardsOperation> StartRecognizeBusinessCardsFromUriAsync(Uri businessCardUri, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(businessCardUri, nameof(businessCardUri)); recognizeBusinessCardsOptions ??= new RecognizeBusinessCardsOptions(); using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(FormRecognizerClient)}.{nameof(StartRecognizeBusinessCardsFromUri)}"); scope.Start(); try { SourcePath sourcePath = new SourcePath() { Source = businessCardUri.AbsoluteUri }; Response response = await ServiceClient.AnalyzeBusinessCardAsyncAsync(includeTextDetails : recognizeBusinessCardsOptions.IncludeFieldElements, locale : recognizeBusinessCardsOptions.Locale, fileStream : sourcePath, cancellationToken).ConfigureAwait(false); string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader); return(new RecognizeBusinessCardsOperation(ServiceClient, Diagnostics, location)); } catch (Exception e) { scope.Failed(e); throw; } }
public void CopyFile(string filename) { if (SourcePath.Equals("") || DestPath.Equals("")) { return; } if (SourcePath.Equals(DestPath)) { var result = MessageBox.Show("Такой файл уже существует, вы " + "хотите его заменить?", "Замена файла", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result != MessageBoxResult.OK) { return; } } File.Copy(SourcePath + filename, DestPath + filename, true); if (UpdateListListener != null) { UpdateListListener.UpdateList(SourcePath, filename); } }
/// <summary> /// Recognizes layout elements from one or more passed-in forms. /// </summary> /// <param name="formUri">The absolute URI of the remote file to recognize elements from.</param> /// <param name="recognizeContentOptions">A set of options available for configuring the recognize request.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>A <see cref="RecognizeContentOperation"/> to wait on this long-running operation. Its <see cref="RecognizeContentOperation.Value"/> upon successful /// completion will contain layout elements extracted from the form.</returns> public virtual async Task <RecognizeContentOperation> StartRecognizeContentFromUriAsync(Uri formUri, RecognizeContentOptions recognizeContentOptions = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(formUri, nameof(formUri)); recognizeContentOptions ??= new RecognizeContentOptions(); using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(FormRecognizerClient)}.{nameof(StartRecognizeContentFromUri)}"); scope.Start(); try { SourcePath sourcePath = new SourcePath() { Source = formUri.AbsoluteUri }; Response response = await ServiceClient.AnalyzeLayoutAsyncAsync(sourcePath, cancellationToken).ConfigureAwait(false); string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader); return(new RecognizeContentOperation(ServiceClient, Diagnostics, location)); } catch (Exception e) { scope.Failed(e); throw; } }
public override object[] Build() { List <object> items = new List <object>(); // create custom acton Wix.CustomAction action = new Wix.CustomAction(); action.Id = Common.GetId(); action.Directory = "INSTALLDIR"; if (SourcePath.Contains(":")) { action.ExeCommand = SourcePath + " " + Function; // EXE IN TARGET SYSTEM } else { action.ExeCommand = "[SystemFolder]" + SourcePath + " " + Function; // EXE IN TARGET SYSTEM } items.Add(action); // create install execute sequence Wix.InstallExecuteSequence executeSequence = new Wix.InstallExecuteSequence(); executeSequence.ItemsElementName = new Wix.ItemsChoiceType2[] { Wix.ItemsChoiceType2.Custom }; Wix.Custom custom = new Wix.Custom(); custom.Action = action.Id; base.SetExecutionSequence(custom); base.SetExecuteType(custom); executeSequence.Items = new object[] { custom }; items.Add(executeSequence); return(items.ToArray()); }
/// <summary> /// 手动触发更新目标 /// </summary> internal virtual void UpdateTarget() { //TargetPath不能为null var value = SourcePath.GetValue(source); TargetPath.SetValue(GetConvertValue(value)); }
internal sealed record OptionArgs( SourcePath SourcePath, DestinationDirectory DestinationDirectory, DryRun DryRun, KeepGoing KeepGoing, SkipDateSubdirectory SkipDateSubdirectory, Overwrite Overwrite);
/// <summary> /// Recognizes values from one or more receipts. /// </summary> /// <param name="receiptUri">The absolute URI of the remote file to recognize values from.</param> /// <param name="recognizeReceiptsOptions">A set of options available for configuring the recognize request.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>A <see cref="RecognizeReceiptsOperation"/> to wait on this long-running operation. Its <see cref="RecognizeReceiptsOperation.Value"/> upon successful /// completion will contain the extracted receipt.</returns> public virtual RecognizeReceiptsOperation StartRecognizeReceiptsFromUri(Uri receiptUri, RecognizeReceiptsOptions recognizeReceiptsOptions = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(receiptUri, nameof(receiptUri)); recognizeReceiptsOptions ??= new RecognizeReceiptsOptions(); using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(FormRecognizerClient)}.{nameof(StartRecognizeReceiptsFromUri)}"); scope.Start(); try { SourcePath sourcePath = new SourcePath() { Source = receiptUri.AbsoluteUri }; Response response = ServiceClient.AnalyzeReceiptAsync(includeTextDetails: recognizeReceiptsOptions.IncludeFieldElements, sourcePath, cancellationToken); string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader); return(new RecognizeReceiptsOperation(ServiceClient, Diagnostics, location)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Recognizes pages from one or more forms, using a model trained with custom forms. /// </summary> /// <param name="modelId">The ID of the model to use for recognizing form values.</param> /// <param name="formUri">The absolute URI of the remote file to recognize elements from.</param> /// <param name="recognizeCustomFormsOptions">A set of options available for configuring the recognize request.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>A <see cref="RecognizeCustomFormsOperation"/> to wait on this long-running operation. Its <see cref="RecognizeCustomFormsOperation.Value"/> upon successful /// completion will contain recognized pages from the input document.</returns> public virtual async Task <RecognizeCustomFormsOperation> StartRecognizeCustomFormsFromUriAsync(string modelId, Uri formUri, RecognizeCustomFormsOptions recognizeCustomFormsOptions = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(modelId, nameof(modelId)); Argument.AssertNotNull(formUri, nameof(formUri)); recognizeCustomFormsOptions ??= new RecognizeCustomFormsOptions(); using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(FormRecognizerClient)}.{nameof(StartRecognizeCustomFormsFromUri)}"); scope.Start(); try { Guid guid = ClientCommon.ValidateModelId(modelId, nameof(modelId)); SourcePath sourcePath = new SourcePath() { Source = formUri.AbsoluteUri }; Response response = await ServiceClient.AnalyzeWithCustomModelAsync(guid, includeTextDetails : recognizeCustomFormsOptions.IncludeFieldElements, sourcePath, cancellationToken).ConfigureAwait(false); string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader); return(new RecognizeCustomFormsOperation(ServiceClient, Diagnostics, location)); } catch (Exception e) { scope.Failed(e); throw; } }
public override IEnumerable <NPath> GetFiles() { var files = SourcePath.Files("*.cs", recurse: true); var ignoreDirectories = FindDirectories(); return(files.Where(f => f.HasExtension("cs") && !ignoreDirectories.Any(f.IsChildOf))); }
public FileType GetFileType() { FileType type = ParseFileTypeValue(); //If SourcePath is for a special file type, then return that type. if (Path.GetExtension(SourcePath) == Xv2CoreLib.EffectContainer.EffectContainerFile.ZipExtension) { return(FileType.VfxPackage); } else if (Path.GetExtension(SourcePath) == Xv2CoreLib.ACB_NEW.ACB_File.MUSIC_PACKAGE_EXTENSION) { return(FileType.MusicPackage); } if (type == FileType.Default) { //Simulates the original behavior before FileType was added. Will infer type from SourcePath. if (SourcePath.EndsWith("/") || SourcePath.EndsWith(@"\")) { return(FileType.CopyDir); } return((Path.GetExtension(SourcePath) != ".xml") ? FileType.CopyFile : FileType.XML); } else { return(type); } }
public void SourcePath_MakeParent(object[] items, string expectedString) { var path = new SourcePath(); foreach (var item in items) { if (item is int i) { path.AddArrayIndex(i); } else if (item is string s) { path.AddFieldName(s); } } var parent = path.MakeParent(); var result = parent.ArrayString(); Assert.AreEqual(expectedString, result); var origin = parent.AsOrigin(); Assert.AreEqual(parent, origin.Path); Assert.AreEqual(SourceLocation.None, origin.Location); }
public override int GetHashCode() { int hashType = Type.GetHashCode(); int hashSourcePath = SourcePath == null ? 0 : SourcePath.GetHashCode(); int hashTargetPath = TargetPath == null ? 0 : TargetPath.GetHashCode(); return(hashSourcePath ^ hashTargetPath ^ hashType); }
public static SourcePath TrimPath(string txt) { SourcePath sourcePath = new SourcePath(); sourcePath.wildCard = Path.GetFileName(txt); sourcePath.path = Path.GetDirectoryName(txt); return(sourcePath); }
public void SourcePath_NoPathIsNotTHeSameAsEmptyPath() { // saftey check in case operator overloads for path happen var noPath = SourcePath.None; var emptyPath = new SourcePath(); Assert.IsTrue(noPath != emptyPath, "An empty path must not have equality to the 'None' path"); }
/// <summary> /// Get the path relative to the source directory /// </summary> public string GetRelativePath(string file) { string folder = Path.GetDirectoryName(file).Replace("\\", "/"); string[] foldersSplitted = folder.Split(new[] { SourcePath.Replace("\\", "/") }, StringSplitOptions.RemoveEmptyEntries); // cut the source path and the "rest" of the path return(foldersSplitted.Length > 1 ? foldersSplitted[1] : ""); // return the "rest" }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (Module.Expression != null) { targetCommand.AddParameter("Module", Module.Get(context)); } if (FullyQualifiedModule.Expression != null) { targetCommand.AddParameter("FullyQualifiedModule", FullyQualifiedModule.Get(context)); } if (SourcePath.Expression != null) { targetCommand.AddParameter("SourcePath", SourcePath.Get(context)); } if (LiteralPath.Expression != null) { targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context)); } if (Recurse.Expression != null) { targetCommand.AddParameter("Recurse", Recurse.Get(context)); } if (UICulture.Expression != null) { targetCommand.AddParameter("UICulture", UICulture.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (UseDefaultCredentials.Expression != null) { targetCommand.AddParameter("UseDefaultCredentials", UseDefaultCredentials.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
/// <summary> /// Initializes a new instance of the <see cref="GraphFieldDataSource" /> class. /// </summary> /// <param name="rawSource">The singular raw source item which will be passed as the source data to the resolver of this request.</param> /// <param name="path">The path in the object graph pointed to by this data source.</param> /// <param name="dataItems">The set of data items making up the raw source.</param> public GraphFieldDataSource( object rawSource, SourcePath path, params GraphDataItem[] dataItems) { this.Path = path; this.Value = rawSource; this.Items = new List <GraphDataItem>(dataItems); }
/// <summary> /// Initializes a new instance of the <see cref="GraphFieldDataSource" /> class. /// </summary> /// <param name="rawSource">The singular raw source item which will be passed as the source data to the resolver of this request.</param> /// <param name="path">The path in the object graph pointed to by this data source.</param> /// <param name="dataItems">The set of data items making up the raw source.</param> public GraphFieldDataSource( object rawSource, SourcePath path, IEnumerable <GraphDataItem> dataItems) { this.Path = path; this.Value = rawSource; this.Items = dataItems == null ? new List <GraphDataItem>() : new List <GraphDataItem>(dataItems); }
public override async Task <bool> Download(Archive a, AbsolutePath destination) { await using var src = SourcePath.OpenRead(); await using var dest = destination.Create(); var size = SourcePath.Size; await src.CopyToWithStatusAsync(size, dest, "Copying from Game folder"); return(true); }
public string SourcePathFor(params string[] relative) { return(Path.Combine( SourcePath .AsArray() .Concat(relative) .ToArray() )); }
public Task MediaTypeJson() => Test(async(host, pipeline) => { var value = new SourcePath { Source = "anything" }; var response = await new ServiceClient(ClientDiagnostics, pipeline, host).AnalyzeBodyAsync(value); Assert.AreEqual("Nice job with JSON", response.Value); });
/// <summary> /// Adds or replaces the source data supplied to the field request. /// </summary> /// <param name="sourceData">The source data.</param> /// <param name="path">An optional to mock where in the graph query the data originated.</param> /// <returns>MockFieldRequest.</returns> public FieldContextBuilder AddSourceData(object sourceData, SourcePath path = null) { path = path ?? SourcePath.None; var item = new GraphDataItem(_mockInvocationContext.Object, sourceData, path); var dataSource = new GraphFieldDataSource(sourceData, path, item); _mockRequest.Setup(x => x.DataSource).Returns(dataSource); return(this); }
// Asynch loading public AudioSourceWrapper(SourcePath path, DeAudioGroup group, AudioManager manager) { this.Path = path; this.Group = group; this.manager = manager; this.Asynch = true; this.Loaded = false; manager.OnAudioStarted(this); }
/// <summary> /// Initializes a new instance of the <see cref="FieldSelectionSet" /> class. /// </summary> /// <param name="graphType">The graph type this selection set is acting on.</param> /// <param name="rootPath">The document specific root path under which all fields should be nested in this selection set.</param> public FieldSelectionSet(IGraphType graphType, SourcePath rootPath) { this.GraphType = Validation.ThrowIfNullOrReturn(graphType, nameof(graphType)); _knownFieldAliases = new CharMemoryHashSet(); _fields = new List <FieldSelection>(); Validation.ThrowIfNull(rootPath, nameof(rootPath)); this.RootPath = rootPath.Clone(); }
void DefaultTreeSourceInit() { string url; SourceType st; if (Application.dataPath.StartsWith ("http")) { url = Application.dataPath + "/CustomTrees/"; st = SourceType.web; } else { url = "file://"+Application.dataPath + "/CustomTrees/"; st = SourceType.file; } SourcePath sp = new SourcePath (); sp.url = url; sp.sourceType = st; treeSourcePaths.Add(sp); PlayerPrefs.SetString ("source1", url); }
void AddSourcePath(string url) { SourceType st; if (url.StartsWith ("http")) { st = SourceType.web; } else { url = url; st = SourceType.file; } SourcePath sp = new SourcePath (); sp.url = url; sp.sourceType = st; treeSourcePaths.Add(sp); }
/// <summary> /// Разбор конфига Техпрогноза /// </summary> /// <param name="file_name">Имя файла - конфига</param> /// <param name="source_id">ID-источника</param> private SourcePath ParseConfigFile(int source_id) { SourcePath source_path = default(SourcePath); if (source_id != -1) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(СonfigFile); XmlNodeList nodeList = xmlDoc.DocumentElement.GetElementsByTagName("a:IdSource"); foreach (XmlNode sourceNode in nodeList) if (source_id.ToString() == sourceNode.InnerText) { string param = GetNodeName(GetNodeID(sourceNode, NODE_PARAM)); string sensor = GetNodeName(GetNodeID(sourceNode, NODE_SENSOR)); string measure_point = GetNodeName(GetNodeID(sourceNode, NODE_MEASURE_POINT)); string mashine_part = GetNodeName(GetNodeID(sourceNode, NODE_MASHINE_PART)); string mashine = GetNodeName(GetNodeID(sourceNode, NODE_MASHINE)); source_path = new SourcePath(param, sensor, measure_point, mashine_part, mashine); break; } } return source_path; }