コード例 #1
0
        public virtual void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            this._processDefinition = creationContext.ProcessDefinition;

            Type delegatingObjectClass = creationContext.DelegatingObject.GetType();

            if (delegatingObjectClass == typeof(AttributeImpl))
            {
                String type = xmlElement.GetProperty("type");
                if ((Object)type != null)
                {
                    this._className = ((String)attributeTypes[type]);
                    string suportedTypes = "supported types: ";
                    foreach (Object o in attributeTypes.Keys)
                    {
                        suportedTypes += o.ToString() + " ,";
                    }
                    creationContext.Check(((Object)this._className != null), "attribute type '" + type + "' is not supported. " + suportedTypes + " !");
                }
                else
                {
                    this._className = xmlElement.GetProperty("serializer");
                    creationContext.Check(((Object)this._className != null), "for an attribute, you must specify either a type or a serializer");
                }
            }
            else if (delegatingObjectClass == typeof(FieldImpl))
            {
                this._className = xmlElement.GetProperty("class");
                creationContext.Check(((Object)this._className != null), "no class specified for a delegation : " + xmlElement);
            }
            else
            {
                this._className = xmlElement.GetProperty("handler");
                creationContext.Check(((Object)this._className != null), "no handler specified for a delegation : " + xmlElement);
            }

            log.Debug("parsing delegation for tag '" + xmlElement.Name + "' : " + this._className);

            // parse the exception handler
            String exceptionHandlerText = xmlElement.GetAttribute("on-exception");

            if ((Object)exceptionHandlerText != null)
            {
                _exceptionHandlingType = ExceptionHandlingTypeHelper.FromText(exceptionHandlerText);
                creationContext.Check((_exceptionHandlingType != 0), "unknown exception handler '" + exceptionHandlerText + "' in delegation " + xmlElement);
            }

            // create the configuration string
            XmlElement  configurationXml = new XmlElement("cfg");
            IEnumerator iter             = xmlElement.GetChildElements("parameter").GetEnumerator();

            while (iter.MoveNext())
            {
                configurationXml.AddChild((XmlElement)iter.Current);
            }
            _configuration = configurationXml.ToString();
        }
コード例 #2
0
        private void delegation <T>(XmlElement delegationElement, DelegationImpl delegation)
        {
            Type delegatingObjectClass = typeof(T);

            if (delegatingObjectClass == typeof(AttributeImpl))
            {
                String type = delegationElement.GetProperty("type");
                if (string.IsNullOrEmpty(type) == false)
                {
                    delegation.ClassName = ((String)DelegationImpl.attributeTypes[type]);
                    string suportedTypes = "supported types: ";
                    foreach (Object o in DelegationImpl.attributeTypes.Keys)
                    {
                        suportedTypes += o.ToString() + " ,";
                    }
                }
                else
                {
                    delegation.ClassName = delegationElement.GetProperty("serializer");
                }
            }
            else if (delegatingObjectClass == typeof(FieldImpl))
            {
                delegation.ClassName = delegationElement.GetProperty("class");
            }
            else
            {
                delegation.ClassName = delegationElement.GetProperty("handler");
            }

            // parse the exception handler
            String exceptionHandlerText = delegationElement.GetAttribute("on-exception");

            if ((Object)exceptionHandlerText != null)
            {
                delegation.ExceptionHandlingType = ExceptionHandlingTypeHelper.FromText(exceptionHandlerText);
            }

            // create the configuration string
            XmlElement  configurationXml = new XmlElement("cfg");
            IEnumerator iter             = delegationElement.GetChildElements("parameter").GetEnumerator();

            while (iter.MoveNext())
            {
                configurationXml.AddChild((XmlElement)iter.Current);
            }
            delegation.Configuration = configurationXml.ToString();
        }