Exemple #1
0
 public UnresolvedReference(object referencingObject,
                            string destinationName,
                            ProcessBlock destinationScope,
                            string property,
                            Type destinationType)
 {
     this.ReferencingObject = referencingObject;
     this.DestinationName   = destinationName;
     this.DestinationScope  = destinationScope;
     this.Property          = property;
     this.DestinationType   = destinationType;
 }
        public void AddReferencableObject(string name, ProcessBlock scope, Type type, object referencableObject)
        {
            ReferencableObject           referenceType = new ReferencableObject(scope, type);
            IDictionary <string, object> referencables = null;

            if (!referencableObjects.ContainsKey(referenceType))
            {
                referencables = new Dictionary <string, object>();
                referencableObjects.Add(referenceType, referencables);
            }
            else
            {
                referencables = referencableObjects[referenceType];
            }

            referencables.Add(name, referencableObject);
        }
        private Object FindInScope(UnresolvedReference unresolvedReference, ProcessBlock scope)
        {
            Object referencedObject = null;

            if (scope != null)
            {
                ReferencableObject referenceType = new ReferencableObject(scope, unresolvedReference.DestinationType);

                var referencables = referencableObjects[referenceType];

                if ((referencables != null) && (referencables.ContainsKey(unresolvedReference.DestinationName)))
                {
                    referencedObject = referencables[unresolvedReference.DestinationName];
                }
                else
                {
                    referencedObject = FindInScope(unresolvedReference, scope.ParentBlock);
                }
            }

            return(referencedObject);
        }
        public void ResolveReferences()
        {
            foreach (UnresolvedReference unresolvedReference in unresolvedReferences)
            {
                Object       referencingObject        = unresolvedReference.ReferencingObject;
                String       referenceDestinationName = unresolvedReference.DestinationName;
                ProcessBlock scope    = unresolvedReference.DestinationScope;
                String       property = unresolvedReference.Property;

                Object referencedObject = FindInScope(unresolvedReference, unresolvedReference.DestinationScope);
                if (referencedObject == null)
                {
                    // AddError("failed to deploy process archive : couldn't resolve " + property + "=\"" + referenceDestinationName + "\" from " + referencingObject + " in scope " + scope);
                }
                else
                {
                    if (referencingObject is Transition)
                    {
                        if (property.Equals("to"))
                        {
                            Transition transition = (Transition)referencingObject;
                            transition.To = (Node)referencedObject;
                            //transition.ToId = transition.To.Id;
                        }
                    }
                    if (referencingObject is Field)
                    {
                        if (property.Equals("attribute"))
                        {
                            Field field = (Field)referencingObject;
                            field.Attribute = (AttributeDef)referencedObject;
                        }
                    }
                }
            }
        }
 public void AddUnresolvedReference(object referencingObject, string destinationName, ProcessBlock destinationScope, string property, Type destinationType)
 {
     unresolvedReferences.Add(new UnresolvedReference(referencingObject, destinationName, destinationScope, property, destinationType));
 }
Exemple #6
0
 public ReferencableObject(ProcessBlock scope, Type type)
 {
     Type  = type;
     Scope = scope;
 }