示例#1
0
            public static CodeTypeMember[] CreateOtherMembers <T>(BaseSchema schema)
            {
                List <CodeTypeMember> members = new List <CodeTypeMember>();
                //
                // 在实体类中声明:IndexInscriber
                CodeTypeReference type         = new CodeTypeReference(typeof(IndexInscriber));
                CodeMemberField   fieldIndexer = new CodeMemberField(type, "_Indexer");

                members.Add(fieldIndexer);
                // 声明IMapper
                CodeMemberField iMapperField = new CodeMemberField(typeof(IMapper <T>), "_IMapper");

                members.Add(iMapperField);
                // 声明importing(用于标识是否正在导入数据)
                CodeMemberField importingField = new CodeMemberField(typeof(bool), "_Importing");

                members.Add(importingField);
                //
                CodeConstructor defaultCtor = new CodeConstructor();

                defaultCtor.Attributes = MemberAttributes.Public;
                defaultCtor.Statements.Add(new CodeAssignStatement(
                                               new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "_IMapper"),
                                               new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(typeof(Mapping)), "GetIMapper", new CodeTypeReference[] { new CodeTypeReference(typeof(T)) }))
                                               ));
                defaultCtor.Statements.Add(new CodeAssignStatement(
                                               new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "_Indexer"),
                                               new CodeObjectCreateExpression(typeof(IndexInscriber), new CodePrimitiveExpression(schema.FieldCount))
                                               ));
                members.Add(defaultCtor);

                //
                return(members.ToArray());
            }
示例#2
0
        /// <summary>
        /// Returns an ordered ListItemCollection for use with DropDowns, RadioButtonLists, and CheckBoxLists
        /// </summary>
        /// <param name="textColumn">The name of the column which should be used as the text value column</param>
        /// <returns></returns>
        public static ListItemCollection GetListItems(string textColumn)
        {
            ListItemCollection list    = new ListItemCollection();
            string             pkCol   = BaseSchema.PrimaryKey.ColumnName;
            string             textCol = BaseSchema.GetColumn(textColumn).ColumnName;

            // run a query retrieving the two columns
            Query q = new Query(BaseSchema)
            {
                SelectList = String.Concat(pkCol, ",", textCol),
                OrderBy    = OrderBy.Asc(textCol)
            };

            using (IDataReader rdr = q.ExecuteReader())
            {
                while (rdr.Read())
                {
                    ListItem listItem = new ListItem(rdr[1].ToString(), rdr[0].ToString());
                    list.Add(listItem);
                }

                rdr.Close();
            }
            return(list);
        }
示例#3
0
        protected async override Task ExecuteCoreAsync(BaseSchema baseSchema, string manifestContent, string filePath)
        {
            var manifest       = Deserialize <ProjectManifest>(manifestContent);
            var projectService = GetProjectService();
            var repoService    = GetRepositoryService();


            using var op = Insights.BeginOperation($"Validating Manifest file [{filePath}]...", "Validation");
            if (manifest.Validate())
            {
                var outcome = await EnsureProjectExistsAsync(manifest, projectService);

                await ProcessPermissionsAsync(manifest, projectService, outcome);
                await EnsureTeamProvisionedAsync(manifest, projectService, outcome);
                await EnsureRepositoriesExistsAsync(manifest, repoService, outcome.Item1, outcome.Item2);

                var seOutcome = await EnsureServiceEndpointExistsAsync(manifest, projectService, outcome);
                await EnsureEnvironmentExistsAsync(manifest, outcome.Item1, seOutcome);
                await EnsureBuildFoldersAsync(manifest, outcome.Item1);
                await EnsureReleaseFoldersAsync(manifest, outcome.Item1);
            }
            else
            {
                op.EndWithFailure("Invalid manifest file!");
            }
        }
