Exemple #1
0
        public void Equals_ForTwoEnumElementsOfSameValue_ReturnsTrueEvenForDiffrentDescription()
        {
            var firstEnumElement = new EnumElement<SimpleEnum>(SimpleEnum.TwentyOne, "description");
            var secondEnumElement = new EnumElement<SimpleEnum>(SimpleEnum.TwentyOne, "diffrent description");

            Assert.IsTrue(firstEnumElement.Equals(secondEnumElement));
        }
    private static T CreateItemFromRow <T>(DataRow row, IEnumerable <PropertyInfo> properties) where T : new()
    {
        var item = new T();

        foreach (var property in properties.Where(p => !Attribute.IsDefined(p, typeof(NotMappedAttribute))))
        {
            if (property.GetCustomAttributes(true)
                .Any(p => Attribute.IsDefined(property, typeof(MappedFromJsonField))))
            {
                var jsonField = property.GetCustomAttribute <MappedFromJsonField>().JsonField;

                if (row[jsonField] != Convert.DBNull)
                {
                    var jsonObject = JsonHelper.Deserialize((string)row[jsonField]);
                    var value      = JsonHelper.GetPropertyValue(jsonObject, property.Name, property.PropertyType);

                    property.SetValue(item, value, null);
                }
                else
                {
                    property.SetValue(item, null, null);
                }
            }
            else
            {
                var value = property.PropertyType.IsEnum ?
                            EnumElement.ToEnum(property.PropertyType, row[property.Name]) :
                            row[property.Name] == Convert.DBNull ? null : row[property.Name];

                property.SetValue(item, value, null);
            }
        }
        return(item);
    }
Exemple #3
0
    public void SetRunaElement(EnumElement element)
    {
        Element = element;
        switch (element)
        {
        case EnumElement.Air:
            SkeletonAnimation.Skeleton.SetSkin("Runa de Ar");
            SkeletonAnimation.Skeleton.SetSlotsToSetupPose();
            break;

        case EnumElement.Earth:
            SkeletonAnimation.Skeleton.SetSkin("Runa de terra");
            SkeletonAnimation.Skeleton.SetSlotsToSetupPose();
            break;

        case EnumElement.Fire:
            SkeletonAnimation.Skeleton.SetSkin("Runas de fogo");
            SkeletonAnimation.Skeleton.SetSlotsToSetupPose();
            break;

        case EnumElement.Water:
            SkeletonAnimation.Skeleton.SetSkin("Runa de Agua");
            SkeletonAnimation.Skeleton.SetSlotsToSetupPose();
            break;

        case EnumElement.Light:
            SkeletonAnimation.Skeleton.SetSkin("Runa de Luz");
            SkeletonAnimation.Skeleton.SetSlotsToSetupPose();
            break;
        }
    }
Exemple #4
0
        /// <summary>
        /// Adds new enum value element.
        /// </summary>
        /// <param name="type">The enum type.</param>
        /// <param name="customBuildEntriesDelegate">The custom entries layout builder. Allows to hide existing or add different enum values to editor.</param>
        /// <param name="formatMode">The formatting mode.</param>
        /// <returns>The created element.</returns>
        public EnumElement Enum(Type type, EnumComboBox.BuildEntriesDelegate customBuildEntriesDelegate = null, EnumDisplayAttribute.FormatMode formatMode = EnumDisplayAttribute.FormatMode.Default)
        {
            var element = new EnumElement(type, customBuildEntriesDelegate, formatMode);

            OnAddElement(element);
            return(element);
        }
Exemple #5
0
        public void Equals_ForTwoEnumElementsOfDiffrentValue_ReturnsFalse()
        {
            var firstEnumElement = new EnumElement<SimpleEnum>(SimpleEnum.One, "description");
            var secondEnumElement = new EnumElement<SimpleEnum>(SimpleEnum.TwentyOne, "description");

            Assert.IsFalse(firstEnumElement.Equals(secondEnumElement));
        }
