static void Main() { TemplateSchema schema = TemplateSchema.FromDefaultUri(); var generator = new CSharpGenerator(schema); generator.Generate(); }
internal static TemplateToken Read( TemplateContext context, String type, IObjectReader objectReader, Int32?fileId, TemplateSchema schema, out Int32 bytes) { TemplateToken result = null; var reader = new TemplateReader(context, schema, objectReader, fileId); var originalBytes = context.Memory.CurrentBytes; try { objectReader.ValidateStart(); var definition = new DefinitionInfo(schema, type); result = reader.ReadValue(definition); objectReader.ValidateEnd(); } catch (Exception ex) { context.Error(fileId, null, null, ex); } finally { bytes = context.Memory.CurrentBytes - originalBytes; } return(result); }
public PipelineTemplateEvaluator( ITraceWriter trace, TemplateSchema schema) { if (!String.Equals(schema.Version, PipelineTemplateConstants.Workflow_1_0, StringComparison.Ordinal)) { throw new NotSupportedException($"Unexpected template schema version '{schema.Version}'"); } m_trace = trace; m_schema = schema; }
private TemplateReader( TemplateContext context, TemplateSchema schema, IObjectReader objectReader, Int32?fileId) { m_context = context; m_schema = schema; m_memory = context.Memory; m_objectReader = objectReader; m_fileId = fileId; }
public DefinitionInfo( TemplateSchema schema, String name) { m_schema = schema; // Lookup the definition Definition = m_schema.GetDefinition(name); // Record allowed context AllowedContext = Definition.ReaderContext; }
public TemplateSchema CreateSchema() { var assembly = Assembly.GetExecutingAssembly(); var json = default(String); using (var stream = assembly.GetManifestResourceStream("GitHub.DistributedTask.Pipelines.ObjectTemplating.workflow-v1.0.json")) using (var streamReader = new StreamReader(stream)) { json = streamReader.ReadToEnd(); } var objectReader = new JsonObjectReader(null, json); return(TemplateSchema.Load(objectReader)); }
public override void Initialize(IHostContext hostContext) { base.Initialize(hostContext); var assembly = Assembly.GetExecutingAssembly(); var json = default(string); using (var stream = assembly.GetManifestResourceStream("GitHub.Runner.Worker.action_yaml.json")) using (var streamReader = new StreamReader(stream)) { json = streamReader.ReadToEnd(); } var objectReader = new JsonObjectReader(null, json); _actionManifestSchema = TemplateSchema.Load(objectReader); ArgUtil.NotNull(_actionManifestSchema, nameof(_actionManifestSchema)); Trace.Info($"Load schema file with definitions: {StringUtil.ConvertToJson(_actionManifestSchema.Definitions.Keys)}"); }
public DefinitionInfo( TemplateSchema schema, String name) { m_schema = schema; // Lookup the definition Definition = m_schema.GetDefinition(name); // Determine whether to expand if (Definition.Context.Length > 0) { AllowedContext = Definition.Context; } else { AllowedContext = new String[0]; } }
public static TemplateSchema GetSchema() { if (s_schema == null) { var assembly = Assembly.GetExecutingAssembly(); var json = default(String); using (var stream = assembly.GetManifestResourceStream("GitHub.DistributedTask.Pipelines.ObjectTemplating.workflow-v1.0.json")) using (var streamReader = new StreamReader(stream)) { json = streamReader.ReadToEnd(); } var objectReader = new JsonObjectReader(null, json); var schema = TemplateSchema.Load(objectReader); Interlocked.CompareExchange(ref s_schema, schema, null); } return(s_schema); }
public DefinitionInfo( TemplateSchema schema, String name, HashSet <String> availableContext) { m_schema = schema; m_availableContext = availableContext; // Lookup the definition Definition = m_schema.GetDefinition(name); // Determine whether to expand m_allowedContext = Definition.EvaluatorContext; if (Definition.EvaluatorContext.Length > 0) { Expand = m_availableContext.IsSupersetOf(m_allowedContext); } else { Expand = false; } }
public CSharpGenerator(TemplateSchema schema, string outputDir = null) : base(schema, outputDir) { }