Ejemplo n.º 1
0
    public static void AttributeSave(string AttributeName, string AttributeValue)
    {
        ClassAttribute oAttr = new ClassAttribute(AttributeName);

        oAttr.DeleteByName(AttributeName);
        oAttr.AttributeName = AttributeName;
        oAttr.AttributeValue = AttributeValue;
        oAttr.Save(0);
    }
Ejemplo n.º 2
0
    public static string AttributeLoad(string AttributeName, string DefaultValue)
    {
        string RetVal = DefaultValue;

        ClassAttribute oAttr = new ClassAttribute(AttributeName);

        if (oAttr.AttributeId != 0)
            RetVal = oAttr.AttributeValue;

        return RetVal;
    }
Ejemplo n.º 3
0
        public virtual IList <TTControl> ControlAttributeStartWithCollection <TTControl>(string name, string value, bool isSearchAllSubElement = false) where TTControl : ControlBase, new()
        {
            IList <TTControl> controlCollection = new List <TTControl>();

            foreach (var item in FindWebElementFromCurrentWebElements(ClassAttribute.Get(typeof(TTControl)) + string.Format("[starts-with(@{0},'{1}')]", name, value), isSearchAllSubElement))
            {
                TTControl tt = new TTControl();
                tt.WrappedElement = item;
                controlCollection.Add(tt);
            }

            return(controlCollection);
        }
Ejemplo n.º 4
0
 public override TTControl ControlText <TTControl>(string text, bool isSearchAllSubElement = false)
 {
     if (typeof(TTControl) == this.GetType())
     {
         WrappedElement = FindWebElementFromCurrentWebElement(_thBase + string.Format("[text()='{0}']", text), isSearchAllSubElement);
         return(this as TTControl);
     }
     else
     {
         TTControl tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(_thBase + ClassAttribute.Get(typeof(TTControl)) + string.Format("[text()='{0}']", text), isSearchAllSubElement);
         return(tt);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Select Cell by Attrubute (Some controls like row and table whose args of constructor is different from normal controls need to override this function)
 /// </summary>
 /// <typeparam name="TTControl">Sub Control Type</typeparam>
 /// <param name="name">Attribute Name</param>
 /// <param name="value">Attribute value</param>
 /// <returns></returns>
 public virtual TTControl ControlAttributeFuzzy <TTControl>(string name, string value) where TTControl : ControlBase, new()
 {
     if (typeof(TTControl) == this.GetType())
     {
         WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::") + string.Format("[contains(@{0},'{1}')]", name, value));
         return(this as TTControl);
     }
     else
     {
         TTControl tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)) + string.Format("[contains(@{0},'{1}')]", name, value));
         return(tt);
     }
 }
Ejemplo n.º 6
0
 public virtual TTControl ControlTextFuzzy <TTControl>(string text, bool isSearchAllSubElement = false) where TTControl : ControlBase, new()
 {
     if (typeof(TTControl) == this.GetType())
     {
         WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::") + string.Format("[contains(text(),'{0}')]", text), isSearchAllSubElement);
         return(this as TTControl);
     }
     else
     {
         TTControl tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)) + string.Format("[contains(text(),'{0}')]", text), isSearchAllSubElement);
         return(tt);
     }
 }
