public CurrentElement(OpenXmlSimpleType value, ElementProperty <OpenXmlSimpleType> property, bool isAttribute, Action <ValidationErrorInfo> addError)
 {
     Value       = value;
     Property    = property;
     IsAttribute = isAttribute;
     AddError    = addError;
 }
示例#2
0
        public static int Calculate(List <ElementProperty> elements, ElementProperty element)
        {
            var lcom = 0;

            // Methods in this class
            var methods = elements
                          .Where(e => e.Type == "function" && e.FunctionClass == element.Name)
                          .ToList();

            // For every pair of methods
            for (var i = 0; i < methods.Count; i++)
            {
                for (var j = i + 1; j < methods.Count; j++)
                {
                    var m = methods[i];
                    var n = methods[j];

                    // Increment lcom1 if they access no common members
                    if ((m.Members.Count == 0 || n.Members.Count == 0) &&
                        !m.Members.Intersect(n.Members).Any())
                    {
                        lcom++;
                    }
                }
            }
            return(lcom);
        }
        //
        public virtual void PopulatePropertyList(ElementProperty prop)
        {
            // Remove Observer
            m_GridView.SetDataChangeObserver(null);
            m_GridView.RemoveAll();

            PropertyObject propObj = null;
            GridViewItem   itemSub = null;

            prop.InitPropertyMap();

            // Use var keyword to enumerate dictionary
            foreach (var pair in prop.List)
            {
                propObj = pair.Value;
                m_GridView.AddItem(0, 0, propObj.Name);
                itemSub            = m_GridView.AddItem(0, 1, "", propObj.Type);
                itemSub.m_ItemData = propObj;
                // May be not necessary if use this in the object itself..
                //SetProValues(prop, propObj.Name, itemSub);
                itemSub.m_Data = propObj.List;
            }
            // Will be used as Adapter object's data
            m_GridView.Tag = prop;
            m_GridView.SetDataChangeObserver(this);
        }
示例#4
0
        private void ElementLV_ItemClick(object sender, ItemClickEventArgs e)
        {
            Elemento clicado = (Elemento)e.ClickedItem;

            ElementLB.Text = String.Format("{0} ({1})", clicado.Name, clicado.Symbol.Replace(" ", ""));

            // load UI elements
            PropLV.Items.Clear();
            IsotopesLV.Items.Clear();
            AtomImageLV.Items.Clear();

            PropLV.Items.Add(new ElementProperty("Atomic Number:", clicado.ANumber));
            PropLV.Items.Add(new ElementProperty("Atomic Mass:", clicado.AMass));
            PropLV.Items.Add(new ElementProperty("Boiling Point:", clicado.BP));
            PropLV.Items.Add(new ElementProperty("Melting Point:", clicado.MP));
            PropLV.Items.Add(new ElementProperty("Protons and Electrons:", clicado.NoPE));
            PropLV.Items.Add(new ElementProperty("Classification: ", clicado.Classification));
            PropLV.Items.Add(new ElementProperty("Density:", clicado.Density));
            PropLV.Items.Add(new ElementProperty("Color:", clicado.Color));
            PropLV.Items.Add(new ElementProperty("Crystal Structure:", clicado.CrystalGeo));

            // update isotopes
            IsotopesLV.Items.Add(new ElementProperty("Isotopes", clicado.Name));
            foreach (KeyValuePair <string, string> kv in clicado.Isotopes)
            {
                ElementProperty prop = new ElementProperty(kv.Key, " " + kv.Value);
                IsotopesLV.Items.Add(prop);
            }

            // update image
            ImageProperty ip = new ImageProperty(new BitmapImage(
                                                     new Uri(clicado.AtomicStructureImage, UriKind.Absolute)));

            AtomImageLV.Items.Add(ip);
        }
示例#5
0
 public DrawElement()
 {
     m_eTextAlign  = TextAlign.Left;
     m_bDrawBorder = true;
     m_Factory     = null;
     m_Property    = null;
 }
