コード例 #1
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.ObjContainer == null))
     {
         IObjectTemplateExp objContainerCasted = item.As <IObjectTemplateExp>();
         if ((objContainerCasted != null))
         {
             this._parent.ObjContainer = objContainerCasted;
             return;
         }
     }
     if ((this._parent.ReferredProperty == null))
     {
         IProperty referredPropertyCasted = item.As <IProperty>();
         if ((referredPropertyCasted != null))
         {
             this._parent.ReferredProperty = referredPropertyCasted;
             return;
         }
     }
     if ((this._parent.Value == null))
     {
         IOclExpression valueCasted = item.As <IOclExpression>();
         if ((valueCasted != null))
         {
             this._parent.Value = valueCasted;
             return;
         }
     }
 }
コード例 #2
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IOclExpression memberCasted = item.As <IOclExpression>();

                if ((memberCasted != null))
                {
                    this._parent.Member.Add(memberCasted);
                }
                if ((this._parent.ReferredCollectionType == null))
                {
                    ICollectionType referredCollectionTypeCasted = item.As <ICollectionType>();
                    if ((referredCollectionTypeCasted != null))
                    {
                        this._parent.ReferredCollectionType = referredCollectionTypeCasted;
                        return;
                    }
                }
                if ((this._parent.Rest == null))
                {
                    IVariable restCasted = item.As <IVariable>();
                    if ((restCasted != null))
                    {
                        this._parent.Rest = restCasted;
                        return;
                    }
                }
            }
コード例 #3
0
 private void GenerateString(IOclExpression exp)
 {
     if (exp is IObjectTemplateExp)
     {
         GenerateString((IObjectTemplateExp)exp);
     }
     else if (exp is IVariableExp)
     {
         GenerateString((IVariableExp)exp);
     }
     else if (exp is CSharpOpaqueExpression)
     {
         GenerateString((CSharpOpaqueExpression)exp);
     }
     else if (exp is Assignment)
     {
         GenerateString((Assignment)exp);
     }
     else if (exp is IRelationCallExp)
     {
         GenerateString((IRelationCallExp)exp);
     }
     else
     {
         throw new Exception("OCL Expression not managed: " + exp);
     }
 }
コード例 #4
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Attribute == null))
     {
         IProperty attributeCasted = item.As <IProperty>();
         if ((attributeCasted != null))
         {
             this._parent.Attribute = attributeCasted;
             return;
         }
     }
     if ((this._parent.TupleLiteralExp == null))
     {
         ITupleLiteralExp tupleLiteralExpCasted = item.As <ITupleLiteralExp>();
         if ((tupleLiteralExpCasted != null))
         {
             this._parent.TupleLiteralExp = tupleLiteralExpCasted;
             return;
         }
     }
     if ((this._parent.Value == null))
     {
         IOclExpression valueCasted = item.As <IOclExpression>();
         if ((valueCasted != null))
         {
             this._parent.Value = valueCasted;
             return;
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Owner == null))
     {
         IRelationDomain ownerCasted = item.As <IRelationDomain>();
         if ((ownerCasted != null))
         {
             this._parent.Owner = ownerCasted;
             return;
         }
     }
     if ((this._parent.ValueExp == null))
     {
         IOclExpression valueExpCasted = item.As <IOclExpression>();
         if ((valueExpCasted != null))
         {
             this._parent.ValueExp = valueExpCasted;
             return;
         }
     }
     if ((this._parent.Variable == null))
     {
         IVariable variableCasted = item.As <IVariable>();
         if ((variableCasted != null))
         {
             this._parent.Variable = variableCasted;
             return;
         }
     }
 }
コード例 #6
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Condition == null))
     {
         IOclExpression conditionCasted = item.As <IOclExpression>();
         if ((conditionCasted != null))
         {
             this._parent.Condition = conditionCasted;
             return;
         }
     }
     if ((this._parent.ElseExpression == null))
     {
         IOclExpression elseExpressionCasted = item.As <IOclExpression>();
         if ((elseExpressionCasted != null))
         {
             this._parent.ElseExpression = elseExpressionCasted;
             return;
         }
     }
     if ((this._parent.ThenExpression == null))
     {
         IOclExpression thenExpressionCasted = item.As <IOclExpression>();
         if ((thenExpressionCasted != null))
         {
             this._parent.ThenExpression = thenExpressionCasted;
             return;
         }
     }
 }