Exemple #6
0
        /// <summary>
        /// Adds new enum value element.
        /// </summary>
        /// <param name="type">The enum type.</param>
        /// <param name="cusstomBuildEntriesDelegate">The custom entries layout builder. Allows to hide existing or add diffrent enum values to editor.</param>
        /// <returns>The created element.</returns>
        public EnumElement Enum(Type type, EnumElement.BuildEntriesDelegate cusstomBuildEntriesDelegate = null)
        {
            EnumElement element = new EnumElement(type, cusstomBuildEntriesDelegate);

            OnAddElement(element);
            return(element);
        }
        public override List <Field> GetFieldsForLucene()
        {
            var         fields      = new List <Field>();
            EnumElement enumElement = (EnumElement)programElement;

            fields.Add(new Field(SandoField.Namespace.ToString(), enumElement.Namespace.ToSandoSearchable(), Field.Store.YES, Field.Index.ANALYZED));
            AddBodyField(fields, new Field(SandoField.Body.ToString(), enumElement.RawSource.ToSandoSearchable(), Field.Store.NO, Field.Index.ANALYZED));
            fields.Add(new Field(SandoField.AccessLevel.ToString(), enumElement.AccessLevel.ToString().ToLower(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            AddBodyField(fields, new Field(SandoField.Body.ToString(), enumElement.Body.ToSandoSearchable(), Field.Store.NO, Field.Index.ANALYZED));
            return(fields);
        }
Exemple #8
0
        public EnumType(Program program, EnumElement element)
            : base(program, new UserElementMixin(element))
        {
            List <EnumMember> members = new List <EnumMember>();

            foreach (var m in element.Members)
            {
                members.Add(new EnumMember(m));
            }

            _members = members.ToImmutableList();
        }
Exemple #9
0
 /// <inheritdoc />
 public override void Initialize(LayoutElementsContainer layout)
 {
     if (HasDifferentTypes)
     {
         // No support for different enum types
     }
     else
     {
         element = layout.Enum(Values[0].GetType());
         element.ValueChanged += OnValueChanged;
     }
 }
Exemple #10
0
        private void ShowEnums(Int32 level, String nodeText, String parentNodeText)
        {
            listView1.Items.Clear();
            listView1.Columns.Clear();

            if (level == 0 || level == 1)
            {
                listView1.Columns.Add("Name", -1, HorizontalAlignment.Left);
                listView1.Columns.Add("Description", -1, HorizontalAlignment.Left);
                listView1.Columns.Add("IntegerBased", -1, HorizontalAlignment.Left);
                listView1.Columns.Add("Template", -1, HorizontalAlignment.Left);

                IList list;
                if (level == 0)
                {
                    list = enums;
                }
                else
                {
                    list = new ArrayList();
                    list.Add(EnumElement.FindByName((ArrayList)enums, nodeText));
                }
                foreach (EnumElement e in list)
                {
                    ListViewItem lvi = new ListViewItem(e.Name);
                    lvi.SubItems.Add(e.Description);
                    lvi.SubItems.Add(e.IntegerBased.ToString());
                    lvi.SubItems.Add(e.Template);
                    listView1.Items.Add(lvi);
                }
            }

            if (level == 2 && nodeText.Equals("values"))
            {
                listView1.Columns.Add("Name", -1, HorizontalAlignment.Left);
                listView1.Columns.Add("Code", -1, HorizontalAlignment.Left);
                listView1.Columns.Add("Description", -1, HorizontalAlignment.Left);

                EnumElement e = EnumElement.FindByName((ArrayList)enums, parentNodeText);
                foreach (EnumValueElement v in e.Values)
                {
                    ListViewItem lvi = new ListViewItem(v.Name);
                    lvi.SubItems.Add(v.Code);
                    lvi.SubItems.Add(v.Description);
                    listView1.Items.Add(lvi);
                }
            }
        }
        public void ProgramElementReader_ReadProgramElementFromDocumentReturnValidEnumElementForValidDocument()
        {
            EnumElement element  = SampleProgramElementFactory.GetSampleEnumElement();
            Document    document = DocumentFactory.Create(element).GetDocument();

            EnumElement returnedElement = ConverterFromHitToProgramElement.Create(document).Convert() as EnumElement;

            Assert.IsNotNull(returnedElement, "returned class element is null!");
            Assert.True(element.AccessLevel == returnedElement.AccessLevel, "AccessLevel is different!");
            Assert.True(element.DefinitionLineNumber == returnedElement.DefinitionLineNumber, "DefinitionLineNumber is different!");
            Assert.True(StandardizeFilePath(element.FullFilePath) == returnedElement.FullFilePath, "FullFilePath is different!");
            Assert.True(element.Name == returnedElement.Name, "Name is different!");
            Assert.True(element.Namespace == returnedElement.Namespace, "Namespace is different!");
            Assert.True(element.ProgramElementType == returnedElement.ProgramElementType, "ProgramElementType is different!");
            Assert.True(element.RawSource == returnedElement.RawSource, "Snippet is different!");
            Assert.True("not stored in index" == returnedElement.Body, "Body is different");
        }
Exemple #12
0
        private List <FieldDeclaration> DeclareFields(EnumElement enumeration, bool isBitmask, Dictionary <string, EnumMapping> enumLookup)
        {
            var result = new List <FieldDeclaration>();

            if (enumeration != null)
            {
                if (isBitmask && !enumeration.Fields.Values.Any(x => x.Value == "0" && !x.IsBitmask))
                {
                    AddNoneField(result);
                }

                var fieldNameLookup = enumeration.Fields.Values.ToDictionary(x => x.VkName, x => this.nameFormatter.FormatName(enumeration, x, x.IsBitmask));
                var fieldNameCount  = fieldNameLookup.Values.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());

                foreach (var field in enumeration.Fields.Values)
                {
                    var name = fieldNameLookup[field.VkName];
                    if (fieldNameCount[name] > 1)
                    {
                        name += field.ExtensionNamespace;
                    }
                    string value = field.Value;

                    if (field.IsBitmask)
                    {
                        value = $"1 << {value}";
                    }

                    result.Add(new FieldDeclaration
                    {
                        VkName    = field.VkName,
                        Name      = name,
                        Extension = field.ExtensionNamespace,
                        Value     = value
                    });

                    enumLookup.Add(field.VkName, new EnumMapping(enumeration.VkName, name));
                }
            }
            else
            {
                AddNoneField(result);
            }

            return(result);
        }
Exemple #13
0
        public string FormatName(EnumElement enumeration, EnumField value, bool isBitmask)
        {
            string digitsPrefix = JoinNameParts(enumeration.NameParts.TakeWhile(x => !digitsSuffix.Contains(x)));

            int skipAtEnd = isBitmask && digitsSuffix.Contains(value.NameParts.Last())
                                ? 1
                                : 0;

            string result = JoinNameParts(value.NameParts.Take(value.NameParts.Length - skipAtEnd));

            if (!char.IsLetter(result[0]))
            {
                result = digitsPrefix + result;
            }

            return(result);
        }
Exemple #14
0
    private Runa createRuna(int column, int row)
    {
        int quantityOfAvailibleElements = Enum.GetValues(typeof(EnumElement)).Length;

        EnumElement element = (EnumElement)_random.Next(0, quantityOfAvailibleElements);

        GameObject runaPrefab = Instantiate(RunaPrefab);

        Runa runa = runaPrefab.GetComponent <Runa>();

        runa.SetRunaElement(element);

        runa.SpotInKeyboard = new Vector2(column, row);

        setRunaPosition(runa, column, row, false);

        return(runa);
    }
Exemple #15
0
        internal EnumElement Restore()
        {
            var model = new EnumElement(this.FullName);

            model.Label  = this.Label;
            model.Left   = this.Left;
            model.Top    = this.Top;
            model.Width  = this.Width;
            model.Height = this.Height;

            foreach (var item in this.Items)
            {
                var modelItem = item.Restore();
                model.Items.Add(modelItem);
            }

            return(model);
        }
Exemple #16
0
        public Ability(string Name, EnumAbilityStrength abilityStrength, EnumElement element, EnumAbilityType abilityType, EnumTargets targets, EnumTargetModifier targetModifier, EnumDuration duration)
        {
            this.Name = Name;
            this.abilityStrength = abilityStrength;
            this.element = element;
            this.abilityType = abilityType;
            this.targets = targets;
            this.targetModifier = targetModifier;
            this.duration = duration;
            this.RoundsLeft = (int)duration;

            Cost = (int)abilityStrength + 1 +
                   (abilityType == EnumAbilityType.HEAL ? 2 : 1) +
                   (int)targets + 1 +
                   (targetModifier == EnumTargetModifier.RANDOM ? 1 : 2) +
                   (int)duration;

            Damage = 10 * (int)abilityStrength;
        }
Exemple #17
0
        /// <inheritdoc />
        public override void Initialize(LayoutElementsContainer layout)
        {
            var mode       = EnumDisplayAttribute.FormatMode.Default;
            var attributes = Values.GetAttributes();

            if (attributes?.FirstOrDefault(x => x is EnumDisplayAttribute) is EnumDisplayAttribute enumDisplay)
            {
                mode = enumDisplay.Mode;
            }

            if (HasDifferentTypes)
            {
                // No support for different enum types
            }
            else
            {
                element = layout.Enum(Values[0].GetType(), null, mode);
                element.ValueChanged += OnValueChanged;
            }
        }
Exemple #18
0
        internal static EnumElementXml ConvertToNode(EnumElement model)
        {
            var xml = new EnumElementXml();

            xml.FullName = model.Name;
            xml.Label    = model.Label;
            xml.Left     = model.Left;
            xml.Top      = model.Top;
            xml.Width    = model.Width;
            xml.Height   = model.Height;

            xml.Items = new EnumItemElementXml[model.Items.Count];
            for (int i = 0, c = model.Items.Count; i < c; i++)
            {
                var property    = model.Items[i];
                var propertyXml = EnumItemElementXml.ConvertToNode(property);
                xml.Items[i] = propertyXml;
            }

            return(xml);
        }
Exemple #19
0
        internal static EnumElementXml ConvertToNode(EnumElement model)
        {
            var xml = new EnumElementXml();

            xml.FullName = model.Name;
            xml.Label = model.Label;
            xml.Left = model.Left;
            xml.Top = model.Top;
            xml.Width = model.Width;
            xml.Height = model.Height;

            xml.Items = new EnumItemElementXml[model.Items.Count];
            for (int i = 0, c = model.Items.Count; i < c; i++)
            {
                var property = model.Items[i];
                var propertyXml = EnumItemElementXml.ConvertToNode(property);
                xml.Items[i] = propertyXml;
            }

            return xml;
        }
Exemple #20
0
        public void EnumParserTest()
        {
            SrcMLCSharpParser parser = new SrcMLCSharpParser(generator);
            var  elements            = parser.Parse("TestFiles\\ShortCSharpFile.txt");
            bool hasEnum             = false;

            foreach (var programElement in elements)
            {
                if (programElement as EnumElement != null)
                {
                    EnumElement enumElem = (EnumElement)programElement;
                    Assert.AreEqual(enumElem.Name, "LanguageEnum");
                    Assert.AreEqual(enumElem.DefinitionLineNumber, 7);
                    Assert.AreEqual(enumElem.Namespace, "Sando.Parser");
                    Assert.AreEqual(enumElem.Body, "Java C CSharp");
                    Assert.AreEqual(enumElem.AccessLevel, AccessLevel.Public);
                    Assert.True(enumElem.FullFilePath.EndsWith("TestFiles\\ShortCSharpFile.txt"));
                    hasEnum = true;
                }
            }
            Assert.IsTrue(hasEnum);
        }
Exemple #21
0
        public void ParseUndefinedNameEnumTest()
        {
            bool hasEnum  = false;
            var  parser   = new SrcMLCppParser(generator);
            var  elements = parser.Parse("TestFiles\\PlayMp3Dlg.h.txt");

            Assert.IsNotNull(elements);
            foreach (ProgramElement pe in elements)
            {
                if (pe is EnumElement)
                {
                    EnumElement enumElem = (EnumElement)pe;
                    Assert.AreEqual(enumElem.Name, "");
                    Assert.AreEqual(enumElem.DefinitionLineNumber, 30);
                    Assert.AreEqual(enumElem.Body, "IDD IDD_PLAYMP3_DIALOG");
                    Assert.AreEqual(enumElem.AccessLevel, AccessLevel.Public);
                    Assert.True(enumElem.FullFilePath.EndsWith("TestFiles\\PlayMp3Dlg.h.txt"));
                    hasEnum = true;
                }
            }
            Assert.IsTrue(hasEnum);
        }
Exemple #22
0
        /// <inheritdoc />
        public override void Initialize(LayoutElementsContainer layout)
        {
            var mode       = EnumDisplayAttribute.FormatMode.Default;
            var attributes = Values.GetAttributes();

            if (attributes?.FirstOrDefault(x => x is EnumDisplayAttribute) is EnumDisplayAttribute enumDisplay)
            {
                mode = enumDisplay.Mode;
            }

            if (HasDifferentTypes)
            {
                // No support for different enum types
            }
            else
            {
                var enumType = Values.Type.Type != typeof(object) || Values[0] == null?TypeUtils.GetType(Values.Type) : Values[0].GetType();

                element = layout.Enum(enumType, null, mode);
                element.ComboBox.ValueChanged += OnValueChanged;
            }
        }
Exemple #23
0
        private List <FieldDeclaration> DeclareFields(EnumElement enumeration, bool isBitmask, Dictionary <string, EnumMapping> enumLookup)
        {
            var result = new List <FieldDeclaration>();

            if (enumeration != null)
            {
                if (isBitmask && !enumeration.Fields.Values.Any(x => x.Value == "0" && !x.IsBitmask))
                {
                    AddNoneField(result);
                }

                foreach (var field in enumeration.Fields.Values)
                {
                    var    name  = this.nameFormatter.FormatName(enumeration, field, field.IsBitmask);
                    string value = field.Value;

                    if (field.IsBitmask)
                    {
                        value = $"1 << {value}";
                    }

                    result.Add(new FieldDeclaration
                    {
                        VkName = field.VkName,
                        Name   = name,
                        Value  = value
                    });

                    enumLookup.Add(field.VkName, new EnumMapping(enumeration.VkName, name));
                }
            }
            else
            {
                AddNoneField(result);
            }

            return(result);
        }
Exemple #24
0
 private void CreateSqlElementAssociations(ParserValidationDelegate vd)
 {
     // find and assign the foreign entity and EnumElement now that they are parsed
     foreach (DatabaseElement database in databases)
     {
         foreach (SqlEntityElement sqlEntity in database.SqlEntities)
         {
             foreach (ConstraintElement constraint in sqlEntity.Constraints)
             {
                 if (constraint.ForeignEntity.Name.Length > 0)
                 {
                     SqlEntityElement entity = SqlEntityElement.FindByName(DatabaseElement.GetAllSqlEntities(databases), constraint.ForeignEntity.Name);
                     if (entity != null)
                     {
                         constraint.ForeignEntity = (SqlEntityElement)entity.Clone();
                     }
                     else
                     {
                         vd(ParserValidationArgs.NewError("ForeignEntity (" + constraint.ForeignEntity.Name + ") specified in constraint " + constraint.Name + " could not be found as an defined entity"));
                     }
                 }
                 if (constraint.CheckEnum.Name.Length > 0)
                 {
                     EnumElement entity = EnumElement.FindByName(enumtypes as ArrayList, constraint.CheckEnum.Name);
                     if (entity != null)
                     {
                         constraint.CheckEnum = (EnumElement)entity.Clone();
                     }
                     else
                     {
                         vd(ParserValidationArgs.NewError("CheckEnum (" + constraint.CheckEnum.Name + ") specified in constraint " + constraint.Name + " could not be found as an defined entity"));
                     }
                 }
             }
         }
     }
 }
Exemple #25
0
        public void ParseCPPHeaderTest()
        {
            bool hasClass = false;
            bool hasEnum  = false;
            var  parser   = new SrcMLCppParser(generator);
            var  elements = parser.Parse("TestFiles\\Event.H.txt");

            Assert.IsNotNull(elements);
            Assert.AreEqual(elements.Count, 8);
            foreach (ProgramElement pe in elements)
            {
                if (pe is ClassElement)
                {
                    ClassElement classElem = (ClassElement)pe;
                    Assert.AreEqual(classElem.Name, "Event");
                    Assert.AreEqual(classElem.DefinitionLineNumber, 12);
                    Assert.AreEqual(classElem.AccessLevel, AccessLevel.Public);
                    Assert.AreEqual(classElem.Namespace, String.Empty);
                    Assert.True(classElem.FullFilePath.EndsWith("TestFiles\\Event.H.txt"));
                    hasClass = true;
                }
                else if (pe is EnumElement)
                {
                    EnumElement enumElem = (EnumElement)pe;
                    Assert.AreEqual(enumElem.Name, "EventType");
                    Assert.AreEqual(enumElem.DefinitionLineNumber, 6);
                    Assert.AreEqual(enumElem.Namespace, String.Empty);
                    Assert.AreEqual(enumElem.Body, "SENSED_DATA_READY SENDING_DONE RECEIVING_DONE");
                    Assert.AreEqual(enumElem.AccessLevel, AccessLevel.Public);
                    Assert.True(enumElem.FullFilePath.EndsWith("TestFiles\\Event.H.txt"));
                    hasEnum = true;
                }
            }
            Assert.IsTrue(hasClass);
            Assert.IsTrue(hasEnum);
        }
Exemple #26
0
    private static int CalculateSpellForce(List <Runa> selectedRunas, AttributePoints playerAttributes)
    {
        EnumElement element = selectedRunas[0].Element;

        int elementForce = 0;

        if (element == EnumElement.Air)
        {
            elementForce = playerAttributes.Air;
        }
        else if (element == EnumElement.Earth)
        {
            elementForce = playerAttributes.Earth;
        }
        else if (element == EnumElement.Fire)
        {
            elementForce = playerAttributes.Fire;
        }
        else if (element == EnumElement.Light)
        {
            elementForce = playerAttributes.Light;
        }
        else if (element == EnumElement.Water)
        {
            elementForce = playerAttributes.Water;
        }

        var force = 0;

        var runasBuff   = selectedRunas.Count(x => x.PoweredUp);
        var runasNormal = selectedRunas.Count(x => !x.PoweredUp);

        force = (int)(elementForce * (runasBuff * 5) * 1.5) + (elementForce * runasNormal * 5);

        return(force);
    }
        public void Execute(IServiceCollection target)
        {
            var enums = new Dictionary <string, EnumElement>();

            foreach (var vkEnum in this.xmlCache.GetVkXml().Element("registry").Elements("enums"))
            {
                string name = vkEnum.Attribute("name").Value;
                string type = vkEnum.Attribute("type")?.Value;

                string   extension = null;
                string[] nameParts = name == "API Constants"
                                        ? new[] { name }
                                        : this.nameParser.GetNameParts(name, out extension);

                var newEnum = new EnumElement
                {
                    VkName             = name,
                    Type               = type,
                    NameParts          = nameParts,
                    ExtensionNamespace = extension
                };

                foreach (var vkField in vkEnum.Elements("enum"))
                {
                    string fieldName = vkField.Attribute("name").Value;
                    bool   isBitmask = true;
                    string value     = vkField.Attribute("bitpos")?.Value;
                    string comment   = SimpleParser.NormaliseComment(vkField.Attribute("comment")?.Value);

                    if (value == null)
                    {
                        isBitmask = false;
                        value     = vkField.Attribute("value")?.Value;

                        // Special case for mapping C "unsigned long long"
                        // (64-bit unsigned integer) to C# UInt64
                        if (value == "(~0ULL)")
                        {
                            value = "(~0UL)";
                        }

                        value = value?.Trim('(', ')');
                    }

                    IEnumerable <string> fieldNameParts = this.nameParser.ParseEnumField(fieldName, nameParts);

                    newEnum.Fields.Add(fieldName, new EnumField
                    {
                        VkName    = fieldName,
                        NameParts = fieldNameParts.ToArray(),
                        IsBitmask = isBitmask,
                        Value     = value,
                        Comment   = comment != null ? new List <string> {
                            comment
                        } : null
                    });
                }

                enums.Add(name, newEnum);
            }


            foreach (var vkExtension in this.xmlCache.GetVkXml()
                     .Element("registry")
                     .Element("extensions")
                     .Elements("extension"))
            {
                int    extensionNumber = int.Parse(vkExtension.Attribute("number").Value);
                string extensionName   = vkExtension.Attribute("name").Value;

                var extensionNameParts = extensionName.Split('_');

                string extensionSuffix = extensionNameParts[1].ToLower().FirstToUpper();

                foreach (var vkExtensionEnum in vkExtension.Elements("require")
                         .SelectMany(x => x.Elements("enum"))
                         .Where(x => x.Attribute("extends") != null))
                {
                    string vkName       = vkExtensionEnum.Attribute("name").Value;
                    var    extendedEnum = enums[vkExtensionEnum.Attribute("extends").Value];

                    int? value     = null;
                    bool isBitmask = false;

                    if (vkExtensionEnum.Attribute("offset") != null)
                    {
                        int offset = int.Parse(vkExtensionEnum.Attribute("offset").Value);

                        value = 1000000000 + 1000 * (extensionNumber - 1) + offset;
                    }
                    else if (vkExtensionEnum.Attribute("bitpos") != null)
                    {
                        value     = int.Parse(vkExtensionEnum.Attribute("bitpos").Value);
                        isBitmask = true;
                    }
                    else if (vkExtensionEnum.Attribute("value") != null)
                    {
                        value = int.Parse(vkExtensionEnum.Attribute("value").Value);
                    }

                    if (vkExtensionEnum.Attribute("dir")?.Value == "-")
                    {
                        value = -value;
                    }

                    var nameParts = this.nameParser.ParseEnumField(vkName, extendedEnum.NameParts);

                    extendedEnum.Fields[vkName] = new EnumField
                    {
                        VkName             = vkName,
                        Value              = value?.ToString(),
                        NameParts          = nameParts.ToArray(),
                        IsBitmask          = isBitmask,
                        ExtensionNamespace = extensionSuffix
                    };
                }
            }

            foreach (var element in enums.Values)
            {
                target.AddSingleton(element);
            }
        }
Exemple #28
0
    public static CreateSpellType GetPreviewSpellType(EnumElement?comboStoneElement, EnumElement currentSelectedElement)
    {
        if (comboStoneElement == null)
        {
            return(CreateSpellType.Attack);
        }

        switch (comboStoneElement)
        {
        case EnumElement.Air:
            switch (currentSelectedElement)
            {
            case EnumElement.Air: return(CreateSpellType.Attack);

            case EnumElement.Earth: return(CreateSpellType.Attack);

            case EnumElement.Fire: return(CreateSpellType.Attack);

            case EnumElement.Water: return(CreateSpellType.FreezeTime);

            case EnumElement.Light: return(CreateSpellType.Time);

            default: throw new Exception("Combinação de elementos não encontrada");
            }

        case EnumElement.Earth:
            switch (currentSelectedElement)
            {
            case EnumElement.Air: return(CreateSpellType.Attack);

            case EnumElement.Earth: return(CreateSpellType.Attack);

            case EnumElement.Fire: return(CreateSpellType.Attack);

            case EnumElement.Water: return(CreateSpellType.Attack);

            case EnumElement.Light: return(CreateSpellType.Protection);

            default: throw new Exception("Combinação de elementos não encontrada");
            }

        case EnumElement.Fire:
            switch (currentSelectedElement)
            {
            case EnumElement.Air: return(CreateSpellType.Attack);

            case EnumElement.Earth: return(CreateSpellType.Attack);

            case EnumElement.Fire: return(CreateSpellType.Attack);

            case EnumElement.Water: return(CreateSpellType.Attack);

            case EnumElement.Light: return(CreateSpellType.Clear);

            default: throw new Exception("Combinação de elementos não encontrada");
            }

        case EnumElement.Water:
            switch (currentSelectedElement)
            {
            case EnumElement.Air: return(CreateSpellType.FreezeTime);

            case EnumElement.Earth: return(CreateSpellType.Attack);

            case EnumElement.Fire: return(CreateSpellType.Attack);

            case EnumElement.Water: return(CreateSpellType.Attack);

            case EnumElement.Light: return(CreateSpellType.Health);

            default: throw new Exception("Combinação de elementos não encontrada");
            }

        case EnumElement.Light:
            switch (currentSelectedElement)
            {
            case EnumElement.Air: return(CreateSpellType.Time);

            case EnumElement.Earth: return(CreateSpellType.Protection);

            case EnumElement.Fire: return(CreateSpellType.Clear);

            case EnumElement.Water: return(CreateSpellType.Health);

            case EnumElement.Light: return(CreateSpellType.Attack);

            default: throw new Exception("Combinação de elementos não encontrada");
            }

        default: throw new Exception("Combinação de elementos não encontrada");
        }
    }
 public EnumDocument(EnumElement enumElement)
     : base(enumElement)
 {
 }
Exemple #30
0
        internal EnumElement Restore()
        {
            var model = new EnumElement(this.FullName);

            model.Label = this.Label;
            model.Left = this.Left;
            model.Top = this.Top;
            model.Width = this.Width;
            model.Height = this.Height;

            foreach (var item in this.Items)
            {
                var modelItem = item.Restore();
                model.Items.Add(modelItem);
            }

            return model;
        }
Exemple #31
0
 public ConstantCollator(IEnumerable <EnumElement> enums, NameFormatter nameFormatter)
 {
     this.constantsEnum = enums.Single(x => x.VkName == "API Constants");
     this.nameFormatter = nameFormatter;
 }
Exemple #32
0
 private static IEnumerable <String> ExtractEnumWords(EnumElement element)
 {
     return(GetDefaultLetterWords(element.Body));
 }
Exemple #33
0
 public int BuffModify(int damage, EnumElement element)
 {
     if (element == this.element)
         if (this.buffType == EnumBuffType.DAMAGE)
             return (int)(damage * (double)abilityStrength);
         else
             return (int)(damage / (double)abilityStrength);
     else
         return damage;
 }
Exemple #34
0
    public static ISpell Create(EnumElement element, EnumElement?elementLastRuna, List <Runa> selectedRunas, Character origin, Character target, AttributePoints attributes)
    {
        EnumElement element1 = element;
        EnumElement?element2 = elementLastRuna;

        var prefabSpell = CreateSpellPrefab();

        var force = CalculateSpellForce(selectedRunas, attributes);

        switch (element1)
        {
        case EnumElement.Air:
            switch (element2)
            {
            case EnumElement.Air:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/AirSpell"), force, origin, target, true));

            case EnumElement.Earth:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/AirSpell"), force, origin, target, false));

            case EnumElement.Fire:
                return(CreateBurnSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/BurnSpell"), force, attributes, origin, target));

            case EnumElement.Water:
                return(CreateFreezeTimeSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/FreezeSpell"), attributes));

            case EnumElement.Light:
                return(CreateTimeSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/AddTimeSpell"), attributes));

            case null:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/AirSpell"), force, origin, target, false));

            default:
                return(null);
            }

        case EnumElement.Earth:
            switch (element2)
            {
            case EnumElement.Air:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/EarthSpell"), force, origin, target, false));

            case EnumElement.Earth:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/EarthSpell"), force, origin, target, true));

            case EnumElement.Fire:
                return(CreateLavaSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/LavaSpell"), force, attributes, origin, target));

            case EnumElement.Water:
                return(CreateRootingSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/RootingSpell"), force, attributes, origin, target));

            case EnumElement.Light:
                return(CreateProtectionSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/ProtectionSpell"), force, attributes, origin, target));

            case null:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/EarthSpell"), force, origin, target, false));

            default:
                return(null);
            }

        case EnumElement.Fire:
            switch (element2)
            {
            case EnumElement.Air:
                return(CreateBurnSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/BurnSpell"), force, attributes, origin, target));

            case EnumElement.Earth:
                return(CreateLavaSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/LavaSpell"), force, attributes, origin, target));

            case EnumElement.Fire:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/FireSpell"), force, origin, target, true));

            case EnumElement.Water:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/FireSpell"), force, origin, target, false));

            case EnumElement.Light:
                return(CreateClearStatusSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/ClearStatusSpell"), origin));

            case null:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/FireSpell"), force, origin, target, false));

            default:
                return(null);
            }

        case EnumElement.Water:
            switch (element2)
            {
            case EnumElement.Air:
                return(CreateFreezeTimeSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/FreezeSpell"), attributes));

            case EnumElement.Earth:
                return(CreateRootingSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/RootingSpell"), force, attributes, origin, target));

            case EnumElement.Fire:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/WaterSpell"), force, origin, target, false));

            case EnumElement.Water:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/WaterSpell"), force, origin, target, true));

            case EnumElement.Light:
                return(CreateHealthSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/CureSpell"), force, attributes, origin));

            case null:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/WaterSpell"), force, origin, target, false));

            default:
                return(null);
            }

        case EnumElement.Light:
            switch (element2)
            {
            case EnumElement.Air:
                return(CreateTimeSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/AddTimeSpell"), attributes));

            case EnumElement.Earth:
                return(CreateProtectionSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/ProtectionSpell"), force, attributes, origin, target));

            case EnumElement.Fire:
                return(CreateClearStatusSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/ClearStatusSpell"), origin));

            case EnumElement.Water:
                return(CreateHealthSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/CureSpell"), force, attributes, origin));

            case EnumElement.Light:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/LightSpell"), force, origin, target, false));

            case null:
                return(CreateAttackSpell(prefabSpell, CustomResources.Load <Sprite>("Spells/LightSpell"), force, origin, target, false));

            default:
                return(null);
            }

        default:
            return(null);
        }
    }
Exemple #35
0
 public UserElementMixin(EnumElement enumElement)
     : this(enumElement.Name, enumElement.Location, enumElement.Documentation, enumElement.Annotations)
 {
 }
        public static ColoredString Element(EnumElement element)
        {
            Color elementColor;

              switch (element)
              {
            case EnumElement.COLD:
              elementColor = Color.DarkBlue;
              break;
            case EnumElement.FIRE:
              elementColor = Color.Blue;
              break;
            case EnumElement.HOLY:
              elementColor = Color.LightGoldenrodYellow;
              break;
            case EnumElement.LIGHTNING:
              elementColor = Color.Yellow;
              break;
            case EnumElement.PHYSICAL:
              elementColor = Color.Gray;
              break;
            case EnumElement.POISON:
              elementColor = Color.Green;
              break;
            case EnumElement.UNHOLY:
              elementColor = Color.Purple;
              break;
            default:
              elementColor = Color.Black;
              break;
              }
              return new ColoredString(elementColor, element.ToString());
        }
Exemple #37
0
        public void Parse(String filename)
        {
            FileInfo file = new FileInfo(filename);

            if (!file.Exists)
            {
                throw new FileNotFoundException("Could not load config file", filename);
            }
            isValid = true;
            ValidateSchema(filename);

            doc = new XmlDocument();
            Stream filestream = XIncludeReader.GetStream(filename);

            doc.Load(filestream);
            filestream.Close();

            if (doc == null)
            {
                throw new InvalidOperationException("Could not parse xml document: " + filename);
            }

            // event handler for all of the ParseFromXml methods
            ParserValidationDelegate vd = new ParserValidationDelegate(ParserValidationEventHandler);

            XmlNode root = doc.DocumentElement["config"];

            if (root != null)
            {
                this.options = new Configuration(root, vd);
            }
            else
            {
                this.options = new Configuration();
            }

            sqltypes = SqlTypeElement.ParseFromXml(doc, vd);
            types    = TypeElement.ParseFromXml(options, doc, vd);

            // parse generate/task information so that type registration will happen before other types are loaded
            generator = GeneratorElement.ParseFromXml(options, doc, vd);
            TaskElement.RegisterTypes(doc, options, generator.Tasks, types);

            // see if we want to generate collections for all entities
            XmlNodeList collectionElement = doc.DocumentElement.GetElementsByTagName("collections");
            XmlNode     collectionNode    = collectionElement[0];

            if (collectionNode.Attributes["generateall"] == null)
            {
                options.GenerateAllCollections = false;
            }
            else
            {
                options.GenerateAllCollections = Boolean.Parse(collectionNode.Attributes["generateall"].Value.ToString());
            }

            // if the root directory is not specified, make it the directory the config file is loaded from
            if (options.RootDirectory.Equals(String.Empty))
            {
                options.RootDirectory = file.DirectoryName + "\\";
            }
            if (!options.RootDirectory.EndsWith("\\"))
            {
                options.RootDirectory += "\\";
            }

            enumtypes         = EnumElement.ParseFromXml(options, doc, sqltypes, types, vd);
            databases         = DatabaseElement.ParseFromXml(options, doc, sqltypes, types, vd);
            entities          = EntityElement.ParseFromXml(options, doc, sqltypes, types, DatabaseElement.GetAllSqlEntities(databases), vd);
            messages          = MessageElement.ParseFromXml(options, doc, sqltypes, types, DatabaseElement.GetAllSqlEntities(databases), vd);
            reportExtractions = ReportExtractionElement.ParseFromXml(options, doc, sqltypes, types, entities, vd);
            ArrayList collectableClasses  = new ArrayList();
            ArrayList autoGenerateClasses = new ArrayList();

            collectableClasses.AddRange(entities);
            collectableClasses.AddRange(reportExtractions);
            autoGenerateClasses.AddRange(entities);
            autoGenerateClasses.AddRange(reportExtractions);
            collections = CollectionElement.ParseFromXml(options, doc, sqltypes, types, vd, collectableClasses, autoGenerateClasses, (ArrayList)entities);

            CreateSqlElementAssociations(vd);
            CreateEntityElementAssociations(vd);
            Validate(vd);
        }