/// <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.Impl == null)) { IOperation implCasted = item.As <IOperation>(); if ((implCasted != null)) { this._parent.Impl = implCasted; return; } } if ((this._parent.InDirectionOf == null)) { ITypedModel inDirectionOfCasted = item.As <ITypedModel>(); if ((inDirectionOfCasted != null)) { this._parent.InDirectionOf = inDirectionOfCasted; return; } } if ((this._parent.Relation == null)) { IRelation relationCasted = item.As <IRelation>(); if ((relationCasted != null)) { this._parent.Relation = relationCasted; return; } } }
/// <summary> /// Create a parameter from MemberInfo (Field / Property) /// </summary> /// <param name="member"></param> /// <returns>TypedParameter if member is valid Field / Property, otherwise null</returns> public static TypedParameter Create(ITypedModel typedModel, MemberInfo member) { var p = Create(member); if (p != null) { p.TypedModel = typedModel; } return(p); }
public static MemberTypedConstraint Create(ITypedModel typedModel, MemberInfo member) { switch (member) { case MethodInfo method: return(Create(typedModel, method)); default: return(null); } }
public static PropertyTypedObjective Create(ITypedModel typedModel, MemberInfo member) { switch (member) { case PropertyInfo property: return(Create(typedModel, property)); default: return(null); } }
public static PropertyTypedObjective Create(ITypedModel typedModel, PropertyInfo property) { var attr = property.GetCustomAttribute <ObjectiveAttribute>(); var name = attr.Name ?? property.Name; var type = property.PropertyType; if (type != typeof(double)) { Console.WriteLine($"Analyzer Warning: type of Constraint {name} must be double. (in {typedModel})"); return(null); } return(new PropertyTypedObjective { Name = name, Type = type, Priority = attr.Priority, TypedModel = typedModel }); }
public static MethodTypedObjective Create(ITypedModel typedModel, MethodInfo methodInfo) { var attr = methodInfo.GetCustomAttribute <ObjectiveAttribute>(); var name = attr.Name ?? methodInfo.Name; var type = methodInfo.ReturnType; if (type != typeof(double)) { Console.WriteLine($"Analyzer Warning: type of Constraint {name} must be double. (in {typedModel})"); return(null); } return(new MethodTypedObjective { Name = name, Type = type, Method = methodInfo, Priority = attr.Priority, TypedModel = typedModel }); }
public static MemberTypedConstraint Create(ITypedModel typedModel, MethodInfo method) { var attr = method.GetCustomAttribute <ConstraintAttribute>(); if (method.ReturnType != typeof(bool)) { return(null); } var name = attr.Name ?? method.Name; return(new MemberTypedConstraint { Name = name, Type = method.ReturnType, Method = method, Priority = attr.Priority, Description = attr.Description, Model = typedModel }); }
/// <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.Rule == null)) { IRule ruleCasted = item.As <IRule>(); if ((ruleCasted != null)) { this._parent.Rule = ruleCasted; return; } } if ((this._parent.TypedModel == null)) { ITypedModel typedModelCasted = item.As <ITypedModel>(); if ((typedModelCasted != null)) { this._parent.TypedModel = typedModelCasted; return; } } }
/// <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) { ITypedModel typedModelItem = item.As <ITypedModel>(); if (((typedModelItem != null) && this._parent.DependsOn.Remove(typedModelItem))) { return(true); } if ((this._parent.Transformation == item)) { this._parent.Transformation = null; return(true); } IPackage packageItem = item.As <IPackage>(); if (((packageItem != null) && this._parent.UsedPackage.Remove(packageItem))) { return(true); } return(false); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { ITypedModel dependsOnCasted = item.As <ITypedModel>(); if ((dependsOnCasted != null)) { this._parent.DependsOn.Add(dependsOnCasted); } if ((this._parent.Transformation == null)) { ITransformation transformationCasted = item.As <ITransformation>(); if ((transformationCasted != null)) { this._parent.Transformation = transformationCasted; return; } } IPackage usedPackageCasted = item.As <IPackage>(); if ((usedPackageCasted != null)) { this._parent.UsedPackage.Add(usedPackageCasted); } }
public static object Activate(this ITypedModel typedModel) => Activator.CreateInstance(typedModel.Type, 0, null, null, null, null);
public static string CheckTowardsMethodName(ITypedModel targetModel) { return("CheckTowards" + targetModel.Name); }
public static string EnforceTowardsMethodName(ITypedModel targetModel) { return("EnforceTowards" + Util.ToFirstUpper(targetModel.Name)); }
public static string TypedModelVariableName(ITypedModel model) { return(Util.ToFirstUpper(model.Name)); }
public GlobalOptimizer(ITypedModel typedModel) { TypedModel = typedModel; }
public static string SetParamMethodName(ITypedModel model) { return("SetParam" + Util.ToFirstUpper(model.Name)); }
public static string RelationCheckTowards(IRelation relation, ITypedModel param) { return("CheckTowards" + ToFirstUpper(param.Name)); }
public static string RelationMatchTargetTowards(IRelation relation, ITypedModel targetParam) { return("MatchTargetTowards" + ToFirstUpper(targetParam.Name)); }
public static string RelationMatchSourceTowards(IRelation relation, ITypedModel param) { return("MatchSourceTowards" + ToFirstUpper(param.Name)); }