示例#6
0
        public int AddItemToFaing(ElementProperty script, int fadingtime)        //添加腐坏序列
        {
            FadingItem temp;

            temp.obj        = script;
            temp.fadingTime = fadingtime;
            fadinglist.Add(temp);
            return(fadinglist.Count - 1);
        }
        protected override void Act()
        {
            Container.RegisterInstance <IWindowsFormsEditorService>(new Mock <IWindowsFormsEditorService>().Object);
            Container.RegisterInstance <IUIService>(new Mock <IUIService>().Object);

            var sectionModel = SectionViewModel.CreateSection(Container, "mock section", new ConfigurationElementWithComponentModelEditor());

            var originalPropertyDescriptor = TypeDescriptor.GetProperties(typeof(ConfigurationElementWithComponentModelEditor)).OfType <PropertyDescriptor>().Where(x => x.Name == "Prop3").First();

            property = sectionModel.CreateElementProperty(sectionModel, new PropertyDescriptorReturnEditor(originalPropertyDescriptor));
        }
示例#8
0
        /// <summary>
        /// Sets any HTML element property in the HTML code by the ID of the tag
        /// </summary>
        /// <param name="ID">The ID of the HTML tag (&lt;h1 ID = 'ThisID'&gt;XXX&lt;/h1&gt;)</param>
        /// <param name="property">The property that will be set</param>
        /// <param name="data">The data that will be set on the property specified</param>
        /// <returns>True if the property was found and set</returns>
        public bool SetElementByID(string ID, ElementProperty property, string data)
        {
            var element = GetElementByID(ID);

            if (_propertyCache.TryGetValue(property, out PropertyInfo propertyInfo))
            {
                propertyInfo.SetValue(element, data);
                return(true);
            }

            return(false);
        }
        public void then_readonly_properties_with_editors_dont_offer_editors()
        {
            var exceptionType    = model.GetDescendentsOfType <ExceptionTypeData>().First();
            var typeNameProperty = new ElementProperty(Container.Resolve <IServiceProvider>(),
                                                       exceptionType,
                                                       TypeDescriptor.GetProperties(typeof(ExceptionTypeData)).OfType <PropertyDescriptor>().Where(x => x.Name == "TypeName").First(),
                                                       new Attribute[] { new EditorAttribute(typeof(TypeSelectionEditor), typeof(UITypeEditor)) });

            Assert.IsTrue(typeNameProperty.ReadOnly);
            Assert.IsTrue(typeNameProperty.BindableProperty is PopupEditorBindableProperty);
            Assert.IsNull(typeNameProperty.BindableProperty.GetEditor(typeof(UITypeEditor)));
        }
示例#10
0
        public static float Calculate(List <ElementProperty> elements, ElementProperty element)
        {
            if (Options == null)
            {
                Options = new MIndexOptions();
            }

            return(element.LinesOfCode * Options.LinesOfCodeWeight
                   + element.CyclomaticComplexity * Options.ComplexityWeight
                   + element.Cohesion * Options.CohesionWeight
                   + element.Dependencies.Count * Options.CouplingWeight);
        }
