//public bool CanBrowseFileFullName() //{ // return //} public void BrowseFileFullName() { //OpenFileDialog openFileDialog1 = new OpenFileDialog(); //openFileDialog1.InitialDirectory = "c:\\"; //openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; //openFileDialog1.FilterIndex = 2; //openFileDialog1.RestoreDirectory = true; //openFileDialog1.ShowDialog(); IFileSystemAccessor accessor = SelectedApplication.ServiceContainer.Resolve <IFileSystemAccessor>(); OpenFileViewModel viewModel = new OpenFileViewModel(accessor); if (!string.IsNullOrEmpty(FileFullName)) { viewModel.InitialDirectory = System.IO.Path.GetDirectoryName(FileFullName); viewModel.FileName = System.IO.Path.GetFileName(FileFullName); } viewModel.Filter = "Executable (*.exe)|*.exe"; bool?result = _application.ViewModelManager.ShowDialog(viewModel); if (result.HasValue && result.Value) { FileFullName = viewModel.FileName; } }
public bool Parse(IFileSystemAccessor fs, string key, JsonNode value) { switch (key) { case "multipleOf": MultipleOf = value.GetInt32(); return(true); case "maximum": Maximum = value.GetInt32(); return(true); case "exclusiveMaximum": ExclusiveMaximum = value.GetBoolean(); return(true); case "minimum": Minimum = value.GetInt32(); return(true); case "exclusiveMinimum": ExclusiveMinimum = value.GetBoolean(); return(true); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="Interpreter"/> class. /// </summary> /// <param name="environmentInitializers">Array of environment initializers</param> /// <param name="fsAccessor">The file system accessor</param> public Interpreter(IEnumerable <CreateSymbolTableDelegate> environmentInitializers = null, IFileSystemAccessor fsAccessor = null) { this.fsAccessor = fsAccessor; if (this.fsAccessor == null) { this.fsAccessor = new DisabledFileSystemAccessor(); } // populate an empty environment for the initializer to potentially work with this.environment = Environment.CreateEmpty(); this.macroTable = new Dictionary <Symbol, Procedure>(); environmentInitializers = environmentInitializers ?? new List <CreateSymbolTableDelegate>(); environmentInitializers = new CreateSymbolTableDelegate[] { Builtins.CreateBuiltins }.Concat(environmentInitializers); foreach (CreateSymbolTableDelegate initializer in environmentInitializers) { this.environment = new Environment(initializer(this), this.environment); } foreach (var iniReader in GetInitializeFiles()) { this.Evaluate(iniReader); } }
public ProjectDefinitionWriter( IProjectDefinitionsReader projectDefinitionsReader, IFileSystemAccessor fileSystemAccessor) { this.projectDefinitionsReader = projectDefinitionsReader; this.fileSystemAccessor = fileSystemAccessor; }
public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value) { switch (key) { case "multipleOf": MultipleOf = value.GetInt32(); return(true); case "maximum": Maximum = value.GetInt32(); return(true); case "exclusiveMaximum": ExclusiveMaximum = value.GetBoolean(); return(true); case "minimum": Minimum = value.GetInt32(); return(true); case "exclusiveMinimum": ExclusiveMinimum = value.GetBoolean(); return(true); } return(false); }
public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value) { switch (key) { case "maxProperties": MaxProperties = value.GetInt32(); return(true); case "minProperties": MinProperties = value.GetInt32(); return(true); case "required": { foreach (var req in value.ArrayItems()) { m_required.Add(req.GetString()); } } return(true); case "properties": { foreach (var prop in value.ObjectItems()) { AddProperty(fs, prop.Key.GetString(), prop.Value); } } return(true); case "patternProperties": PatternProperties = value.GetString(); return(true); case "additionalProperties": { var sub = new JsonSchema(); sub.Parse(fs, value, "additionalProperties"); AdditionalProperties = sub; } return(true); case "dependencies": { foreach (var kv in value.ObjectItems()) { Dependencies.Add(kv.Key.GetString(), kv.Value.ArrayItems().Select(x => x.GetString()).ToArray()); } } return(true); case "propertyNames": return(true); } return(false); }
public OpenFileViewModel(IFileSystemAccessor accessor) { _accessor = new FilteredFileSystemAccessor(accessor); _parentDirectory = new ParentDirectoryInfo(); _fileSystemInfos = new ObservableCollection <object>(); Drives = _accessor.GetLogicalDrives(); SelectedDrive = Drives.FirstOrDefault(); InitialDirectory = Properties.Settings.Default.OpenFileViewLastUsedPath; }
public static JsonSchema ParseFromPath(IFileSystemAccessor fs) { // parse JSON var json = fs.ReadAllText(); var root = JsonParser.Parse(json); // create schema var schema = new JsonSchema(); schema.Parse(fs, root, "__ParseFromPath__" + fs.ToString()); return(schema); }
public void AddProperty(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value) { var sub = new JsonSchema(); sub.Parse(fs, value, key); if (Properties.ContainsKey(key)) { if (sub.Validator != null) { Properties[key].Validator.Merge(sub.Validator); } } else { Properties.Add(key, sub); } }
public bool Parse(IFileSystemAccessor fs, string key, JsonNode value) { switch (key) { case "maxLength": MaxLength = value.GetInt32(); return(true); case "minLength": MinLength = value.GetInt32(); return(true); case "pattern": Pattern = new Regex(value.GetString().Replace("\\\\", "\\")); return(true); } return(false); }
public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value) { switch (key) { case "maxLength": MaxLength = value.GetInt32(); return(true); case "minLength": MinLength = value.GetInt32(); return(true); case "pattern": Pattern = new Regex(value.GetString().Replace("\\\\", "\\")); return(true); } return(false); }
public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value) { switch (key) { case "items": if (value.IsArray()) { throw new NotImplementedException(); } else { var sub = new JsonSchema(); sub.Parse(fs, value, "items"); Items = sub; } return(true); case "additionalItems": return(true); case "maxItems": MaxItems = value.GetInt32(); return(true); case "minItems": MinItems = value.GetInt32(); return(true); case "uniqueItems": return(true); case "contains": return(true); } return(false); }
public FilteredFileSystemAccessor(IFileSystemAccessor accessor) { _accessor = accessor; Filter = new FileSystemFilter(); }
public void Parse(IFileSystemAccessor fs, JsonNode root, string Key) { m_context.Push(Key); var compositionType = default(CompositionType); var composition = new List <JsonSchema>(); foreach (var kv in root.ObjectItems) { //Console.WriteLine(kv.Key); switch (kv.Key) { case "$schema": Schema = kv.Value.GetString(); break; case "$ref": { var refFs = fs.Get(kv.Value.GetString()); // parse JSON var json = refFs.ReadAllText(); var refRoot = JsonParser.Parse(json); Parse(refFs, refRoot, "$ref"); } break; #region Annotation case "title": Title = kv.Value.GetString(); break; case "description": Description = kv.Value.GetString(); break; case "default": Default = kv.Value.Value.Segment; break; #endregion #region Validation // http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1 case "type": Validator = JsonSchemaValidatorFactory.Create(kv.Value.GetString()); break; case "enum": Validator = JsonEnumValidator.Create(kv.Value); break; case "const": break; #endregion #region Composite // http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.7 case "oneOf": break; case "not": break; case "anyOf": // composition case "allOf": // composition { compositionType = (CompositionType)Enum.Parse(typeof(CompositionType), kv.Key, true); foreach (var item in kv.Value.ArrayItems) { if (item.ContainsKey("$ref")) { var sub = JsonSchema.ParseFromPath(fs.Get(item["$ref"].GetString())); composition.Add(sub); } else { var sub = new JsonSchema(); sub.Parse(fs, item, compositionType.ToString()); composition.Add(sub); } } Composite(compositionType, composition); } break; #endregion // http://json-schema.org/latest/json-schema-validation.html#rfc.section.7 case "format": break; #region Gltf case "gltf_detailedDescription": break; case "gltf_webgl": break; case "gltf_uriType": break; #endregion default: { if (Validator != null) { if (Validator.Parse(fs, kv.Key, kv.Value)) { continue; } } throw new NotImplementedException(string.Format("unknown key: {0}", kv.Key)); } } } m_context.Pop(); if (Validator == null) { SkipComparison = true; } }
public bool Parse(IFileSystemAccessor fs, string key, JsonNode value) { throw new NotImplementedException(); }
public ContextualFileContentReader(ILoggerFactory loggerFactory, IFileSystemAccessor fileSystemAccessor) { _LoggerFactory = loggerFactory; _FileSystemAccessor = fileSystemAccessor; _Log = loggerFactory.CreateLogger <FileContentObserver>(); }
internal DirectoryInfo(string fullName, IFileSystemAccessor accessor) : base(fullName.Length == 2 ? fullName + System.IO.Path.DirectorySeparatorChar : fullName, accessor) { }
public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value) { return(false); }
public bool Parse(IFileSystemAccessor fs, string key, JsonNode value) { return(false); }
public ProjectDefinitionsReader( IFileSystemAccessor fileReader) { this.fileReader = fileReader; }
internal FileInfo(string fullName, IFileSystemAccessor accessor) : base(fullName, accessor) { }
public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value) { throw new NotImplementedException(); }
protected FileSystemInfo(string fullName, IFileSystemAccessor accessor) { FullName = System.IO.Path.GetFullPath(fullName); Accessor = accessor; }
internal void ChangeFileSystemAccessor(IFileSystemAccessor accessor) { Accessor = accessor; }