Ejemplo n.º 7
0
        private void Inject(ClassAttribute attribute)
        {
            if (attribute.MethodInvocationPoint == MethodInvocationPoint.BeforeMethod ||
                attribute.MethodInvocationPoint == MethodInvocationPoint.MethodBoundary)
            {
                Processor.InsertBeforeMethod(GetBeforeMethodActionInjection());
            }

            if (attribute.MethodInvocationPoint == MethodInvocationPoint.AfterMethod ||
                attribute.MethodInvocationPoint == MethodInvocationPoint.MethodBoundary)
            {
                Processor.InsertAfterMethod(GetAfterMethodActionInjection());
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Select Cell by Attrubute (Some controls like row and table whose args of constructor is different from normal controls need to override this function)
 /// </summary>
 /// <typeparam name="TTControl">Sub Control Type</typeparam>
 /// <param name="name">Attribute Name</param>
 /// <param name="value">Attribute value</param>
 /// <returns></returns>
 public override TTControl ControlAttributeFuzzy <TTControl>(string name, string value)
 {
     if (typeof(TTControl) == this.GetType())
     {
         TTControl tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(_trBase + string.Format("[contains(@{0},'{1}')]", name, value));
         return(tt);
     }
     else
     {
         TTControl tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(_trBase + ClassAttribute.Get(typeof(TTControl)) + string.Format("[contains(@{0},'{1}')]", name, value));
         return(tt);
     }
 }
    public void Test3()
    {
        var obj3 = new ClassAttribute(22);

        if (obj3.getAttribute() != 22)
        {
            Environment.Exit(-1);
        }

        obj3.setAttribute(false);

        if (obj3.getAttribute() == true)
        {
            Environment.Exit(-1);
        }
    }
Ejemplo n.º 10
0
        internal static AttributeEntityMappingProvider FromAttribute(Type type, ClassAttribute classMapping)
        {
            var types = new List <Type>()
            {
                typeof(Type)
            };
            var parameters = new List <object>()
            {
                type
            };

            AddTerm(types, parameters, classMapping.MappedIri, classMapping.Prefix, classMapping.Term);
            AddTerm(types, parameters, classMapping.GraphIri, classMapping.GraphPrefix, classMapping.GraphTerm);
            return((AttributeEntityMappingProvider)typeof(AttributeEntityMappingProvider)
                   .GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, types.ToArray(), null).Invoke(parameters.ToArray()));
        }
Ejemplo n.º 11
0
        public void ShouldInitializeTypeWithSeveralAttributes()
        {
            MockObjectMultipleAttributes obj = new MockObjectMultipleAttributes();

            inst.obj = obj;

            MockObjectMultipleAttributes actual = decorator.InitializeType <MockObjectMultipleAttributes>(typeof(MockObjectMultipleAttributes), new Object[0]);

            for (int i = actual.AttibuteClasses.Count - 1; i >= 0; i--)
            {
                ClassAttribute attribute = (ClassAttribute)actual.AttibuteClasses[i];
                Assert.AreEqual(0, ((MockAttribute)attribute).preInstantiated);
                Assert.AreEqual(1, ((MockAttribute)attribute).before);
                Assert.AreEqual(2, ((MockAttribute)attribute).postInstantiated);
                Assert.AreEqual(3, ((MockAttribute)attribute).after);
            }
        }
Ejemplo n.º 12
0
 public RadioItem GetRadioItemByText <TTControl>(string text) where TTControl : ControlBase, new()
 {
     if (base.WrappedElement == null)
     {
         var tt = new TTControl();
         tt.WrappedElement = tt.CurrentBrowser.WebDriver.FindElement(By.XPath("/" + string.Format("{0}", ClassAttribute.Get(typeof(TTControl)))));
         var t = new RadioItem(By.XPath("/" + ClassAttribute.Get(typeof(TTControl)) + string.Format("[contains(text(),'{0}')]", text)));
         return(t);
     }
     else
     {
         var tt = new TTControl();
         tt.WrappedElement = FindWebElementFromCurrentWebElement(string.Format("/{0}", ClassAttribute.Get(typeof(TTControl))));
         var t = tt.ControlTextFuzzy <TTControl>(text).PrecedingSibling <RadioItem>();
         return(t);
     }
 }
    public void Test4()
    {
        ClassAttribute obj4 = new ClassAttribute(24);

        Console.WriteLine(obj4.getAttribute());

        int n = obj4.getAttribute();

        Console.WriteLine(n);

        obj4.setAttribute("Hello");
        Console.WriteLine(obj4.getAttribute());

        string s = obj4.getAttribute();

        Console.WriteLine(s);

        obj4.setAttribute(true);
        Console.WriteLine(obj4.getAttribute());

        bool b = obj4.getAttribute();

        Console.WriteLine(b);

        obj4.setAttribute(7.9);
        Console.WriteLine(obj4.getAttribute());

        double n2 = obj4.getAttribute();

        Console.WriteLine(n2);

        obj4.setAttribute(obj4);
        Console.WriteLine(obj4.getAttribute());

        object obj5 = obj4.getAttribute();

        Console.WriteLine(obj5);

        obj4.setAttribute('P');
        Console.WriteLine(obj4.getAttribute());

        char character = obj4.getAttribute();

        Console.WriteLine(character);
    }
Ejemplo n.º 14
0
        public Tag Classes(params string[] classes)
        {
            HtmlAttribute attribute;

            if (!_attributes.TryGetValue(HtmlAttribute.Class, out attribute))
            {
                attribute = new ClassAttribute(classes);
                _attributes[attribute.Name] = attribute;
            }
            else
            {
                foreach (var @class in classes)
                {
                    ((ClassAttribute)attribute).Values.Add(@class);
                }
            }
            return(this);
        }
    public void Test1()
    {
        var obj = new ClassAttribute(2);

        if (obj.getAttribute() != 2)
        {
            Environment.Exit(-1);
        }

        var number = obj.getAttribute();

        if (number != 2)
        {
            Environment.Exit(-1);
        }

        var aux = obj.getAttribute() + 58;

        if (aux != 60)
        {
            Environment.Exit(-1);
        }

        var o = obj.getAttribute();

        if (o != 2)
        {
            Environment.Exit(-1);
        }

        var d = obj.getAttribute();

        if (d != 2.0)
        {
            Environment.Exit(-1);
        }

        double d2 = obj.getAttribute();

        if (d2 != 2.0)
        {
            Environment.Exit(-1);
        }
    }
Ejemplo n.º 16
0
        /*
         * Build an attribute based on a value. Search in the static fields for the value.
         * */
        public static Logical GetLogicalAttribute(String value)
        {
            Domain.Entities.Attribute attribute = null;

            if (fuel.Contains(value))
            {
                attribute = new EngineAttribute(value);
            }
            if (colors.Contains(value))
            {
                attribute = new ColorAttribute(value);
            }
            if (vehicleClass.Contains(value))
            {
                attribute = new ClassAttribute(value);
            }
            if (transmission.Contains(value))
            {
                attribute = new TransmissionAttribute(value);
            }

            if (value.Contains("seater"))
            {
                attribute = new SeatsAttribute(value);
            }
            if (value.Equals("gps"))
            {
                attribute = new GPSAttribute();
            }
            if (value.Equals("sunroof"))
            {
                attribute = new SunroofAttribute();
            }

            if (attribute == null)
            {
                throw new ParseException($"Attribute {value} not found!");
            }

            return(new LogicalAttribute(attribute));
        }
        private static Type[] GetTypesWithClassAttribute(Assembly asm)
        {
            Type[]            types      = asm.GetTypes();
            Collection <Type> classTypes = new Collection <Type>();

            foreach (Type t in types)
            {
                //Console.WriteLine("type:" + t.Name);
                Type           tAtt = typeof(ClassAttribute);
                ClassAttribute a    = (ClassAttribute)Attribute.GetCustomAttribute(t, tAtt);
                if (a != null)
                {
                    //Console.WriteLine("Are clasa: " + a.Name);
                    classTypes.Add(t);
                }
            }

            Type[] classTypesArray = new Type[classTypes.Count];
            classTypes.CopyTo(classTypesArray, 0);
            return(classTypesArray);
        }
    public void Test2()
    {
        var obj2 = new ClassAttribute(22);

        if (obj2.getAttribute() != 22)
        {
            Environment.Exit(-1);
        }

        obj2.setAttribute(new ClassAttribute(true));
        if (!(obj2.getAttribute() is ClassAttribute))
        {
            Environment.Exit(-1);
        }

        obj2.setAttribute(3.3);
        if (obj2.getAttribute() != 3.3)
        {
            Environment.Exit(-1);
        }
    }
        public List <ClassAttribute> ReadAttribute()
        {
            List <ClassAttribute> attributes = new List <ClassAttribute>();
            ClassAttribute        attribute;
            int    buffer;
            string fullPath = _path + _characterName + ".xml";

            _reader = XmlReader.Create(fullPath);
            while (_reader.ReadToFollowing("Attribute"))
            {
                attribute = new ClassAttribute();
                _reader.MoveToFirstAttribute();
                attribute.Name = _reader.Value;
                _reader.MoveToNextAttribute();
                attribute.Short = _reader.Value;
                _reader.MoveToNextAttribute();
                Int32.TryParse(_reader.Value, out buffer);
                attribute.Score = buffer;
                attributes.Add(attribute);
            }
            return(attributes);
        }
Ejemplo n.º 20
0
    public static void Main()
    {
        Type classType = typeof(Weapon);

        object[] attributes = classType.GetCustomAttributes(false);

        foreach (var attr in attributes)
        {
            ClassAttribute classAttr = attr as ClassAttribute;

            if (classAttr != null)
            {
                string command;
                while ((command = Console.ReadLine()) != "END")
                {
                    switch (command)
                    {
                    case "Author":
                        Console.WriteLine($"Author: {classAttr.Author}");
                        break;

                    case "Revision":
                        Console.WriteLine($"Revision: {classAttr.Revision}");
                        break;

                    case "Description":
                        Console.WriteLine($"Class description: {classAttr.Description}");
                        break;

                    case "Reviewers":
                        Console.WriteLine($"Reviewers: {string.Join(", ", classAttr.Reviewers)}");
                        break;
                    }
                }
            }
        }

        Console.WriteLine();
    }
    public void Test1()
    {
        ClassAttribute obj = new ClassAttribute(2);

        Console.WriteLine(obj.getAttribute());

        int number = obj.getAttribute();

        Console.WriteLine(number);

        var aux = obj.getAttribute() + 58;

        Console.WriteLine(aux);

        object o = obj.getAttribute();

        Console.WriteLine(o);

        double d = obj.getAttribute();

        Console.WriteLine(d);
    }
Ejemplo n.º 22
0
        public List <Tuple <IObjectAttribute, ClassAttribute> > ImportDataObject(string fileName, byte[] fileContent)
        {
            IObjectAttributeFactory objectAttributeFactory = Pkcs11Admin.Instance.Factories.ObjectAttributeFactory;

            List <Tuple <IObjectAttribute, ClassAttribute> > objectAttributes = StringUtils.GetCreateDefaultAttributes(Pkcs11Admin.Instance.Config.DataObjectAttributes, null);

            bool ckaLabelFound = false;
            bool ckaValueFound = false;

            for (int i = 0; i < objectAttributes.Count; i++)
            {
                IObjectAttribute objectAttribute = objectAttributes[i].Item1;
                ClassAttribute   classAttribute  = objectAttributes[i].Item2;

                if (objectAttribute.Type == (ulong)CKA.CKA_LABEL)
                {
                    objectAttributes[i] = new Tuple <IObjectAttribute, ClassAttribute>(objectAttributeFactory.Create(CKA.CKA_LABEL, fileName), classAttribute);
                    ckaLabelFound       = true;
                }
                else if (objectAttribute.Type == (ulong)CKA.CKA_VALUE)
                {
                    objectAttributes[i] = new Tuple <IObjectAttribute, ClassAttribute>(objectAttributeFactory.Create(CKA.CKA_VALUE, fileContent), classAttribute);
                    ckaValueFound       = true;
                }
            }

            if (!ckaLabelFound)
            {
                throw new Exception("TODO - ClassAttributeNotFoundException");
            }

            if (!ckaValueFound)
            {
                throw new Exception("TODO - ClassAttributeNotFoundException");
            }

            return(objectAttributes);
        }
    public void Test1()
    {
        ClassAttribute obj = new ClassAttribute(2);

        if (obj.getAttribute() != 2)
        {
            Environment.Exit(-1);
        }

        int number = obj.getAttribute();

        if (number != 2)
        {
            Environment.Exit(-1);
        }

        var aux = obj.getAttribute() + 58;

        if (aux != 60)
        {
            Environment.Exit(-1);
        }

        object o = obj.getAttribute();

        if (!((o is Int32) && ((int)o == 2)))
        {
            Environment.Exit(-1);
        }

        double d = obj.getAttribute();

        if (d != 2)
        {
            Environment.Exit(-1);
        }
    }
Ejemplo n.º 24
0
        public virtual IList <TTControl> ControlTextFuzzyCollection <TTControl>(string text, bool isSearchAllSubElement = false) where TTControl : ControlBase, new()
        {
            IList <TTControl> controlCollection = new List <TTControl>();

            if (typeof(TTControl) == this.GetType())
            {
                foreach (var item in FindWebElementFromCurrentWebElements(string.Format("[contains(text(),'{0}')]", text), isSearchAllSubElement))
                {
                    TTControl tt = new TTControl();
                    tt.WrappedElement = item;
                    controlCollection.Add(tt);
                }
            }
            else
            {
                foreach (var item in FindWebElementFromCurrentWebElements(ClassAttribute.Get(typeof(TTControl)) + string.Format("[contains(text(),'{0}')]", text), isSearchAllSubElement))
                {
                    TTControl tt = new TTControl();
                    tt.WrappedElement = item;
                    controlCollection.Add(tt);
                }
            }
            return(controlCollection);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// For getting the elements if the xpath can get 2 more elements
        /// </summary>
        //public IList<IWebElement> Collection
        //{
        //    get
        //    {
        //        return FindWebElementFromCurrentWebElement(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::"));
        //    }
        //}

        public virtual IList <TTControl> GetControlCollection <TTControl>() where TTControl : ControlBase, new()
        {
            IList <TTControl> controlCollection = new List <TTControl>();

            try
            {
                foreach (var item in FindWebElementFromCurrentWebElements(ClassAttribute.Get(typeof(TTControl)).Replace("/", "/parent::")))
                {
                    TTControl tt = new TTControl();
                    tt.WrappedElement = item;
                    controlCollection.Add(tt);
                }
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }
            catch (NotFoundException)
            {
                Assert.Fail("No Control Found");
            }

            return(controlCollection);
        }
Ejemplo n.º 26
0
 public int CompareTo(SyntaxClass other)
 {
     return(ClassAttribute.CompareTo(other.ClassAttribute));
 }
Ejemplo n.º 27
0
 public override int GetHashCode()
 {
     return(ClassAttribute.GetHashCode());
 }
Ejemplo n.º 28
0
        public List <Tuple <IObjectAttribute, ClassAttribute> > ImportCertificate(string fileName, byte[] fileContent)
        {
            IObjectAttributeFactory objectAttributeFactory = Pkcs11Admin.Instance.Factories.ObjectAttributeFactory;

            X509CertificateParser x509CertificateParser = new X509CertificateParser();
            X509Certificate       x509Certificate       = x509CertificateParser.ReadCertificate(fileContent);

            List <Tuple <IObjectAttribute, ClassAttribute> > objectAttributes = StringUtils.GetCreateDefaultAttributes(Pkcs11Admin.Instance.Config.CertificateAttributes, (ulong)CKC.CKC_X_509);

            for (int i = 0; i < objectAttributes.Count; i++)
            {
                IObjectAttribute objectAttribute = objectAttributes[i].Item1;
                ClassAttribute   classAttribute  = objectAttributes[i].Item2;

                if (objectAttribute.Type == (ulong)CKA.CKA_LABEL)
                {
                    string label = fileName;
                    Dictionary <string, List <string> > subject = Utils.ParseX509Name(x509Certificate.SubjectDN);
                    if (subject.ContainsKey(X509ObjectIdentifiers.CommonName.Id) && (subject[X509ObjectIdentifiers.CommonName.Id].Count > 0))
                    {
                        label = subject[X509ObjectIdentifiers.CommonName.Id][0];
                    }

                    objectAttributes[i] = new Tuple <IObjectAttribute, ClassAttribute>(objectAttributeFactory.Create(CKA.CKA_LABEL, label), classAttribute);
                }
                else if (objectAttribute.Type == (ulong)CKA.CKA_START_DATE)
                {
                    objectAttributes[i] = new Tuple <IObjectAttribute, ClassAttribute>(objectAttributeFactory.Create(CKA.CKA_START_DATE, x509Certificate.NotBefore), classAttribute);
                }
                else if (objectAttribute.Type == (ulong)CKA.CKA_END_DATE)
                {
                    objectAttributes[i] = new Tuple <IObjectAttribute, ClassAttribute>(objectAttributeFactory.Create(CKA.CKA_END_DATE, x509Certificate.NotAfter), classAttribute);
                }
                else if (objectAttribute.Type == (ulong)CKA.CKA_SUBJECT)
                {
                    objectAttributes[i] = new Tuple <IObjectAttribute, ClassAttribute>(objectAttributeFactory.Create(CKA.CKA_SUBJECT, x509Certificate.SubjectDN.GetDerEncoded()), classAttribute);
                }
                else if (objectAttribute.Type == (ulong)CKA.CKA_ID)
                {
                    byte[] thumbPrint = null;
                    using (SHA1Managed sha1Managed = new SHA1Managed())
                        thumbPrint = sha1Managed.ComputeHash(x509Certificate.GetEncoded());

                    objectAttributes[i] = new Tuple <IObjectAttribute, ClassAttribute>(objectAttributeFactory.Create(CKA.CKA_ID, thumbPrint), classAttribute);
                }
                else if (objectAttribute.Type == (ulong)CKA.CKA_ISSUER)
                {
                    objectAttributes[i] = new Tuple <IObjectAttribute, ClassAttribute>(objectAttributeFactory.Create(CKA.CKA_ISSUER, x509Certificate.IssuerDN.GetDerEncoded()), classAttribute);
                }
                else if (objectAttribute.Type == (ulong)CKA.CKA_SERIAL_NUMBER)
                {
                    objectAttributes[i] = new Tuple <IObjectAttribute, ClassAttribute>(objectAttributeFactory.Create(CKA.CKA_SERIAL_NUMBER, new DerInteger(x509Certificate.SerialNumber).GetDerEncoded()), classAttribute);
                }
                else if (objectAttribute.Type == (ulong)CKA.CKA_VALUE)
                {
                    objectAttributes[i] = new Tuple <IObjectAttribute, ClassAttribute>(objectAttributeFactory.Create(CKA.CKA_VALUE, x509Certificate.GetEncoded()), classAttribute);
                }
            }

            return(objectAttributes);
        }
Ejemplo n.º 29
0
        internal static Property Parse(ClassAttribute clsa, String vocabBindingRealm, ClassRepository cr, Dictionary <string, Package> derivationSuppliers)
        {
            // TODO: Support EnumerationValue stuff
            Property retVal = new Property();

            // Name (and busines names)
            retVal.Name = clsa.Name;
            foreach (BusinessName bn in clsa.BusinessName)
            {
                if (bn.Language == MifCompiler.Language || bn.Language == null)
                {
                    retVal.BusinessName = bn.Name;
                }
            }

            // Documentation
            if (clsa.Annotations != null)
            {
                retVal.Documentation = DocumentationParser.Parse(clsa.Annotations.Documentation);
            }

            // Conformance
            retVal.Conformance = clsa.IsMandatory ? ClassContent.ConformanceKind.Mandatory : clsa.Conformance == ConformanceKind.Required ? ClassContent.ConformanceKind.Required :
                                 ClassContent.ConformanceKind.Optional;

            if (retVal.Conformance != Property.ConformanceKind.Mandatory && clsa.MinimumMultiplicity == "1")
            {
                retVal.Conformance = Property.ConformanceKind.Populated;
            }

            // Min / Max occurs
            if (retVal.Conformance == MohawkCollege.EHR.gpmr.COR.Property.ConformanceKind.Mandatory)
            {
                retVal.MinOccurs = "1";
            }
            else
            {
                retVal.MinOccurs = clsa.MinimumMultiplicity;
            }
            retVal.MaxOccurs = clsa.MaximumMultiplicity == "-1" ? "*" : clsa.MaximumMultiplicity;
            retVal.MaxLength = clsa.MaximumLength;
            retVal.MinLength = clsa.MinimumLength;

            // Structural or non?
            retVal.PropertyType = clsa.IsImmutable ? Property.PropertyTypes.Structural : Property.PropertyTypes.NonStructural;

            // Default value
            retVal.DefaultValue = clsa.DefaultValue;
            retVal.Initializor  = clsa.DefaultFrom == DefaultDeterminerKind.ITS ? Property.InitializorTypes.ITS :
                                  clsa.DefaultFrom == DefaultDeterminerKind.Realm ? Property.InitializorTypes.Realm :
                                  clsa.DefaultFrom == DefaultDeterminerKind.ReferencingAttribute ? Property.InitializorTypes.ReferencedAttributes : Property.InitializorTypes.DefaultValue;

            if (clsa.DerivedFrom != null)
            {
                retVal.Realization = new List <ClassContent>();
                foreach (var dei in clsa.DerivedFrom)
                {
                    MohawkCollege.EHR.gpmr.COR.Feature ss = null;
                    Package derivationPkg = null;
                    if (!derivationSuppliers.TryGetValue(dei.StaticModelDerivationId, out derivationPkg) || derivationPkg == null)
                    {
                        continue;
                    }

                    // Has the package been compiled?
                    if (!cr.TryGetValue(string.Format("{0}", derivationPkg.PackageLocation.Artifact == ArtifactKind.RIM ? "RIM" : derivationPkg.PackageLocation.ToString(MifCompiler.NAME_FORMAT)), out ss))
                    {
                        // Attempt to parse
                        PackageParser.Parse(derivationPkg.PackageLocation.ToString(MifCompiler.NAME_FORMAT), derivationPkg.MemberOfRepository, cr);
                        // Ditch if still can't find
                        if (!cr.TryGetValue(string.Format("{0}", derivationPkg.PackageLocation.Artifact == ArtifactKind.RIM ? "RIM" : derivationPkg.PackageLocation.ToString(MifCompiler.NAME_FORMAT)), out ss))
                        {
                            System.Diagnostics.Trace.WriteLine(String.Format("Can't find derivation class '{0}' for association '{1}' (derivation supplier {2})", dei.ClassName, dei.AttributeName, dei.StaticModelDerivationId), "warn");
                        }
                    }

                    // Feature was found
                    var f = (ss as MohawkCollege.EHR.gpmr.COR.SubSystem).FindClass(dei.ClassName);
                    if (f != null)
                    {
                        ClassContent cc = f.GetFullContent().Find(o => o.Name == dei.AttributeName);
                        retVal.Realization.Add(cc);
                    }
                    else
                    {
                        System.Diagnostics.Trace.WriteLine(String.Format("Can't find derivation class '{0}' for association '{1}' (derivation supplier {2})", dei.ClassName, dei.AttributeName, dei.StaticModelDerivationId), "warn");
                    }
                }
            }

            // Derived from
            retVal.DerivedFrom = clsa;

            // Fixed Value
            retVal.FixedValue = clsa.FixedValue;

            // Sort key
            retVal.SortKey = clsa.SortKey;

            // Datatype
            retVal.Type = TypeReferenceParser.Parse(clsa.Type);

            // Update Modes
            retVal.UpdateMode = clsa.UpdateModeDefault.ToString();
            if (clsa.UpdateModesAllowed != null)
            {
                retVal.AllowedUpdateModes = new List <string>();
                foreach (string s in clsa.UpdateModesAllowed.Split(','))
                {
                    retVal.AllowedUpdateModes.Add(s);
                }
            }

            // Supplier domains
            if (clsa.Vocabulary != null)
            {
                if (clsa.Vocabulary.Code != null && !String.IsNullOrEmpty(clsa.Vocabulary.Code.Code)) // Fixed code
                {
                    retVal.FixedValue = string.Format("{0}", clsa.Vocabulary.Code.Code);
                }

                // JF: If the code system is identified, then bind
                if (clsa.Vocabulary.Code != null && !String.IsNullOrEmpty(clsa.Vocabulary.Code.CodeSystemName)) // Very odd thing that is present in UV mifs
                {
                    Trace.WriteLine(String.Format("'{0}' is specified as fixed code's code system, however no fixed code is present. Assuming this is a bound code system instead", "assumption"));
                    retVal.SupplierDomain = cr.Find(o => o is CodeSystem && (o as CodeSystem).Name.Equals(clsa.Vocabulary.Code.CodeSystemName)) as Enumeration;
                    if (retVal.SupplierDomain == null)
                    {
                        Trace.WriteLine(String.Format("'{0}' could not be bound to '{1}' as the code system was not found", clsa.Name, clsa.Vocabulary.Code.CodeSystemName), "warn");
                    }
                }
                if (clsa.Vocabulary.ConceptDomain != null)
                {
                    retVal.SupplierDomain = cr.Find(o => o is ConceptDomain && (o as ConceptDomain).Name.Equals(clsa.Vocabulary.ConceptDomain.Name)) as Enumeration;
                    if (retVal.SupplierDomain == null && MifCompiler.hostContext.Mode == Pipeline.OperationModeType.Quirks)
                    {
                        retVal.SupplierDomain = cr.Find(o => o is Enumeration && o.Name.Equals(clsa.Vocabulary.ConceptDomain.Name)) as Enumeration;
                        if (retVal.SupplierDomain != null)
                        {
                            Trace.WriteLine(String.Format("'{0}' couldn't be bound to concept domain '{1}', '{2}' with name '{1}' was located, so the binding was changed", clsa.Name, clsa.Vocabulary.ConceptDomain.Name, retVal.SupplierDomain.EnumerationType), "quirks");
                        }
                    }
                    if (retVal.SupplierDomain == null)
                    {
                        Trace.WriteLine(String.Format("'{0}' could not be bound to '{1}' as the concept domain was not found", clsa.Name, clsa.Vocabulary.ConceptDomain.Name), "warn");
                    }
                }
                if (clsa.Vocabulary.ValueSet != null)
                {
                    retVal.SupplierDomain = cr.Find(o => o is ValueSet && (o as ValueSet).Name.Equals(clsa.Vocabulary.ValueSet.Name)) as Enumeration;
                    if (retVal.SupplierDomain == null)
                    {
                        Trace.WriteLine(String.Format("'{0}' could not be bound to '{1}' as the value set was not found", clsa.Name, clsa.Vocabulary.ValueSet.Name), "warn");
                    }

                    if (!String.IsNullOrEmpty(clsa.Vocabulary.ValueSet.RootCode))
                    {
                        bool shouldFix = false;
                        if (retVal.SupplierDomain != null)
                        {
                            var enumLiteral = retVal.SupplierDomain.Literals.Find(o => o.Name == clsa.Vocabulary.ValueSet.RootCode);
                            shouldFix = enumLiteral != null && enumLiteral.RelatedCodes != null && enumLiteral.RelatedCodes.Count == 0;
                        }
                        if (shouldFix)
                        {
                            retVal.FixedValue = String.Format("{0}", clsa.Vocabulary.ValueSet.RootCode);
                        }
                    }
                }

                // Supplier strength(s)
                if (clsa.Vocabulary.ValueSet != null)
                {
                    retVal.SupplierStrength = clsa.Vocabulary.ValueSet.CodingStrength == CodingStrengthKind.CNE ? (Property.CodingStrengthKind?)Property.CodingStrengthKind.CodedNoExtensions:
                                              clsa.Vocabulary.ValueSet.CodingStrength == CodingStrengthKind.CWE ? (Property.CodingStrengthKind?)Property.CodingStrengthKind.CodedNoExtensions : null;
                }

                // Supplier domain strength
                if (retVal.SupplierDomain != null)
                {
                    if (defaultCodingStrengths.ContainsKey(retVal.SupplierDomain.Name ?? "") && !retVal.SupplierStrength.HasValue)
                    {
                        retVal.SupplierStrength = defaultCodingStrengths[retVal.SupplierDomain.Name];
                    }
                    else
                    {
                        retVal.SupplierStrength = Property.CodingStrengthKind.CodedNoExtensions;
                        System.Diagnostics.Trace.WriteLine(string.Format("No vocabulary value set on property {0}! Defaulting to CNE for supplier strength", retVal.Name), "assumption");
                    }
                }
            }

            return(retVal);
        }
Ejemplo n.º 30
0
        protected override void deserialize(PowerPlannerSending.BaseItem item, List <PropertyNames> changedProperties)
        {
            ClassAttribute from = item as ClassAttribute;

            base.deserialize(from, changedProperties);
        }
Ejemplo n.º 31
0
    public static void AttributeDelete(string AttributeName)
    {
        ClassAttribute oAttr = new ClassAttribute(AttributeName);

        oAttr.DeleteByName(AttributeName);
    }
Ejemplo n.º 32
0
 /// <summary>
 /// Interpret ClassAttribute
 /// </summary>
 /// <param name="attribute">ClassAttribute to interpret</param>
 public override void Visit(ClassAttribute attribute)
 {   //Add class attribute
     Current.AddAttribute("class", attribute.GetClass());
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Parser for ClassAttribute
        /// </summary>
        /// <returns>Parsed ClassAttribute</returns>
        public ClassAttribute ParseClassAttribute()
        {
            ClassAttribute classAttribute = new ClassAttribute();

            //Get class token
            CurrentToken = TokenStream.NextToken();
            classAttribute.SetClass(CurrentToken.GetValue().ToString());

            return classAttribute;
        }
Ejemplo n.º 34
0
        public JavaClass convert(Type abstractMojoType, string groupId)
        {
            JavaClass javaClass = new JavaClass();

            javaClass.PackageName      = abstractMojoType.Namespace;
            javaClass.ClassName        = abstractMojoType.Name;
            javaClass.ExtendsClassName = "org.apache.npanday.plugins.AbstractMojo";

            ImportPackage importPackage = new ImportPackage();

            javaClass.ImportPackage = importPackage.AddPackage("org.apache.npanday.plugins.FieldAnnotation");

            List <String> classComments = new List <String>();

            System.Attribute[] attributes =
                System.Attribute.GetCustomAttributes(abstractMojoType);

            foreach (Attribute attribute in attributes)
            {
                if (attribute is ClassAttribute)
                {
                    ClassAttribute mojo = (ClassAttribute)attribute;
                    classComments.Add(@"@phase " + mojo.Phase);
                    classComments.Add(@"@goal " + mojo.Goal);
                    break;
                }
            }

            javaClass.Comments = classComments;

            List <JavaField> javaFields = new List <JavaField>();

            foreach (FieldInfo field in abstractMojoType.GetFields())
            {
                foreach (Attribute attribute in field.GetCustomAttributes(true))
                {
                    FieldAttribute mojo = (FieldAttribute)attribute;
                    javaFields.Add(CreateJavaField("public", mojo.Type, mojo.Name,
                                                   CreateMojoComment(mojo.Expression),
                                                   "FieldAnnotation()"));
                }
            }

            //mojo parameters
            javaFields.Add(CreateJavaField("private", "org.apache.maven.project.MavenProject", "project",
                                           CreateMojoComment("${project}"), null));
            javaFields.Add(CreateJavaField("private", "String", "localRepository",
                                           CreateMojoComment("${settings.localRepository}"), null));
            javaFields.Add(CreateJavaField("private", "String", "vendor",
                                           CreateMojoComment("${vendor}"), null));
            javaFields.Add(CreateJavaField("private", "String", "vendorVersion",
                                           CreateMojoComment("${vendorVersion}"), null));
            javaFields.Add(CreateJavaField("private", "String", "frameworkVersion",
                                           CreateMojoComment("${frameworkVersion}"), null));

            //components
            List <String> comments = new List <String>();

            comments.Add("@component");
            javaFields.Add(CreateJavaField("private", "npanday.executable.NetExecutableFactory",
                                           "netExecutableFactory", comments, null));
            javaFields.Add(CreateJavaField("private", "org.apache.npanday.plugins.PluginContext",
                                           "pluginContext", comments, null));

            //methods
            List <JavaMethod> javaMethods = new List <JavaMethod>();

            javaMethods.Add(CreateJavaMethod("public", "String", "getMojoArtifactId",
                                             new Code().AddLine(@"return """
                                                                + abstractMojoType.Namespace + @""";")));

            javaMethods.Add(CreateJavaMethod("public", "String", "getMojoGroupId",
                                             new Code().AddLine(@"return """
                                                                + groupId + @""";")));

            javaMethods.Add(CreateJavaMethod("public", "String", "getClassName",
                                             new Code().AddLine(@"return """ + abstractMojoType.Namespace
                                                                + "." + abstractMojoType.Name + @""";")));

            javaMethods.Add(CreateJavaMethod("public", "org.apache.npanday.plugins.PluginContext",
                                             "getNetPluginContext",
                                             CreateCodeWithSimpleReturnType("pluginContext")));

            javaMethods.Add(CreateJavaMethod("public", "npanday.executable.NetExecutableFactory",
                                             "getNetExecutableFactory",
                                             CreateCodeWithSimpleReturnType("netExecutableFactory")));

            javaMethods.Add(CreateJavaMethod("public", "org.apache.maven.project.MavenProject", "getMavenProject",
                                             CreateCodeWithSimpleReturnType("project")));

            javaMethods.Add(CreateJavaMethod("public", "String", "getLocalRepository",
                                             CreateCodeWithSimpleReturnType("localRepository")));

            javaMethods.Add(CreateJavaMethod("public", "String", "getVendorVersion",
                                             CreateCodeWithSimpleReturnType("vendorVersion")));

            javaMethods.Add(CreateJavaMethod("public", "String", "getVendor",
                                             CreateCodeWithSimpleReturnType("vendor")));

            javaMethods.Add(CreateJavaMethod("public", "String", "getFrameworkVersion",
                                             CreateCodeWithSimpleReturnType("frameworkVersion")));
            javaClass.JavaMethods = javaMethods;
            javaClass.JavaFields  = javaFields;
            return(javaClass);
        }
Ejemplo n.º 35
0
 public virtual void Visit(ClassAttribute attribute)
 {
     VisitSubNodes(attribute);
 }