示例#4
0
        private bool DictionaryInterpret <TKey>(object value, BaseSchema schema, string path, IProcessContext context)
        {
            if (value is IDictionary <TKey, object> dict)
            {
                foreach (var keyRaw in dict.Keys.ToList())
                {
                    var key = keyRaw as string;
                    if (key != null)
                    {
                        BaseSchema baseSchema = null;
                        schema?.Properties?.TryGetValue(key, out baseSchema);
                        var val = dict[keyRaw];
                        var obj = InterpretCore(val, baseSchema, $"{path}/{key}", context);
                        if (!ReferenceEquals(obj, val))
                        {
                            dict[keyRaw] = obj;
                        }
                    }
                    else
                    {
                        throw new NotSupportedException("Only support string as key");
                    }
                }
                return(true);
            }

            return(false);
        }
        protected async Task ExportProjectPermissionsAsync(AzDoServices.Dtos.Project project)
        {
            var graphService = GetGraphService();
            var groups       = await graphService.ListGroupsInProjectAsync(project.Id);

            var manifest = BaseSchema.GetEmpty(project.Name, ManifestKind.Permission);

            manifest.Permissions = new List <PermissionSchemaManifest>();

            foreach (var group in groups)
            {
                var memberCollection = await graphService.GetGroupMembersAsync(group.Descriptor);

                if (memberCollection != null && memberCollection.Members != null && memberCollection.Members.Any())
                {
                    var permissionManifest = PermissionSchemaManifest.Create(group.DisplayName);
                    manifest.Permissions.Add(permissionManifest);

                    await PopulateMembershipAsync(graphService, memberCollection, permissionManifest);
                }
            }

            if (manifest.Permissions.Any())
            {
                await this.fs.WriteManifestAsync(project, ManifestKind.Permission, Serialize(manifest));
            }
        }
示例#6
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value == null || !CanInterpret(schema))
            {
                return value;
            }

            if (!(value is string val))
            {
                throw new ArgumentException($"{value.GetType()} is not supported type string.");
            }

            if (_aggregateXrefs)
            {
                AddUidLinkSource(context.UidLinkSources, new LinkSourceInfo
                {
                    Target = val,
                    SourceFile = context.OriginalFileAndType.File
                });
            }

            if (_resolveXrefs)
            {
                // TODO: add resolved xref to the object if needed
                var xref = context.BuildContext.GetXrefSpec(val);
                if (xref == null)
                {
                    Logger.LogWarning($"Unable to find file with uid \"{val}\".", WarningCodes.Build.UidNotFound);
                }
            }

            return value;
        }
示例#7
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value == null || !CanInterpret(schema))
            {
                return(value);
            }

            var uid = JsonPointer.GetChild(value, "uid") as string;

            if (uid == null)
            {
                // schema validation threw error when uid is required, so here when uid is null, it must be optional, which is allowed
                return(value);
            }

            if (string.IsNullOrEmpty(uid))
            {
                Logger.LogWarning($"Invalid xrefProperties for /{path}: empty uid is not allowed.");
                return(value);
            }

            var xrefSpec = new XRefSpec
            {
                Uid = uid
            };

            var parts = schema.XrefProperties ?? new List <string> {
                "name", "fullName"
            };
            var root = context.GetModel <object>();

            foreach (var part in parts.Distinct())
            {
                var jsonPointer = new JsonPointer(path + "/" + part);
                var property    = jsonPointer.GetValue(root);
                if (property != null)
                {
                    if (property is string str)
                    {
                        xrefSpec[part] = str;
                    }
                    else
                    {
                        Logger.LogWarning($"Type {property.GetType()} from {jsonPointer} is not supported as the value of xref spec.");
                    }
                }
            }

            if (IsInternalXrefSpec(schema))
            {
                context.Uids.Add(new UidDefinition(uid, context.OriginalFileAndType.FullPath, path: path + "/uid"));
                xrefSpec.Href = ((RelativePath)context.OriginalFileAndType.File).GetPathFromWorkingFolder().UrlEncode().ToString();
                context.XRefSpecs.Add(xrefSpec);
            }
            else
            {
                context.ExternalXRefSpecs.Add(xrefSpec);
            }
            return(value);
        }
示例#8
0
文件: IMapper.cs 项目: radtek/Shop
        public ObjectMapper(ObjectSchema <T> schema)
        {
            _schema = schema;
            if (!_schema.IsReadonly)
            {
                _schema.Compile();
            }

            _propertyValues = new IPropertyValue <T> [schema.FieldMaps().Count];

            foreach (FieldMap <T> fieldMap in schema.FieldMaps())
            {
                _propertyValues[schema.IndexOf(fieldMap.Field)] = new PropertyValueForLambda <T>(fieldMap.Expression);
            }
            //

            if (this._schema.Name == null)
            {
                BlockExpression be = BlockExpression.Block(Expression.New(typeof(T)));
                _creator = Expression.Lambda <Func <T> >(be).Compile();
            }
            else
            {
                _Type = EntityBuilder.BuilderEntityClass <T>(schema.FieldMaps().Select(x => (FieldMap <T>)x), schema);
                BlockExpression be = BlockExpression.Block(Expression.New(_Type));
                _creator = Expression.Lambda <Func <T> >(be).Compile();
            }
        }
