コード例 #1
0
        public static TriggerBaseNode CreateTrigger(TriggerSourceInformation triggerSource, SceneViewModel viewModel)
        {
            RoutedEventInformation eventInformation    = triggerSource as RoutedEventInformation;
            PropertyInformation    propertyInformation = triggerSource as PropertyInformation;

            if ((TriggerSourceInformation)eventInformation != (TriggerSourceInformation)null)
            {
                EventTriggerNode eventTriggerNode = EventTriggerNode.Factory.Instantiate(viewModel);
                eventTriggerNode.RoutedEvent = eventInformation.RoutedEvent;
                return((TriggerBaseNode)eventTriggerNode);
            }
            if (!((TriggerSourceInformation)propertyInformation != (TriggerSourceInformation)null))
            {
                return((TriggerBaseNode)null);
            }
            TriggerNode        triggerNode        = (TriggerNode)null;
            DependencyProperty dependencyProperty = propertyInformation.DependencyProperty;

            if (dependencyProperty != null)
            {
                triggerNode = TriggerNode.Factory.Instantiate(viewModel);
                ITriggerConditionNode triggerConditionNode = (ITriggerConditionNode)triggerNode;
                triggerConditionNode.PropertyKey = dependencyProperty;
                triggerConditionNode.Value       = dependencyProperty.DefaultMetadata.DefaultValue;
            }
            return((TriggerBaseNode)triggerNode);
        }
コード例 #2
0
        public static TriggerBaseNode FindOrCreateTrigger(TriggerSourceInformation triggerSource, ITriggerContainer triggerContainer, SceneViewModel viewModel)
        {
            RoutedEventInformation eventInformation    = triggerSource as RoutedEventInformation;
            PropertyInformation    propertyInformation = triggerSource as PropertyInformation;

            foreach (TriggerBaseNode triggerBaseNode in (IEnumerable <TriggerBaseNode>)triggerContainer.VisualTriggers)
            {
                EventTriggerNode eventTriggerNode = triggerBaseNode as EventTriggerNode;
                TriggerNode      triggerNode      = triggerBaseNode as TriggerNode;
                if (eventTriggerNode != null && (TriggerSourceInformation)eventInformation != (TriggerSourceInformation)null && eventTriggerNode.RoutedEvent == eventInformation.RoutedEvent)
                {
                    return((TriggerBaseNode)eventTriggerNode);
                }
                if (triggerNode != null && (TriggerSourceInformation)propertyInformation != (TriggerSourceInformation)null && ((ITriggerConditionNode)triggerNode).PropertyKey == propertyInformation.DependencyProperty)
                {
                    return((TriggerBaseNode)triggerNode);
                }
            }
            TriggerBaseNode trigger = TriggersHelper.CreateTrigger(triggerSource, viewModel);

            if (trigger != null)
            {
                triggerContainer.VisualTriggers.Add(trigger);
            }
            return(trigger);
        }
コード例 #3
0
        private void InsertInPropertOrder(PropertyInformation property)
        {
            if (this.Properties.Count == 0)
            {
                this.Properties.Add(property);
                return;
            }

            if (this.PropertiesAreInOrder(property, this.Properties[0]))
            {
                this.Properties.Insert(0, property);
                return;
            }

            for (var i = 0; i < this.Properties.Count - 1; i++)
            {
                if (this.PropertiesAreInOrder(this.Properties[i], property) && this.PropertiesAreInOrder(property, this.Properties[i + 1]))
                {
                    this.Properties.Insert(i + 1, property);
                    return;
                }
            }

            this.Properties.Add(property);
        }
