public void Add <TKey>(object extended, TKey key, IExtensionAttribute func)
 {
     // in globalattributemap extended object (argument) is not considered
     if (!MappedAttributes.ContainsKey(key))
     {
         MappedAttributes.Add(key, func);
     }
     else
     {
         throw new AlreadyExtendedException(key);
     }
 }
        /// <summary>
        /// Stores the attribute in an extension.
        /// </summary>
        /// <param name="extensible">The object that is being extended.</param>
        /// <param name="attribute">The attribute to store.</param>
        /// <returns>This method always returns true.</returns>
        public bool StoreAttribute(IExtensible extensible, IExtensionAttribute attribute)
        {
            TestExtension extension;

            extension = extensible.Extensions.FirstOrDefault((e) => e.Name == TestExtension.ExtensionName) as TestExtension;
            if (extension == null)
            {
                extension = new TestExtension();
                extensible.Extensions.Add(extension);
            }

            extension.AddAttribute(attribute);

            return true;
        }
        public void Add <TKey>(object extended, TKey key, IExtensionAttribute func)
        {
            Type type = extended.GetType();

            if (dictionary.TryGetValue(type, out IAttributeMap map))
            {
                map.Add(extended, key, func);
            }
            else
            {
                IAttributeMap nested = factory();
                dictionary.Add(type, nested);
                nested.Add(extended, key, func);
            }
        }
        /// <summary>
        /// Stores the attribute in an extension.
        /// </summary>
        /// <param name="extensible">The object that is being extended.</param>
        /// <param name="attribute">The attribute to store.</param>
        /// <returns>This method always returns true.</returns>
        public bool StoreAttribute(IExtensible extensible, IExtensionAttribute attribute)
        {
            GenericExtension extension;

            extension = extensible.Extensions.FirstOrDefault((e) => e.Name == GenericExtensionHandler.ExtensionName) as GenericExtension;
            if (extension == null)
            {
                extension = new GenericExtension(GenericExtensionHandler.ExtensionName);
                extensible.Extensions.Add(extension);
            }

            extension.AddAttribute(attribute);

            return true;
        }
        /// <summary>
        /// Stores the attribute in an extension.
        /// </summary>
        /// <param name="extensible">The object that is being extended.</param>
        /// <param name="attribute">The attribute to store.</param>
        /// <returns>This method always returns true.</returns>
        public bool StoreAttribute(IExtensible extensible, IExtensionAttribute attribute)
        {
            GenericExtension extension;

            extension = extensible.Extensions.FirstOrDefault((e) => e.Name == GenericExtensionHandler.ExtensionName) as GenericExtension;
            if (extension == null)
            {
                extension = new GenericExtension(GenericExtensionHandler.ExtensionName);
                extensible.Extensions.Add(extension);
            }

            extension.AddAttribute(attribute);

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Stores the attribute in an extension.
        /// </summary>
        /// <param name="extensible">The object that is being extended.</param>
        /// <param name="attribute">The attribute to store.</param>
        /// <returns>This method always returns true.</returns>
        public bool StoreAttribute(IExtensible extensible, IExtensionAttribute attribute)
        {
            CustomExtension extension;

            extension = extensible.Extensions.FirstOrDefault((e) => e.Name == this.ns) as CustomExtension;
            if (extension == null)
            {
                extension = new CustomExtension(this.ns);
                extensible.Extensions.Add(extension);
            }

            extension.AddAttribute(attribute);

            return(true);
        }
        /// <summary>
        /// Stores the attribute in an extension.
        /// </summary>
        /// <param name="extensible">The object that is being extended.</param>
        /// <param name="attribute">The attribute to store.</param>
        /// <returns>This method always returns true.</returns>
        public bool StoreAttribute(IExtensible extensible, IExtensionAttribute attribute)
        {
            TestExtension extension;

            extension = extensible.Extensions.FirstOrDefault((e) => e.Name == TestExtension.ExtensionName) as TestExtension;
            if (extension == null)
            {
                extension = new TestExtension();
                extensible.Extensions.Add(extension);
            }

            extension.AddAttribute(attribute);

            return(true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Adds an attribute member to the extension data.
        /// </summary>
        /// <param name="attribute">The attribute to add.</param>
        public void AddAttribute(IExtensionAttribute attribute)
        {
            ArgValidator.Create(attribute, "attribute").IsNotNull();

            this.attributes.Value.Add(attribute);
        }
 /// <summary>
 /// Adds an attribute member to the extension data.
 /// </summary>
 /// <param name="attribute">The attribute to add.</param>
 public void AddAttribute(IExtensionAttribute attribute)
 {
     this.attributes.Add(attribute);
 }
 public void Add <TKey>(object extended, TKey key, IExtensionAttribute func)
 {
     WasAdded = true;
 }
        public void AttributeFactory_CreateActionReturnsTypeFuncDualParam()
        {
            IExtensionAttribute attribute = factory.CreateFuncAttribute <string, int, int, int>("key", (i, j) => 42);

            Assert.AreEqual(typeof(FuncAttributeDualParam <int, int, int>), attribute.GetType());
        }
        public void AttributeFactory_CreateActionReturnsTypeActionParamAttribute()
        {
            IExtensionAttribute attribute = factory.CreateActionAttribute <string, int>("key", (i) => { });

            Assert.AreEqual(typeof(ActionParamAttribute <int>), attribute.GetType());
        }
        public void AttributeFactory_CreateActionReturnsTypeActionAttribute()
        {
            IExtensionAttribute attribute = factory.CreateActionAttribute("key", () => { });

            Assert.AreEqual(typeof(ActionAttribute), attribute.GetType());
        }
        /// <summary>
        /// Adds an attribute member to the extension data.
        /// </summary>
        /// <param name="attribute">The attribute to add.</param>
        public void AddAttribute(IExtensionAttribute attribute)
        {
            ArgValidator.Create(attribute, "attribute").IsNotNull();

            this.attributes.Value.Add(attribute);
        }
Exemplo n.º 15
0
 public void Add <TKey>(object extended, TKey key, IExtensionAttribute func)
 {
     //do nothing
 }
Exemplo n.º 16
0
 /// <summary>
 /// Adds an attribute member to the extension data.
 /// </summary>
 /// <param name="attribute">The attribute to add.</param>
 public void AddAttribute(IExtensionAttribute attribute)
 {
     this.attributes.Add(attribute);
 }