示例#9
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value == null || !CanInterpret(schema))
            {
                return(value);
            }

            if (!(value is string val))
            {
                throw new ArgumentException($"{value.GetType()} is not supported type string.");
            }

            var filePath = val;
            var relPath  = RelativePath.TryParse(val);

            if (relPath != null)
            {
                var currentFile = (RelativePath)context.OriginalFileAndType.File;
                filePath = currentFile + relPath;
            }

            context.SetOriginalContentFile(path, new FileAndType(context.OriginalFileAndType.BaseDir, filePath, DocumentType.Article));

            return(EnvironmentContext.FileAbstractLayer.ReadAllText(filePath));
        }
示例#10
0
        internal WSTableSource Clone(MetaFunctions _Func, byte?_UserRole = null)
        {
            WSTableSource src = new WSTableSource(ReturnType, SecurityZone, NAME, _Func, _UserRole == null ? UserRole : (byte)_UserRole, false, AccessLevel, AVAILABLE_FORMATS, ALIACES);

            src.PrintStatus             = PrintStatus;
            src.ShowMessageInaccessible = ShowMessageInaccessible;
            src.AllowOwnerAccess        = AllowOwnerAccess;
            src.BaseFilter            = BaseFilter == null ? null : BaseFilter.JString.ToJson();
            src.DeletableFilter       = DeletableFilter == null ? null : DeletableFilter.JString.ToJson();
            src.EditableFilter        = EditableFilter == null ? null : EditableFilter.JString.ToJson();
            src.CreatableFilter       = CreatableFilter == null ? null : CreatableFilter.JString.ToJson();
            src.ReadableFilter        = ReadableFilter == null ? null : ReadableFilter.JString.ToJson();
            src.DefaultSchemaDeepness = DefaultSchemaDeepness;
            src._IsReadableBySchema   = _IsReadableBySchema;
            src._IsCreatableBySchema  = _IsCreatableBySchema;
            src._IsEditableBySchema   = _IsEditableBySchema;
            src._IsDeletableBySchema  = _IsDeletableBySchema;
            src.Params = Params.Select(x => x is WSTableParam ? ((WSTableParam)x).Clone() : x.Clone());
            //PrimParams = PrimParams == null ? null : PrimParams.Select(c => c.Clone());
            src.DeleteFlag = DeleteFlag == null ? null : DeleteFlag.Clone();
            //Json = Json;
            //CoreSchema = CoreSchema;
            src./*_*/ SecurityZone = SecurityZone;
            src.BaseSchema         = BaseSchema == null?null:(WSEntitySchema)BaseSchema.Clone(src);
            //src._IsReady = null;
            return(src);
        }
示例#11
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value == null || !CanInterpret(schema))
            {
                return(value);
            }

            if (!(value is string val))
            {
                throw new ArgumentException($"{value.GetType()} is not supported type string.");
            }

            if (!Uri.TryCreate(val, UriKind.RelativeOrAbsolute, out Uri uri))
            {
                var message = $"{val} is not a valid href";
                Logger.LogError(message, code: ErrorCodes.Build.InvalidHref);
                throw new DocumentException(message);
            }

            // "/" is also considered as absolute to us
            if (uri.IsAbsoluteUri || val.StartsWith("/", StringComparison.Ordinal))
            {
                return(Helper.RemoveHostName(val, _siteHostName));
            }

            // sample value: a/b/c?hello
            var filePath  = UriUtility.GetPath(val);
            var fragments = UriUtility.GetQueryStringAndFragment(val);
            var relPath   = RelativePath.TryParse(filePath);

            if (relPath != null)
            {
                var originalFile = context.GetOriginalContentFile(path);
                var currentFile  = (RelativePath)originalFile.File;
                relPath = (currentFile + relPath.UrlDecode()).GetPathFromWorkingFolder();
                if (_exportFileLink)
                {
                    (context.FileLinkSources).AddFileLinkSource(new LinkSourceInfo
                    {
                        Target     = relPath,
                        Anchor     = UriUtility.GetFragment(val),
                        SourceFile = originalFile.File
                    });
                }

                if (_updateValue && context.BuildContext != null)
                {
                    var resolved = (RelativePath)context.BuildContext.GetFilePath(relPath);
                    if (resolved != null)
                    {
                        val = resolved.MakeRelativeTo(((RelativePath)context.FileAndType.File).GetPathFromWorkingFolder()).UrlEncode() + fragments;
                    }
                }
            }

            return(val);
        }
