コード例 #1
0
 protected EAttribute initEAttribute
     (EAttribute a,
     EGenericType type,
     String name,
     String defaultValue,
     int lowerBound,
     int upperBound,
     Type containerClass,
     bool isTransient,
     bool isVolatile,
     bool isChangeable,
     bool isUnsettable,
     bool isID,
     bool isUnique,
     bool isDerived,
     bool isOrdered)
 {
     initEStructuralFeature
         (a,
         type,
         name,
         defaultValue,
         lowerBound,
         upperBound,
         containerClass,
         isTransient,
         isVolatile,
         isChangeable,
         isUnsettable,
         isUnique,
         isDerived,
         isOrdered);
     a.iD = isID;
     return(a);
 }
コード例 #2
0
        private String value(EObject eobject, EAttribute attribute)
        {
            var classifier = attribute.eType;

            if (classifier.Equals(EcorePackageImpl.Literals.EBOOLEAN))
            {
                return($"{eobject.eGet(attribute)}");
            }
            else if (classifier.Equals(EcorePackageImpl.Literals.EINT))
            {
                return($"{eobject.eGet(attribute)}");
            }
            else if (classifier.Equals(EcorePackageImpl.Literals.EDOUBLE))
            {
                return($"{eobject.eGet(attribute)}");
            }
            else if (classifier.Equals(EcorePackageImpl.Literals.EFLOAT))
            {
                return($"{eobject.eGet(attribute)}");
            }
            else if (classifier.Equals(EcorePackageImpl.Literals.ESTRING))
            {
                return($"\"{eobject.eGet(attribute)}\"");
            }
            else if (classifier.Equals(EcorePackageImpl.Literals.ECHAR))
            {
                return($"\"{eobject.eGet(attribute)}\"");
            }
            else
            {
                throw new ArgumentException();
            }
        }
コード例 #3
0
 protected EAttribute initEAttribute
     (EAttribute a,
     EClassifier type,
     String name,
     String defaultValue,
     int lowerBound,
     int upperBound,
     bool isTransient,
     bool isVolatile,
     bool isChangeable,
     bool isUnsettable,
     bool isID,
     bool isUnique,
     bool isDerived)
 {
     return
         (initEAttribute
              (a,
              type,
              name,
              defaultValue,
              lowerBound,
              upperBound,
              isTransient,
              isVolatile,
              isChangeable,
              isUnsettable,
              isID,
              isUnique,
              isDerived,
              true));
 }
コード例 #4
0
 protected EAttribute initEAttribute
     (EAttribute a,
     EClassifier type,
     String name,
     String defaultValue,
     int lowerBound,
     int upperBound,
     bool isTransient,
     bool isVolatile,
     bool isChangeable,
     bool isUnsettable,
     bool isID,
     bool isUnique,
     bool isDerived,
     bool isOrdered)
 {
     initEAttribute
         (a,
         type,
         name,
         defaultValue,
         lowerBound,
         upperBound,
         ((EClassifier)a.eContainer()).instanceClass,
         isTransient,
         isVolatile,
         isChangeable,
         isUnsettable,
         isID,
         isUnique,
         isDerived,
         isOrdered);
     return(a);
 }
コード例 #5
0
        public static string getID(EObject eObject)
        {
            EClass     eClass       = eObject.eClass();
            EAttribute eIDAttribute = eClass.eIDAttribute;

            return(eIDAttribute == null || !eObject.eIsSet(eIDAttribute) ? null : convertToString(
                       eIDAttribute.eAttributeType,
                       eObject.eGet(eIDAttribute)));
        }
コード例 #6
0
        protected DiagnosticChain createBadDataValueDiagnostic
            (EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Dictionary <object, object> context)
        {
            BasicDiagnostic diagnostic =
                createDiagnostic
                    (BasicDiagnostic.ERROR,
                    DIAGNOSTIC_SOURCE,
                    EOBJECT__EVERY_DATA_VALUE_CONFORMS,
                    "_UI_BadDataValue_diagnostic",
                    new Object[]
            {
                getFeatureLabel(eAttribute, context),
                getObjectLabel(eObject, context)
            },
                    new Object[] { eObject, eAttribute },
                    context);

            diagnostics.add(diagnostic);
            return(diagnostic);
        }
コード例 #7
0
        public bool validateEAttribute(EAttribute obj, DiagnosticChain diagnostics, Dictionary <object, object> context)
        {
            if (!validate_NoCircularContainment(obj, diagnostics, context))
            {
                return(false);
            }
            bool result = validate_EveryMultiplicityConforms(obj, diagnostics, context);

            if (result || diagnostics != null)
            {
                result &= validate_EveryDataValueConforms(obj, diagnostics, context);
            }
            if (result || diagnostics != null)
            {
                result &= validate_EveryReferenceIsContained(obj, diagnostics, context);
            }
            if (result || diagnostics != null)
            {
                result &= validate_EveryBidirectionalReferenceIsPaired(obj, diagnostics, context);
            }
            //if (result || diagnostics != null) result &= validate_EveryProxyResolves(obj, diagnostics, context);
            if (result || diagnostics != null)
            {
                result &= validate_UniqueID(obj, diagnostics, context);
            }
            if (result || diagnostics != null)
            {
                result &= validate_EveryKeyUnique(obj, diagnostics, context);
            }
            if (result || diagnostics != null)
            {
                result &= validate_EveryMapEntryUnique(obj, diagnostics, context);
            }

            return(result);
        }
コード例 #8
0
ファイル: PlayerHealth.cs プロジェクト: MatiGP/SmallBraveHero
 public int GetStat(EAttribute attribute)
 {
     return(playerStats[(int)attribute].Value);
 }
