Esempio n. 1
0
 public AutoEntityMapper()
 {
     System.Attribute attr = System.Attribute.GetCustomAttributes(typeof(T))[0];
     Schema("dbo");
     Table((attr as DataStorage).TableName);
     AutoMap();
 }
Esempio n. 2
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attrs)
        {
            List<PropertyDescriptor> propList = new List<PropertyDescriptor>();

            PropertyInfo interactionsProperty = component.GetType().GetProperty("Interactions");
            if (interactionsProperty != null)
            {
                Interactions interactions = (Interactions)interactionsProperty.GetValue(component, null);
                for (int i = 0; i < interactions.FunctionSuffixes.Length; i++)
                {
                    string eventName = interactions.DisplayNames[i];
                    if (UpdateEventName != null)
                    {
                        eventName = UpdateEventName(eventName);
                    }
                    if (eventName.IndexOf("$$") < 0)
                    {
                        // Only add the event if the cursor mode exists
                        propList.Add(new InteractionPropertyDescriptor(component, i, interactions.FunctionSuffixes[i], eventName));
                    }
                }
            }

            return new PropertyDescriptorCollection(propList.ToArray());
        }
Esempio n. 3
0
 public Mapping(PropertyInfo propertyInfo, IGenerator <T> generator)
 {
     PropertyName = propertyInfo.Name;
     PropertyInfo = propertyInfo;
     object[] a = propertyInfo.GetCustomAttributes(false);
     foreach (var item in a)
     {
         try
         {
             System.Attribute attr = (System.Attribute)item;
             //TODO: Refactor this out to be more flexible and support more annotations
             if (attr.GetType() == typeof(System.ComponentModel.DataAnnotations.StringLengthAttribute))
             {
                 System.ComponentModel.DataAnnotations.StringLengthAttribute sla = (System.ComponentModel.DataAnnotations.StringLengthAttribute)attr;
                 if (generator.GetType() == typeof(Generators.TextGenerator))
                 {
                     generator = (IGenerator <T>) new Generators.TextGenerator(sla.MaximumLength);
                 }
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     Generator = generator;
 }
Esempio n. 4
0
 private static bool needEncoded(object[] attributes)
 {
     if (attributes == null || attributes.Length <= 0)
     {
         return(true);
     }
     for (int i = 0; i < attributes.Length; i++)
     {
         System.Attribute attribute = (System.Attribute)attributes[i];
         if (attribute is Encode)
         {
             Encode encode = attribute as Encode;
             bool   result;
             if (encode.NeedEncoded)
             {
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }
     }
     return(false);
 }
        public void Initialize(Attribute attribute)
        {
            //Get all parametters of the Attribute: the name and their values.
            //For example:
            //In LengthAttribute the parametter are Min and Max.
            System.Type clazz = attribute.GetType();

            IRuleArgs ruleArgs = attribute as IRuleArgs;

            if (ruleArgs == null)
            {
                throw new ArgumentException("Attribute " + clazz + " doesn't implement IRuleArgs interface.");
            }
            else
            {
                if (ruleArgs.Message == null)
                {
                    throw new ArgumentException(string.Format("The value of the message in {0} attribute is null (nothing for VB.Net Users). Add some message ", clazz) +
            "on the attribute to solve this issue. For Example:\n" +
            "- private string message = \"Error on property Foo\";\n" +
            "Or you can use interpolators with resources files:\n" +
            "-private string message = \"{validator.MyValidatorMessage}\";");
                }

                attributeMessage = ruleArgs.Message;
            }

            foreach (PropertyInfo property in clazz.GetProperties())
            {
                attributeParameters.Add(property.Name.ToLowerInvariant(), property.GetValue(attribute, null));
            }
        }
		/// <summary>
		/// Tests to determine if the current platform is supported
		/// based on a platform attribute.
		/// </summary>
		/// <param name="platformAttribute">The attribute to examine</param>
		/// <returns></returns>
		public bool IsPlatformSupported( Attribute platformAttribute )
		{
			//Use reflection to avoid dependency on a particular framework version
			string include = (string)Reflect.GetPropertyValue( 
				platformAttribute, "Include", 
				BindingFlags.Public | BindingFlags.Instance );

			string exclude = (string)Reflect.GetPropertyValue(
				platformAttribute, "Exclude", 
				BindingFlags.Public | BindingFlags.Instance );

			try
			{
				if (include != null && !IsPlatformSupported(include))
				{
					reason = string.Format("Only supported on {0}", include);
					return false;
				}

				if (exclude != null && IsPlatformSupported(exclude))
				{
					reason = string.Format("Not supported on {0}", exclude);
					return false;
				}
			}
			catch( ArgumentException ex )
			{
				reason = string.Format( "Invalid platform name: {0}", ex.ParamName );
				return false; 
			}

			return true;
		}
Esempio n. 7
0
        private static List <Type> GetUsedCustomControls(GUIControlCollection controls)
        {
            List <Type> customControls = new List <Type>();

            foreach (GUIControl control in controls)
            {
                // Found a custom GUIControl.  Ensure that the "ControlAttribute" is present
                System.Attribute attribute = System.Attribute.GetCustomAttribute(control.GetType(), typeof(Plugins.ControlAttribute));
                if (attribute != null)
                {
                    Otter.Plugins.ControlAttribute  controlAttribute  = (Otter.Plugins.ControlAttribute)attribute;
                    Otter.Plugins.ControlDescriptor controlDescriptor = controlAttribute.GetDescriptor();

                    customControls.Add(control.GetType());
                }

                List <Type> list = GetUsedCustomControls(control.Controls);

                foreach (Type type in list)
                {
                    if (!customControls.Contains(type))
                    {
                        customControls.Add(type);
                    }
                }
            }

            return(customControls);
        }
 public static bool ExcludeKnownAttrsFilter(Attribute x)
 {
     return x.GetType() != typeof(RouteAttribute)
         && x.GetType() != typeof(DescriptionAttribute)
         && x.GetType().Name != "DataContractAttribute"  //Type equality issues with Mono .NET 3.5/4
         && x.GetType().Name != "DataMemberAttribute";
 }
		public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
		{
			PropertyDescriptorCollection props = base.GetProperties(attributes);
			List<PropertyDescriptor> allProperties = new List<PropertyDescriptor>();
			
			DesignerHelper.AddDefaultProperties(allProperties,props);
			PropertyDescriptor prop = null;
			
			prop = props.Find("SectionOffset",true);
			allProperties.Add(prop);
			
			prop = props.Find("SectionMargin",true);
			allProperties.Add(prop);
			
			prop = props.Find("DrawBorder",true);
			allProperties.Add(prop);
			
			prop = props.Find("PageBreakAfter",true);
			allProperties.Add(prop);
			
			prop = props.Find("Controls",true);
			allProperties.Add(prop);
			
			prop = props.Find("FrameColor",true);
			allProperties.Add(prop);
			return new PropertyDescriptorCollection(allProperties.ToArray());
		}
Esempio n. 10
0
        /// <summary>
        ///  This method is called by Inventor when it loads the addin.
        ///  The AddInSiteObject provides access to the Inventor Application object.
        ///  The FirstTime flag indicates if the addin is loaded for the first time.
        /// </summary>
        /// <param name="addInSiteObject"></param>
        /// <param name="firstTime"></param>
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            try
            {
                InventorApplication = addInSiteObject.Application;

                //retrieve the GUID for this class and assign it to the string member variable
                //intended to hold it
                GuidAttribute addInClsid = (GuidAttribute)Attribute.GetCustomAttribute
                                               (typeof(StandardAddInServer), typeof(GuidAttribute));
                string addInClsidString = "{" + addInClsid.Value + "}";
                AddInServerId = addInClsidString;

                //Set a reference to the user interface manager to determine the interface style
                UserInterfaceManager userInterfaceManager = InventorApplication.UserInterfaceManager;
                InterfaceStyleEnum   interfaceStyle       = userInterfaceManager.InterfaceStyle;

                RectangleDependencyManager = new RectangleToolsDependencyMapper();

                if (interfaceStyle == InterfaceStyleEnum.kRibbonInterface)
                {
                    if (firstTime == true)
                    {
                        RectangleDependencyManager.InitializeUserInterface();
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            var props = base.GetProperties(attributes);
            var allProperties = new List<PropertyDescriptor>();

            TypeProviderHelper.AddDefaultProperties(allProperties,props);

            PropertyDescriptor prop = null;

            prop = props.Find("DrawBorder",true);
            allProperties.Add(prop);

            prop = props.Find("ForeColor",true);
            allProperties.Add(prop);

            prop = props.Find("Visible",true);
            allProperties.Add(prop);

            prop = props.Find("FrameColor",true);
            allProperties.Add(prop);

            prop = props.Find("Controls",true);
            allProperties.Add(prop);

            prop = props.Find("PageBreakOnGroupChange",true);
            allProperties.Add(prop);

            return new PropertyDescriptorCollection(allProperties.ToArray());
        }
Esempio n. 12
0
        private static void ExtractOptions(EntityBase ent, IDictionary <string, List <DisplayOption> > dict)
        {
            var props = ent.GetType().GetPropertiesSorted();

            foreach (var info in props.Reverse())
            {
                //info
                if (!Attribute.IsDefined(info, typeof(EntityDescriptorAttribute)))
                {
                    continue;
                }
                var prop = (EntityDescriptorAttribute)info.GetCustomAttribute(typeof(EntityDescriptorAttribute));
                if (!dict.ContainsKey(prop.Category))
                {
                    dict.Add(prop.Category, new List <DisplayOption>());
                }

                object min = null, max = null;
                var    multiline = Attribute.IsDefined(info, typeof(MultilineStringAttribute));

                if (Attribute.IsDefined(info, typeof(MinMaxAttribute)))
                {
                    var att = (MinMaxAttribute)info.GetCustomAttribute(typeof(MinMaxAttribute));
                    min = att.Minimum;
                    max = att.Maximum;
                }

                dict[prop.Category].Insert(0,
                                           new DisplayOption(prop.Name, info.Name, info.PropertyType, ent, prop.Description, min, max, multiline, prop.IsEnabledPath, prop.FixedSize, prop.DataGridRowHeaderPath));
            }
        }
Esempio n. 13
0
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);
            string[] ta = new string[] { "PasswordChar" };
            Attribute[] aa = new Attribute[0];
            for (int num1 = 0; num1 < ta.Length; num1++)
            {
                PropertyDescriptor desc = (PropertyDescriptor)properties[ta[num1]];
                if (desc != null)
                {
                    properties[ta[num1]] = TypeDescriptor.CreateProperty(typeof(TextBoxXDesigner), desc, aa);
                }
            }

            ta = new string[] { "Text" };
            aa = new Attribute[0];
            for (int num1 = 0; num1 < ta.Length; num1++)
            {
                PropertyDescriptor desc = (PropertyDescriptor)properties[ta[num1]];
                if (desc != null)
                {
                    properties[ta[num1]] = TypeDescriptor.CreateProperty(typeof(TextBoxXDesigner), desc, aa);
                }
            }

        }
        public static List<BaseDrawer> GetCompositeDrawers(EditorMember member, Attribute[] attributes)
        {
            List<BaseDrawer> drawers;
            if (_cachedCompositeDrawers.TryGetValue(member.Id, out drawers))
                return drawers;

            drawers = new List<BaseDrawer>();

            var applied = GetAppliedAttributes(member.Type, attributes);
            if (applied != null)
            {
                var compositeAttributes = applied.OfType<CompositeAttribute>()
                                                 .OrderBy(x => x.id)
                                                 .ToList();

                for (int i = 0; i < compositeAttributes.Count; i++)
                {
                    var drawer = NewCompositeDrawer(compositeAttributes[i].GetType());
                    if (!drawer.CanHandle(member.Type))
                    {
                        Debug.LogError("Drawer {0} can't seem to handle type {1}. Make sure you're not applying attributes on the wrong members"
                             .FormatWith(drawer.GetType().GetNiceName(), member.TypeNiceName));
                        continue;
                    }
                    drawers.Add(drawer);
                }
            }

            _cachedCompositeDrawers.Add(member.Id, drawers);
            return drawers;
        }
		public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
		{
			PropertyDescriptorCollection props = base.GetProperties(attributes);
			List<PropertyDescriptor> allProperties = new List<PropertyDescriptor>();

			TypeProviderHelper.AddDefaultProperties(allProperties,props);
			
			PropertyDescriptor prop = null;
			
			prop = props.Find("DrawBorder",true);
			allProperties.Add(prop);
			
			prop = props.Find("ForeColor",true);
			allProperties.Add(prop);
			
			prop = props.Find("Visible",true);
			allProperties.Add(prop);
			
			prop = props.Find("FrameColor",true);
			allProperties.Add(prop);
			
			prop = props.Find("Controls",true);
			allProperties.Add(prop);
	
//			prop = props.Find("AlternateBackColor",true);
//			allProperties.Add(prop);
//			
//			prop = props.Find("ChangeBackColorEveryNRow",true);
//			allProperties.Add(prop);
			
			return new PropertyDescriptorCollection(allProperties.ToArray());
		}
Esempio n. 16
0
        public PropertyDescriptorCollection AddProperty(PropertyDescriptorCollection pdc, string propertyName, Type propertyType, TypeConverter converter,
            Attribute[] attributes)
        {
            List<PropertyDescriptor> properties = new List<PropertyDescriptor>(pdc.Count);

            for (int i = 0; i < pdc.Count; i++)
            {
                PropertyDescriptor pd = pdc[i];

                if (pd.Name != propertyName)
                {
                    properties.Add(pd);
                }
            }

            InstanceSavePropertyDescriptor ppd = new InstanceSavePropertyDescriptor(
                propertyName, propertyType, attributes);

            ppd.TypeConverter = converter;

            properties.Add(ppd);

            //PropertyDescriptor propertyDescriptor;

            return new PropertyDescriptorCollection(properties.ToArray());
        }
 public LambdaPropertyDescriptor(string propertyName, Type propertyType, Attribute[] attrs,
                                 Type componentType = null)
     : base(propertyName, attrs)
 {
     _propertyType = propertyType;
     _componentType = componentType;
 }
        /// <summary>
        /// Returns the property descriptors for this instance.
        /// </summary>
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            Guard.NotNull(() => context, context);

            var descriptors = base.GetProperties(context, value, attributes).Cast<PropertyDescriptor>();

            // Remove descriptors for the data type of this property (string)
            descriptors = descriptors.Where(descriptor => descriptor.ComponentType != typeof(string));

            // Get the model element being described
            var selection = context.Instance;
            ModelElement mel = selection as ModelElement;
            var pel = selection as PresentationElement;
            if (pel != null)
            {
                mel = pel.Subject;
            }

            var element = ExtensionElement.GetExtension<ArtifactExtension>(mel);
            if (element != null)
            {
                // Copy descriptors from owner (make Browsable)
                var descriptor1 = new DelegatingPropertyDescriptor(element, TypedDescriptor.CreateProperty(element, extension => extension.OnArtifactActivation),
                    new BrowsableAttribute(true), new DefaultValueAttribute(element.GetPropertyDefaultValue<ArtifactExtension, ArtifactActivatedAction>(e => e.OnArtifactActivation)));
                var descriptor2 = new DelegatingPropertyDescriptor(element, TypedDescriptor.CreateProperty(element, extension => extension.OnArtifactDeletion),
                    new BrowsableAttribute(true), new DefaultValueAttribute(element.GetPropertyDefaultValue<ArtifactExtension, ArtifactDeletedAction>(e => e.OnArtifactDeletion)));
                descriptors = descriptors.Concat(new[] { descriptor1, descriptor2 });
            }

            return new PropertyDescriptorCollection(descriptors.ToArray());
        }
        private JObject CreateObject(Type type, Attribute[] attributes, object instance)
        {
            var jObject = CreateEmptyObject(instance);

            var properties = new JArray();
            jObject.Add("properties", properties);
            var hypermediaObject = instance as HypermediaType ?? new HypermediaObject();

            var addedProperties = new Dictionary<string, string>();

            foreach (var propertyInfo in type.GetProperties()) {
                if (PropertyIgnoreList.Contains(propertyInfo.Name)) {
                    continue;
                }

                var property = GetProperty(propertyInfo, instance, hypermediaObject);

                addedProperties.Add(propertyInfo.Name, propertyInfo.Name);
                property.Add("name", ToCamelCase(propertyInfo.Name));
                properties.Add(property);
            }

            foreach (var hypermediaProperty in hypermediaObject.Properties) {
                if (addedProperties.ContainsKey(hypermediaProperty.Key)) {
                    continue;
                }

                var property = SerializeValueType(hypermediaProperty.Value);
                property.Add("name", ToCamelCase(hypermediaProperty.Key));
                properties.Add(property);
            }

            return jObject;
        }
		public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
		{
			PropertyDescriptorCollection props = base.GetProperties(attributes);
			List<PropertyDescriptor> allProperties = new List<PropertyDescriptor>();
			
			DesignerHelper.AddDefaultProperties(allProperties,props);
			
			PropertyDescriptor prop = null;
			prop = props.Find("ForeColor",true);
			allProperties.Add(prop);
			
			prop = props.Find("FromPoint",true);
			allProperties.Add(prop);
			
			prop = props.Find("ToPoint",true);
			allProperties.Add(prop);
			
			prop = props.Find("StartLineCap",true);
			allProperties.Add(prop);
			
			prop = props.Find("EndLineCap",true);
			allProperties.Add(prop);
			
			prop = props.Find("dashLineCap",true);
			allProperties.Add(prop);
			
			prop = props.Find("DashStyle",true);
			allProperties.Add(prop);
			
			prop = props.Find("Thickness",true);
			allProperties.Add(prop);
			
			return new PropertyDescriptorCollection(allProperties.ToArray());
		}
 public static int Main()
 {
     Attribute[]
     attr_array
     =
     new
     Attribute
     [1];
     object
     obj
     =
     (object)
     attr_array;
     object
     []
     obj_array
     =
     (object[])
     obj;
     obj_array
     =
     obj
     as
     object[];
     if
     (obj_array
     ==
     null)
     return
     1;
     return
     0;
 }
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            //var cols = base.GetProperties();
            var props = new PropertyDescriptorCollection(null);

            foreach (FieldInfo fi in value.GetType().GetFields())
            {
                var prop = new WsdlFieldDescriptor(fi, attributes);
                props.Add(prop);
                if (fi.FieldType.BaseType.FullName == "System.Array")
                {
                    TypeDescriptor.AddAttributes(fi.FieldType, new TypeConverterAttribute(typeof(ArrayConverter)));
                    Type elemType = fi.FieldType.GetElementType();
                    TypeDescriptorModifier.modifyType(elemType);
                }
                else if (fi.FieldType.BaseType.FullName == "System.Enum")
                {
                }
                else
                {
                    TypeDescriptorModifier.modifyType(fi.FieldType);
                }
            }

            if (props.Count > 0)
                return props;

            return base.GetProperties(context, value, attributes);
        }
Esempio n. 23
0
 public int CompareTo(Attribute t)
 {
     if (t.GetType() == typeof(DateAttribute))
         return this._date.CompareTo((DateTime)t.Value);
     else
         return -1;
 }
        // public methods
        /// <summary>
        /// Apply an attribute to these serialization options and modify the options accordingly.
        /// </summary>
        /// <param name="serializer">The serializer that these serialization options are for.</param>
        /// <param name="attribute">The serialization options attribute.</param>
        public override void ApplyAttribute(IBsonSerializer serializer, Attribute attribute)
        {
            EnsureNotFrozen();
            var itemSerializer = serializer.GetItemSerializationInfo().Serializer;
            if (_itemSerializationOptions == null)
            {
                var itemDefaultSerializationOptions = itemSerializer.GetDefaultSerializationOptions();

                // special case for legacy collections: allow BsonRepresentation on object
                if (itemDefaultSerializationOptions == null &&
                    (serializer.GetType() == typeof(EnumerableSerializer) || serializer.GetType() == typeof(QueueSerializer) || serializer.GetType() == typeof(StackSerializer)) &&
                    attribute.GetType() == typeof(BsonRepresentationAttribute))
                {
                    itemDefaultSerializationOptions = new RepresentationSerializationOptions(BsonType.Null); // will be modified later by ApplyAttribute
                }

                if (itemDefaultSerializationOptions == null)
                {
                    var message = string.Format(
                        "A serialization options attribute of type {0} cannot be used when the serializer is of type {1} and the item serializer is of type {2}.",
                        BsonUtils.GetFriendlyTypeName(attribute.GetType()),
                        BsonUtils.GetFriendlyTypeName(serializer.GetType()),
                        BsonUtils.GetFriendlyTypeName(itemSerializer.GetType()));
                    throw new NotSupportedException(message);
                }

                _itemSerializationOptions = itemDefaultSerializationOptions.Clone();
            }
            _itemSerializationOptions.ApplyAttribute(itemSerializer, attribute);
        }
 private WorkitemPropertyDescriptor(Entity entity, string name, string attribute, Attribute[] attrs, PropertyUpdateSource updateSource)
     : base(name, attrs) {
     this.entity = entity;
     this.attribute = attribute;
     this.updateSource = updateSource;
     readOnly = entity.IsPropertyDefinitionReadOnly(Attribute) || entity.IsPropertyReadOnly(Attribute);
 }
Esempio n. 26
0
 public bool Member(EditorMember member, Attribute[] attributes, bool ignoreComposition)
 {
     attributes = attributes ?? Empty;
     var memberDrawer = MemberDrawersHandler.GetMemberDrawer(member, attributes, ignoreComposition);
     memberDrawer.Initialize(member, attributes, this);
     return Member(member, attributes, memberDrawer, ignoreComposition);
 }
Esempio n. 27
0
        private IType GetExternalEnumeratorItemType(IType iteratorType)
        {
            Type type      = ((ExternalType)iteratorType).ActualType;
            var  attribute = (EnumeratorItemTypeAttribute)Attribute.GetCustomAttribute(type, typeof(EnumeratorItemTypeAttribute));

            return(null != attribute?Map(attribute.ItemType) : null);
        }
 public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
 {
     var pdl = propertyDescriptorList.FindAll(pd => pd.Attributes.Contains(attributes));
     PreProcess(pdl);
     var pdcReturn = new PropertyDescriptorCollection(pdl.ToArray());
     return pdcReturn;
 }
Esempio n. 29
0
        /// <summary>
        /// Retorna as informações das DLL's SB1Util e Model
        /// </summary>
        public void prepare()
        {
            try
            {
                prepared            = true;
                this.user           = DBFacade.getInstance().Connection.Company.UserName;
                this.companyVersion = "" + DBFacade.getInstance().Connection.Company.Version;

                Assembly AssLib = Assembly.LoadFrom("SB1Util.dll");
                Assembly AssMod = Assembly.LoadFrom("Model.dll");

                FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo("SB1Util.dll");
                this.libVersion = versionInfo.FileVersion;// AssLib.GetName().Version.ToString();

                versionInfo       = FileVersionInfo.GetVersionInfo("Model.dll");
                this.addonVersion = versionInfo.FileVersion;// AssMod.GetName().Version.ToString();

                System.Attribute attr = System.Attribute.GetCustomAttribute(AssMod, typeof(ModelName));
                this.addonName = ((ModelName)attr).Name;
            }catch (Exception e)
            {
                //B1Connection.getInstance().App.SetStatusBarMessage("Erro ao Iniciar Log: " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Long);
                SB1ControlException.SB1ControlException.Save(e);
            }
        }
        /// <summary>
        /// Returns the properties for customization that reflect the current state of the class.
        /// </summary>
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            var properties = base.GetProperties(attributes).Cast<PropertyDescriptor>();
            var policy = (CustomizationPolicySchema)this.ModelElement;

            return ApplyDesignPolicy(policy, properties);
        }
 public void AddInterpolator(Attribute attribute, IValidator validator)
 {
     DefaultMessageInterpolator interpolator = new DefaultMessageInterpolator();
     interpolator.Initialize(messageBundle, defaultMessageBundle, culture);
     interpolator.Initialize(attribute);
     interpolators[validator] = interpolator;
 }
 protected override Microsoft.VisualStudio.Modeling.Design.RolePlayerPropertyDescriptor CreateRolePlayerPropertyDescriptor(Microsoft.VisualStudio.Modeling.ModelElement sourceRolePlayer, Microsoft.VisualStudio.Modeling.DomainRoleInfo targetRoleInfo, Attribute[] sourceDomainRoleInfoAttributes)
 {
     System.Type type = targetRoleInfo.DomainRelationship.ImplementationClass;
     if ((sourceRolePlayer is ExternModelContext) && (type == typeof(ExternModelContextReferencesModelContext)))
         return new BaseModelContextRolePlayerPropertyDescriptor(sourceRolePlayer, targetRoleInfo, sourceDomainRoleInfoAttributes);
     return base.CreateRolePlayerPropertyDescriptor(sourceRolePlayer, targetRoleInfo, sourceDomainRoleInfoAttributes);
 }
Esempio n. 33
0
        public static EventDescriptorCollection GetEvents(object self, Attribute[] attributes) {
            if (attributes == null || attributes.Length == 0) return GetEvents(self);
            //!!! update when we support attributes on python types

            // you want things w/ attributes?  we don't have attributes!
            return EventDescriptorCollection.Empty;
        }
Esempio n. 34
0
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            ArrayList props = new ArrayList();

            foreach(XmlNode progressTextNode in progressTextNodes) {
                ArrayList attrs = new ArrayList();

                // Add default attributes Category, TypeConverter and Description
                attrs.Add(new CategoryAttribute("WXS Attribute"));

                // Show file name editor
                attrs.Add(new EditorAttribute(typeof(MultiLineUITypeEditor),typeof(System.Drawing.Design.UITypeEditor)));

                // Make Attribute array
                Attribute[] attrArray = (Attribute[])attrs.ToArray(typeof(Attribute));

                // Create and add PropertyDescriptor
                ProgressTextElementPropertyDescriptor pd = new ProgressTextElementPropertyDescriptor(wixFiles, progressTextNode, progressTextNode.Attributes["Action"].Value, attrArray);

                props.Add(pd);
            }

            PropertyDescriptor[] propArray = props.ToArray(typeof(PropertyDescriptor)) as PropertyDescriptor[];

            return new PropertyDescriptorCollection(propArray);
        }