示例#12
0
        public object Process(object raw, BaseSchema schema, IProcessContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(InterpretCore(raw, schema, string.Empty, context));
        }
示例#13
0
 public async Task ExecuteAsync(BaseSchema baseSchema, string manifest, string filePath)
 {
     var exponentialBackoffFactor = 5000;
     var retryCount = 1;
     await ExecutionSupports.Retry(async() =>
     {
         await ExecuteCoreAsync(baseSchema, manifest, filePath);
     },
                                   exception => { Insights.TrackException(exception); }, exponentialBackoffFactor, retryCount);
 }
示例#14
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value == null || !CanInterpret(schema))
            {
                return(value);
            }

            var uid = JsonPointer.GetChild(value, "uid") as string;

            if (string.IsNullOrEmpty(uid))
            {
                Logger.LogWarning($"Invalid xrefProperties for {path}: uid is not defined.");
                return(value);
            }

            var xrefSpec = new XRefSpec
            {
                Uid = uid
            };

            var parts = schema.XrefProperties ?? new List <string> {
                "name", "fullName"
            };
            var root = context.Model.Content;

            foreach (var part in parts.Distinct())
            {
                var jsonPointer = new JsonPointer(path + "/" + part);
                var property    = jsonPointer.GetValue(root);
                if (property != null)
                {
                    if (property is string str)
                    {
                        xrefSpec[part] = str;
                    }
                    else
                    {
                        Logger.LogWarning($"Type {property.GetType()} from {jsonPointer} is not supported as the value of xref spec.");
                    }
                }
            }

            if (IsInternalXrefSpec(schema))
            {
                context.Properties.Uids.Add(new UidDefinition(uid, context.Model.LocalPathFromRoot, path: path + "/uid"));
                xrefSpec.Href = ((RelativePath)context.Model.Key).UrlEncode().ToString();
                context.Properties.XRefSpecs.Add(xrefSpec);
            }
            else
            {
                context.Properties.ExternalXRefSpecs.Add(xrefSpec);
            }
            return(value);
        }
示例#15
0
        /// <summary>
        /// Checks if this schema can read data written by the given schema. Used for decoding data.
        /// </summary>
        /// <param name="writerSchema">writer schema</param>
        /// <returns>true if this and writer schema are compatible based on the AVRO specification, false otherwise</returns>
        public override bool CanRead(Schema writerSchema)
        {
            if (writerSchema.Tag != Tag)
            {
                return(false);
            }

            LogicalSchema that = writerSchema as LogicalSchema;

            return(BaseSchema.CanRead(that.BaseSchema));
        }
示例#16
0
        private object Interpret(object value, BaseSchema schema, string path, IProcessContext context)
        {
            var val = value;

            foreach (var i in _interpreters.Where(s => s.CanInterpret(schema)))
            {
                val = i.Interpret(schema, val, context, path);
            }

            return(val);
        }
