public void DataProvider_ListMetadataFormats() { string expected = $@"{_xmlRoot} {_oaiPmhRoot} <responseDate>2018-05-08T11:05:00Z</responseDate> <request verb=""ListMetadataFormats"">{_baseUrl}</request> <ListMetadataFormats> <metadataFormat> <metadataPrefix>oai_dc</metadataPrefix> <schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema> <metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace> </metadataFormat> <metadataFormat> <metadataPrefix>rdf</metadataPrefix> <schema>http://www.openarchives.org/OAI/2.0/rdf.xsd</schema> <metadataNamespace>http://www.w3.org/1999/02/22-rdf-syntax-ns#</metadataNamespace> </metadataFormat> </ListMetadataFormats> </OAI-PMH>"; var arguments = new ArgumentContainer(OaiVerb.ListMetadataFormats.ToString()); var actual = _dataProvider.ToString(new DateTime(2018, 5, 8, 11, 5, 0, DateTimeKind.Utc), arguments); Assert.AreEqual(expected, actual); }
protected override Task <ArgumentParseResult> ParseArgumentsGuildAsync(IGuildCommandContext context) { ArgumentContainer argOut = new ArgumentContainer(); if (!ArgumentParsing.TryParseGuildTextChannel(context, context.Arguments.First, out argOut.channel)) { return(Task.FromResult(new ArgumentParseResult(Arguments[0], "Failed to parse to a guild text channel!"))); } if (context.Message.Content.Length > Identifier.Length + context.Arguments.First.Length + 2) { context.Arguments.Index++; string embedText = context.RemoveArgumentsFront(1).Replace("[3`]", "```"); if (JSONContainer.TryParse(embedText, out JSONContainer json, out string errormessage)) { if (EmbedHelper.TryGetMessageFromJSONObject(json, out argOut.embed, out argOut.messageContent, out string error)) { return(Task.FromResult(new ArgumentParseResult(argOut))); } else { return(Task.FromResult(new ArgumentParseResult(Arguments[1], error))); } } else { return(Task.FromResult(new ArgumentParseResult(Arguments[1], $"Unable to parse JSON text to a json data structure! Error: `{errormessage}`"))); } }
protected IEnumerator Say(Expression e, float time) { // TODO: figure this stuff out // var eWithoutParameters = new Container<Expression>(null); // Agent.MentalState.StartCoroutine(Agent.MentalState.ReplaceParameters(e, eWithoutParameters)); // while (eWithoutParameters.Item == null) { // yield return null; // } // GameObject eContainer = ArgumentContainer.From(eWithoutParameters.Item); var eContainer = ArgumentContainer.From(e); ArgumentContainer eContainerScript = eContainer.GetComponent <ArgumentContainer>(); eContainerScript.GenerateVisual(); var display = Agent.gameObject.transform.Find("Display"); eContainer.transform.position = display.position; eContainer.transform.rotation = display.rotation; eContainer.transform.localScale *= 0.5f; eContainer.transform.SetParent(display); yield return(new WaitForSeconds(time)); Destroy(eContainer); yield break; }
public void DataProvider_GetRecord() { string expected = $@"{_xmlRoot} {_oaiPmhRoot} <responseDate>2018-05-08T11:05:00Z</responseDate> <request verb=""GetRecord"" identifier=""12"" metadataPrefix=""oai_dc"">http://localhost/test</request> <GetRecord> <record> <header> <identifier>12</identifier> <datestamp>2018-02-16T02:00:00Z</datestamp> </header> <metadata> {_oaiDcRoot} <dc:title>Title 2</dc:title> <dc:creator>Owner 2</dc:creator> <dc:date>2018-02-16T02:00:00Z</dc:date> <dc:identifier>12</dc:identifier> </oai_dc:dc> </metadata> </record> </GetRecord> </OAI-PMH>"; var arguments = new ArgumentContainer(OaiVerb.GetRecord.ToString(), "oai_dc", string.Empty, "12"); var actual = _dataProvider.ToString(new DateTime(2018, 5, 8, 11, 5, 0, DateTimeKind.Utc), arguments); Assert.AreEqual(expected, actual); }
public override IElement Action(ArgumentContainer Args) { // let's assume that all parameters are collections of the form: // [condition-expr then-expr] foreach (var param in Args.GetRawRestArguments().Value) { if (param is Collection cond) { var values = cond.GetInnerValues(); if (values.Count == 2) { var testResult = Interpreter.VisitAndGetResult(values.First()); if (testResult is TrueFalse tf) { if (tf.Value == true) { return(Interpreter.VisitAndGetResult(values.Skip(1).First())); } // else move on to the next pair } else { throw new TypeException("Returned value to IF was not a boolean value!"); } } else { throw new TypeException("IF must recieve collections with exactly 2 items in each"); } } } return(new Noop()); }
public void Video_Duration() { var video = VideoInfo.FromFileInfo(VideoLibrary.LocalVideo); var output = Input.OutputLocation(VideoType.Mp4); var arguments = new ArgumentContainer(); arguments.Add(new InputArgument(VideoLibrary.LocalVideo)); arguments.Add(new DurationArgument(TimeSpan.FromSeconds(video.Duration.TotalSeconds - 5))); arguments.Add(new OutputArgument(output)); try { Encoder.Convert(arguments); Assert.IsTrue(File.Exists(output.FullName)); var outputVideo = new VideoInfo(output.FullName); Assert.AreEqual(video.Duration.Days, outputVideo.Duration.Days); Assert.AreEqual(video.Duration.Hours, outputVideo.Duration.Hours); Assert.AreEqual(video.Duration.Minutes, outputVideo.Duration.Minutes); Assert.AreEqual(video.Duration.Seconds - 5, outputVideo.Duration.Seconds); } finally { if (File.Exists(output.FullName)) { output.Delete(); } } }
public IElement OnAction(List <IElement> Arguments) { var args = new ArgumentContainer(); args.InputSignature(cachedSignature, Arguments); return(Action(args)); }
/// <summary> /// Transforms the provided OAI-PMH arguments to an XML document. /// </summary> /// <param name="date">The date to be included in the response.</param> /// <param name="arguments">The OAI-PMH arguments.</param> /// <returns>The transformed OAI-PMH arguments as an XML document.</returns> public XDocument ToXDocument(DateTime date, ArgumentContainer arguments) { if (Enum.TryParse(arguments.Verb, out OaiVerb parsedVerb)) { switch (parsedVerb) { case OaiVerb.Identify: return(CreateIdentify(date, arguments)); case OaiVerb.ListMetadataFormats: return(CreateListMetadataFormats(date, arguments)); case OaiVerb.ListRecords: return(CreateListIdentifiersOrRecords(date, arguments, parsedVerb)); case OaiVerb.ListIdentifiers: return(CreateListIdentifiersOrRecords(date, arguments, parsedVerb)); case OaiVerb.GetRecord: return(CreateGetRecord(date, arguments)); case OaiVerb.ListSets: return(CreateListSets(date, arguments)); case OaiVerb.None: default: return(CreateErrorDocument(date, OaiVerb.None, arguments, OaiErrors.BadVerb)); } } else { return(CreateErrorDocument(date, OaiVerb.None, arguments, OaiErrors.BadVerb)); } }
public void Video_ToMP4_Args() { var container = new ArgumentContainer(); container.Add(new VideoCodecArgument(VideoCodec.LibX264)); Convert(VideoType.Mp4, container); }
/// <summary> /// Obtiene los records del repositorio en función de los argumentos pasados /// </summary> /// <param name="arguments">Parámetros de la consulta</param> /// <param name="resumptionToken">Token de reanudación</param> /// <returns></returns> public RecordContainer GetRecords(ArgumentContainer arguments, IResumptionToken resumptionToken = null) { RecordContainer container = new RecordContainer(); DateTime inicio = DateTime.MinValue; if (_dateConverter.TryDecode(arguments.From, out DateTime from)) { inicio = from; } HashSet <string> ids = GetCurriculumsIDs(inicio, _configOAI_PMH_CVN.GetXML_CVN_Repository()); List <CVN> listCVN = new List <CVN>(); foreach (string id in ids) { DateTime date = DateTime.UtcNow.AddDays(-100 + int.Parse(id)); if (date > inicio) { listCVN.Add(GetCurriculum(id, arguments.Verb == OaiVerb.ListIdentifiers.ToString(), _configOAI_PMH_CVN.GetXML_CVN_Repository())); } } if (arguments.Verb == OaiVerb.ListIdentifiers.ToString()) { container.Records = listCVN.Select(r => ToIdentifiersRecord(r)); } else { container.Records = listCVN.Select(r => ToRecord(r, arguments.MetadataPrefix)); } container.Records = container.Records.Where(x => x.Header.Datestamp > inicio).ToList(); return(container); }
/// <summary> /// split video by time lines in Dir /// </summary> /// <param name="timeLines">time lines</param> public void Split(TimeLineVolume[] timeLines) { char sep = Path.DirectorySeparatorChar; FFMpeg ffmpeg = new FFMpeg(); for (int i = 0; i < timeLines.Length; i++) { ArgumentContainer container = new ArgumentContainer(); // input arg container.Add(new InputArgument(Source)); // split arg container.Add(new SplitArgument(timeLines[i])); // output path VideoPartInfo partInfo = new VideoPartInfo() { IsNoise = timeLines[i].Volume == VolumeValue.Noise ? true: false, Name = "videoPart", FileExtension = SourceExtension, Number = i, }; string outputPath = $"{Dir.FullName}{sep}{partInfo.FullName}"; container.Add(new OutputArgument(outputPath)); // convert ffmpeg.Convert(container); } }
public FileResult Get(OaiVerb verb, string identifier = "", string metadataPrefix = "", string from = "", string until = "", string set = "", string resumptionToken = "") { //CONFIG OAI-PMH _configOAI.BaseUrl = () => { Uri baseUri = new Uri(_configOAI_PMH_CVN.GetConfigUrl()); return(baseUri.AbsoluteUri); }; //MetadataFormatRepository MetadataFormatRepository metadataFormatRepository = new MetadataFormatRepository(); RecordRepository recordRepository = new RecordRepository(_configOAI, _configOAI_PMH_CVN); //SetRepository SetRepository setRepository = new SetRepository(_configOAI); DataProvider provider = new DataProvider(_configOAI, metadataFormatRepository, recordRepository, setRepository); ArgumentContainer arguments = new ArgumentContainer(verb.ToString(), metadataPrefix, resumptionToken, identifier, from, until, set); XDocument document = provider.ToXDocument(DateTime.Now.AddMinutes(100), arguments); var memoryStream = new MemoryStream(); var xmlWriter = XmlWriter.Create(memoryStream); document.WriteTo(xmlWriter); xmlWriter.Flush(); byte[] array = memoryStream.ToArray(); return(File(array, "application/xml")); }
public void Video_UpdatesProgress() { var output = Input.OutputLocation(VideoType.Mp4); var percentageDone = 0.0; void OnProgess(double percentage) => percentageDone = percentage; Encoder.OnProgress += OnProgess; var arguments = new ArgumentContainer { new InputArgument(VideoLibrary.LocalVideo), new DurationArgument(TimeSpan.FromSeconds(8)), new OutputArgument(output) }; try { Encoder.Convert(arguments); Encoder.OnProgress -= OnProgess; Assert.IsTrue(File.Exists(output.FullName)); Assert.AreNotEqual(0.0, percentageDone); } finally { if (File.Exists(output.FullName)) { output.Delete(); } } }
public void Video_ToOGV_Resize_Args() { var container = new ArgumentContainer(); container.Add(new ScaleArgument(VideoSize.Ed)); container.Add(new VideoCodecArgument(VideoCodec.LibTheora)); Convert(VideoType.Ogv, container); }
/// <summary> /// Obtiene los sets del repositorio en función de los argumentos pasados /// </summary> /// <param name="arguments">Parámetros de la consulta</param> /// <param name="resumptionToken">Token de reanudación</param> /// <returns></returns> public SetContainer GetSets(ArgumentContainer arguments, IResumptionToken resumptionToken = null) { SetContainer container = new SetContainer(); IQueryable<Set> sets = _sets.AsQueryable().OrderBy(s => s.Name); int totalCount = sets.Count(); container.Sets = sets.Take(_configuration.PageSize); return container; }
public override IElement Action(ArgumentContainer Args) { var joining = Args.GetVisitedArgumentAs <Str>("separator"); var list = Args.GetVisitedArgumentAs <Collection>("alist"); var items = list.Value.Select(item => item.Repr()); return(new Str().Initialize(String.Join(joining.Value, items))); }
private static List <T> ArgumentContainerToList <T>(ArgumentContainer <string, object> argumentList, string itemName) { if (!argumentList.ContainsKey(itemName)) { return(new List <T>()); } return(ArrayOrItemToList <T>(argumentList[itemName])); }
private XDocument CreateErrorDocument(DateTime date, OaiVerb verb, ArgumentContainer arguments, XElement error) { IList <XElement> root = new List <XElement>(); root.Add(CreateRequest(verb, arguments)); root.Add(error); return(CreateXml(date, root.ToArray())); }
public void Video_ToTS_Args() { var container = new ArgumentContainer(); container.Add(new CopyArgument()); container.Add(new BitStreamFilterArgument(Channel.Video, Filter.H264_Mp4ToAnnexB)); container.Add(new ForceFormatArgument(VideoCodec.MpegTs)); Convert(VideoType.Ts, container); }
public void Video_ToMP4_Resize_Args() { var container = new ArgumentContainer { new ScaleArgument(VideoSize.Ld), new VideoCodecArgument(VideoCodec.LibX264) }; Convert(VideoType.Mp4, container); }
GameObject SpawnArgumentContainer(Expression e, Vector3 pos, Quaternion rot) { var argContainer = ArgumentContainer.From(e); argContainer.GetComponent <ArgumentContainer>().GenerateVisual(); argContainer.transform.position = pos; argContainer.transform.rotation = rot; return(argContainer); }
public void Convert(VideoType type, ArgumentContainer container) { var output = Input.OutputLocation(type); try { var input = VideoInfo.FromFileInfo(Input); var arguments = new ArgumentContainer { new InputArgument(input) }; foreach (var arg in container) { arguments.Add(arg.Value); } arguments.Add(new OutputArgument(output)); var scaling = container.Find <ScaleArgument>(); Encoder.Convert(arguments); var outputVideo = new VideoInfo(output.FullName); Assert.IsTrue(File.Exists(output.FullName)); Assert.AreEqual(outputVideo.Duration, input.Duration); if (scaling == null) { Assert.AreEqual(outputVideo.Width, input.Width); Assert.AreEqual(outputVideo.Height, input.Height); } else { if (scaling.Value.Width != -1) { Assert.AreEqual(outputVideo.Width, scaling.Value.Width); } if (scaling.Value.Height != -1) { Assert.AreEqual(outputVideo.Height, scaling.Value.Height); } Assert.AreNotEqual(outputVideo.Width, input.Width); Assert.AreNotEqual(outputVideo.Height, input.Height); } } finally { if (File.Exists(output.FullName)) { File.Delete(output.FullName); } } }
protected override async Task ExecuteGuild(IGuildCommandContext context, object argObj) { ArgumentContainer args = argObj as ArgumentContainer; GuildModerationLog guildModerationLog = GuildModerationLog.GetOrCreateGuildModerationLog(context.Guild.Id); UserModerationLog userModerationLog = guildModerationLog.GetOrCreateUserModerationLog(args.UserId); UserModerationEntry moderationEntry = new UserModerationEntry(context.Guild.Id, ModerationType.Note, null, context.GuildUser, args.Note); await userModerationLog.AddModerationEntry(moderationEntry); await context.Channel.SendEmbedAsync($"Added Note `{args.Note}` to modlogs for {(args.TargetUser == null ? Markdown.InlineCodeBlock(args.UserId.ToString()) : args.TargetUser.Mention)}"); }
public override IElement Action(ArgumentContainer Args) { var args = Args.GetVisitedRestArguments(); InnerScope.NewDynamicScope(); InnerScope.AddNamesToDynamicScope(OnEnterBlock(args.Value)); var bodyResult = Interpreter.VisitAndGetResult(Body); InnerScope.PopDynamicScope(); return(bodyResult); }
public void Builder_BuildString_Concat() { var container = new ArgumentContainer(); container.Add(new ConcatArgument(concatFiles)); container.Add(new OutputArgument("output.mp4")); var str = builder.BuildArguments(container); Assert.AreEqual(str, "-i \"concat:1.mp4|2.mp4|3.mp4|4.mp4\" \"output.mp4\""); }
bool IsMessageYoungEnough(IMessage message, ArgumentContainer args) { if (args.End == EndMode.Time || args.End == EndMode.TimeRelative) { return(message.CreatedAt > args.DeleteAfter); } else { return(args.RemoveCount > 0); } }
private void ButInsertAfter_Click(System.Object sender, System.EventArgs e) { if (IsFormComplete) { ArgumentContainer.Insert(ArgumentContainer.IndexOf(SelectedArgument.Value) + 1, new CustomAttributeNamedArgument(ItemName.Text, AttributeArgumentEditor.SelectedArgument)); DialogResult = DialogResult.OK; } else { DialogResult = DialogResult.None; } }
private XDocument CreateIdentify(DateTime date, ArgumentContainer arguments) { OaiVerb verb = OaiVerb.Identify; OaiArgument allowedArguments = OaiArgument.None; if (!OaiErrors.ValidateArguments(arguments, allowedArguments, out XElement errorElement)) { return(CreateErrorDocument(date, verb, arguments, errorElement)); } IList <XElement> root = new List <XElement>(); root.Add(CreateRequest(verb, arguments)); XElement content = new XElement(verb.ToString()); root.Add(content); TryAddXElement(content, "repositoryName", _configuration.RepositoryName); TryAddXElement(content, "baseURL", _configuration.BaseUrl()); TryAddXElement(content, "protocolVersion", _configuration.ProtocolVersion); if (_configuration.AdminEmails != null) { foreach (var adminEmail in _configuration.AdminEmails) { TryAddXElement(content, "adminEmail", adminEmail); } } TryAddXElement(content, "earliestDatestamp", _configuration.EarliestDatestamp); TryAddXElement(content, "deletedRecord", _configuration.DeletedRecord); TryAddXElement(content, "granularity", GetDisplayGranularity()); if (_configuration.Compressions != null) { foreach (var compression in _configuration.Compressions) { TryAddXElement(content, "compression", compression); } } if (_configuration.Descriptions != null) { foreach (var description in _configuration.Descriptions) { TryAddXElement(content, "description", description); } } return(CreateXml(date, root.ToArray())); }
private void ButAppend_Click(object sender, EventArgs e) { if (IsFormComplete) { ArgumentContainer.Add(new CustomAttributeNamedArgument(ItemName.Text, AttributeArgumentEditor.SelectedArgument)); DialogResult = DialogResult.OK; } else { DialogResult = DialogResult.None; } }
public VideoInfo Convert(ArgumentContainer arguments) { var args = ArgumentBuilder.BuildArguments(arguments); var output = ((OutputArgument)arguments[typeof(OutputArgument)]).GetAsFileInfo(); if (!RunProcess(arguments, output)) { throw new FFMpegException(FFMpegExceptionType.Operation, "Could not replace the video audio."); } return(new VideoInfo(output)); }