private void CacheTargets(Assembly assm)
        {
            foreach (Type t in assm.GetTypes())
            {
                TargetAttribute ta = (TargetAttribute)Helper.CheckType(t, typeof(TargetAttribute), typeof(ITarget));

                if (ta == null)
                {
                    continue;
                }

                if (t.IsAbstract)
                {
                    continue;
                }

                ITarget target = (ITarget)assm.CreateInstance(t.FullName);
                if (target == null)
                {
                    throw new MissingMethodException("Could not create ITarget instance");
                }

                m_Targets[ta.Name] = target;
            }
        }
示例#2
0
 public void SetAttributes(string _nam, string _des, int _dam, TargetTypes _tar, TargetAttribute _atr)
 {
     _name = _nam;
     _description = _des;
     _damage = _dam;
     _target = _tar;
     _attribute = _atr;
 }
示例#3
0
 public void SetAttributes(string _nam, string _des, int _dam, TargetTypes _tar, TargetAttribute _atr)
 {
     _name        = _nam;
     _description = _des;
     _damage      = _dam;
     _target      = _tar;
     _attribute   = _atr;
 }
示例#4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Id != null ? Id.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)TargetType;
         hashCode = (hashCode * 397) ^ (TargetTypeName != null ? TargetTypeName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TargetAttribute != null ? TargetAttribute.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (RuleConditions != null ? RuleConditions.GetHashCode() : 0);
         return(hashCode);
     }
 }
示例#5
0
        public void AllByMethodsCanMapToTarget(ByMethod byMethod)
        {
            // arrange
            var fixture    = new Fixture();
            var targetName = fixture.Create <string>();
            var sut        = new TargetAttribute(byMethod, fixture.Create <string>());
            // act
            var actual = sut.CreateTarget(targetName);

            // arrange
            Assert.NotNull(actual);
            Assert.Equal(actual.Name, targetName);
        }
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }

            if (obj is null || GetType() != obj.GetType())
            {
                return(false);
            }

            var other = (EqualsAnyOfExpression)obj;

            return(TargetAttribute.Equals(other.TargetAttribute) && Constants.SequenceEqual(other.Constants));
        }
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }

            if (obj is null || GetType() != obj.GetType())
            {
                return(false);
            }

            var other = (MatchTextExpression)obj;

            return(TargetAttribute.Equals(other.TargetAttribute) && TextValue.Equals(other.TextValue) && MatchKind == other.MatchKind);
        }
 public static MvcHtmlString BootstrapActionLinkButton(
     this System.Web.Mvc.HtmlHelper html,
     string actionName,
     object routeValues,
     ContextualColor contextualColor,
     TargetAttribute targetAttribute)
 {
     return(html.ActionLink(
                actionName,
                actionName,
                routeValues,
                new
     {
         @class = $"btn btn-{ContextualColors[contextualColor]}",
         target = Bootstrap.BootstrapExtensions.TargetAttributes[targetAttribute]
     }));
 }
 public static MvcHtmlString BootstrapActionLinkButton(
     this System.Web.Mvc.HtmlHelper html,
     string linkText,
     string actionName,
     ContextualColor contextualColor =
     ContextualColor.Default,
     TargetAttribute targetAttribute = TargetAttribute.Self)
 {
     return(html.ActionLink(
                linkText,
                actionName,
                null,
                new
     {
         @class = $"btn btn-{ContextualColors[contextualColor]}"
     }));
 }
 /// <summary>
 ///     Creates a Bootstrap-styled button for a Html.ActionLink
 ///     with the specified action name, id parameter, and
 ///     contextual class. The action name is used as the link
 ///     text.
 /// </summary>
 /// <param name="html">The HTML.</param>
 /// <param name="actionName">Name of the action.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="contextualColor">The contextual class.</param>
 /// <returns>MvcHtmlString.</returns>
 /// TODO Edit XML Comment Template for BootstrapActionLinkButton
 public static MvcHtmlString BootstrapActionLinkButton(
     this System.Web.Mvc.HtmlHelper html,
     string actionName,
     int id,
     ContextualColor contextualColor =
     ContextualColor.Default,
     TargetAttribute targetAttribute = TargetAttribute.Self)
 {
     return(html.ActionLink(
                actionName,
                actionName,
                new
     {
         id
     },
                new
     {
         @class = $"btn btn-{ContextualColors[contextualColor]}",
         target = Bootstrap.BootstrapExtensions.TargetAttributes[targetAttribute]
     }));
 }
示例#11
0
        static string SimpleTypeName(Type t)
        {
            if (t == typeof(byte))
            {
                return("xs:byte");
            }
            if (t == typeof(int))
            {
                return("xs:integer");
            }
            if (t == typeof(long))
            {
                return("xs:long");
            }
            if (t == typeof(string))
            {
                return("xs:string");
            }
            if (t == typeof(bool))
            {
                return("xs:boolean");
            }

            TargetAttribute ta = (TargetAttribute)Attribute.GetCustomAttribute(t, typeof(TargetAttribute));

            if (ta != null)
            {
                return(ta.Name);
            }

            LayoutAttribute la = (LayoutAttribute)Attribute.GetCustomAttribute(t, typeof(LayoutAttribute));

            if (la != null)
            {
                return(la.Name);
            }

            return(t.Name);
        }
