private static void SaveDecorators(IDecoratable decoratable, CodeWriter writer) { foreach (Decorator decorator in decoratable.Decorators) { DecoratorDef decoratorDef = decorator.Definition; writer.Write("[{0}", decoratorDef.Name); if (decorator.Arguments.Count > 0 && decoratorDef.Properties.Count > 0) { writer.Write("("); Boolean isFirst = true; for (Int32 i = 0; i < decorator.Arguments.Count; i += 1) { DecoratorPropertyDef propertyDef = decorator.Arguments[i].Definition; if (!decorator.Arguments[i].Value.Equals(propertyDef.Default)) { if (!isFirst) { writer.Write(", "); } else { isFirst = false; } writer.Write("{0} = {1}", propertyDef.Name, decorator.Arguments[i].Value); } } writer.Write(")"); } writer.WriteLine("]"); } }
protected void Decorators(IDecoratable member) { foreach (var memberDecorator in member.Decorators.OrderBy(c => c.Order)) { Visit(memberDecorator); } }
/// <inheritdoc cref="AbstractUpdateAwareDecorator.OnAttached" /> /// <inheritdoc cref="IDecorator.OnAttached" /> public override void OnAttached(IDecoratable decoratable) { base.OnAttached(decoratable); _currentPhase = ADSRPhase.Attack; _currentPhaseValue = Attack; _repetitionCount = 0; _currentValue = 0; }
/// <inheritdoc /> public override void OnDetached(IDecoratable decoratable) { base.OnDetached(decoratable); if (DecoratedObjects.Count == 0) { RGBSurface.Instance.Updating -= OnSurfaceUpdating; } }
/// <summary> /// Gets an enumeration of all decorators that can convert a reference to the given type</summary> /// <typeparam name="T">Decorator type, must be ref type</typeparam> /// <param name="decoratable">Decoratable object</param> /// <returns>Enumerable returning all decorators of the given type</returns> public static IEnumerable <T> AsAll <T>(this IDecoratable decoratable) where T : class { if (decoratable != null) { foreach (object decorator in decoratable.GetDecorators(typeof(T))) { yield return(decorator as T); } } }
public static IDictionary <string, MetaAttribute> GetMetas(IDecoratable decoratable, IDictionary <string, MetaAttribute> inheritedMeta, bool onlyInheritable) { if (decoratable == null) { return(EmptyMeta); } var map = new Dictionary <string, MetaAttribute>(inheritedMeta); IDictionary <string, MetaAttribute> metaAttributes = onlyInheritable ? decoratable.InheritableMetaData : decoratable.MappedMetaData; foreach (var metaAttribute in metaAttributes) { string name = metaAttribute.Key; MetaAttribute meta; MetaAttribute inheritedAttribute; map.TryGetValue(name, out meta); inheritedMeta.TryGetValue(name, out inheritedAttribute); if (meta == null) { meta = new MetaAttribute(name); map[name] = meta; } else if (meta == inheritedAttribute) { // overriding inherited meta attribute. meta = new MetaAttribute(name); map[name] = meta; } meta.AddValues(metaAttribute.Value.Values); } return(map); }
public void Decorate(IDecoratable objectToDecorate) { this.ObjetoToDecorate = objectToDecorate; }
public Decorator Decorate(Decorator objectToDecorate) { this.ObjetoToDecorate = (IDecoratable)objectToDecorate; return(objectToDecorate); }
public static IDictionary <string, MetaAttribute> GetMetas(IDecoratable decoratable, IDictionary <string, MetaAttribute> inheritedMeta) { return(GetMetas(decoratable, inheritedMeta, false)); }
public MapperHierarchyNode(ModelMapper mapper, ICanvas canvas, IGraphElement parent, HierarchyViewer viewer) : base() { Mapper = mapper; FCanvas = canvas; FViewer = viewer; MouseClick += FViewer.MouseClickHandler; MouseDoubleClick += FViewer.MouseDoubleClickHandler; Tag = mapper.Model; //graphelements FBackground = canvas.CreateRectangle(this); FPoly = canvas.CreatePoly(this); FText = canvas.CreateText(null, ""); FIcon = FCanvas.CreateRectangle(null); parent.Add(FBackground); FBackground.Add(FPoly); FBackground.Add(FText); FBackground.Add(FIcon); //compute level of depth IGraphElement p = FBackground; while (p.Parent != null) { FDepth++; p = p.Parent; } FDepth -= 1; //init static properties via Mapper if (Mapper.CanMap <ISelectable>()) { FSelectable = Mapper.Map <ISelectable>(); FSelectable.SelectionChanged += selectable_SelectionChanged; Selected = FSelectable.Selected; } if (Mapper.CanMap <IDecoratable>()) { FDecoratable = Mapper.Map <IDecoratable>(); FDecoratable.DecorationChanged += decorated_DecorationChanged; } if (Mapper.CanMap <ILinkSource>()) { FLinkSource = Mapper.Map <ILinkSource>(); FLinkSourceRectangle = FCanvas.CreateRectangle(null); FBackground.Add(FLinkSourceRectangle); FLinkOffset = FTextOffset; } if (Mapper.CanMap <ILinkSink>()) { FLinkSink = Mapper.Map <ILinkSink>(); FLinkSinkRectangle = FCanvas.CreateRectangle(null); FBackground.Add(FLinkSinkRectangle); } if (Mapper.CanMap <INamed>()) { FNamed = Mapper.Map <INamed>(); FNamed.Renamed += named_Renamed; SetCaption(FNamed.Name); } if (Mapper.CanMap <IParent>()) { var node = Mapper.Map <IParent>(); if (node.Childs != null) { // Keep Nodes and items in sync FSynchronizer = FSubTree.SyncWith(node.Childs, CreateChildNode); FSynchronizer.Synced += synchronizer_Synced; } } //init dynamic properties via Mapper UpdateColors(); UpdateIcon(); UpdateLinkSink(); UpdateLinkSource(); }
/// <summary> /// Appends decorators to decoratable node /// </summary> /// <param name="node">Decoratable syntax node</param> /// <param name="decorators">Set of decorator attributes</param> protected void AddDecorators(IDecoratable node, IEnumerable <TsDecoratorAttribute> decorators) { var decs = decorators.Select(c => new RtDecorator(c.Decorator, c.Order)); node.Decorators.AddRange(decs); }
public Root(ILevel4 level4, IMultipleGeneric <int>[] multiples, IDecoratable decoratable) { }
public static IDictionary<string, MetaAttribute> GetMetas(IDecoratable decoratable, IDictionary<string, MetaAttribute> inheritedMeta) { return GetMetas(decoratable, inheritedMeta, false); }
private void BindPersistentClassCommonValues(XmlNode node, IDecoratable classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas) { // DISCRIMINATOR XmlAttribute discriminatorNode = node.Attributes["discriminator-value"]; model.DiscriminatorValue = (discriminatorNode == null) ? model.EntityName : discriminatorNode.Value; // DYNAMIC UPDATE XmlAttribute dynamicNode = node.Attributes["dynamic-update"]; model.DynamicUpdate = (dynamicNode == null) ? false : "true".Equals(dynamicNode.Value); // DYNAMIC INSERT XmlAttribute insertNode = node.Attributes["dynamic-insert"]; model.DynamicInsert = (insertNode == null) ? false : "true".Equals(insertNode.Value); // IMPORT // For entities, the EntityName is the key to find a persister // NH Different behavior: we are using the association between EntityName and its more certain implementation (AssemblyQualifiedName) // Dynamic entities have no class, reverts to EntityName. -AK string qualifiedName = model.MappedClass == null ? model.EntityName : model.MappedClass.AssemblyQualifiedName; mappings.AddImport(qualifiedName, model.EntityName); if (mappings.IsAutoImport && model.EntityName.IndexOf('.') > 0) mappings.AddImport(qualifiedName, StringHelper.Unqualify(model.EntityName)); // BATCH SIZE XmlAttribute batchNode = node.Attributes["batch-size"]; if (batchNode != null) model.BatchSize = int.Parse(batchNode.Value); // SELECT BEFORE UPDATE XmlAttribute sbuNode = node.Attributes["select-before-update"]; if (sbuNode != null) model.SelectBeforeUpdate = "true".Equals(sbuNode.Value); // OPTIMISTIC LOCK MODE XmlAttribute olNode = node.Attributes["optimistic-lock"]; model.OptimisticLockMode = GetOptimisticLockMode(olNode); // META ATTRIBUTES model.MetaAttributes = classMapping != null ? GetMetas(classMapping, inheritedMetas) : GetMetas(node.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas); // PERSISTER XmlAttribute persisterNode = node.Attributes["persister"]; if (persisterNode == null) { //persister = typeof( EntityPersister ); } else model.EntityPersisterClass = ClassForNameChecked(persisterNode.Value, mappings, "could not instantiate persister class: {0}"); // CUSTOM SQL HandleCustomSQL(node, model); foreach (XmlNode syncNode in node.SelectNodes(HbmConstants.nsSynchronize, namespaceManager)) model.AddSynchronizedTable(XmlHelper.GetAttributeValue(syncNode, "table")); bool? isAbstract = null; XmlAttribute abstractNode = node.Attributes["abstract"]; if (abstractNode != null) { if ("true".Equals(abstractNode.Value) || "1".Equals(abstractNode.Value)) isAbstract = true; else if ("false".Equals(abstractNode.Value) || "0".Equals(abstractNode.Value)) isAbstract = false; } model.IsAbstract = isAbstract; }
protected void BindClass(XmlNode node, IDecoratable classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas) { // transfer an explicitly defined entity name // handle the lazy attribute XmlAttribute lazyNode = node.Attributes["lazy"]; bool lazy = lazyNode == null ? mappings.DefaultLazy : "true".Equals(lazyNode.Value); // go ahead and set the lazy here, since pojo.proxy can override it. model.IsLazy = lazy; string entityName = (node.Attributes["entity-name"] != null ? node.Attributes["entity-name"].Value : null) ?? ClassForNameChecked(node.Attributes["name"].Value, mappings, "persistent class {0} not found"). FullName; if (entityName == null) { throw new MappingException("Unable to determine entity name"); } model.EntityName = entityName; BindPocoRepresentation(node, model); BindXmlRepresentation(node, model); BindMapRepresentation(node, model); BindPersistentClassCommonValues(node, classMapping, model, inheritedMetas); }
public void SetDecoratable(IDecoratable decoratable) { this.decoratable = decoratable; }
public Decorator(IDecoratable baseobject) { this.baseobject = baseobject; }
public Decorator(IDecoratable decorated) { }
public DecoratableReference(IDecoratable decoratable) { }
public static IDictionary<string, MetaAttribute> GetMetas(IDecoratable decoratable, IDictionary<string, MetaAttribute> inheritedMeta, bool onlyInheritable) { if(decoratable == null) { return EmptyMeta; } var map = new Dictionary<string, MetaAttribute>(inheritedMeta); IDictionary<string, MetaAttribute> metaAttributes = onlyInheritable ? decoratable.InheritableMetaData : decoratable.MappedMetaData; foreach (var metaAttribute in metaAttributes) { string name = metaAttribute.Key; MetaAttribute meta; MetaAttribute inheritedAttribute; map.TryGetValue(name, out meta); inheritedMeta.TryGetValue(name, out inheritedAttribute); if (meta == null) { meta = new MetaAttribute(name); map[name] = meta; } else if (meta == inheritedAttribute) { // overriding inherited meta attribute. meta = new MetaAttribute(name); map[name] = meta; } meta.AddValues(metaAttribute.Value.Values); } return map; }
public override void OnDetached(IDecoratable decoratable) { Dispose(); }