示例#17
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value == null || !CanInterpret(schema))
            {
                return(value);
            }

            if (!(value is string val))
            {
                throw new ArgumentException($"{value.GetType()} is not supported type string.");
            }

            if (!Uri.TryCreate(val, UriKind.RelativeOrAbsolute, out Uri uri))
            {
                throw new DocumentException($"{val} is not a valid href");
            }

            // "/" is also considered as absolute to us
            if (uri.IsAbsoluteUri || val.StartsWith("/"))
            {
                return(value);
            }

            // sample value: a/b/c?hello
            var filePath  = UriUtility.GetPath(val);
            var fragments = UriUtility.GetQueryStringAndFragment(val);
            var relPath   = RelativePath.TryParse(filePath);

            if (relPath != null)
            {
                var currentFile = (RelativePath)context.Model.OriginalFileAndType.File;
                relPath = (currentFile + relPath.UrlDecode()).GetPathFromWorkingFolder();
                if (_exportFileLink)
                {
                    ((Dictionary <string, List <LinkSourceInfo> >)context.Properties.FileLinkSources).AddFileLinkSource(new LinkSourceInfo
                    {
                        Target     = relPath,
                        Anchor     = UriUtility.GetFragment(val),
                        SourceFile = context.Model.OriginalFileAndType.File
                    });
                }

                if (_updateValue && context.BuildContext != null)
                {
                    var resolved = (RelativePath)context.BuildContext.GetFilePath(relPath);
                    if (resolved != null)
                    {
                        val = resolved.MakeRelativeTo(((RelativePath)context.Model.File).GetPathFromWorkingFolder()).UrlEncode() + fragments;
                    }
                }
            }

            return(val);
        }
示例#18
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            var val             = value;
            var tagInterpreters = _tagInterpreters.Where(s => schema.Tags.Contains(s.TagName, StringComparer.OrdinalIgnoreCase));

            foreach (var i in tagInterpreters)
            {
                val = i.Interpret(schema, val, context, path);
            }

            return(val);
        }
示例#19
0
文件: Merger.cs 项目: ws-tools/docfx
 private bool TestKey(object source, object overrides, BaseSchema schema)
 {
     if (overrides == null || overrides == null)
     {
         return(false);
     }
     return(schema?.Properties != null && schema.Properties.Any(p => p.Value.MergeType == MergeType.Key) && schema.Properties.Where(p => p.Value.MergeType == MergeType.Key).All(p =>
     {
         (source as IDictionary <string, object>).TryGetValue(p.Key, out var s);
         (overrides as IDictionary <string, object>).TryGetValue(p.Key, out var o);
         return object.Equals(s, o);
     }));
 }
示例#20
0
 /// <summary>
 /// Writes logical schema in JSON format
 /// </summary>
 /// <param name="writer">JSON writer</param>
 /// <param name="names">list of named schemas already written</param>
 /// <param name="encspace">enclosing namespace of the schema</param>
 protected internal override void WriteJson(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("type");
     BaseSchema.WriteJson(writer, names, encspace);
     writer.WritePropertyName("logicalType");
     writer.WriteValue(LogicalTypeName);
     if (null != Props)
     {
         Props.WriteJson(writer);
     }
     writer.WriteEndObject();
 }
示例#21
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value == null || !CanInterpret(schema))
            {
                return(value);
            }

            if (value is MarkdownDocument val)
            {
                return(MarkupCore(val, context, path));
            }

            return(_inner.Interpret(schema, value, context, path));
        }
示例#22
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value == null || !CanInterpret(schema))
            {
                return(value);
            }

            if (!(value is string val))
            {
                throw new ArgumentException($"{value.GetType()} is not supported type string.");
            }

            return(MarkupCore(val, context, path));
        }
示例#23
0
        private bool IsInternalXrefSpec(BaseSchema schema)
        {
            if (schema.Properties == null)
            {
                return(false);
            }

            if (schema.Properties.TryGetValue("uid", out var innerSchema) != true)
            {
                return(false);
            }

            return(innerSchema.ContentType == ContentType.Uid);
        }
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value is IDictionary <string, object> || value is IDictionary <object, object> || value is IList <object> )
            {
                return(value);
            }

            var markdownDocument = value as MarkdownDocument;

            if (markdownDocument != null && (schema?.ContentType != ContentType.Markdown))
            {
                Logger.LogWarning(
                    $"There is an invalid H2: `{markdownDocument.GetData(Constants.OPathStringDataName)}`: the contentType of this property in schema must be `markdown`",
                    line: markdownDocument.GetData(Constants.OPathLineNumberDataName)?.ToString(),
                    code: WarningCodes.Overwrite.InvalidMarkdownFragments);
                return(value);
            }

            if (schema == null)
            {
                return(value);
            }

            if (markdownDocument == null && schema.ContentType == ContentType.Markdown)
            {
                Logger.LogWarning(
                    $"Markdown property `{path.Trim('/')}` is not allowed inside a YAML code block",
                    code: WarningCodes.Overwrite.InvalidMarkdownFragments);
                return(value);
            }
            ;

            if (schema.MergeType == MergeType.Key)
            {
                return(value);
            }

            if (schema.IsLegalInFragments())
            {
                return(value);
            }

            // TODO: improve error message by including line number and OPathString for YAML code block
            Logger.LogWarning(
                $"You cannot overwrite a readonly property: `{path.Trim('/')}`, please add an `editable` tag on this property or mark its contentType as `markdown` in schema if you want to overwrite this property",
                code: WarningCodes.Overwrite.InvalidMarkdownFragments);

            return(value);
        }
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value == null || !CanInterpret(schema) || !(value is string val))
            {
                return(value);
            }

            // If *content is from an included file, it should be marked instead of consider it as a placeholder
            if ((schema == null || schema.Reference == ReferenceType.None) && context.ContentAnchorParser != null)
            {
                return(context.ContentAnchorParser.Parse(val));
            }

            return(_inner.Interpret(schema, value, context, path));
        }
