public void It_allows_you_to_look_up_template_definitions_by_name() { var section = new Section("foo"); var templateDefinition = new TemplateDefinition("bar"); section.Add(templateDefinition); var actual = section.GetTemplateDefinition(templateDefinition.Name); Assert.AreSame(templateDefinition, actual); }
public void It_renders_its_child_parts() { var a = new TemplateDefinition("a"); a.Load(new Part[] { new LiteralText("b") }); var writer = new StringWriter(); var context = new RenderContext(new Template(), null, writer, null); a.Render(context); Assert.AreEqual("b", writer.GetStringBuilder().ToString()); }
public SpriteCompositeTemplate AddTemplate(SpriteTransform transform, ISpriteTemplate template) { var def = new TemplateDefinition { Template = template, Transform = transform }; this.templateDefinitions.Add(def); return this; }
protected void OnAddSubColumn(object sender, CommandEventArgs e) { if (Parent is Tab) { PortalDefinition pd = PortalDefinition.Load(); PortalDefinition.Column _objCurrentColumn = pd.GetColumn(e.CommandArgument.ToString()); if (_objCurrentColumn != null) { PortalDefinition.Column _objNewColumn = PortalDefinition.Column.Create(_objCurrentColumn); _objCurrentColumn.Columns.Add(_objNewColumn); pd.Save(); if (AddSubColumn != null) { AddSubColumn(this, _objNewColumn); } } } else if (Parent is Template) { TemplateDefinition td = TemplateDefinition.Load(); PortalDefinition.Column _objCurrentColumn = td.GetColumn(e.CommandArgument.ToString()); if (_objCurrentColumn != null) { PortalDefinition.Column _objNewColumn = PortalDefinition.Column.Create(_objCurrentColumn); _objCurrentColumn.Columns.Add(_objNewColumn); td.Save(); if (AddSubColumn != null) { AddSubColumn(this, _objNewColumn); } } } }
private void populateTheme() { shopScroller.ClearScroller(); Dictionary <int, TemplateDefinition> dictionary = Service.Get <GameData>().Get <Dictionary <int, TemplateDefinition> >(); shopScroller.filteredItems = new List <CatalogItemData>(); if (subNavCategory != "All" && navCategory == CatalogShopNavEnum.RECENT) { for (int i = 0; i < shopScroller.items.Count; i++) { int definitionId = shopScroller.items[i].equipment.definitionId; TemplateDefinition templateDefinition = dictionary.Values.ToList().First((TemplateDefinition x) => x.Id == definitionId); if (templateDefinition != null && templateDefinition.CategoryKey.Key.Equals(subNavCategory)) { shopScroller.filteredItems.Add(shopScroller.items[i]); } } } else { shopScroller.filteredItems = shopScroller.items; } shopScroller.GenerateScrollData(shopScroller.filteredItems); shopScroller.lastNumShopRows = shopScroller.numShopRows; if (shopScroller.items == null || shopScroller.items.Count == 0) { Service.Get <ICPSwrveService>().Action("clothing_catalog_challenge", "no_submissions"); NoSubmissions.SetActive(value: true); return; } NoSubmissions.SetActive(value: false); shopScroller.isShopScrollInitialized = true; for (int i = 0; i < shopScroller.numShopRows; i++) { shopScroller.Scroller.AddElement(1); } }
internal void Load(string path) { if (Document != null) { Document.RemoveAll(); Document = null; TemplateSelector.ClearTemplates(); } Document = new XmlDocument(); Document.Load(path); XmlNodeList blockList = Document.GetElementsByTagName("blocks"); BlockManager = new BlockManager(RootPath); foreach (XmlNode block in blockList[0]) { if (block.Name != "block") { continue; } BlockDefinition blockDef = ProxyDeserializer.DeserializeBlock(BlockManager, block); BlockManager.AddBlock(blockDef); } XmlNodeList templateList = Document.GetElementsByTagName("template"); foreach (XmlNode template in templateList) { if (template.Name != "template") { continue; } TemplateDefinition templateDef = ProxyDeserializer.DeserializeTemplate(template); templateDef.rootPath = RootPath; TemplateSelector.AddTemplate(templateDef); } }
public void FilterTemplateByType(string templateType) { TemplateDefinition td = TemplateDefinition.Load(); CurrentTemplateType = templateType; if (templateType == "") // Don't filter { //Hidden TabEdit and TemplateEdit when Load first time TemplateCtrl.Visible = false; TemplateListCtrl.Visible = true; //Load data to TemplateList TemplateListCtrl.LoadData(td); } else { //Hidden TabEdit and TemplateEdit when Load first time TemplateCtrl.Visible = false; TemplateListCtrl.Visible = true; //Load data to TemplateList TemplateListCtrl.LoadData(td, templateType); } }
private LinkButton CreateButton(Control container, TemplateDefinition template) { var button = new LinkButton { ID = "iel" + ID + "_" + template.Definition.GetDiscriminatorWithTemplateKey().Replace('/', '_'), Text = string.IsNullOrEmpty(template.Definition.IconUrl) ? string.Format("<b class='{0}'></b> {1}", template.Definition.IconClass, template.Definition.Title) : string.Format("<img src='{0}' alt='ico'/>{1}", template.Definition.IconUrl, template.Definition.Title), ToolTip = template.Definition.ToolTip, CausesValidation = false, CssClass = "addButton" }; var closureDefinition = template.Definition; button.Command += (s, a) => { ContentItem item = CreateItem(closureDefinition); item.ZoneName = ZoneName; AddedDefinitions.Add(closureDefinition.GetDiscriminatorWithTemplateKey()); CreateItemEditor(item); }; container.Controls.Add(button); return(button); }
public virtual object VisitTemplateDefinition(TemplateDefinition templateDefinition, object data) { throw new global::System.NotImplementedException("TemplateDefinition"); }
public ProxyTemplateItemModel() { _def = new TemplateDefinition(); }
protected virtual async Task <string> GetContentOrNullAsync(TemplateDefinition templateDefinition) { return(await TemplateContentProvider.GetContentOrNullAsync(templateDefinition)); }
private TemplateDefinition CreateTemplateDefinition(Template template) { var friendlyName = template.Name.Replace("'", "_").Replace(" ", "_"); TemplateDefinition templateDef = new TemplateDefinition(); templateDef.context = new context(); templateDef.context.path = template.PrimaryContext; templateDef.name = friendlyName.Length > 80 ? friendlyName.Substring(0, 80) : friendlyName; templateDef.isClosed = !template.IsOpen; templateDef.id = template.Oid; // Get the actual identifier if (template.IsIdentifierOID()) { string oid; template.GetIdentifierOID(out oid); templateDef.id = oid; } else if (template.IsIdentifierII()) { string oid, ext; DateTime extDate; template.GetIdentifierII(out oid, out ext); templateDef.id = oid; templateDef.versionLabel = ext; if (DateTime.TryParse(ext, out extDate)) { templateDef.effectiveDate = extDate; templateDef.effectiveDateSpecified = true; } } // template type TemplateProperties property = new TemplateProperties(); templateDef.classification = new TemplateProperties[] { property }; if (template.PrimaryContextType.ToLower() == "clinicaldocument") { property.type = TemplateTypes.cdaheaderlevel; } else if (template.PrimaryContextType.ToLower() == "section") { property.type = TemplateTypes.cdasectionlevel; } else { property.type = TemplateTypes.cdaentrylevel; } // release date based on implementation guide's publish date if (template.OwningImplementationGuide.IsPublished()) { if (template.OwningImplementationGuide.PublishDate != null) { templateDef.officialReleaseDate = template.OwningImplementationGuide.PublishDate.Value; templateDef.officialReleaseDateSpecified = true; } } // Status if (template.Status == this.publishedStatus) { templateDef.statusCode = TemplateStatusCodeLifeCycle.active; } else if (template.Status == this.retiredStatus) { templateDef.statusCode = TemplateStatusCodeLifeCycle.retired; } else { templateDef.statusCode = TemplateStatusCodeLifeCycle.draft; } // description if (!string.IsNullOrEmpty(template.Description)) { XmlNode[] anyField = new XmlNode[] { dom.CreateTextNode(template.Description) }; templateDef.desc = new FreeFormMarkupWithLanguage[] { new FreeFormMarkupWithLanguage() { Any = anyField } }; } // samples/examples List <example> examples = new List <example>(); foreach (var sample in template.TemplateSamples) { example templateExample = new example(); XmlNode[] anyField = new XmlNode[] { dom.CreateTextNode(sample.XmlSample) }; templateExample.Any = anyField; examples.Add(templateExample); } if (examples.Count > 0) { templateDef.example = examples.ToArray(); } // constraints ConstraintExporter constraintExporter = new ConstraintExporter(dom, template, igSettings, this.tdb); templateDef.Items = constraintExporter.ExportConstraints(); return(templateDef); }
public PartialTemplate(AutoInterfaceTargets memberTargets, Regex?memberFilter, TemplateDefinition template) { this.MemberTargets = memberTargets; this.MemberFilter = memberFilter; this.Template = template; }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public static Image GenerateProxy(BlockManager manager, string rootPath, TemplateDefinition template, Dictionary <string, string> values) { var path = Path.Combine(rootPath, template.src); Image temp = GraphicUtils.LoadImage(path); Bitmap b = ((Bitmap)temp).Clone(new Rectangle(0, 0, temp.Width, temp.Height), PixelFormat.Format32bppArgb); //b.MakeTransparent(); //ret.PixelFormat = PixelFormat.Format32bppArgb; using (Graphics graphics = Graphics.FromImage(b)) { foreach (LinkDefinition overlay in template.GetOverLayBlocks(values)) { BlockDefinition block = manager.GetBlock(overlay.Block); if (block.type != "overlay") { continue; } block.src = Path.Combine(rootPath, block.src); GraphicUtils.MergeOverlay(graphics, block); } foreach (LinkDefinition section in template.GetTextBlocks(values)) { List <Property> clonedProps = new List <Property>(); BlockDefinition block = manager.GetBlock(section.Block); if (block.type != "text") { continue; } clonedProps.AddRange(section.NestedProperties); foreach (Property prop in section.NestedProperties) { if (!values.ContainsKey(prop.Name)) { clonedProps.Remove(prop); } if (clonedProps.Contains(prop) && (values[prop.Name] == null || values[prop.Name].Length == 0)) { clonedProps.Remove(prop); } } StringBuilder toWrite = new StringBuilder(); if (clonedProps.Count > 1) { for (int i = 0; i < clonedProps.Count; i++) { string propertyName = clonedProps[i].Name; string format = clonedProps[i].Format.Replace("{}", values[propertyName]); if (i < (clonedProps.Count - 1)) { toWrite.Append(string.Format("{0} {1}", format, section.Separator)); } else { toWrite.Append(format); } } } else { if (clonedProps.Count > 0) { string propertyName = clonedProps[0].Name; string format = clonedProps[0].Format.Replace("{}", values[propertyName]); toWrite.Append(format); } } GraphicUtils.WriteString(graphics, block, toWrite.ToString()); } } return(b); }
public static TemplateDefinition WithScribanEngine([NotNull] this TemplateDefinition templateDefinition) { return(templateDefinition.WithRenderEngine(ScribanTemplateRenderingEngine.EngineName)); }
public virtual object VisitTemplateDefinition(TemplateDefinition templateDefinition, object data) { Debug.Assert((templateDefinition != null)); Debug.Assert((templateDefinition.Attributes != null)); Debug.Assert((templateDefinition.Bases != null)); for (int i = 0; i < templateDefinition.Attributes.Count; i++) { AttributeSection o = templateDefinition.Attributes[i]; Debug.Assert(o != null); nodeStack.Push(o); o.AcceptVisitor(this, data); o = (AttributeSection)nodeStack.Pop(); if (o == null) templateDefinition.Attributes.RemoveAt(i--); else templateDefinition.Attributes[i] = o; } for (int i = 0; i < templateDefinition.Bases.Count; i++) { TypeReference o = templateDefinition.Bases[i]; Debug.Assert(o != null); nodeStack.Push(o); o.AcceptVisitor(this, data); o = (TypeReference)nodeStack.Pop(); if (o == null) templateDefinition.Bases.RemoveAt(i--); else templateDefinition.Bases[i] = o; } return null; }
public void DefineTemplate(string name, HashList formalArgs, bool optional) { TemplateDefinition tdef = new TemplateDefinition(name, formalArgs, optional); templates.Add(tdef.name, tdef); }
protected string GetTemplateSignature(TemplateDefinition tdef) { StringBuilder buf = new StringBuilder(); if ( tdef.optional ) { buf.Append("optional "); } buf.Append(tdef.name); if ( tdef.formalArgs != null ) { buf.Append('('); bool needSeparator = false; foreach (string name in tdef.formalArgs.Keys) { if ( needSeparator ) { buf.Append(", "); } buf.Append(name); needSeparator = true; } buf.Append(')'); } else { buf.Append("()"); } return buf.ToString(); }
// Methods public void AddTemplateDefinition(TemplateDefinition templateDefinition) { }
void TypeParameterConstraints( #line 397 "VBNET.ATG" TemplateDefinition template) { #line 399 "VBNET.ATG" TypeReference constraint; Expect(50); if (la.kind == 23) { lexer.NextToken(); TypeParameterConstraint( #line 405 "VBNET.ATG" out constraint); #line 405 "VBNET.ATG" if (constraint != null) { template.Bases.Add(constraint); } while (la.kind == 12) { lexer.NextToken(); TypeParameterConstraint( #line 408 "VBNET.ATG" out constraint); #line 408 "VBNET.ATG" if (constraint != null) { template.Bases.Add(constraint); } } Expect(24); } else if (StartOf(6)) { TypeParameterConstraint( #line 411 "VBNET.ATG" out constraint); #line 411 "VBNET.ATG" if (constraint != null) { template.Bases.Add(constraint); } } else SynErr(234); }
void TypeParameter( #line 390 "VBNET.ATG" out TemplateDefinition template) { Identifier(); #line 392 "VBNET.ATG" template = new TemplateDefinition(t.val, null); if (la.kind == 50) { TypeParameterConstraints( #line 393 "VBNET.ATG" template); } }
public DisplayedTemplate(TemplateDefinition definition, int level, string mascotName) { Definition = definition; Level = level; MascotName = mascotName; }
/// <summary> /// 设置Scriban引擎 /// </summary> /// <param name="templateDefinition">模板定义</param> public static TemplateDefinition WithScribanEngine(this TemplateDefinition templateDefinition) => templateDefinition.WithRenderEngine(ScribanTemplateRenderingEngine.EngineName);
// Some classes are handled by their parent (TemplateDefinition by TypeDeclaration/MethodDeclaration etc.) // so we don't need to implement Visit for them. public object VisitTemplateDefinition(TemplateDefinition templateDefinition, object data) { throw new ApplicationException("Visited TemplateDefinition."); }
public void It_has_a_useful_ToString_method() { var a = new TemplateDefinition("a"); Assert.AreEqual("TemplateDefinition(\"a\")", a.ToString()); }
public void LoadData(TemplateDefinition td) { LoadData(td.templates); }
/// <summary> /// Thủ tục lưu các thông tin đã xác lập của 1 Cột /// </summary> /// <param name="sender"></param> /// <param name="args"></param> protected void OnSave(object sender, EventArgs args) { try { if (Page.IsValid) { // Save PortalDefinition.Column _objColumn = null; PortalDefinition pd = null; TemplateDefinition td = null; if (Parent is Tab) { // Lấy thông tin về cột cần sửa pd = PortalDefinition.Load(); _objColumn = pd.GetColumn(CurrentColumnReference); } else if (Parent is Template) { td = TemplateDefinition.Load(); _objColumn = td.GetColumn(CurrentColumnReference); } if (_objColumn != null) { // Cập nhật lại tên cột và độ rộng của cột _objColumn.ColumnName = txtTitle.Text; // Cập nhật màu nền của cột _objColumn.ColumnCustomStyle = txtCustomStyle.Text; // Cập nhật mức độ của cột _objColumn.ColumnLevel = Convert.ToInt32(drdColumnLevel.SelectedValue); //lay ve do rong cua cot string strColWidth = txtColWidth.Text; try { _objColumn.ColumnWidth = chkDefaultColumnWidth.Checked ? "" : strColWidth; } catch { // Nếu có lỗi, lấy độ rộng mặc định _objColumn.ColumnWidth = ""; } } if (Parent is Tab) { pd.Save(); } else if (Parent is Template) { td.Save(); } CurrentColumnReference = _objColumn.ColumnReference; if (Save != null) { Save(this, new EventArgs()); } } } catch (Exception e) { lbError.Text = e.Message; } }
public void LoadData(TemplateDefinition td, string templateType) { LoadData(td.templates, templateType); }
public EditorPartEditableDesignerRegion(EditorZone zone, TemplateDefinition templateDefinition) : base(templateDefinition) { this._zone = zone; }
public static void Main(string[] args) { Utils.InitLog(); _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); if (args.Length == 6 || args.Length == 8 || args.Length == 10 || args.Length == 4) { for (var i = 0; i < args.Length; i++) { var arg = args[i]; switch (arg) { case "--p": i++; ArtifactPath = args[i]; continue; case "--n": i++; ArtifactName = args[i]; continue; case "--t": i++; var t = Convert.ToInt32(args[i]); ArtifactType = (ArtifactType)t; continue; case "--b": i++; var b = Convert.ToInt32(args[i]); BaseType = (TokenType)b; continue; case "--c": i++; var c = Convert.ToInt32(args[i]); TemplateType = (TemplateType)c; continue; case "--v": i++; var v = args[i]; TaxonomyVersion = new TaxonomyVersion { Id = Guid.NewGuid().ToString(), Version = v }; continue; default: continue; } } } else { if (args.Length == 0) { _log.Info( "Usage: dotnet factgen --p [PATH_TO_ARTIFACTS FOLDER] --t [ARTIFACT_TYPE: 0 = Base, 1 = Behavior, 2 = BehaviorGroup, 3 = PropertySet, 4 - TemplateFormula or 5 - TemplateDefinition] --n [ARTIFACT_NAME],"); _log.Info( "--b [baseTokenType: 0 = fungible, 1 = non-fungible, 2 = hybrid]"); _log.Info( "--c [templateType: 0 = singleToken, 1 = hybrid] Is required for a Template Type"); _log.Info( "To update the TaxonomyVersion: dotnet factgen --v [VERSION_STRING] --p [PATH_TO_ARTIFACTS FOLDER]"); return; } _log.Error( "Required arguments --p [path-to-artifact folder] --n [artifactName] --t [artifactType: 0 = Base, 1 = Behavior, 2 = BehaviorGroup, 3 = PropertySet or 4 - TokenTemplate],"); _log.Error( "--b [baseTokenType: 0 = fungible, 1 = non-fungible, 2 = hybrid-fungibleBase, 3 = hybrid-non-fungibleBase, 4 = hybrid-fungibleBase-hybridChildren, 5 = hybrid-non-fungibleBase-hybridChildren]"); _log.Error( "To update the TaxonomyVersion: dotnet factgen --v [VERSION_STRING] --p [PATH_TO_ARTIFACTS FOLDER]"); throw new Exception("Missing required parameters."); } _log.Info("Generating Artifact: " + ArtifactName + " of type: " + ArtifactType); var folderSeparator = "/"; var fullPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (Os.IsWindows()) { fullPath += "\\" + ArtifactPath + "\\"; folderSeparator = "\\"; } else { fullPath += "/" + ArtifactPath + "/"; } Latest = folderSeparator + "latest"; string artifactTypeFolder; var jsf = new JsonFormatter(new JsonFormatter.Settings(true)); if (string.IsNullOrEmpty(ArtifactPath)) { throw new Exception("Missing value for --p."); } if (TaxonomyVersion != null) { _log.Info("Updating Taxonomy Version Only."); var tx = new Taxonomy { Version = TaxonomyVersion }; var txVersionJson = jsf.Format(tx); var formattedTxJson = JToken.Parse(txVersionJson).ToString(); //test to make sure formattedJson will Deserialize. try { JsonParser.Default.Parse <Taxonomy>(formattedTxJson); _log.Info("Taxonomy: " + TaxonomyVersion.Version + " successfully deserialized."); } catch (Exception e) { _log.Error("Json failed to deserialize back into Taxonomy"); _log.Error(e); return; } _log.Info("Creating Taxonomy: " + formattedTxJson); var txStream = File.CreateText(fullPath + "Taxonomy.json"); txStream.Write(formattedTxJson); txStream.Close(); _log.Info("Creating Formula and Grammar Definitions"); var formula = GenerateFormula(); var formulaJson = jsf.Format(formula); var formattedFormulaJson = JToken.Parse(formulaJson).ToString(); //test to make sure formattedJson will Deserialize. try { JsonParser.Default.Parse <FormulaGrammar>(formattedFormulaJson); _log.Info("FormulaGrammar successfully deserialized."); } catch (Exception e) { _log.Error("Json failed to deserialize back into FormulaGrammar."); _log.Error(e); return; } var formulaStream = File.CreateText(fullPath + "FormulaGrammar.json"); formulaStream.Write(formattedFormulaJson); formulaStream.Close(); return; } if (string.IsNullOrEmpty(ArtifactName)) { throw new Exception("Missing value for --n "); } string artifactJson; DirectoryInfo outputFolder; var artifact = new Artifact { Name = ArtifactName, ArtifactSymbol = new ArtifactSymbol { Id = Guid.NewGuid().ToString(), Type = ArtifactType, Tooling = "", Visual = "", Version = "1.0" }, ArtifactDefinition = new ArtifactDefinition { BusinessDescription = "This is a " + ArtifactName + " of type: " + ArtifactType, BusinessExample = "", Comments = "", Analogies = { new ArtifactAnalogy { Name = "Analogy 1", Description = ArtifactName + " analogy 1 description" } } }, Maps = new Maps { CodeReferences = { new MapReference { MappingType = MappingType.SourceCode, Name = "Code 1", Platform = TargetPlatform.Daml, ReferencePath = "" } }, ImplementationReferences = { new MapReference { MappingType = MappingType.Implementation, Name = "Implementation 1", Platform = TargetPlatform.ChaincodeGo, ReferencePath = "" } }, Resources = { new MapResourceReference { MappingType = MappingType.Resource, Name = "Regulation Reference 1", Description = "", ResourcePath = "" } } }, IncompatibleWithSymbols = { new ArtifactSymbol { Type = ArtifactType, Tooling = "", Visual = "" } }, Dependencies = { new SymbolDependency { Description = "", Symbol = new ArtifactSymbol() } }, Aliases = { "alias1", "alias2" } }; switch (ArtifactType) { case ArtifactType.Base: artifactTypeFolder = "base"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var artifactBase = new Base { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "Base"), TokenType = BaseType }; artifactBase.Artifact.InfluencedBySymbols.Add(new SymbolInfluence { Description = "Whether or not the token class will be divisible will influence the decimals value of this token. If it is non-divisible, the decimals value should be 0.", Symbol = new ArtifactSymbol { Id = "d5807a8e-879b-4885-95fa-f09ba2a22172", Type = ArtifactType.Behavior, Tooling = "~d", Visual = "<i>~d</i>", Version = "" } }); artifactBase.Artifact.InfluencedBySymbols.Add(new SymbolInfluence { Description = "Whether or not the token class will be divisible will influence the decimals value of this token. If it is divisible, the decimals value should be greater than 0.", Symbol = new ArtifactSymbol { Id = "6e3501dc-5800-4c71-b59e-ad11418a998c", Type = ArtifactType.Behavior, Tooling = "d", Visual = "<i>d</i>", Version = "" } }); artifactBase.TokenType = BaseType; artifactJson = jsf.Format(artifactBase); break; case ArtifactType.Behavior: artifactTypeFolder = "behaviors"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var artifactBehavior = new Behavior { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "Behaviors"), Invocations = { new Invocation { Name = "InvocationRequest1", Description = "Describe the what the this invocation triggers in the behavior", Request = new InvocationRequest { ControlMessageName = "InvocationRequest", Description = "The request", InputParameters = { new InvocationParameter { Name = "Input Parameter 1", ValueDescription = "Contains some input data required for the invocation to work." } } }, Response = new InvocationResponse { ControlMessageName = "InvocationResponse", Description = "The response", OutputParameters = { new InvocationParameter { Name = "Output Parameter 1", ValueDescription = "One of the values that the invocation should return." } } } } } }; artifactBehavior.Properties.Add(new Property { Name = "Property1", ValueDescription = "Some Value", TemplateValue = "", PropertyInvocations = { new Invocation { Name = "PropertyGetter", Description = "The property value.", Request = new InvocationRequest { ControlMessageName = "GetProperty1Request", Description = "", InputParameters = { new InvocationParameter { Name = "input1", ValueDescription = "value" } } }, Response = new InvocationResponse { ControlMessageName = "GetProperty1Response", Description = "Return value", OutputParameters = { new InvocationParameter { Name = "Output1", ValueDescription = "value of property" } } } } } }); artifactBehavior.Artifact.InfluencedBySymbols.Add(new SymbolInfluence { Description = "", Symbol = new ArtifactSymbol { Tooling = "", Visual = "" } }); artifactBehavior.Artifact.Dependencies.Add(new SymbolDependency { Description = "", Symbol = new ArtifactSymbol { Tooling = "", Visual = "" } }); artifact.IncompatibleWithSymbols.Add(new ArtifactSymbol()); artifactJson = jsf.Format(artifactBehavior); break; case ArtifactType.BehaviorGroup: artifactTypeFolder = "behavior-groups"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var artifactBehaviorGroup = new BehaviorGroup { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "BehaviorGroups") }; artifactBehaviorGroup.Behaviors.Add(new BehaviorReference { Reference = new ArtifactReference { Id = "", ReferenceNotes = "", Type = ArtifactType.Behavior, Values = new ArtifactReferenceValues { ControlUri = "" } }, Properties = { new Property { Name = "", TemplateValue = "", ValueDescription = "" } } }); artifactJson = jsf.Format(artifactBehaviorGroup); break; case ArtifactType.PropertySet: artifactTypeFolder = "property-sets"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var artifactPropertySet = new PropertySet { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "PropertySets"), Properties = { new Property { Name = "Property1", ValueDescription = "This is the property required to be implemented and should be able to contain data of type X.", TemplateValue = "", PropertyInvocations = { new Invocation { Name = "Property1 Getter", Description = "Request the value of the property", Request = new InvocationRequest { ControlMessageName = "GetProperty1Request", Description = "The request" }, Response = new InvocationResponse { ControlMessageName = "GetProperty1Response", Description = "The response", OutputParameters = { new InvocationParameter { Name = "Property1.Value", ValueDescription = "Returning the value of the property." } } } }, new Invocation { Name = "Property1 Setter", Description = "Set the Value of the Property, note if Roles should be applied to the Setter.", Request = new InvocationRequest { ControlMessageName = "SetProperty1Request", Description = "The request", InputParameters = { new InvocationParameter { Name = "New Value of Property", ValueDescription = "The data to set the property to." } } }, Response = new InvocationResponse { ControlMessageName = "SetProperty1Response", Description = "The response", OutputParameters = { new InvocationParameter { Name = "Result, true or false", ValueDescription = "Returning the value of the set request." } } } } } } } }; artifactPropertySet.Artifact.InfluencedBySymbols.Add(new SymbolInfluence { Description = "", Symbol = new ArtifactSymbol { Tooling = "", Visual = "" } }); artifactJson = jsf.Format(artifactPropertySet); break; case ArtifactType.TemplateFormula: artifactTypeFolder = "token-templates/formulas"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var templateFormula = new TemplateFormula { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "TemplateFormulas"), TokenBase = GetTemplateBase(fullPath, folderSeparator), TemplateType = TemplateType, Behaviors = { new TemplateBehavior { Behavior = new ArtifactSymbol { Type = ArtifactType.Behavior } } }, BehaviorGroups = { new TemplateBehaviorGroup { BehaviorGroup = new ArtifactSymbol { Type = ArtifactType.BehaviorGroup } } }, PropertySets = { new TemplatePropertySet { PropertySet = new ArtifactSymbol { Type = ArtifactType.PropertySet } } } }; artifactJson = jsf.Format(templateFormula); break; case ArtifactType.TemplateDefinition: artifactTypeFolder = "token-templates/definitions"; outputFolder = Directory.CreateDirectory( fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest); var templateDefinition = new TemplateDefinition { Artifact = AddArtifactFiles(outputFolder, folderSeparator, artifact, "TemplateDefinition"), TokenBase = GetBaseReference(fullPath, folderSeparator), Behaviors = { new BehaviorReference { Reference = new ArtifactReference { Type = ArtifactType.Behavior, Id = "a guid", ReferenceNotes = "" }, ConstructorType = "", IsExternal = true, Invocations = { new Invocation() }, InfluenceBindings = { new InfluenceBinding { InfluencedId = "", InfluencedInvocationId = "", InfluenceType = InfluenceType.Intercept, InfluencingInvocation = new Invocation(), InfluencedInvocation = new Invocation() } }, Properties = { new Property { TemplateValue = "definition value" } } } }, BehaviorGroups = { new BehaviorGroupReference { Reference = new ArtifactReference { Type = ArtifactType.BehaviorGroup, Id = "a guid", ReferenceNotes = "" } } }, PropertySets = { new PropertySetReference { Reference = new ArtifactReference { Type = ArtifactType.PropertySet, Id = "a guid", ReferenceNotes = "" }, Properties = { new Property { TemplateValue = "template value" } } } } }; templateDefinition.FormulaReference = new ArtifactReference(); artifactJson = jsf.Format(templateDefinition); break; default: _log.Error("No matching type found for: " + ArtifactType); throw new ArgumentOutOfRangeException(); } _log.Info("Artifact Destination: " + outputFolder); var formattedJson = JToken.Parse(artifactJson).ToString(); //test to make sure formattedJson will Deserialize. try { switch (ArtifactType) { case ArtifactType.Base: var testBase = JsonParser.Default.Parse <Base>(formattedJson); _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " + testBase.Artifact.Name); break; case ArtifactType.Behavior: var testBehavior = JsonParser.Default.Parse <Behavior>(formattedJson); _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " + testBehavior.Artifact.Name); break; case ArtifactType.BehaviorGroup: var testBehaviorGroup = JsonParser.Default.Parse <BehaviorGroup>(formattedJson); _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " + testBehaviorGroup.Artifact.Name); break; case ArtifactType.PropertySet: var testPropertySet = JsonParser.Default.Parse <PropertySet>(formattedJson); _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " + testPropertySet.Artifact.Name); break; case ArtifactType.TemplateFormula: break; case ArtifactType.TemplateDefinition: break; default: throw new ArgumentOutOfRangeException(); } } catch (Exception e) { _log.Error("Json failed to deserialize back into: " + ArtifactType); _log.Error(e); return; } _log.Info("Creating Artifact: " + formattedJson); var artifactStream = File.CreateText(outputFolder.FullName + folderSeparator + ArtifactName + ".json"); artifactStream.Write(formattedJson); artifactStream.Close(); _log.Info("Complete"); }
public IEnumerable <TemplateDefinition> GetTemplates(Type contentType) { var httpContext = httpContextProvider.Get(); if (httpContext == null) { logger.Warn("Trying to get templates with no context"); return(Enumerable.Empty <TemplateDefinition>()); } try { httpContext.Request.GetType(); } catch (Exception ex) { logger.Warn("Trying to get templates with invalid context", ex); return(Enumerable.Empty <TemplateDefinition>()); } const string cacheKey = "RazorDefinitions"; var definitions = httpContext.Cache[cacheKey] as IEnumerable <ItemDefinition>; lock (this) { if (definitions == null || rebuild) { if (registrator.QueuedRegistrations.Count > 0) { logger.DebugFormat("Dequeuing {0} registrations", registrator.QueuedRegistrations.Count); DequeueRegistrations(); } var vpp = vppProvider.Get(); var descriptions = analyzer.AnalyzeViews(vpp, httpContext, sources).ToList(); if (descriptions.Count > 0) { logger.DebugFormat("Got {0} descriptions", descriptions.Count); definitions = BuildDefinitions(descriptions); logger.Debug("Built definitions"); var files = descriptions.SelectMany(p => p.Context.TouchedPaths).Distinct().ToList(); if (files.Count > 0) { logger.DebugFormat("Setting up cache dependency on {0} files", files.Count); var cacheDependency = vpp.GetCacheDependency(files.FirstOrDefault(), files, DateTime.UtcNow); httpContext.Cache.Remove(cacheKey); httpContext.Cache.Add(cacheKey, definitions, cacheDependency, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.AboveNormal, delegate { logger.Debug("Razor template changed"); }); } } rebuild = false; } } if (definitions == null) { return(Enumerable.Empty <TemplateDefinition>()); } var templates = definitions.Where(d => d.ItemType == contentType).Select(d => { var td = new TemplateDefinition { Definition = d, Description = d.Description, Name = d.TemplateKey, OriginalFactory = () => null, TemplateFactory = () => activator.CreateInstance(d.ItemType, null, d.TemplateKey), TemplateUrl = null, Title = d.Title, ReplaceDefault = "Index".Equals(d.TemplateKey, StringComparison.InvariantCultureIgnoreCase) }; return(td); }).ToArray(); return(templates); }
public virtual void DefineTemplate(string name, IDictionary <string, FormalArgument> formalArgs, bool optional) { TemplateDefinition d = new TemplateDefinition(name, formalArgs, optional); _templates[d.name] = d; }
public WizardStepTemplatedEditableRegion(TemplateDefinition templateDefinition, WizardStepBase wizardStep) : base(templateDefinition) { this._wizardStep = wizardStep; base.EnsureSize = true; }
public virtual void DefineTemplate( string name, IDictionary<string, FormalArgument> formalArgs, bool optional ) { TemplateDefinition d = new TemplateDefinition( name, formalArgs, optional ); _templates[d.name] = d; }
public IEnumerable<TemplateDefinition> GetTemplates(Type contentType) { var httpContext = httpContextProvider.Get(); try { httpContext.Request.GetType(); } catch (Exception) { return new TemplateDefinition[0]; } const string cacheKey = "RazorDefinitions"; var definitions = httpContext.Cache[cacheKey] as IEnumerable<ItemDefinition>; lock (this) { if (definitions == null || rebuild) { DequeueRegistrations(); var vpp = vppProvider.Get(); var registrations = analyzer.FindRegistrations(vpp, httpContext, sources).ToList(); definitions = BuildDefinitions(registrations); var files = registrations.SelectMany(p => p.TouchedPaths).Distinct().ToList(); //var dirs = files.Select(f => f.Substring(0, f.LastIndexOf('/'))).Distinct(); var cacheDependency = vpp.GetCacheDependency(files.FirstOrDefault(), files, DateTime.UtcNow); httpContext.Cache.Remove(cacheKey); httpContext.Cache.Add(cacheKey, definitions, cacheDependency, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.AboveNormal, new CacheItemRemovedCallback(delegate { Debug.WriteLine("Razor template changed"); })); rebuild = false; } } var templates = definitions.Where(d => d.ItemType == contentType).Select(d => { var td = new TemplateDefinition(); td.Definition = d; td.Description = d.Description; td.Name = d.Template; td.Original = () => null; td.Template = () => activator.CreateInstance(d.ItemType, null, d.Template); td.TemplateUrl = null; td.Title = d.Title; td.ReplaceDefault = "Index".Equals(d.Template, StringComparison.InvariantCultureIgnoreCase); return td; }).ToArray(); return templates; }
public ReorderListDesignerRegion(object obj, ITemplate template, PropertyDescriptor descriptor, TemplateDefinition definition) : base(definition) { _template = template; _object = obj; _prop = descriptor; EnsureSize = true; }
public ProxyTemplateItemModel(TemplateDefinition t) { _def = t; }
public sealed override object VisitTemplateDefinition(TemplateDefinition templateDefinition, object data) { BeginVisit(templateDefinition); object result = TrackedVisitTemplateDefinition(templateDefinition, data); EndVisit(templateDefinition); return result; }
public virtual object VisitTemplateDefinition(TemplateDefinition templateDefinition, object data) { Debug.Assert((templateDefinition != null)); Debug.Assert((templateDefinition.Attributes != null)); Debug.Assert((templateDefinition.Bases != null)); foreach (AttributeSection o in templateDefinition.Attributes) { Debug.Assert(o != null); o.AcceptVisitor(this, data); } foreach (TypeReference o in templateDefinition.Bases) { Debug.Assert(o != null); o.AcceptVisitor(this, data); } return null; }
public IEnumerable<TemplateDefinition> GetTemplates(Type contentType) { var httpContext = httpContextProvider.Get(); if (httpContext == null) { logger.Warn("Trying to get templates with no context"); return Enumerable.Empty<TemplateDefinition>(); } try { httpContext.Request.GetType(); } catch (Exception ex) { logger.Warn("Trying to get templates with invalid context", ex); return Enumerable.Empty<TemplateDefinition>(); } const string cacheKey = "RazorDefinitions"; var definitions = httpContext.Cache[cacheKey] as IEnumerable<ItemDefinition>; lock (this) { if (definitions == null || rebuild) { logger.DebugFormat("Dequeuing {0} registrations", registrator.QueuedRegistrations.Count); DequeueRegistrations(); var vpp = vppProvider.Get(); var descriptions = analyzer.AnalyzeViews(vpp, httpContext, sources).ToList(); logger.DebugFormat("Got {0} descriptions", descriptions.Count); definitions = BuildDefinitions(descriptions); logger.Debug("Built definitions"); var files = descriptions.SelectMany(p => p.Context.TouchedPaths).Distinct().ToList(); logger.DebugFormat("Setting up cache dependency on {0} files", files.Count); var cacheDependency = vpp.GetCacheDependency(files.FirstOrDefault(), files, DateTime.UtcNow); httpContext.Cache.Remove(cacheKey); httpContext.Cache.Add(cacheKey, definitions, cacheDependency, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.AboveNormal, new CacheItemRemovedCallback(delegate { logger.Debug("Razor template changed"); })); rebuild = false; } } var templates = definitions.Where(d => d.ItemType == contentType).Select(d => { var td = new TemplateDefinition(); td.Definition = d; td.Description = d.Description; td.Name = d.TemplateKey; td.OriginalFactory = () => null; td.TemplateFactory = () => activator.CreateInstance(d.ItemType, null, d.TemplateKey); td.TemplateUrl = null; td.Title = d.Title; td.ReplaceDefault = "Index".Equals(d.TemplateKey, StringComparison.InvariantCultureIgnoreCase); return td; }).ToArray(); return templates; }
internal void MoveColumnRight(string _strColumnReference) { // Nạp cấu trúc Portal TemplateDefinition _objPortal = TemplateDefinition.Load(); // Lấy thông tin về cột cần dịch chuyển PortalDefinition.Column _objSelectedColumn = _objPortal.GetColumn(_strColumnReference); // Nếu cột cần dịch chuyển không tồn tại thì kết thúc hàm if (_objSelectedColumn != null) { // Tìm kiếm danh sách cột trong đó có cột đang xét PortalDefinition.Column _objParentColumn = _objSelectedColumn.ColumnParent; ArrayList _arrColumnsList = null; // Nếu cột cha rỗng thì cột đang xét trực thuộc Tab if (_objParentColumn == null) { // Lấy thông tin Tab hiện thời TemplateDefinition.Template _objCurrentTemplate = _objPortal.GetTemplate(CurrentTemplateReference); if (_objCurrentTemplate != null) { // Lấy danh sách cột của Tab _arrColumnsList = _objCurrentTemplate.Columns; } } else { // Nếu cột đang xét là cột con của 1 cột khác, thì trả về danh sách các cột đồng cấp _arrColumnsList = _objParentColumn.Columns; } // Biến lưu vị trí của cột đã chọn trong danh sách int _intCurrentColumnIndex = 0; // Biến lưu trữ số cột đồng mức với cột đã chọn int _intSameLevelColumnsCount = 0; // Kiểm duyệt danh sách cột đồng cấp // Đếm cột có cùng Level for (int _intColumnCount = 0; _intColumnCount < _arrColumnsList.Count; _intColumnCount++) { PortalDefinition.Column _objColumn = _arrColumnsList[_intColumnCount] as PortalDefinition.Column; if (_objColumn.ColumnLevel == _objSelectedColumn.ColumnLevel) { if (_objColumn.ColumnReference == _objSelectedColumn.ColumnReference) { _intCurrentColumnIndex = _intSameLevelColumnsCount; } _intSameLevelColumnsCount++; } } // Duyệt danh sách các cột cùng cấp if (_arrColumnsList != null && _intSameLevelColumnsCount > 0) { // Để di chuyển sang phải --> không thể đang là vị trí cuối cùng if (_intCurrentColumnIndex >= (_intSameLevelColumnsCount - 1)) { return; } else { // Di chuyển cột đã chọn sang trái _arrColumnsList.RemoveAt(_intCurrentColumnIndex); _arrColumnsList.Insert(_intCurrentColumnIndex + 1, _objSelectedColumn); } } } // Lưu cấu trúc Portal _objPortal.Save(); // Nạp dữ liệu Template LoadData(CurrentTemplateReference); // Nạp dữ liệu cột if (CurrentColumnReference != "") { EditColumn(CurrentColumnReference); } }
// Constructors public TemplatedEditableDesignerRegion(TemplateDefinition templateDefinition) { }
public SelectTemplate(TemplateDefinition templateData, Sprite templateSprite) { TemplateData = templateData; TemplateSprite = templateSprite; }
protected virtual string GetTemplateSignature( TemplateDefinition d ) { StringBuilder buf = new StringBuilder(); if ( d.optional ) { buf.Append( "optional " ); } buf.Append( d.name ); if ( d.formalArgs != null ) { StringBuilder args = new StringBuilder(); args.Append( '(' ); int i = 1; foreach ( string name in d.formalArgs.Keys ) { if ( i > 1 ) { args.Append( ", " ); } args.Append( name ); i++; } args.Append( ')' ); buf.Append( args ); } else { buf.Append( "()" ); } return buf.ToString(); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public static Image GenerateProxy(BlockManager manager, string rootPath, TemplateDefinition template, Dictionary <string, string> values, string specialPath) { if (rootPath == null || template == null || template.src == null) { throw new UserMessageException(L.D.Exception__InvalidProxyDefinition); } var path = Path.Combine(rootPath, template.src); Bitmap temp = GraphicUtils.LoadImage(path, PixelFormat.Format32bppArgb); using (Graphics graphics = Graphics.FromImage(temp)) { foreach (LinkDefinition overlay in template.GetOverLayBlocks(values)) { BlockDefinition block = null; if (overlay.SpecialBlock != null) { block = overlay.SpecialBlock; if (specialPath == null) { continue; } block.src = specialPath; GraphicUtils.MergeArtOverlay(graphics, block); } else { block = manager.GetBlock(overlay.Block); if (block.type != "overlay") { continue; } block.src = Path.Combine(rootPath, block.src); GraphicUtils.MergeOverlay(graphics, block); } } foreach (LinkDefinition section in template.GetTextBlocks(values)) { List <Property> clonedProps = new List <Property>(); BlockDefinition block = manager.GetBlock(section.Block); if (block.type != "text") { continue; } clonedProps.AddRange(section.NestedProperties); foreach (Property prop in section.NestedProperties) { if (!values.ContainsKey(prop.Name)) { clonedProps.Remove(prop); } if (clonedProps.Contains(prop) && (values[prop.Name] == null || values[prop.Name].Length == 0)) { clonedProps.Remove(prop); } } StringBuilder toWrite = new StringBuilder(); if (clonedProps.Count > 1) { for (int i = 0; i < clonedProps.Count; i++) { string propertyName = clonedProps[i].Name; string format = clonedProps[i].Format.Replace("{}", values[propertyName]); if (i < (clonedProps.Count - 1)) { toWrite.Append(string.Format("{0} {1}", format, section.Separator)); } else { toWrite.Append(format); } } } else { if (clonedProps.Count > 0) { string propertyName = clonedProps[0].Name; string format = clonedProps[0].Format.Replace("{}", values[propertyName]); toWrite.Append(format); } } GraphicUtils.WriteString(graphics, block, toWrite.ToString()); } } return(temp); }
public LoginViewDesignerRegion(ControlDesigner owner, object obj, ITemplate template, System.ComponentModel.PropertyDescriptor descriptor, TemplateDefinition definition) : base(definition) { this._template = template; this._object = obj; this._prop = descriptor; base.EnsureSize = true; }
public virtual object TrackedVisitTemplateDefinition(TemplateDefinition templateDefinition, object data) { return base.VisitTemplateDefinition(templateDefinition, data); }