Esempio n. 35
0
		public static CustomAttributeBuilder CreateCustomAttribute(Attribute attribute)
		{
			Type attType = attribute.GetType();

			ConstructorInfo ci;

			object[] ctorArgs = GetConstructorAndArgs(attType, attribute, out ci);

			PropertyInfo[] properties;

			object[] propertyValues = GetPropertyValues(attType, out properties, attribute);

			FieldInfo[] fields;

			object[] fieldValues = GetFieldValues(attType, out fields, attribute);

			// here we are going to try to initialize the attribute with the collected arguments
			// if we are good (created successfuly) we return it, otherwise, it is ignored.
			try
			{
				Activator.CreateInstance(attType, ctorArgs);
				return new CustomAttributeBuilder(ci, ctorArgs, properties, propertyValues, fields, fieldValues);
			}
			catch
			{
				// there is no real way to log a warning here...
				Trace.WriteLine(@"Dynamic Proxy 2: Unable to find matching parameters for replicating attribute " + attType.FullName +
				                ".");
				return null;
			}
		}
    public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
    {
      PropertyDescriptorCollection coll =
          TypeDescriptor.GetProperties(this, attributes, true);

      List<PropertyDescriptor> props = new List<PropertyDescriptor>();

      foreach (PropertyDescriptor pd in coll)
      {
        if (!pd.IsBrowsable) continue;

        if (pd.Name == "Precision" || pd.Name == "Scale")
        {
          if (DataType != null &&
              DataType.ToLowerInvariant() == "decimal")
            props.Add(pd);
        }
        else if (pd.Name == "CharacterSet" || pd.Name == "Collation")
        {
          CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd);
          newPd.SetReadOnly(DataType == null ||
              !Metadata.IsStringType(DataType));
          props.Add(newPd);
        }
        else
          props.Add(pd);
      }
      return new PropertyDescriptorCollection(props.ToArray());
    }
 /// <summary>
 /// provides a simple access to an object with its attribute
 /// </summary>
 /// <param name="parent">the parent object of the object. null if the object is static</param>
 /// <param name="objectName">the name of the object</param>
 /// <param name="attribute">the attribute of the object</param>
 public AttributedObject(object parent, string objectName, Attribute attribute)
     : this(parent.GetType(), objectName, attribute)
 {
     _parent = parent;
     if (IsStatic)
         _parent = null;
 }