コード例 #7
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.InitExpression == null))
     {
         IOclExpression initExpressionCasted = item.As <IOclExpression>();
         if ((initExpressionCasted != null))
         {
             this._parent.InitExpression = initExpressionCasted;
             return;
         }
     }
     if ((this._parent.LetExp == null))
     {
         ILetExp letExpCasted = item.As <ILetExp>();
         if ((letExpCasted != null))
         {
             this._parent.LetExp = letExpCasted;
             return;
         }
     }
     if ((this._parent.RepresentedParameter == null))
     {
         IParameter representedParameterCasted = item.As <IParameter>();
         if ((representedParameterCasted != null))
         {
             this._parent.RepresentedParameter = representedParameterCasted;
             return;
         }
     }
 }
コード例 #8
0
 public static string GenerateExpression(IOclExpression expression, bool useMetamodelInterface)
 {
     if (expression is IOperationCallExp)
     {
         IOperationCallExp value = (IOperationCallExp)expression;
         return("transformation.Functions." + value.ReferredOperation.Name + "(" + string.Join(",", value.Argument.Select(u => GenerateExpression(u, useMetamodelInterface))) + ")");
     }
     if (expression is CSharpOpaqueExpression)
     {
         CSharpOpaqueExpression value = (CSharpOpaqueExpression)expression;
         return(value.Code);
     }
     if (expression is IVariableExp)
     {
         return(((IVariableExp)expression).ReferredVariable.Name);
     }
     if (expression is Assignment)
     {
         Assignment assignment = (Assignment)expression;
         return(assignment.AssignedVariable.Type.GetRealTypeName() + " " + assignment.AssignedVariable.Name + " = " + GenerateExpression(assignment.Value, useMetamodelInterface));
     }
     if (expression is IRelationCallExp)
     {
         IRelationCallExp relationCallExp = (IRelationCallExp)expression;
         return("transformation." + QvtCodeGeneratorStrings.RelationClassName(relationCallExp.ReferredRelation)
                + ".CheckAndEnforce(" + string.Join(",", relationCallExp.Argument.Select(u => GenerateExpression(u, useMetamodelInterface))) + ")");
     }
     throw new CodeGeneratorException("Cannot manage expression: " + expression);
 }
コード例 #9
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IOclExpression memberCasted = item.As <IOclExpression>();

                if ((memberCasted != null))
                {
                    this._parent.Member.Add(memberCasted);
                }
            }
コード例 #10
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IOclExpression argumentCasted = item.As <IOclExpression>();

                if ((argumentCasted != null))
                {
                    this._parent.Argument.Add(argumentCasted);
                }
            }
コード例 #11
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IOclExpression oclExpressionItem = item.As <IOclExpression>();

                if (((oclExpressionItem != null) &&
                     this._parent.Member.Remove(oclExpressionItem)))
                {
                    return(true);
                }
                return(false);
            }
コード例 #12
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Item == null))
     {
         IOclExpression itemCasted = item.As <IOclExpression>();
         if ((itemCasted != null))
         {
             this._parent.Item = itemCasted;
             return;
         }
     }
 }
コード例 #13
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Source == null))
     {
         IOclExpression sourceCasted = item.As <IOclExpression>();
         if ((sourceCasted != null))
         {
             this._parent.Source = sourceCasted;
             return;
         }
     }
 }
コード例 #14
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.QueryExpression == null))
     {
         IOclExpression queryExpressionCasted = item.As <IOclExpression>();
         if ((queryExpressionCasted != null))
         {
             this._parent.QueryExpression = queryExpressionCasted;
             return;
         }
     }
 }
コード例 #15
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Value == null))
     {
         IOclExpression valueCasted = item.As <IOclExpression>();
         if ((valueCasted != null))
         {
             this._parent.Value = valueCasted;
             return;
         }
     }
 }
コード例 #16
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IOclExpression oclExpressionItem = item.As <IOclExpression>();

                if (((oclExpressionItem != null) &&
                     this._parent.Argument.Remove(oclExpressionItem)))
                {
                    return(true);
                }
                if ((this._parent.ReferredOperation == item))
                {
                    this._parent.ReferredOperation = null;
                    return(true);
                }
                return(false);
            }
コード例 #17
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IOclExpression argumentCasted = item.As <IOclExpression>();

                if ((argumentCasted != null))
                {
                    this._parent.Argument.Add(argumentCasted);
                }
                if ((this._parent.ReferredOperation == null))
                {
                    IOperation referredOperationCasted = item.As <IOperation>();
                    if ((referredOperationCasted != null))
                    {
                        this._parent.ReferredOperation = referredOperationCasted;
                        return;
                    }
                }
            }