コード例 #4
0
        /// <summary>
        /// Generate a randerable section for the given property information.
        /// </summary>
        /// <typeparam name="TValue">Property value type.</typeparam>
        /// <param name="builder">Render tree.</param>
        private void GenerateRenderTreeForInputField <TValue>(RenderTreeBuilder builder)
        {
            var componentType = GetComponentTypeToRenderForValueType <TValue>();

            if (componentType == default)
            {
                GenerateRenderTreeForChildInputFields <TValue>(builder);

                return;
            }

            var constant     = Expression.Constant(CascadedEditContext.Model, CascadedEditContext.Model.GetType());
            var exp          = Expression.Property(constant, PropertyInformation.Name);
            var lambda       = Expression.Lambda(exp);
            var castedLambda = (Expression <Func <TValue> >)lambda;
            var currentValue = (TValue)PropertyInformation.GetValue(CascadedEditContext.Model);

            builder.OpenComponent(0, componentType);
            builder.AddAttribute(1, "id", PropertyInformation.Name);
            builder.AddAttribute(2, nameof(InputBase <TValue> .Value), currentValue);
            builder.AddAttribute(3, nameof(InputBase <TValue> .ValueExpression), castedLambda);
            builder.AddAttribute(4, nameof(InputBase <TValue> .ValueChanged), RuntimeHelpers.TypeCheck(
                                     EventCallback.Factory.Create(
                                         this,
                                         EventCallback.Factory.CreateInferred(this, val => PropertyInformation.SetValue(CascadedEditContext.Model, val),
                                                                              (TValue)PropertyInformation.GetValue(CascadedEditContext.Model)))));
            builder.CloseComponent();
        }
        public void GetTypeInformation_WhenListDatasetsThenDatasetPropertyDescriptionsShouldBeReturned()
        {
            // Act
            IEnumerable <TypeInformation> result = WhenTypeInformationForTheAssemblyIsCreated(GetCalculationClassWithListDescriptionsExampleAssembly());

            // Assert
            result.Should().NotBeNull("Result should not be null");

            result.Should().ContainSingle(c => c.Name == "Calculations");

            TypeInformation datasetType = result.Where(e => e.Name == "Datasets").FirstOrDefault();

            datasetType.Name.Should().Be("Datasets");
            datasetType.Description.Should().BeNull();
            datasetType.Type.Should().Be("Datasets");

            List <PropertyInformation> properties = new List <PropertyInformation>(datasetType.Properties);

            PropertyInformation firstDataset = properties[0];

            firstDataset.Should().NotBeNull("firstDataset should not be null");
            firstDataset.Name.Should().Be("ABTestDataset240301001");
            firstDataset.FriendlyName.Should().Be("AB Test Dataset 2403-01-001");
            firstDataset.Description.Should().Be("High Needs Student Numbers");

            PropertyInformation secondDataset = properties[1];

            secondDataset.Should().NotBeNull("firstDataset should not be null");
            secondDataset.Name.Should().Be("ABTestDataset24030020011");
            secondDataset.FriendlyName.Should().Be("AB Test Dataset 2403-002-0011");
            secondDataset.Description.Should().Be("High Needs Student Numbers");

            properties.Should().HaveCount(4, "Datasets should contain expected number of properties");
        }
        public void GetTypeInformation_WithListDatasetsReturnsCalculationObjectWithValidProperties()
        {
            // Act
            IEnumerable <TypeInformation> result = WhenTypeInformationForTheAssemblyIsCreated(GetCalculationClassWithListDatasetsExampleAssembly());

            // Assert
            result.Should().NotBeNull("Result should not be null");

            result.Should().ContainSingle(c => c.Name == "Calculations");

            TypeInformation calculationType = result.Where(e => e.Name == "Calculations").FirstOrDefault();

            calculationType.Name.Should().Be("Calculations");
            calculationType.Description.Should().BeNull();
            calculationType.Type.Should().Be("Calculations");

            calculationType.Properties.Should().NotBeNull();

            PropertyInformation datasetsProperty = calculationType.Properties.Where(p => p.Name == "Datasets").SingleOrDefault();

            datasetsProperty.Should().NotBeNull();

            datasetsProperty.Type.Should().Be("Datasets");

            result.Should().ContainSingle(t => t.Name == "Datasets");
            TypeInformation datasetsType = result.Where(t => t.Name == "Datasets").SingleOrDefault();

            datasetsType.Should().NotBeNull();

            PropertyInformation firstPropertyOfDatasets = datasetsType.Properties.First();

            firstPropertyOfDatasets.Type.Should().Be("List(Of DemoTestAPTDatasetSchemaNoRequiredDataset)");
        }