Esempio n. 38
0
        /// <summary>
        /// 获取表名称
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public string GetTableName <T>() where T : class
        {
            System.Attribute attr = System.Attribute.GetCustomAttributes(typeof(T))[0];
            var tableName         = (attr as dynamic).TableName;

            return(tableName);
        }
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            var props = base.GetProperties(attributes);
            var allProperties = new List<PropertyDescriptor>();

            TypeProviderHelper.AddDefaultProperties(allProperties,props);

            TypeProviderHelper.AddTextBasedProperties(allProperties,props);

            var prop = props.Find("Text", true);
            allProperties.Add(prop);

            prop = props.Find("DrawBorder",true);
            allProperties.Add(prop);

            prop = props.Find("FrameColor",true);
            allProperties.Add(prop);

            prop = props.Find("ForeColor",true);
            allProperties.Add(prop);

            prop = props.Find("Visible",true);
            allProperties.Add(prop);

            prop = props.Find("Expression",true);
            allProperties.Add(prop);

            return new PropertyDescriptorCollection(allProperties.ToArray());
        }
Esempio n. 40
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 /// <param name="value"></param>
 /// <param name="attributes"></param>
 /// <returns></returns>
 public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
 {
     System.Attribute[] attrs = new System.Attribute[]
     {
         new System.ComponentModel.BrowsableAttribute(true)
     };
     return(TypeDescriptor.GetProperties(value, attrs));
 }