コード例 #9
0
ファイル: PlayerHealth.cs プロジェクト: MatiGP/SmallBraveHero
 public void DecreaseStat(EAttribute attribute, int value)
 {
     playerStats[(int)attribute].Decrease(value);
 }
コード例 #10
0
        private string getFragment(EObject eobject)
        {
            EAttribute idfeature = eobject.eClass().eIDAttribute;

            return($"#//{eobject.eGet(idfeature)}");
        }
コード例 #11
0
        protected bool validate_DataValueConforms(EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Dictionary <object, object> context)
        {
            if (!eObject.eIsSet(eAttribute))
            {
                return(true);
            }
            bool      result    = true;
            EDataType eDataType = eAttribute.eAttributeType;

            EValidator rootValidator = getRootEValidator(context);
            object     value         = eObject.eGet(eAttribute);

            /*
             * if (FeatureMapUtil.isFeatureMap(eAttribute))
             * {
             *  Collection<FeatureMap.Entry> featureMap = (Collection<FeatureMap.Entry>)value;
             *  EClass eClass = eObject.eClass();
             *  Dictionary<EStructuralFeature, DiagnosticChain> entryFeatureToDiagnosticChainMap = null;
             *  for (Iterator<FeatureMap.Entry> i = featureMap.iterator(); i.hasNext() && (result || diagnostics != null);)
             *  {
             *      FeatureMap.Entry entry = i.next();
             *      EStructuralFeature entryFeature = entry.getEStructuralFeature();
             *      if (entryFeature instanceof EAttribute &&
             *            ExtendedMetaData.INSTANCE.getAffiliation(eClass, entryFeature) == eAttribute)
             *      {
             *          EDataType entryType = (EDataType)entryFeature.getEType();
             *          Object entryValue = entry.getValue();
             *          bool entryIsValid = rootValidator.validate(entryType, entryValue, null, context);
             *          if (!entryIsValid)
             *          {
             *              result = false;
             *              if (diagnostics != null)
             *              {
             *                  if (entryFeatureToDiagnosticChainMap == null)
             *                  {
             *                      entryFeatureToDiagnosticChainMap = new HashMap<EStructuralFeature, DiagnosticChain>();
             *                  }
             *                  DiagnosticChain entryFeatureDiagnostic = entryFeatureToDiagnosticChainMap.get(entryFeature);
             *                  if (entryFeatureDiagnostic == null)
             *                  {
             *                      entryFeatureDiagnostic = createBadDataValueDiagnostic(eObject, (EAttribute)entryFeature, diagnostics, context);
             *                      entryFeatureToDiagnosticChainMap.put(entryFeature, entryFeatureDiagnostic);
             *                  }
             *                  rootValidator.validate(entryType, entryValue, entryFeatureDiagnostic, context);
             *              }
             *          }
             *      }
             *  }
             * }
             * else*/
            if (eAttribute.many)
            {
                foreach (object item in value as IList <object> )
                {
                    result &= rootValidator.validate(eDataType, item, null, context);
                }


                if (!result && diagnostics != null)
                {
                    DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context);

                    foreach (object item in value as IList <object> )
                    {
                        rootValidator.validate(eDataType, item, diagnostic, context);
                    }
                }
            }
            else if (value != null)
            {
                result = rootValidator.validate(eDataType, value, null, context);
                if (!result && diagnostics != null)
                {
                    DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context);
                    rootValidator.validate(eDataType, value, diagnostic, context);
                }
            }

            return(result);
        }
コード例 #12
0
        protected bool validate_KeyUnique
            (EObject eObject, EReference eReference, DiagnosticChain diagnostics, Dictionary <object, object> context)
        {
            bool result = true;
            Dictionary <List <Object>, EObject> keys = new Dictionary <List <Object>, EObject>();
            List <EAttribute> eAttributes            = eReference.eKeys;// (EAttribute[])((BasicEList <?>)eReference.getEKeys()).data();

            List <EObject> values = (List <EObject>)eObject.eGet(eReference);

            foreach (EObject value in values)
            {
                List <Object> key = new List <Object>();
                for (int i = 0, size = eAttributes.Count; i < size; ++i)
                {
                    EAttribute eAttribute = eAttributes[i];
                    if (eAttribute == null)
                    {
                        break;
                    }
                    else
                    {
                        key.Add(value.eGet(eAttribute));
                    }
                }
                EObject otherValue = null;
                if (keys.ContainsKey(key))
                {
                    otherValue = keys[key];
                }

                keys.Add(key, value);

                if (otherValue != null)
                {
                    result = false;
                    if (diagnostics == null)
                    {
                        break;
                    }
                    else
                    {
                        String uriFragmentSegment = ((InternalEObject)eObject).eURIFragmentSegment(eReference, value);
                        int    index = uriFragmentSegment.IndexOf('[', 0);
                        if (index != -1)
                        {
                            uriFragmentSegment = uriFragmentSegment.Substring(index);
                        }
                        diagnostics.add
                            (createDiagnostic
                                (BasicDiagnostic.ERROR,
                                DIAGNOSTIC_SOURCE,
                                EOBJECT__EVERY_KEY_UNIQUE,
                                "_UI_DuplicateKey_diagnostic",
                                new Object[]
                        {
                            getFeatureLabel(eReference, context),
                            uriFragmentSegment,
                            getObjectLabel(value, context),
                            getObjectLabel(otherValue, context)
                        },
                                new Object[] { eObject, eReference, value, otherValue },
                                context));
                    }
                }
            }

            return(result);
        }
コード例 #13
0
 public virtual T caseEAttribute(EAttribute theEObject)
 {
     return(default(T));
 }