protected override IViewModelData BuildModelData(object value, IFieldData field, ITemplateData template) { return Dependencies.DataFactory.GetModelData( (IFieldSet)value, field.EmbeddedSchema.BaseData as ISchema, //Assuming it's DD4T implemented template.BaseData as IComponentTemplate); }
public string Run(Template template, ITemplateData data) { var sw = new StringWriter(); Run(template, data, sw); return(sw.ToString()); }
public Dynamic.IComponentPresentation BuildComponentPresentation(IComponentData component, ITemplateData componentTemplate) { return new Dynamic.ComponentPresentation //Locking in to default DD4T implementation { Component = component.BaseData as Dynamic.Component, //Assuming default DD4T implementation ComponentTemplate = componentTemplate.BaseData as Dynamic.ComponentTemplate //Assuming default DD4T implementation }; }
//public RichTextFieldAttribute(string fieldName) : base(fieldName) { } public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory) { return field.Values.Cast<string>() .Select(v => v.ResolveRichText()); //Hidden dependency on DD4T implementation }
private static string GetParentSuffix(ITemplateData currTemplate) { string suffix = currTemplate.GetSetting(CommonVariables.ParentSuffix); if (suffix == null) suffix = currTemplate.GetVariable(CommonVariables.ParentSuffix); if (suffix == null) suffix = "Parent"; return suffix; }
public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory) { IEnumerable result = null; if (component != null && component.MultimediaData != null) { result = new string[] { component.MultimediaData.Url }; } return result; }
public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory) { return component == null ? null : new string[] { component.Title }; }
public HomeController(ITemplateData data) : base(data) { }
/// <summary> /// The Key of a Keyword field. /// </summary> /// <param name="fieldName">Tridion schema field name</param> //public KeywordKeyFieldAttribute(string fieldName) : base(fieldName) { } public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory) { IEnumerable value = null; var values = field.Values.Cast<Dynamic.IKeyword>(); if (IsBooleanValue) value = values.Select(k => { bool b; return bool.TryParse(k.Key, out b) && b; }); else value = values.Select(k => k.Key); return value; }
/// <summary> /// When overriden in a derived class, this gets the value of the Property for a given Component Template /// </summary> /// <param name="template">Component Template for the View Model</param> /// <param name="propertyType">Actual return type for the Property</param> /// <param name="factory">View Model factory</param> /// <returns>The Property value</returns> public abstract object GetPropertyValues(ITemplateData template, Type propertyType, IViewModelFactory factory);
protected override IViewModelData BuildModelData(object value, IFieldData field, ITemplateData template) { var keyword = (IKeyword)value; var categoryName = (field.BaseData as IField).CategoryName; return Dependencies.DataFactory.GetModelData(keyword, categoryName); }
public ComponentPresentation(IComponentData component, ITemplateData template) { this.component = component; this.template = template; this.cp = Helper.BuildComponentPresentation(component.BaseData as IComponent, template.BaseData as IComponentTemplate); }
public ContentPresentationData(IFieldsData content, ISchemaData schema, ITemplateData template) { this.content = content; this.schema = schema; this.template = template; publicationId = template.PublicationId; }
public ComponentPresentation(IComponent component, IComponentTemplate template) { this.cp = Helper.BuildComponentPresentation(component, template); //Helps get around naming conflicts this.component = new Component(component); this.template = new ComponentTemplate(template); }
public ComponentPresentation(IComponentPresentation cp) { this.cp = cp; component = new Component(cp.Component); template = new ComponentTemplate(cp.ComponentTemplate); }
internal static string GetClassPrefix(string tableName, ITemplateData currTemplate) { string className = ClassItemTemplate.GenerateClassName(tableName); if (currTemplate != null) { string suffixReplacementMap = currTemplate.GetVariable(SuffixReplacementMapVariableName); if (!string.IsNullOrEmpty(suffixReplacementMap)) className = TextUtil.ReplaceSuffixes(className, suffixReplacementMap); } return className; }
protected override IViewModelData BuildModelData(object value, IFieldData field, ITemplateData template) { var component = (IComponent)value; var componentData = Dependencies.DataFactory.GetModelData(component); return Dependencies.DataFactory.GetModelData( Dependencies.DD4TFactory.BuildComponentPresentation(componentData, template)); }
/// <summary> /// When overriden in a derived class, this method should return the value of the View Model property from a Field object /// </summary> /// <param name="field">The Field</param> /// <param name="propertyType">The concrete type of the view model property for this attribute</param> /// <param name="template">The Component Template to use</param> /// <param name="factory">The View Model Builder</param> /// <returns></returns> public abstract IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template,IViewModelFactory factory = null);
private DigitAndDigitRectangle SearchImageForDigit(Image <Bgr, byte> imageToSearch, Image <Bgr, byte> searchTemplate, ITemplateData templateData) { int numberToSearchFor = templateData.NumberValue; using (Image <Gray, float> result = imageToSearch.MatchTemplate(searchTemplate, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed)) { double[] minValues, maxValues; Point[] minLocations, maxLocations; result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations); // You can try different values of the threshold. I guess somewhere between 0.75 and 0.95 would be good. if (maxValues[0] > 0.92) { // This is a match. Do something with it, for example draw a rectangle around it. Rectangle match = new Rectangle(maxLocations[0], searchTemplate.Size); for (int i = searchTemplate.Size.Width; i > 1; i--) { match = new Rectangle(maxLocations[0].X + 5, maxLocations[0].Y, searchTemplate.Size.Width - (10 + i), searchTemplate.Size.Height); imageToSearch.Draw(match, new Bgr(Color.Gray), 3); } return(new DigitAndDigitRectangle() { FoundRectangle = match, ResultImage = imageToSearch, FoundInteger = numberToSearchFor, DigitImageName = templateData.TemplatePath }); } } return(null); }
public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template,IViewModelFactory factory = null) { IEnumerable fieldValue = null; var values = GetRawValues(field); if (values != null) { if (ComplexTypeMapping == null && ReturnRawData) fieldValue = values; else fieldValue = values.Cast<object>() .Select(value => BuildModel(factory, BuildModelData(value, field, template))) .Where(value => value != null); } return fieldValue; }
protected BaseController(ITemplateData data) { this.Data = data; }
protected abstract IViewModelData BuildModelData(object value, IFieldData field, ITemplateData template);
public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory) { var result = new List<object>(); foreach (var value in field.Values) { object parsed; if (EnumTryParse(property.ModelType, value, out parsed)) { result.Add(parsed); } } return result; }
/// <summary> /// When overriden in a derived class, this gets the value of the Property for a given Component /// </summary> /// <param name="component">Component for the View Model</param> /// <param name="propertyType">Actual return type for the Property</param> /// <param name="template">Component Template</param> /// <param name="factory">View Model factory</param> /// <returns>The Property value</returns> public abstract IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory);
public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory) { IMultimediaData result = null; if (component != null && component.MultimediaData != null) { result = component.MultimediaData; } return new IMultimediaData[] { result }; }
public string Run(string template, ITemplateData data) { return(Run(new Template(template), data)); }
//public NumericKeywordKeyFieldAttribute(string fieldName) : base(fieldName) { } public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory) { return field.Values.Cast<Dynamic.IKeyword>() .Select(k => { double i; double.TryParse(k.Key, out i); return i; }); }
//public DateFieldAttribute(string fieldName) : base(fieldName) { } public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory) { return field.Values.Cast<DateTime>(); }
//public ResolvedUrlFieldAttribute(string fieldName) : base(fieldName) { } public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory) { return field.Values.Cast<Dynamic.IComponent>() .Select(x => x.GetResolvedUrl()); }
private IEnumerable <DigitAndDigitRectangle> FindDigit(Image <Bgr, byte> source, ITemplateData digitTemplateInfo) { if (!File.Exists(digitTemplateInfo.TemplatePath)) { return(null); } Image <Bgr, byte> template = new Image <Bgr, byte>(digitTemplateInfo.TemplatePath); var foundRectanglesList = new List <Rectangle>(); var foundResultsList = new List <DigitAndDigitRectangle>(); DigitAndDigitRectangle findResult = new DigitAndDigitRectangle() { ResultImage = source }; do { findResult = SearchImageForDigit(findResult.ResultImage, template, digitTemplateInfo); if (findResult != null) { foundRectanglesList.Add(findResult.FoundRectangle); foundResultsList.Add(findResult); } } while (findResult != null); return(foundResultsList); }
public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory) { IEnumerable fieldValue = null; var values = field.Values.Cast<string>(); if (IsBooleanValue) fieldValue = values.Select(v => { bool b; return bool.TryParse(v, out b) && b; }); else fieldValue = values; return fieldValue; }
private static string GetRecursiveParentSuffix(ITemplateData currTemplate) { string suffix = currTemplate.GetSetting(CommonVariables.RecursiveParentSuffix); if (suffix == null) suffix = currTemplate.GetVariable(CommonVariables.RecursiveParentSuffix); if (suffix == null) suffix = "Superior"; return suffix; }
//Example of using the BaseData object public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory) { Dynamic.IMultimedia[] result = null; if (component != null && component.MultimediaData != null) { result = new Dynamic.IMultimedia[] { component.MultimediaData.BaseData as Dynamic.IMultimedia }; } return result; }
public void Run(Template template, ITemplateData data, TextWriter writer) { Run(template, (object)data, writer); }