Esempio n. 41
0
 // Vérifier ???
 internal static string GetStringFromAttribute(PropertyInfo property, Type typeAttributeWant, string valueNameWant)
 {
     System.Attribute attribute = property.GetCustomAttributes(typeAttributeWant).FirstOrDefault();
     if (attribute == null)
     {
         return(null);
     }
     return(PropertiesTools.GetStringReflexion(attribute, valueNameWant));
 }
Esempio n. 42
0
        /// <summary>
        /// Function determines if a property in a SQLiteEnabled object is set to be serialized into the database.
        /// </summary>
        /// <param name="ThisMember">A property on a SQLiteEnabled object.</param>
        /// <returns>False if the property has the attribute SQLiteEnabledSerialization with Serialize set to false.</returns>
        private static bool IsPropertySQLiteEnabledSerialized(System.Reflection.MemberInfo ThisMember)
        {
            System.Attribute SerializeAttribute = System.Attribute.GetCustomAttribute(ThisMember, typeof(SQLiteEnabledSerialization));
            if (SerializeAttribute != null && ((SQLiteEnabledSerialization)SerializeAttribute).Serialize == false)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 43
0
 IEnumerable <TaskParameter> GetTaskParameters(Type taskType)
 {
     return(from property in taskType.GetProperties()
            let attribute = (TaskAttributeAttribute)Attribute.GetCustomAttribute(property, typeof(TaskAttributeAttribute))
                            where attribute != null
                            let name = attribute.Name.Replace("-", "")
                                       select new TaskParameter {
         Name = name, Property = property
     });
 }
Esempio n. 44
0
        private IType GetExternalEnumeratorItemType(IType iteratorType)
        {
            Type type = ((ExternalType)iteratorType).ActualType;

#if DNXCORE50
            var attribute = CustomAttributeExtensions.GetCustomAttribute <EnumeratorItemTypeAttribute>(type.GetTypeInfo());
#else
            var attribute = (EnumeratorItemTypeAttribute)Attribute.GetCustomAttribute(type, typeof(EnumeratorItemTypeAttribute));
#endif
            return(null != attribute?Map(attribute.ItemType) : null);
        }
Esempio n. 45
0
        public static string GetDescription(this Type type, Func <Type, string> noDescriptionCallback)
        {
            DescriptionAttribute attr =
                Attribute.GetCustomAttribute(type, typeof(DescriptionAttribute)) as DescriptionAttribute;

            if (attr == null)
            {
                return(noDescriptionCallback(type));
            }
            return(attr.Description);
        }
Esempio n. 46
0
 /// <summary>
 /// Fetch the first attribute of the given type
 /// </summary>
 public T Attribute <T>() where T : System.Attribute
 {
     System.Attribute a = System.Attribute.GetCustomAttribute(this.Type, typeof(T));
     if (a != null)
     {
         return(a as T);
     }
     else
     {
         return(null);
     }
 }
        public static FarsiPage GetFarsiPage(System.Web.UI.Page page)
        {
            Type type = page.GetType();

            System.Attribute attr = System.Attribute.GetCustomAttribute(type, typeof(FarsiPage));
            if (attr is FarsiPage)
            {
                FarsiPage farsiPage = attr as FarsiPage;
                return(farsiPage);
            }
            throw new InvalidOperationException("Each Page Must Implement Farsi Page Interface");
        }
Esempio n. 48
0
        /// <summary>
        /// Get all attributes on an assembly.
        /// </summary>
        /// <param name="assembly">The assembly to examine</param>
        /// <param name="inherit">True to include inherited attributes</param>
        /// <returns>The attributes or null</returns>
        public static System.Attribute[] GetAttributes(Assembly assembly, bool inherit)
        {
            object[]           attributes = assembly.GetCustomAttributes(inherit);
            System.Attribute[] result     = new System.Attribute[attributes.Length];
            int n = 0;

            foreach (Attribute attribute in attributes)
            {
                result[n++] = attribute;
            }
            return(result);
        }
Esempio n. 49
0
 public static void SetAttribute(object o, string property, System.Attribute newattrib, bool on)
 {
     System.ComponentModel.MemberDescriptor memb = null;
     if (o is System.Type)
     {
         memb = (System.ComponentModel.MemberDescriptor)System.ComponentModel.TypeDescriptor.GetProperties((Type)o)[property];
     }
     else
     {
         memb = (System.ComponentModel.MemberDescriptor)System.ComponentModel.TypeDescriptor.GetProperties(o)[property];
     }
     InternalSetAttribute(memb, property, newattrib, on);
 }
        private static System.Attribute[] getPropertyDescriptorAttributes(string name)
        {
            System.ComponentModel.PropertyDescriptor desc = getPropertyDescriptor(name);
            if (desc == null)
            {
                return(null);
            }

            System.Attribute[] attributes = new System.Attribute[desc.Attributes.Count];
            desc.Attributes.CopyTo(attributes, 0);

            return(attributes);
        }
        protected int GetArgumentSemantic(MethodInfo p)
        {
            if (p == null)
            {
                return(0);
            }

            System.Attribute attr = System.Attribute.GetCustomAttributes(p).FirstOrDefault(x => x.GetType().Name == "ExportAttribute");
            if (attr != null)
            {
                return((int)attr.GetType().GetProperty("ArgumentSemantic").GetValue(attr, null));
            }
            return(0);
        }
Esempio n. 52
0
        /// <summary>
        /// Get all attributes on a member.
        /// </summary>
        /// <param name="member">The member to examine</param>
        /// <param name="inherit">True to include inherited attributes</param>
        /// <returns>The attribute or null</returns>
        public static System.Attribute[] GetAttributes(
            ICustomAttributeProvider member, bool inherit)
        {
            object[]           attributes = member.GetCustomAttributes(inherit);
            System.Attribute[] result     = new System.Attribute[attributes.Length];
            int n = 0;

            foreach (Attribute attribute in attributes)
            {
                result[n++] = attribute;
            }

            return(result);
        }
Esempio n. 53
0
        protected string GetSelector(MethodInfo p)
        {
            if (p == null)
            {
                return(null);
            }

            System.Attribute attr = System.Attribute.GetCustomAttributes(p).FirstOrDefault(x => x.GetType().Name == "ExportAttribute");
            if (attr != null)
            {
                return((string)attr.GetType().GetProperty("Selector").GetValue(attr, null));
            }
            return(null);
        }
Esempio n. 54
0
        protected void Register <T>(ushort opCode)
        {
            var    type = default(T);
            IntPtr ptr  = Marshal.AllocHGlobal(Marshal.SizeOf(type));

            Marshal.StructureToPtr(type, ptr, false);
            _opCodeLookup.Add(ptr, opCode);
            _typeLookup.Add(opCode, ptr);
            System.Attribute attrs = System.Attribute.GetCustomAttributes(typeof(T)).Where(p => p is Packet).FirstOrDefault();
            if (attrs != null)
            {
                base.Add((attrs as Packet).Code.GetType(), opCode);
            }
        }
Esempio n. 55
0
        protected virtual void InitializeAttributes()
        {
            Type nodeType = GetType();
            
            _hasDebugOverride = Attribute.GetCustomAttribute(nodeType, typeof(DebugOverrideAttribute)) != null;

            _isObsolete = Attribute.GetCustomAttribute(nodeType, typeof(ObsoleteAttribute)) != null;
            
            _isExperimental = Attribute.GetCustomAttribute(nodeType, typeof(ExperimentalAttribute)) != null;
            
            InputCountAttribute inputCountAttribute = (InputCountAttribute) Attribute.GetCustomAttribute(nodeType, typeof(InputCountAttribute));
            _inputCount = inputCountAttribute == null ? 0 : inputCountAttribute.count;
            
            InputLabelsAttribute inputAttribute = (InputLabelsAttribute) Attribute.GetCustomAttribute(nodeType, typeof(InputLabelsAttribute));
            _inputLabels = inputAttribute == null ? new string[0] : inputAttribute.labels;
            
            OutputCountAttribute outputCountAttribute = (OutputCountAttribute) Attribute.GetCustomAttribute(nodeType, typeof(OutputCountAttribute));
            _outputCount = outputCountAttribute == null ? 0 : outputCountAttribute.count;
            
            OutputLabelsAttribute outputAttribute = (OutputLabelsAttribute) Attribute.GetCustomAttribute(nodeType, typeof(OutputLabelsAttribute));
            _outputLabels = outputAttribute == null ? new string[0] : outputAttribute.labels;
            
            #if UNITY_EDITOR
            
            SkinAttribute skinAttribute = (SkinAttribute) Attribute.GetCustomAttribute(nodeType, typeof(SkinAttribute));
            _backgroundSkinId = skinAttribute != null ? skinAttribute.backgroundSkinId : "NodeBodyBg";
            _titleSkinId = skinAttribute != null ? skinAttribute.titleSkinId : "NodeTitleBg";
            
            SizeAttribute sizeAttribute = (SizeAttribute) Attribute.GetCustomAttribute(nodeType, typeof(SizeAttribute));
            _size = sizeAttribute != null ? new Vector2(sizeAttribute.width, sizeAttribute.height) : Vector2.one;
            
            DisableBaseGUIAttribute disableBaseGuiAttribute = (DisableBaseGUIAttribute) Attribute.GetCustomAttribute(nodeType, typeof(DisableBaseGUIAttribute));
            _baseGUIEnabled = disableBaseGuiAttribute == null;
            
            CategoryAttribute categoryAttribute = (CategoryAttribute) Attribute.GetCustomAttribute(nodeType, typeof(CategoryAttribute));
            Category = categoryAttribute.type;
            
            //_iconTexture = iconAttribute != null ? IconManager.GetIcon(iconAttribute.iconId) : DashEditorCore.EditorConfig.theme.GetNodeIconByCategory(categoryAttribute.type);
            
            // _nodeBackgroundColor = DashEditorCore.EditorConfig.theme.GetNodeBackgroundColorByCategory(categoryAttribute.type);
            //
            // _titleBackgroundColor = DashEditorCore.EditorConfig.theme.GetNodeTitleBackgroundColorByCategory(categoryAttribute.type);
            //
            // _titleTextColor = DashEditorCore.EditorConfig.theme.GetNodeTitleTextColorByCategory(categoryAttribute.type);

            #endif

            _attributesInitialized = true;
        }
Esempio n. 56
0
        private void InitTypeExtractors()
        {
            System.Attribute annotation = _modelType.GetCustomAttribute <TargetUrl>();
            if (annotation == null)
            {
                _targetUrlPatterns.Add(new Regex("(.*)"));
            }
            else
            {
                TargetUrl targetUrl = (TargetUrl)annotation;
                string[]  value     = targetUrl.Value;

                if (value != null)
                {
                    foreach (string s in value)
                    {
                        _targetUrlPatterns.Add(new Regex("(" + s.Replace(".", "\\.").Replace("*", "[^\"'#]*") + ")"));
                    }
                }
                else
                {
                    _targetUrlPatterns.Add(new Regex("(.*)"));
                }

                _targetUrlRegionSelector = new XPathSelector(string.IsNullOrEmpty(targetUrl.SourceRegion) ? "." : targetUrl.SourceRegion);
            }
            annotation = _modelType.GetCustomAttribute <HelpUrl>();
            if (annotation != null)
            {
                HelpUrl  helpUrl = (HelpUrl)annotation;
                string[] value   = helpUrl.Value;
                foreach (string s in value)
                {
                    _helpUrlPatterns.Add(new Regex("(" + s.Replace(".", "\\.").Replace("*", "[^\"'#]*") + ")"));
                }
                if (!string.IsNullOrEmpty(helpUrl.SourceRegion))
                {
                    _helpUrlRegionSelector = new XPathSelector(helpUrl.SourceRegion);
                }
            }
            annotation = _modelType.GetCustomAttribute <ExtractBy>();
            if (annotation != null)
            {
                ExtractBy extractBy = (ExtractBy)annotation;

                _objectExtractor = ExtractorUtils.GetExtractor(extractBy);
            }
        }
Esempio n. 57
0
        static public bool IsPropBagInstanceWithCorrectType(PropertyInfo propDef, string strTargetType, string instanceKey)
        {
            //IEnumerable<System.Attribute> list = propDef.GetCustomAttributes();
            System.Attribute att = propDef.GetCustomAttribute(typeof(PropBagInstanceAttribute));
            if (att == null)
            {
                return(false);
            }

            //return DoNameSpacesMatch(propDef.PropertyType.ToString(), strTargetType);

            PropBagInstanceAttribute pbia = (PropBagInstanceAttribute)att;

            return(pbia.InstanceKey == instanceKey);
            //return DoNameSpacesMatch(pbia.PropBagTemplate, strTargetType);
        }
Esempio n. 58
0
        //==============================================================================================================================
        // Helper for the GetCustomAttribute() family.
        //==============================================================================================================================
        private static T OneOrNull <T> (this IEnumerable <CustomAttributeData> results) where T : Attribute
        {
            IEnumerator <CustomAttributeData> enumerator = results.GetEnumerator();

            if (!enumerator.MoveNext())
            {
                return(null);
            }
            CustomAttributeData result = enumerator.Current;

            if (enumerator.MoveNext())
            {
                throw new AmbiguousMatchException("", null);
            }
            return((T)(result.Instantiate()));
        }
Esempio n. 59
0
        public static string Attribute(int indent, System.Attribute attribute, string stringAttribute)
        {
            var attributeString = string.Empty;
            var _attribute      = attribute.ToString();

            attributeString += Indent(indent);
            attributeString += "[";
            attributeString += _attribute;
            attributeString += "(";
            attributeString += @"""";
            attributeString += stringAttribute;
            attributeString += @"""";
            attributeString += ")";
            attributeString += "]";

            return(attributeString);
        }
Esempio n. 60
0
        public MaplePakcet(byte[] buffer)
        {
            //获取运行函数
            MethodBase @base = new StackTrace().GetFrame(1).GetMethod();

            System.Attribute attribute = @base.GetCustomAttribute(typeof(PacketHead), true);
            if (attribute != null)
            {
                m_stream = new MemoryStream();
                m_stream.WriteByte(byte.Parse(((PacketHead)attribute).Head.ToString()));
                m_stream.Write(buffer, 0, buffer.Length);
            }
            else
            {
                m_stream = new MemoryStream(buffer);
            }
        }