コード例 #7
0
        private Type ValidateAndGetType(ProtocolElement element, string typeName, Type assignableType, string elementPropertyName)
        {
            Type type;

            try
            {
                type = Type.GetType(typeName, true);
            }
            catch (Exception exception)
            {
                PropertyInformation information = null;
                string filename = string.Empty;
                int    line     = 0;
                if ((element != null) && (element.ElementInformation != null))
                {
                    information = element.ElementInformation.Properties[elementPropertyName];
                    if (information != null)
                    {
                        filename = information.Source;
                        line     = information.LineNumber;
                    }
                }
                throw new ConfigurationErrorsException(exception.Message, exception, filename, line);
            }
            ConfigUtil.CheckAssignableType(assignableType, type, element, elementPropertyName);
            return(type);
        }
コード例 #8
0
        /// <summary>
        /// Delayed loading of the property inspector to avoid creating the entire list of property
        /// editors immediately after selection. Keeps that app running smooth.
        /// </summary>
        /// <returns></returns>
        private async void ProcessIncrementalPropertyAddAsync()
        {
            const int batchAmount = 10;

            var propertiesToAdd = PropertyInformation.GetProperties(_target);

            await Dispatcher.Yield(DispatcherPriority.Background);

            int visiblePropertyCount = 0;

            foreach (var property in propertiesToAdd)
            {
                // iterate over the PropertyInfo objects,
                // setting the property grid's filter on each object,
                // and adding those properties to the observable collection of propertiesToSort (this.properties)
                property.Filter = Filter;

                if (property.IsVisible)
                {
                    _properties.Add(property);
                }
                _allProperties.Add(property);

                // checking whether a property is visible ... actually runs the property filtering code
                if (property.IsVisible)
                {
                    property.Index = visiblePropertyCount++;
                }

                if ((visiblePropertyCount % batchAmount) == 0)
                {
                    await Dispatcher.Yield(DispatcherPriority.Background);
                }
            }
        }