示例#26
0
        /// <summary>
        /// Function to compare equality of two logical schemas
        /// </summary>
        /// <param name="obj">other logical schema</param>
        /// <returns>true if two schemas are equal, false otherwise</returns>
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (obj != null && obj is LogicalSchema that)
            {
                if (BaseSchema.Equals(that.BaseSchema))
                {
                    return(areEqual(that.Props, Props));
                }
            }
            return(false);
        }
示例#27
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (value == null || !CanInterpret(schema))
            {
                return(value);
            }

            if (!(value is string val))
            {
                throw new ArgumentException($"{value.GetType()} is not supported type string.");
            }

            var relPath = RelativePath.TryParse(val);

            if (relPath == null)
            {
                var message = $"{val} is not a valid relative file path that supported by contentType file ";
                Logger.LogError(message, code: ErrorCodes.Build.InvalidRelativePath);
                throw new DocumentException(message);
            }

            var originalFile = context.GetOriginalContentFile(path);

            var currentFile = (RelativePath)originalFile.File;

            relPath = (currentFile + relPath).GetPathFromWorkingFolder();
            if (_exportFileLink)
            {
                (context.FileLinkSources).AddFileLinkSource(new LinkSourceInfo
                {
                    Target     = relPath,
                    SourceFile = originalFile.File
                });
            }

            if (_updateValue && context.BuildContext != null)
            {
                var resolved = (RelativePath)context.BuildContext.GetFilePath(relPath);
                if (resolved != null)
                {
                    val = resolved.MakeRelativeTo(((RelativePath)context.FileAndType.File).GetPathFromWorkingFolder());
                }
            }

            return(val);
        }
示例#28
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (!CanInterpret(schema))
            {
                return(value);
            }
            var val = value;

            foreach (var tag in schema.Tags)
            {
                foreach (var i in _tagInterpreters.Where(t => t.Matches(tag)).OrderBy(t => t.Order))
                {
                    val = i.Interpret(tag, schema, val, context, path);
                }
            }

            return(val);
        }
示例#29
0
        /// <summary>
        /// Report xrefSpec when
        /// 1. ContentType = uid is defined => xref spec to be exported to xrefspec.yml
        /// Or 2. XrefResolver is defined => external xref spec
        /// </summary>
        /// <param name="schema"></param>
        /// <returns></returns>
        public bool CanInterpret(BaseSchema schema)
        {
            if (schema.XrefProperties != null)
            {
                return(true);
            }

            if (schema.Properties == null)
            {
                return(false);
            }

            if (schema.Properties.TryGetValue("uid", out var baseSchema))
            {
                return(baseSchema.ContentType == ContentType.Uid);
            }

            return(false);
        }
示例#30
0
        public object Interpret(BaseSchema schema, object value, IProcessContext context, string path)
        {
            if (!CanInterpret(schema) || value == null)
            {
                return(value);
            }

            if (!(value is string val))
            {
                throw new ArgumentException($"{value.GetType()} is not supported type string.");
            }

            AddUidLinkSource(context.Properties.UidLinkSources, new LinkSourceInfo
            {
                Target     = val,
                SourceFile = context.Model.OriginalFileAndType.File
            });

            return(value);
        }