示例#11
0
        public IDisposable Push(OpenXmlSimpleType value, ElementProperty <OpenXmlSimpleType> property, bool isAttribute)
        {
            var current = Current;
            var element = GetOrCreateElement();

            element.CopyFrom(current);

            element.Value       = value;
            element.Property    = property;
            element.IsAttribute = isAttribute;

            _elements.Push(element);

            return(_popDisposable);
        }
        public object GetValue(ElementProperty property, object defaultValue)
        {
            if (mergeElement == null)
            {
                return(defaultValue);
            }
            if (!mergeElement.OverriddenProperties.AllKeys.Contains(property.ConfigurationName))
            {
                return(defaultValue);
            }

            string overriddenValue = mergeElement.OverriddenProperties[property.ConfigurationName].Value;

            return(property.Converter.ConvertFromString(property, CultureInfo.CurrentUICulture, overriddenValue));
        }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            BindableProperty           bindableProperty = (BindableProperty)context.PropertyDescriptor;
            ElementProperty            property         = (ElementProperty)bindableProperty.Property;
            ElementCollectionViewModel collection       = (ElementCollectionViewModel)property.DeclaringElement.ChildElement(property.DeclaringProperty.Name);
            IUIServiceWpf uiService = (IUIServiceWpf)context.GetService(typeof(IUIServiceWpf));

            PopupCollectionEditorWindow w = new PopupCollectionEditorWindow()
            {
                ContainedContent = new HeaderedListLayout(collection, collection.AddCommands)
            };

            uiService.ShowDialog(w);

            return(value);
        }
示例#14
0
        /// <summary>
        /// Notifies about widget usage.
        /// </summary>
        /// <param name="presentationId">Presentation Id.</param>
        /// <param name="slideId">Slide Id.</param>
        /// <param name="element">Element.</param>
        private void NotifyAboutWidgetUsage(int presentationId, int slideId, Element element)
        {
            ElementProperty widgetCode = element.Properties != null?
                                         element.Properties.FirstOrDefault(p => string.Compare(p.Name, "code", true) == 0) : null,
                            widgetCodeSigned = element.Properties != null?
                                               element.Properties.FirstOrDefault(p => string.Compare(p.Name, "codeSigned", true) == 0) : null;

            if (widgetCode != null && !string.IsNullOrWhiteSpace(widgetCode.Value) && (widgetCodeSigned == null || string.Compare(widgetCodeSigned.Value, "true", true) != 0))
            {
                MessageQueueManager.Current.GetQueue(MessageQueueType.Email).AddMessages(new Message[] { new Message()
                                                                                                         {
                                                                                                             Id      = string.Format("{0}_{1}_{2}", presentationId, slideId, element.Id),
                                                                                                             Subject = string.Format("Widget usage ({0})", Guid.NewGuid()),
                                                                                                             Body    = string.Format("*** {0} <{1}> ***\n\n{2}",
                                                                                                                                     PublishConfiguration.GetAbsoluteUri(Request.RequestUri, presentationId), presentationId, JavascriptDecode(widgetCode.Value))
                                                                                                         } });
            }
        }
