コード例 #1
0
        //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;
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: Schemy.cs プロジェクト: zer/schemy
        /// <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);
            }
        }
コード例 #4
0
 public ProjectDefinitionWriter(
     IProjectDefinitionsReader projectDefinitionsReader,
     IFileSystemAccessor fileSystemAccessor)
 {
     this.projectDefinitionsReader = projectDefinitionsReader;
     this.fileSystemAccessor       = fileSystemAccessor;
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 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;
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
 public FilteredFileSystemAccessor(IFileSystemAccessor accessor)
 {
     _accessor = accessor;
     Filter    = new FileSystemFilter();
 }
コード例 #14
0
        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;
            }
        }
コード例 #15
0
ファイル: JsonEnumValidator.cs プロジェクト: Druba/GGJ2021
 public bool Parse(IFileSystemAccessor fs, string key, JsonNode value)
 {
     throw new NotImplementedException();
 }
コード例 #16
0
 public ContextualFileContentReader(ILoggerFactory loggerFactory, IFileSystemAccessor fileSystemAccessor)
 {
     _LoggerFactory      = loggerFactory;
     _FileSystemAccessor = fileSystemAccessor;
     _Log = loggerFactory.CreateLogger <FileContentObserver>();
 }
コード例 #17
0
 internal DirectoryInfo(string fullName, IFileSystemAccessor accessor)
     : base(fullName.Length == 2 ? fullName + System.IO.Path.DirectorySeparatorChar : fullName, accessor)
 {
 }
コード例 #18
0
 public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value)
 {
     return(false);
 }
コード例 #19
0
 public bool Parse(IFileSystemAccessor fs, string key, JsonNode value)
 {
     return(false);
 }
コード例 #20
0
 public ProjectDefinitionsReader(
     IFileSystemAccessor fileReader)
 {
     this.fileReader = fileReader;
 }
コード例 #21
0
 internal FileInfo(string fullName, IFileSystemAccessor accessor)
     : base(fullName, accessor)
 {
 }
コード例 #22
0
 public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode <JsonValue> value)
 {
     throw new NotImplementedException();
 }
コード例 #23
0
 protected FileSystemInfo(string fullName, IFileSystemAccessor accessor)
 {
     FullName = System.IO.Path.GetFullPath(fullName);
     Accessor = accessor;
 }
コード例 #24
0
 internal void ChangeFileSystemAccessor(IFileSystemAccessor accessor)
 {
     Accessor = accessor;
 }