示例#12
0
        public FileParser(string fileName)
        {
            using (var streamReader = new StreamReader(fileName)) {
                string           line             = string.Empty;
                List <string>    classValues      = new List <string>();
                int              numberOfFeatures = -1;
                List <Attribute> features         = new List <Attribute>();
                int              numberOfExamples = -1;
                List <DataEntry> examples         = new List <DataEntry>();
                TargetAttribute  targetAttribute  = null;

                int featureCounter = 0;
                int exampleCounter = 0;

                var expecting = Expecting.ClassOrFeatureCount;

                do
                {
                    line = streamReader.ReadLine();

                    //If it's empty, skip it
                    if (line.Length > 0)
                    {
                        //If it's a comment, skip it
                        if (line.Length > 2 && line[0] == '/' && line[1] == '/')
                        {
                            continue;
                        }

                        //Valid line. Where the magic happens!
                        switch (expecting)
                        {
                        case Expecting.ClassOrFeatureCount:
                            //If we're a number, set the FeatureCounter and change states
                            if (int.TryParse(line, out numberOfFeatures))
                            {
                                expecting       = Expecting.Features;
                                targetAttribute = new TargetAttribute(0, "class", classValues.ToArray());
                            }
                            else
                            {
                                //Otherwise, we're a class that needs to be read
                                classValues.Add(line);
                            }
                            break;

                        case Expecting.Features:
                            var featureParts = line.Split(' ');
                            features.Add(new Attribute(featureCounter++ + 1, featureParts[0], featureParts.Skip(1).ToArray()));
                            if (featureCounter >= numberOfFeatures)
                            {
                                expecting = Expecting.ExampleCount;
                            }
                            break;

                        case Expecting.ExampleCount:
                            if (int.TryParse(line, out numberOfExamples))
                            {
                                expecting = Expecting.Examples;
                            }
                            break;

                        case Expecting.Examples:
                            line = trimmer.Replace(line, " ");
                            var exampleParts = line.Split(null);
                            if (exampleParts.Length == 2 + featureCounter)
                            {
                                var entryName       = exampleParts[0];
                                var classValue      = exampleParts[1];
                                var attributeValues = exampleParts.Skip(2).ToList();
                                if (attributeValues.Count == features.Count)
                                {
                                    var attribVals = new Dictionary <string, string>();
                                    for (int i = 0; i < attributeValues.Count; i++)
                                    {
                                        attribVals[features[i].Name] = attributeValues[i];
                                    }
                                    var dataEntry = new DataEntry(classValue, attribVals, entryName);
                                    examples.Add(dataEntry);
                                }
                                if (++exampleCounter >= numberOfExamples)
                                {
                                    expecting = Expecting.Nothing;
                                }
                            }
                            break;

                        default:
                            break;
                        }
                    }
                } while(!streamReader.EndOfStream);
                DecisionTreeSchema = new ID3DecisionTreeSchema(targetAttribute, features, examples);
            }
        }
示例#13
0
 public TargetSpeciesProperty(TargetAttribute value)
 {
     this.value = value;
 }
示例#14
0
文件: GameItem.cs 项目: LuckyBYR/RPG
 public void setAlchemyAttributes(int _dam, TargetTypes _tar, TargetAttribute _atr)
 {
     _damage    = _dam;
     _target    = _tar;
     _attribute = _atr;
 }
示例#15
0
 public TargetCondition(TargetAttribute value)
 {
     this.value = value;
 }
示例#16
0
    void SetAttributeName(TargetAttribute attribute, IEnumerable <ProgramTarget> targets, string name)
    {
        var namedAttribute = attribute.CloneWithName <TargetAttribute>(name);

        int index = _program.Attributes.FindIndex(x => x == attribute);

        _program.Attributes[index] = namedAttribute;

        if (namedAttribute is Tool tool)
        {
            foreach (var target in targets)
            {
                if (target.Target.Tool == attribute as Tool)
                {
                    target.Target = target.Target.ShallowClone(); target.Target.Tool = tool;
                }
            }
        }
        else if (namedAttribute is Frame frame)
        {
            foreach (var target in targets)
            {
                if (target.Target.Frame == attribute as Frame)
                {
                    target.Target = target.Target.ShallowClone(); target.Target.Frame = frame;
                }
            }
        }
        else if (namedAttribute is Speed speed)
        {
            foreach (var target in targets)
            {
                if (target.Target.Speed == attribute as Speed)
                {
                    target.Target = target.Target.ShallowClone(); target.Target.Speed = speed;
                }
            }
        }
        else if (namedAttribute is Zone zone)
        {
            foreach (var target in targets)
            {
                if (target.Target.Zone == attribute as Zone)
                {
                    target.Target = target.Target.ShallowClone(); target.Target.Zone = zone;
                }
            }
        }
        else if (namedAttribute is Command command)
        {
            for (int i = 0; i < _program.InitCommands.Count; i++)
            {
                if (_program.InitCommands[i] == attribute as Command)
                {
                    _program.InitCommands[i] = command;
                }
            }

            foreach (var target in targets)
            {
                var group = target.Commands.NotNull();

                for (int i = 0; i < group.Count; i++)
                {
                    if (group[i] == attribute as Command)
                    {
                        group[i] = command;
                    }
                }
            }
        }
    }
示例#17
0
 public TargetCondition(TargetAttribute value)
 {
     this.value = value;
 }
示例#18
0
 public TargetSpeciesProperty(TargetAttribute value)
 {
     this.value = value;
 }
示例#19
0
 public void setAlchemyAttributes(int _dam, TargetTypes _tar, TargetAttribute _atr)
 {
     _damage = _dam;
     _target = _tar;
     _attribute = _atr;
 }