示例#15
0
    public virtual void ReceiveDamage(DamageData damage)
    {
        int             trueDamage = damage.damage;
        ElementProperty pty        = GetProperty(damage.element);

        if (pty == ElementProperty.WEAK)
        {
            trueDamage = (int)((float)trueDamage * 2f);
        }
        else if (pty == ElementProperty.ABSORB)
        {
            //Heal();
            trueDamage = -1;
        }
        else if (pty == ElementProperty.BLOCK)
        {
            ReceiveHeal(trueDamage);
            trueDamage = 0;
        }
        else if (pty == ElementProperty.RESIST)
        {
            //Heal();
            trueDamage = (int)((float)trueDamage * 0.5f);
            if (trueDamage < 1)
            {
                trueDamage = 1;
            }
        }

        if (trueDamage >= 0)
        {
            HP -= damage.damage;
            afterReciveDamage.Invoke();
            if (HP < 0)
            {
                HP = 0;
                afterReciveDeath.Invoke();
                //death;
            }
        }
        UpdateHPBar();
        //  Debug.Log(HP);
    }
    /// <summary>
    ///  This Command method sets the network sync properties for all clients based on the parameters specified.
    ///  Elements have to be removed and inserted in order to get the struct to sync, it seems to be a bug in unity
    ///  that hasn't been addressed yet.
    /// </summary>
    /// <param name="ID">The ID of the shape being changed.</param>
    //[Command]
    public void CmdSetVisibility(byte ID, byte paletteIndex)
    {
        int             targetIndex = -1;
        ElementProperty newElement  = new ElementProperty(0, 0);

        for (int index = 0; index < ServerElements.Count; index++)
        {
            ElementProperty element = ServerElements[index];
            if (element.ID.Equals(ID))
            {
                targetIndex   = index;
                newElement.ID = element.ID;
                newElement.shapePaletteIndex = paletteIndex;
                newElement.shapeFrame        = (byte)Random.Range(0f, 12.9f);
                ServerElements[targetIndex]  = newElement;
                RpcClientFrameIsDirty();
                break;
            }
        }
    }
        public void SetValue(ElementProperty property, object value)
        {
            if (mergeElement == null)
            {
                throw new InvalidOperationException("TODO");
            }

            string valueToSet   = (string)Convert.ChangeType(value, typeof(string));
            string propertyName = property.ConfigurationName;

            if (!mergeElement.OverriddenProperties.AllKeys.Contains(propertyName))
            {
                var overriddenProperty = new KeyValueConfigurationElement(propertyName, valueToSet);
                this.mergeElement.OverriddenProperties.Add(overriddenProperty);
            }
            else
            {
                mergeElement.OverriddenProperties[propertyName].Value = valueToSet;
            }
        }
        public override void OnApplyTemplate()
        {
            BindableProperty property = DataContext as BindableProperty;

            if (property == null)
            {
                return;
            }

            CustomEditorBinder.BindProperty(this, property);

            ElementProperty elementProperty = property.Property as ElementProperty;

            if (elementProperty != null)
            {
                viewModel = elementProperty.DeclaringElement.ChildElement(elementProperty.DeclaringProperty.Name) as ElementCollectionViewModel;
            }

            if (viewModel != null)
            {
                var properties = TypeDescriptor.GetProperties(viewModel.CollectionElementType).OfType <PropertyDescriptor>().Where(x => x.Attributes.OfType <ConfigurationPropertyAttribute>().Any()).ToArray();

                foreach (var childProperty in properties.Where(x => x.IsBrowsable))
                {
                    Collection.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(75, GridUnitType.Star)
                    });
                }

                Collection.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(25)
                });

                Redraw();

                viewModel.ChildElementsCollectionChange += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ChildElements_CollectionChanged);
            }
        }
    /// <summary>
    /// When the server starts populate ServerElements with all the default properties of the GameObjects in the scene with an "ElementScript" attribute.
    /// (This way our server elements are always updated dynamically based on what's actually in the scene)
    /// </summary>
    public override void OnStartServer()
    {
        base.OnStartServer();

        myRpcHeartbeatTimer = 0f;

        // Get the master player script object on the server, if one doesn't
        // exist already, then assign this player object as the master instance
        // so that other objects will use it as such.
        GridPlayerScript[] players = FindObjectsOfType <GridPlayerScript>();
        if (players.Length <= 1)
        {
            isMasterInstance = true;
            myMasterInstance = this;
            myMasterInstance.ServerElements.Clear();

            ElementScript[] elements = FindObjectsOfType <ElementScript>();

            foreach (var element in elements)
            {
                ElementProperty newProperty = new ElementProperty(byte.Parse(element.gameObject.name), (byte)Random.Range(0, 12));
                myMasterInstance.ServerElements.Add(newProperty);
            }
        }
        else
        {
            foreach (GridPlayerScript player in players)
            {
                if (player.isMasterInstance == true)
                {
                    myMasterInstance = player;
                }
            }
        }

        // Use this to print debug messages when server elements change
        //ServerElements.Callback = OnServerElementsChanged;
    }
        protected override void Arrange()
        {
            base.Arrange();

            var locator = new Mock <ConfigurationSectionLocator>();

            locator.Setup(x => x.ConfigurationSectionNames).Returns(new[] { "testSection" });
            Container.RegisterInstance(locator.Object);

            var section = new ElementForValidation();

            var source = new DesignDictionaryConfigurationSource();

            source.Add("testSection", section);

            var sourceModel = Container.Resolve <ConfigurationSourceModel>();

            sourceModel.Load(source);

            Section = sourceModel.Sections.Where(s => s.SectionName == "testSection").Single();

            property = (ElementProperty)Section.Property(ArrangePropertyName());
        }