コード例 #18
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.Body == null))
                {
                    IOclExpression bodyCasted = item.As <IOclExpression>();
                    if ((bodyCasted != null))
                    {
                        this._parent.Body = bodyCasted;
                        return;
                    }
                }
                IVariable iteratorCasted = item.As <IVariable>();

                if ((iteratorCasted != null))
                {
                    this._parent.Iterator.Add(iteratorCasted);
                }
            }
コード例 #19
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.BodyExpression == null))
                {
                    IOclExpression bodyExpressionCasted = item.As <IOclExpression>();
                    if ((bodyExpressionCasted != null))
                    {
                        this._parent.BodyExpression = bodyExpressionCasted;
                        return;
                    }
                }
                if ((this._parent.ContextVariable == null))
                {
                    IVariable contextVariableCasted = item.As <IVariable>();
                    if ((contextVariableCasted != null))
                    {
                        this._parent.ContextVariable = contextVariableCasted;
                        return;
                    }
                }
                IType generatedTypeCasted = item.As <IType>();

                if ((generatedTypeCasted != null))
                {
                    this._parent.GeneratedType.Add(generatedTypeCasted);
                }
                IVariable parameterVariableCasted = item.As <IVariable>();

                if ((parameterVariableCasted != null))
                {
                    this._parent.ParameterVariable.Add(parameterVariableCasted);
                }
                if ((this._parent.ResultVariable == null))
                {
                    IVariable resultVariableCasted = item.As <IVariable>();
                    if ((resultVariableCasted != null))
                    {
                        this._parent.ResultVariable = resultVariableCasted;
                        return;
                    }
                }
            }
コード例 #20
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.BindsTo == null))
     {
         IVariable bindsToCasted = item.As <IVariable>();
         if ((bindsToCasted != null))
         {
             this._parent.BindsTo = bindsToCasted;
             return;
         }
     }
     if ((this._parent.Where == null))
     {
         IOclExpression whereCasted = item.As <IOclExpression>();
         if ((whereCasted != null))
         {
             this._parent.Where = whereCasted;
             return;
         }
     }
 }
コード例 #21
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IOclExpression oclExpressionItem = item.As <IOclExpression>();

                if (((oclExpressionItem != null) &&
                     this._parent.Member.Remove(oclExpressionItem)))
                {
                    return(true);
                }
                if ((this._parent.ReferredCollectionType == item))
                {
                    this._parent.ReferredCollectionType = null;
                    return(true);
                }
                if ((this._parent.Rest == item))
                {
                    this._parent.Rest = null;
                    return(true);
                }
                return(false);
            }
コード例 #22
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.ConditionExpression == null))
     {
         IOclExpression conditionExpressionCasted = item.As <IOclExpression>();
         if ((conditionExpressionCasted != null))
         {
             this._parent.ConditionExpression = conditionExpressionCasted;
             return;
         }
     }
     if ((this._parent.Pattern == null))
     {
         IPattern patternCasted = item.As <IPattern>();
         if ((patternCasted != null))
         {
             this._parent.Pattern = patternCasted;
             return;
         }
     }
 }
コード例 #23
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.First == null))
     {
         IOclExpression firstCasted = item.As <IOclExpression>();
         if ((firstCasted != null))
         {
             this._parent.First = firstCasted;
             return;
         }
     }
     if ((this._parent.Last == null))
     {
         IOclExpression lastCasted = item.As <IOclExpression>();
         if ((lastCasted != null))
         {
             this._parent.Last = lastCasted;
             return;
         }
     }
 }
コード例 #24
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.In == null))
     {
         IOclExpression inCasted = item.As <IOclExpression>();
         if ((inCasted != null))
         {
             this._parent.In = inCasted;
             return;
         }
     }
     if ((this._parent.Variable == null))
     {
         IVariable variableCasted = item.As <IVariable>();
         if ((variableCasted != null))
         {
             this._parent.Variable = variableCasted;
             return;
         }
     }
 }
コード例 #25
0
        public SelectStatement ToSql(IOclExpression expression)
        {
            var context = new SelectContext {
                Body = new PlainSelect()
            };
            var result = GetExpression(context, (dynamic)expression);
            var body   = context.Body;

            body.SelItems.Add(new SelectItem
            {
                Exp   = result,
                Alias = new Alias
                {
                    Name = "res"
                }
            });
            Complete(body, context);
            return(new SelectStatement
            {
                SelectBody = body
            });
        }