コード例 #9
0
        // If a configuration section has a default value coming from 4.0 config and the AppDomain is opted in to auto-config upgrade,
        // set the configuration section element explicitly to its new 4.5 value. If the property has been explicitly set, no change
        // will be made.
        internal static void SetFX45DefaultValue(ConfigurationSection configSection, ConfigurationProperty property, object newDefaultValue)
        {
            if (BinaryCompatibility.Current.TargetsAtLeastFramework45 && !configSection.IsReadOnly())
            {
                PropertyInformation propInfo = configSection.ElementInformation.Properties[property.Name];
                Debug.Assert(propInfo != null);
                Debug.Assert(propInfo.Type.IsInstanceOfType(newDefaultValue));

                if (propInfo.ValueOrigin == PropertyValueOrigin.Default)
                {
                    try
                    {
                        propInfo.Value = newDefaultValue;
                    }
                    catch (ConfigurationErrorsException)
                    {
                        // Calling the Value setter might throw if the configuration element is locked.
                        // We can technically override the "is locked?" check by calling the appropriate
                        // method, but for now let's just honor the locks and ignore these errors. The
                        // config sections we're touching shouldn't really ever be locked anyway, so
                        // nobody should ever run into this in practice.
                    }
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Dynamic form editor factory.
        /// </summary>
        /// <param name="pi">
        /// The pi.
        /// </param>
        /// <returns>
        /// A DynamicFormEditor.
        /// </returns>
        public static DynamicFormEditor DynamicFormEditorFactory(
            PropertyInformation pi)
        {
            var listBoxContent = new DynamicFormListBoxContent
            {
                AssociatedLabel =
                    ParsePropertyNameForLabel(
                        pi.Name),
                CanWrite    = pi.CanWrite,
                BindingMode =
                    pi.CanWrite
            ? BindingMode.TwoWay
            : BindingMode.OneWay,
                BindingPath = pi.Name
            };

            if (pi.TypeName.IndexOf("Boolean", System.StringComparison.Ordinal) == -1)
            {
                listBoxContent.ControlType = pi.CanWrite ?
                                             DynamicFormControlType.TextBox : DynamicFormControlType.TextBlock;
            }
            else
            {
                listBoxContent.ControlType = DynamicFormControlType.CheckBox;
            }

            listBoxContent.DataType      = pi.TypeName;
            listBoxContent.TypeNamespace = pi.TypeNamespace;

            if (listBoxContent.DataType.Contains("Int32"))
            {
                listBoxContent.DataType = "Integer";
            }
            else if (listBoxContent.DataType.Contains("Int16"))
            {
                listBoxContent.DataType = "Short";
            }
            else if (listBoxContent.DataType.Contains("Int64"))
            {
                listBoxContent.DataType = "Long";
            }

            if (pi.TypeName.Contains("Decimal"))
            {
                listBoxContent.StringFormat = "{0:c}";
            }
            else if (pi.TypeName.Contains("Date"))
            {
                listBoxContent.StringFormat = "{0:d}";
            }
            else
            {
                listBoxContent.StringFormat = string.Empty;
            }
            return(new DynamicFormEditor
            {
                DataContext = listBoxContent
            });
        }
コード例 #11
0
        private PropertyInformation CreatePropertyInformation(Type containerType, PropertyDescriptor property)
        {
            PropertyInformation info = new PropertyInformation();

            info.ValueAccessor = CreatePropertyValueAccessor(property);
            info.Prototype     = CreateMetadataPrototype(AsAttributes(property.Attributes), containerType, property.PropertyType, property.Name);
            return(info);
        }
コード例 #12
0
 private bool PropertiesAreInOrder(PropertyInformation first, PropertyInformation last)
 {
     if (_direction == ListSortDirection.Ascending)
     {
         return(first.CompareTo(last) <= 0);
     }
     return(last.CompareTo(first) <= 0);
 }
コード例 #13
0
 internal MonitorPropertyInformation(string server, PropertyInformation propertyInfo) : this()
 {
     this.Server       = server;
     this.PropertyName = propertyInfo.Name;
     this.Description  = propertyInfo.Description;
     this.IsMandatory  = propertyInfo.IsMandatory;
     this[SimpleProviderObjectSchema.Identity] = new MonitorPropertyInformation.MonitorPropertyInformationId(this.PropertyName, this.Description, this.IsMandatory);
 }
コード例 #14
0
        private static bool TryGetValue <T>(ConfigurationElement element, string name, out T value)
        {
            PropertyInformationCollection properties = element.ElementInformation.Properties;
            PropertyInformation           property   = properties.Cast <PropertyInformation>().FirstOrDefault(p => p.Name == name);

            bool hasProperty = property != null;

            value = hasProperty ? (T)property.Value : default(T);
            return(hasProperty);
        }
コード例 #15
0
        private bool IsElementSpecified(string name)
        {
            PropertyInformation p = this.ElementInformation.Properties[name];

            if (p != null)
            {
                return(p.ValueOrigin != PropertyValueOrigin.Default);
            }
            return(false);
        }
コード例 #16
0
        private TModelMetadata CreatePropertyMetadata(Func <object> modelAccessor, PropertyInformation propertyInfo)
        {
            var metadata = CreateMetadataFromPrototype(propertyInfo.Prototype, modelAccessor);

            if (propertyInfo.IsReadOnly)
            {
                metadata.IsReadOnly = true;
            }
            return(metadata);
        }
コード例 #17
0
        private PropertyInformation CreatePropertyInformation(Type containerType, PropertyDescriptor property)
        {
            Contract.Requires(containerType != null);
            Contract.Requires(property != null);

            PropertyInformation info = new PropertyInformation();

            info.ValueAccessor = CreatePropertyValueAccessor(property);
            info.Prototype     = this.CreateMetadataPrototype(AsAttributes(property.Attributes), containerType, property.PropertyType, property.Name);
            return(info);
        }
コード例 #18
0
        public void BitmapSuffix_Set_GetReturnsExpected(string bitmapSuffix)
        {
            var section = new SystemDrawingSection {
                BitmapSuffix = bitmapSuffix
            };

            Assert.Equal(bitmapSuffix, section.BitmapSuffix);

            PropertyInformation propertyInformation = section.ElementInformation.Properties["bitmapSuffix"];

            Assert.Equal(bitmapSuffix, propertyInformation.Value);
        }
コード例 #19
0
        public static PropertyInformation GetDefaultProperty(Type targetType, IDocumentContext documentContext)
        {
            IEnumerator <PropertyInformation> enumerator = PropertyInformation.GetPropertiesForType(targetType, documentContext.TypeResolver).GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (documentContext.CreateNode(typeof(DependencyProperty), (object)enumerator.Current.DependencyProperty) != null)
                {
                    return(enumerator.Current);
                }
            }
            return((PropertyInformation)null);
        }
コード例 #20
0
ファイル: ListingDetailsDA.cs プロジェクト: HTestOrg/TestRepo
        public PropertyInformation GetPropertyInformationDetails(Hashtable listingCriteria)
        {
            var _db  = new DBUtility();
            var temp = new PropertyInformation();
            var _dt  = new DataTable();

            _cmd = new SqlCommand();

            _cmd.CommandType = CommandType.StoredProcedure;
            _cmd.CommandText = "GP_SP_GetPropertyInformationDetails";

            _cmd.Parameters.AddWithValue("@UserId", Convert.ToString(listingCriteria["UserID"]));
            _cmd.Parameters.AddWithValue("@ListingDetailsID", Convert.ToInt64(listingCriteria["ID"]));

            _dt = _db.FillDataTable(_cmd, _dt);
            if (_dt.Rows.Count > 0)
            {
                foreach (DataRow dr in _dt.Rows)
                {
                    temp.ID              = Convert.ToInt64(dr["ID"]);
                    temp.PropertyTypeID  = (Convert.ToString(dr["PropertyTypeID"])) == "" ? 0 : Convert.ToInt32(dr["PropertyTypeID"]);
                    temp.PropertyAddress = Convert.ToString(dr["PropertyAddress"]);

                    temp.City                     = Convert.ToString(dr["City"]);
                    temp.Country                  = Convert.ToString(dr["Country"]);
                    temp.Zip                      = Convert.ToInt32(dr["Zip"]);
                    temp.OccupancyStatusID        = (Convert.ToString(dr["OccupancyStatusID"])) == "" ? 0 : Convert.ToInt32(dr["OccupancyStatusID"]);
                    temp.StateName                = Convert.ToString(dr["StateName"]);
                    temp.PropertyMarketValue      = Convert.ToDouble(dr["PropertyMarketValue"]);
                    temp.PropertyValuationDate    = Convert.ToString(dr["PropertyValuationDate"]);
                    temp.ValuationTypeID          = (Convert.ToString(dr["ValuationTypeID"])) == "" ? 0 : Convert.ToInt32(dr["ValuationTypeID"]);
                    temp.IsCompany                = Convert.ToBoolean(dr["IsCompany"]);
                    temp.PrimaryBorrowerFirstName = Convert.ToString(dr["PrimaryBorrowerFirstName"]);
                    temp.LastName                 = Convert.ToString(dr["LastName"]);
                    temp.MailingAddress           = Convert.ToString(dr["MailingAddress"]);
                    temp.BorrowerCity             = Convert.ToString(dr["BorrowerCity"]);

                    temp.BorrowerState            = Convert.ToString(dr["BorrowerState"]);
                    temp.BorrowerZip              = Convert.ToInt32(dr["BorrowerZip"]);
                    temp.BorrowerHomePh           = Convert.ToInt64(dr["BorrowerHomePh"]);
                    temp.BorrowerWorkPh           = Convert.ToInt64(dr["BorrowerWorkPh"]);
                    temp.BorrowerMobilePh         = Convert.ToInt64(dr["BorrowerMobilePh"]);
                    temp.BorrowerEmail            = Convert.ToString(dr["BorrowerEmail"]);
                    temp.BorrowerFax              = Convert.ToInt64(dr["BorrowerFax"]);
                    temp.BorrowerSSTaxIDNoPrimary = Convert.ToInt64(dr["BorrowerSSTaxIDNoPrimary"]);
                    temp.ListingStatusID          = Convert.ToInt32(dr["ListingStatusID"]);
                }
            }
            return(temp);
        }
コード例 #21
0
        public static ConditionNode CreateDefaultCondition(Type targetType, SceneViewModel viewModel, IDocumentContext documentContext)
        {
            PropertyInformation.GetPropertiesForType(targetType, documentContext.TypeResolver).GetEnumerator();
            PropertyInformation defaultProperty = TriggersHelper.GetDefaultProperty(targetType, documentContext);

            if (!((TriggerSourceInformation)defaultProperty != (TriggerSourceInformation)null))
            {
                return((ConditionNode)null);
            }
            ConditionNode conditionNode = ConditionNode.Factory.Instantiate(viewModel);

            conditionNode.PropertyKey = defaultProperty.DependencyProperty;
            conditionNode.Value       = defaultProperty.DependencyProperty.DefaultMetadata.DefaultValue;
            return(conditionNode);
        }
コード例 #22
0
ファイル: LuceneService.cs プロジェクト: ti24horas/apiosf
        public void AddProperty(Guid classId, PropertyInformation property)
        {
            var propertyId = Guid.NewGuid();

            this.writer.AddDocument(new Document
            {
                new StringField("_id", propertyId.ToString(), Field.Store.NO),
                new StringField("_classId", classId.ToString(), Field.Store.NO),
                new TextField("name", property.Name, Field.Store.YES),
                new TextField("propertyType", property.Type, Field.Store.YES),
                new StoredField("HasGetter", property.HasGetter.ToString()),
                new StoredField("HasSetter", property.HasGetter.ToString()),
                new StringField("type", "Property", Field.Store.YES)
            });
        }
コード例 #23
0
ファイル: Logger.cs プロジェクト: shekky/cuttingedge.logging
        // Throws a ConfigurationErrorsException (descendant of ConfigurationException) on failure.
        private static LoggingProviderBase GetDefaultProvider(LoggingSection loggingSection,
                                                              LoggingProviderCollection providerCollection)
        {
            LoggingProviderBase defaultProvider = providerCollection[loggingSection.DefaultProvider];

            if (defaultProvider == null)
            {
                PropertyInformation property = loggingSection.ElementInformation.Properties["defaultProvider"];

                throw new ConfigurationErrorsException(
                          SR.NoDefaultLoggingProviderFound(SectionName), property.Source, property.LineNumber);
            }

            return(defaultProvider);
        }
コード例 #24
0
        public void WriteField(IndentedTextWriter indentWriter, PropertyInformation info)
        {
            if (info.Relation.HasFlag(Relation.One | Relation.ToOne) && !info.Relation.HasFlag(Relation.DependentSide))
            {
                indentWriter.Write($"section.AddField(x => x.{info.PascalCaseName} == null ? 0 : x.{info.PascalCaseName}.Id)");
                indentWriter.Write(".DisableWhen((e, s) => true)");
            }
            else if (info.Relation.HasFlag(Relation.ToOne))
            {
                indentWriter.Write($"section.AddField(x => x.{info.PascalCaseName}Id)");
            }
            else
            {
                indentWriter.Write($"section.AddField(x => x.{info.PascalCaseName})");
            }

            indentWriter.Write($".SetType(typeof({info.EditorType}))");

            if (info.Details.FirstOrDefault(x => !string.IsNullOrWhiteSpace(x.DataCollectionType)) is PropertyDetailInformation details)
            {
                indentWriter.Write($".SetDataCollection<{details.DataCollectionType}");

                if (details.ConfigList != null || details.ConfigProperties != null)
                {
                    indentWriter.Write($", {details.ConfigType}>(");

                    _configObjectBuilder.WriteConfigObject(indentWriter, details);
                }
                else
                {
                    indentWriter.Write(">(");
                }

                indentWriter.Write(")");
            }
            else if (info.Relation.HasFlag(Relation.ToOne) && !string.IsNullOrEmpty(info.RelatedCollectionAlias))
            {
                indentWriter.Write($".SetCollectionRelation(\"{info.RelatedCollectionAlias}\")");
            }
            else if (info.Relation.HasFlag(Relation.ToMany) && !string.IsNullOrEmpty(info.RelatedCollectionAlias))
            {
                indentWriter.Write($".SetCollectionRelation(\"{info.RelatedCollectionAlias}\")");
            }

            indentWriter.Write($".SetName(\"{info.Name}\")");

            indentWriter.WriteLine(";");
        }
コード例 #25
0
        private IEnumerable <ModelMetadata> GetMetadataForPropertiesImpl(object container, Type containerType)
        {
            TypeInformation typeInfo = GetTypeInformation(containerType);

            foreach (KeyValuePair <string, PropertyInformation> kvp in typeInfo.Properties)
            {
                PropertyInformation propertyInfo  = kvp.Value;
                Func <object>       modelAccessor = null;
                if (container != null)
                {
                    Func <object, object> propertyGetter = propertyInfo.ValueAccessor;
                    modelAccessor = () => propertyGetter(container);
                }
                yield return(CreateMetadataFromPrototype(propertyInfo.Prototype, modelAccessor));
            }
        }
コード例 #26
0
        private static InheritanceTypes GetInheritance(PropertyInformation prop)
        {
            if (Inherits <ConfigurationElementCollection>(prop.Type))
            {
                //For us all are the same:
                // a) We do the sorting anyway,
                // b) Basic does not allow remove/clear anyway, so both properties will never occur
                return(InheritanceTypes.COLLECTION);
            }

            if (Inherits <ConfigurationElement>(prop.Type))
            {
                return(InheritanceTypes.CONFIGURATION_ELEMENT);
            }
            return(InheritanceTypes.NONE);
        }
コード例 #27
0
ファイル: ModuleWeaver.cs プロジェクト: jtheisen/Loom.Fody
    void WeaveType(TypeDefinition @class, CustomAttribute weaveTypeAttribute)
    {
        var propertyInformation = new PropertyInformation[@class.Properties.Count];

        var arguments = weaveTypeAttribute.ConstructorArguments.ToList();

        var propertyImplementationGenericType = arguments[1].Value as TypeDefinition;

        // Methods and events are taken from the MixIn's type directly rather than, as
        // would be more appropriate, the interfaces it implements. That's because that way
        // we don't need to resolve the interface's type.

        WeaveMixInWithEventDelegations(@class, weaveTypeAttribute, out var mixInType, out var mixInField);
        WeavePropertyDelegations(@class, mixInField, propertyImplementationGenericType, propertyInformation);
        WeaveMethodDelegations(@class, mixInType, mixInField, propertyImplementationGenericType, propertyInformation, weaveTypeAttribute);
    }
コード例 #28
0
        public List <Pair <string, object> > CreateExtensions()
        {
            var result = new List <Pair <string, object> >();

            if (_constructors == null)
            {
                lock (_syncRoot)
                {
                    if (_constructors == null)
                    {
                        var constructors = new List <KeyValuePair <string, ConstructorInfo> >();
                        if (_providerData == null)
                        {
                            return(result);
                        }

                        foreach (var configLine in _providerData.XslExtensions)
                        {
                            PropertyInformation propertyInformation = configLine.ElementInformation.Properties["type"];
                            if (propertyInformation == null)
                            {
                                continue;
                            }

                            Type type = propertyInformation.Value as Type;
                            if (type == null)
                            {
                                continue;
                            }

                            ConstructorInfo constructor = type.GetConstructors()[0];
                            constructors.Add(new KeyValuePair <string, ConstructorInfo>(configLine.Name, constructor));
                        }

                        // TODO: uncomment
                        _constructors = constructors;
                    }
                }
            }

            foreach (var pair in _constructors)
            {
                object instance = pair.Value.Invoke(new object[0]);
                result.Add(new Pair <string, object>(pair.Key, instance));
            }
            return(result);
        }
コード例 #29
0
        public void GetTypeInformation_WhenListDatasetsThenPropertyDescriptionShouldBeReturned()
        {
            // Arrange
            ICodeMetadataGeneratorService generator = GetCodeGenerator();

            byte[] assembly = GetCalculationClassWithListDescriptionsExampleAssembly();

            // Act
            IEnumerable <TypeInformation> result = generator.GetTypeInformation(assembly);

            // Assert
            result.Should().NotBeNull("Result should not be null");

            result.Should().ContainSingle(c => c.Name == "Calculations");

            TypeInformation datasetType = result.Where(e => e.Name == "HighNeedsStudentNumbersDataset").FirstOrDefault();

            datasetType.Name.Should().Be("HighNeedsStudentNumbersDataset");
            datasetType.Description.Should().BeNull();
            datasetType.Type.Should().Be("HighNeedsStudentNumbersDataset");

            List <PropertyInformation> properties = new List <PropertyInformation>(datasetType.Properties);

            PropertyInformation ridProperty = properties[0];

            ridProperty.Should().NotBeNull("ridProperty should not be null");
            ridProperty.Name.Should().Be("Rid");
            ridProperty.FriendlyName.Should().Be("Rid");
            ridProperty.Description.Should().Be("Rid is the unique reference from The Store");

            PropertyInformation parentRidProperty = properties[1];

            parentRidProperty.Should().NotBeNull("parentRidProperty should not be null");
            parentRidProperty.Name.Should().Be("ParentRid");
            parentRidProperty.FriendlyName.Should().Be("Parent Rid");
            parentRidProperty.Description.Should().Be("The Rid of the parent provider (from The Store)");

            PropertyInformation highNeedsStudentsProperty = properties[11];

            highNeedsStudentsProperty.Should().NotBeNull("parentRidProperty should not be null");
            highNeedsStudentsProperty.Name.Should().Be("HighNeedsStudents1924");
            highNeedsStudentsProperty.FriendlyName.Should().Be("High Needs Students 19-24");
            highNeedsStudentsProperty.Description.Should().Be("Current year high needs students aged 19-24");

            properties.Should().HaveCount(22, "HighNeedsStudentNumbersDataset should contain expected number of properties");
        }
コード例 #30
0
ファイル: Logger.cs プロジェクト: shekky/cuttingedge.logging
        private static Exception BuildMoreExpressiveException(Exception thrownException,
                                                              ProviderSettings settings)
        {
            PropertyInformation providerInfo = settings.ElementInformation.Properties["type"];

            if (thrownException is ArgumentException)
            {
                // The exception is thrown from within this method. Therefore we do not supply an inner
                // exception.
                return(new ConfigurationErrorsException(thrownException.Message,
                                                        thrownException.InnerException, providerInfo.Source, providerInfo.LineNumber));
            }
            else
            {
                return(new ConfigurationErrorsException(thrownException.Message, thrownException,
                                                        providerInfo.Source, providerInfo.LineNumber));
            }
        }
 public void CopyTo(PropertyInformation[] array, int index)
 {
 }