示例#21
0
        internal static void ValidateValue(ValidationContext validationContext, ValidatorCollection validators, OpenXmlSimpleType value, string qname, ElementProperty <OpenXmlSimpleType> state, bool isAttribute)
        {
            var errors = validationContext.Errors.Count;

            using (validationContext.Push(value, state, isAttribute))
            {
                foreach (var validator in validators)
                {
                    validator.Validate(validationContext);

                    // Break early if validation has hit an error
                    if (errors != validationContext.Errors.Count)
                    {
                        return;
                    }
                }
            }
        }
 private static IComparable GetOtherBoundary(ElementProperty property)
 {
     string propertyToFetch = property.PropertyName == "UpperBound" ? "LowerBound" : "UpperBound";
     return (IComparable)property.DeclaringElement.Properties.Single(p => p.PropertyName == propertyToFetch).Value;
 }
示例#23
0
        public void then_property_has_name_from_configuration_property_information()
        {
            ElementProperty numberProperty = properties.OfType <ElementProperty>().Where(x => x.PropertyName == "Number").FirstOrDefault();

            Assert.AreEqual("number", numberProperty.ConfigurationName);
        }
        private void FillSignalProperties(SignalRule signalRule)
        {
            this.ElementProperties.ToList().ForEach(property => property.PropertyChanged -= this.ElementPropertyChanged);
            this.ElementProperties.Clear();

            if (signalRule != null)
            {
                ElementProperties properties     = new ElementProperties();
                PropertyInfo[]    propertiesInfo = null;

                switch (signalRule.ValueType)
                {
                case ValueDataType.Integer:
                    propertiesInfo = signalRule.GetType().GetIntegerProperties();
                    this.Clear(ValueDataType.Datetime | ValueDataType.String, signalRule);
                    break;

                case ValueDataType.String:
                    propertiesInfo = signalRule.GetType().GetStringProperties();
                    this.Clear(ValueDataType.Integer | ValueDataType.Datetime, signalRule);
                    break;

                case ValueDataType.Datetime:
                    propertiesInfo = signalRule.GetType().GetDateTimeProperties();
                    this.Clear(ValueDataType.Integer | ValueDataType.String, signalRule);
                    break;

                default:
                    propertiesInfo = signalRule.GetType().GetExemptProperties();
                    this.Clear(ValueDataType.Integer | ValueDataType.String | ValueDataType.Datetime, signalRule);
                    break;
                }

                foreach (PropertyInfo propertyInfo in propertiesInfo)
                {
                    ElementProperty elementProperty = null;

                    if (propertyInfo.PropertyType.IsEnum)
                    {
                        elementProperty = this.GetComboBoxProperty(signalRule, propertyInfo);
                    }
                    else if (propertyInfo.PropertyType == typeof(double?))
                    {
                        elementProperty = this.GetDoubleProperty(signalRule, propertyInfo);
                    }
                    else if (propertyInfo.PropertyType == typeof(int?))
                    {
                        elementProperty = this.GetIntegerProperty(signalRule, propertyInfo);
                    }
                    else if (propertyInfo.PropertyType.IsArray)
                    {
                        switch (propertyInfo.PropertyType.Name)
                        {
                        case "String[]":
                            elementProperty = this.GetArrayTextProperty(signalRule, propertyInfo);
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        elementProperty = this.GetTextProperty(signalRule, propertyInfo);
                    }

                    properties.Add(elementProperty);
                }

                this.ElementProperties = properties;

                this.ElementProperties.ToList().ForEach(property =>
                {
                    if (!property.IsReadOnly)
                    {
                        property.PropertyChanged += this.ElementPropertyChanged;
                    }
                });
            }

            this.PrimaryCommand.RaiseCanExecuteChanged();
        }
示例#25
0
        private static IComparable GetOtherBoundary(ElementProperty property)
        {
            string propertyToFetch = property.PropertyName == "UpperBound" ? "LowerBound" : "UpperBound";

            return((IComparable)property.DeclaringElement.Properties.Single(p => p.PropertyName == propertyToFetch).Value);
        }
示例#26
0
        public Slide CloneSlide([FromBody] CloneSlideSettings settings, int presentationId, int?id = null)
        {
            Slide           s   = null;
            Element         e   = null;
            Slide           ret = null;
            Presentation    p   = null;
            ElementProperty pr  = null;

            if (settings != null && presentationId > 0)
            {
                p = base.Service.Read(presentationId);

                if (p != null)
                {
                    s = id.HasValue ? p.Slides.FirstOrDefault(candidate => candidate.Id == id.Value) : null;

                    if (s != null)
                    {
                        ret = new Slide();

                        ret.PresentationId = settings.TargetPresentationId.HasValue ? settings.TargetPresentationId.Value : presentationId;
                        ret.Order          = p.Slides.Max(candidate => candidate.Order) + 1;
                        ret.Title          = settings.Title;
                        ret.Description    = s.Description;
                        ret.PlaybackTime   = s.PlaybackTime;

                        if (s.Elements != null && s.Elements.Any())
                        {
                            foreach (Element elm in s.Elements)
                            {
                                e = new Element();

                                e.Name     = elm.Name;
                                e.Position = elm.Position;
                                e.Type     = elm.Type;
                                e.Order    = s.Elements.Max(candidate => candidate.Order) + ret.Elements.Count() + 1;

                                if (!settings.TargetPresentationId.HasValue)
                                {
                                    e.NavigateSlideId = elm.NavigateSlideId;
                                }

                                if (elm.Offset != null)
                                {
                                    e.Offset = new ElementOffset();

                                    e.Offset.Left = elm.Offset.Left;
                                    e.Offset.Top  = elm.Offset.Top;

                                    if (elm.Offset.Viewport != null)
                                    {
                                        e.Offset.Viewport = new ElementOffsetViewport();

                                        e.Offset.Viewport.Width  = elm.Offset.Viewport.Width;
                                        e.Offset.Viewport.Height = elm.Offset.Viewport.Height;
                                    }
                                }

                                if (elm.Properties != null && elm.Properties.Any())
                                {
                                    foreach (ElementProperty prop in elm.Properties)
                                    {
                                        pr = new ElementProperty();

                                        pr.Name  = prop.Name;
                                        pr.Value = prop.Value;

                                        e.Properties.Add(pr);
                                    }
                                }

                                ret.Elements.Add(e);
                            }
                        }

                        if (settings.TargetPresentationId.HasValue && settings.TargetPresentationId.Value != presentationId)
                        {
                            p = base.Service.Read(settings.TargetPresentationId.Value);
                        }

                        if (p != null)
                        {
                            p.Slides.Add(ret);
                            base.Service.CreateOrUpdate(p);
                        }
                    }
                }
            }

            return(ret);
        }
示例#27
0
        //OnTriggerEnter2D is sent when another object enters a trigger collider attached to this object (2D physics only).
        private void OnTriggerEnter2D(Collider2D other)
        {
            //Check if the tag of the trigger collided with is Exit.
            if (other.tag == "Exit")
            {
                //Invoke the Restart function to start the next level with a delay of restartLevelDelay (default 1 second).
                Invoke("Restart", restartLevelDelay);

                //Disable the player object since level is over.
                enabled = false;
            }

            ElementProperty tar_script = other.transform.GetComponent <ElementProperty> ();

            if (tar_script != null && (tar_script.index.first >= 0 && tar_script.index.second >= 0))
            {
                if (tar_script.type == ElementType.food)                 //人物捡到食物
                {
                    SoundManager.instance.RandomizeSfx(eatSound1, eatSound2);
                    tar_script.DoEffect(this);
                }
                else if (tar_script.type == ElementType.item)                   //人物捡到道具
                {
                    BagSystem.instance.AddItem(tar_script.index);
                    tar_script.Destroy();
                }
                else                  //人物触发剧情
                {
                    ResourcesManager.instance.storiesPool [tar_script.index.first] [tar_script.index.second].effect.Call(this);
                }
            }

            /*//Check if the tag of the trigger collided with is Food.
             * else if(other.tag == "Food")
             * {
             *      //Add pointsPerFood to the players current food total.
             *      food += pointsPerFood;
             *
             *      //Update foodText to represent current total and notify player that they gained points
             *      foodText.text = "+" + pointsPerFood + " Food: " + food;
             *
             *      //Call the RandomizeSfx function of SoundManager and pass in two eating sounds to choose between to play the eating sound effect.
             *      SoundManager.instance.RandomizeSfx (eatSound1, eatSound2);
             *
             *      //Disable the food object the player collided with.
             *      other.gameObject.SetActive (false);
             * }
             *
             * //Check if the tag of the trigger collided with is Soda.
             * else if(other.tag == "Soda")
             * {
             *      //Add pointsPerSoda to players food points total
             *      food += pointsPerSoda;
             *
             *      //Update foodText to represent current total and notify player that they gained points
             *      foodText.text = "+" + pointsPerSoda + " Food: " + food;
             *
             *      //Call the RandomizeSfx function of SoundManager and pass in two drinking sounds to choose between to play the drinking sound effect.
             *      SoundManager.instance.RandomizeSfx (drinkSound1, drinkSound2);
             *
             *      //Disable the soda object the player collided with.
             *      other.gameObject.SetActive (false);
             * }*/
        }
        public void SetValue(ElementProperty property, object value)
        {
            if (mergeElement == null) throw new InvalidOperationException("TODO");

            string valueToSet = (string) Convert.ChangeType(value, typeof(string));
            string propertyName = property.ConfigurationName;

            if (!mergeElement.OverriddenProperties.AllKeys.Contains(propertyName))
            {
                var overriddenProperty = new KeyValueConfigurationElement(propertyName, valueToSet);
                this.mergeElement.OverriddenProperties.Add(overriddenProperty);
            }
            else
            {
                mergeElement.OverriddenProperties[propertyName].Value = valueToSet;
            }
        }
示例#29
0
 public ValidatorContext ToContext(OpenXmlSimpleType simple, ElementProperty <OpenXmlSimpleType> state, bool isAttribute)
 {
     return(new ValidatorContext(simple, FileFormat, Part, Element, state, isAttribute, McContext, AddError));
 }
示例#30
0
 set => SetValue(ElementProperty, value);
        public object GetValue(ElementProperty property, object defaultValue)
        {
            if (mergeElement == null) return defaultValue;
            if (!mergeElement.OverriddenProperties.AllKeys.Contains(property.ConfigurationName)) return defaultValue;

            string overriddenValue = mergeElement.OverriddenProperties[property.ConfigurationName].Value;
            return property.Converter.ConvertFromString(property, CultureInfo.CurrentUICulture, overriddenValue);
        }
示例#32
0
 public Enemy(string name, string id, Enemy parentData = null, EnemyType type = EnemyType.Normal, ElementProperty property = ElementProperty.Normal)
 {
     this.Name            = name;
     this.ID              = id;
     this.Type            = type;
     this.ParentData      = parentData;
     this.ElementProperty = property;
     Enemies.enemies.Add(this);
 }
            private static bool IsKeyItem(ElementProperty property)
            {
                var configPropertyAttribute = property.Attributes.OfType <ConfigurationPropertyAttribute>().FirstOrDefault();

                return(configPropertyAttribute != null && configPropertyAttribute.IsKey == true);
            }