Ejemplo n.º 1
0
 /// <summary>
 /// To be valid a value must be valid for its type or empty.
 /// </summary>
 /// <param name="lowerBound"></param><param name="upperBound"></param><param name="type"></param><param name="format"></param>
 /// <returns></returns>
 public static bool IsValidValues(string lowerBound, string upperBound, MetaAttribute.MetaAttributeDataType type, FormattedOrRaw format)
 {
     if (lowerBound.Contains("-") || upperBound.Contains("-")) return false;
     if (!lowerBound.Equals(String.Empty) && !ValueContainerValidator.Validate(type, lowerBound, format)) return false;
     if (!upperBound.Equals(String.Empty) && !ValueContainerValidator.Validate(type, upperBound, format)) return false;
     return true;
 }
Ejemplo n.º 2
0
        private void CreateRangeFromRawValues(string lowerBound, string upperBound, MetaAttribute.MetaAttributeDataType type, FormattedOrRaw format)
        {
            Contract.Assert(IsValidValues(lowerBound, upperBound, type, format), "Invalid ValueRange.");

            _lowerBound = (lowerBound.Length > 0) ? ValueContainer.Create(lowerBound, type, format) : null;
            _upperBound = (upperBound.Length > 0) ? ValueContainer.Create(upperBound, type, format) : null;
        }
Ejemplo n.º 3
0
 public ValueRange(string rawValues, MetaAttribute.MetaAttributeDataType type)
 {
     Contract.Assert(rawValues.IndexOf("-") == rawValues.LastIndexOf("-"),
         "A range RawValue cannot have more than one '-' symbol.");
     string[] range = rawValues.Split('-');
     CreateRangeFromRawValues(range[0], range[1], type, FormattedOrRaw.RAW);
 }
Ejemplo n.º 4
0
        /// <summary>Build a ValueSet using the value string that comes from the UI listbox. ie value,value</summary>
        public ValueSet(string rawValues, MetaAttribute.MetaAttributeDataType type)
        {
            Contract.Assert(IsValidRawValues(rawValues, type), "Invalid ValueSet.");

            if (rawValues == String.Empty) return;
            string[] values = rawValues.Split(',');

            foreach (string value in values) _values.Add(ValueContainer.Create(value, type, FormattedOrRaw.RAW));
        }
Ejemplo n.º 5
0
 public static bool IsValidRawValues(string rawValues, MetaAttribute.MetaAttributeDataType type)
 {
     if (rawValues.Equals(String.Empty)) return true;
     string[] values = rawValues.Split(',');
     foreach (string value in values)
     {
         if (!ValueContainerValidator.Validate(type, value, FormattedOrRaw.RAW)) return false;
     }
     return true;
 }
Ejemplo n.º 6
0
    public static string QuoteReqIDMetaAttribute(MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "String";
        }

        return "";
    }
Ejemplo n.º 7
0
    public static string HeartBtIntMetaAttribute(MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "int";
        }

        return "";
    }
    public static string TransactTimeMetaAttribute(MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "UTCTimestamp";
        }

        return "";
    }
    public static string LastMsgSeqNumProcessedMetaAttribute(MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "SeqNum";
        }

        return "";
    }
Ejemplo n.º 10
0
    public static string TokenOffsetMetaAttribute(MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "";
        }

        return "";
    }
Ejemplo n.º 11
0
        /// <summary>Validate a string representing a value (for a preference or attribute).</summary>
        /// <param name="type"></param><param name="value"></param><param name="representation"></param>
        /// <returns></returns>
        public static bool Validate(MetaAttribute.MetaAttributeDataType type, string value, FormattedOrRaw representation)
        {
            if (value == null) return false;

            switch (type)
            {
                case MetaAttribute.MetaAttributeDataType.STRING: return ValidateString(value, representation);
                case MetaAttribute.MetaAttributeDataType.INTEGER: return ValidateInteger(value, representation);
                case MetaAttribute.MetaAttributeDataType.CURRENCY: return ValidateCurrency(value, representation);
                default: throw new Exception("Unknown MetaAttributeDataType: " + type.ToString());
            }
        }
Ejemplo n.º 12
0
        public override void ApplyPropertyMeta(SerializedProperty property, MetaAttribute metaAttribute)
        {
            OnValueChangedAttribute onValueChangedAttribute = (OnValueChangedAttribute)metaAttribute;

            UnityEngine.Object target = PropertyUtility.GetTargetObject(property);

            MethodInfo callbackMethod = target.GetType().GetMethod(onValueChangedAttribute.CallbackName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            if (callbackMethod != null &&
                callbackMethod.ReturnType == typeof(void) &&
                callbackMethod.GetParameters().Length == 0)
            {
                property.serializedObject.ApplyModifiedProperties(); // We must apply modifications so that the callback can be invoked with up-to-date data

                callbackMethod.Invoke(target, null);
            }
            else
            {
                string warning = onValueChangedAttribute.GetType().Name + " can invoke only action methods - with void return type and no parameters";
                Debug.LogWarning(warning, target);
            }
        }
Ejemplo n.º 13
0
        public override void ApplyPropertyMeta(SerializedProperty property, MetaAttribute metaAttribute)
        {
            var onValueChangedAttribute = (OnValueChangedAttribute)metaAttribute;
            var target         = PropertyUtility.GetTargetObject(property);
            var callbackMethod = ReflectionUtility.GetMethod(target, onValueChangedAttribute.CallbackName);

            if (callbackMethod != null &&
                callbackMethod.ReturnType == typeof(void) &&
                callbackMethod.GetParameters().Length == 0)
            {
                property.serializedObject
                .ApplyModifiedProperties();         // We must apply modifications so that the callback can be invoked with up-to-date data

                callbackMethod.Invoke(target, null);
            }
            else
            {
                var warning = onValueChangedAttribute.GetType().Name +
                              " can invoke only action methods - with void return type and no parameters";

                Debug.LogWarning(warning, target);
            }
        }
Ejemplo n.º 14
0
        public static IDictionary <string, MetaAttribute> GetMetas(XmlNodeList nodes, IDictionary <string, MetaAttribute> inheritedMeta, bool onlyInheritable)
        {
            var map = new Dictionary <string, MetaAttribute>(inheritedMeta);

            foreach (XmlNode metaNode in nodes)
            {
                if (metaNode.Name != "meta")
                {
                    continue;
                }
                var  inheritableValue = GetAttributeValue(metaNode, "inherit");
                bool inheritable      = inheritableValue != null?IsTrue(inheritableValue) : false;

                if (onlyInheritable & !inheritable)
                {
                    continue;
                }
                string name = GetAttributeValue(metaNode, "attribute");

                MetaAttribute meta;
                MetaAttribute inheritedAttribute;
                map.TryGetValue(name, out meta);
                inheritedMeta.TryGetValue(name, out inheritedAttribute);
                if (meta == null)
                {
                    meta      = new MetaAttribute(name);
                    map[name] = meta;
                }
                else if (meta == inheritedAttribute)
                {
                    meta      = new MetaAttribute(name);
                    map[name] = meta;
                }
                meta.AddValue(metaNode.InnerText);
            }
            return(map);
        }
Ejemplo n.º 15
0
        /// <summary> Load meta attributes from jdom element into a MultiMap.
        ///
        /// </summary>
        /// <returns> MultiMap
        /// </returns>
        protected internal static MultiMap loadMetaMap(Element element)
        {
            MultiMap result = new MultiHashMap();

            SupportClass.ListCollectionSupport metaAttributeList = new SupportClass.ListCollectionSupport();
            metaAttributeList.AddAll(element.SelectNodes("urn:meta", CodeGenerator.nsmgr));

            for (IEnumerator iter = metaAttributeList.GetEnumerator(); iter.MoveNext();)
            {
                Element metaAttrib = (Element)iter.Current;
                // does not use getTextNormalize() or getTextTrim() as that would remove the formatting in new lines in items like description for javadocs.
                string attribute = (metaAttrib.Attributes["attribute"] == null
                                                        ? string.Empty : metaAttrib.Attributes["attribute"].Value);
                string value_Renamed = metaAttrib.InnerText;
                string inheritStr    = (metaAttrib.Attributes["inherit"] == null ? null : metaAttrib.Attributes["inherit"].Value);
                bool   inherit       = true;
                if ((Object)inheritStr != null)
                {
                    try
                    {
                        inherit = Boolean.Parse(inheritStr);
                    }
                    catch
                    {
                    }
                }

                MetaAttribute ma = new MetaAttribute(value_Renamed, inherit);
                if (result[attribute] == null)
                {
                    result[attribute] = new SupportClass.ListCollectionSupport();
                }

                ((SupportClass.ListCollectionSupport)result[attribute]).Add(ma);
            }
            return(result);
        }
Ejemplo n.º 16
0
        public static IDictionary <string, MetaAttribute> GetMetas(IDecoratable decoratable, IDictionary <string, MetaAttribute> inheritedMeta, bool onlyInheritable)
        {
            if (decoratable == null)
            {
                return(EmptyMeta);
            }
            var map = new Dictionary <string, MetaAttribute>(inheritedMeta);

            IDictionary <string, MetaAttribute> metaAttributes = onlyInheritable
                                                                                ? decoratable.InheritableMetaData
                                                                                : decoratable.MappedMetaData;

            foreach (var metaAttribute in metaAttributes)
            {
                string name = metaAttribute.Key;

                MetaAttribute meta;
                MetaAttribute inheritedAttribute;

                map.TryGetValue(name, out meta);
                inheritedMeta.TryGetValue(name, out inheritedAttribute);

                if (meta == null)
                {
                    meta      = new MetaAttribute(name);
                    map[name] = meta;
                }
                else if (meta == inheritedAttribute)
                {
                    // overriding inherited meta attribute.
                    meta      = new MetaAttribute(name);
                    map[name] = meta;
                }
                meta.AddValues(metaAttribute.Value.Values);
            }
            return(map);
        }
        public static string MDEntrySizeMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case MetaAttribute.Epoch: return "unix";
                case MetaAttribute.TimeUnit: return "nanosecond";
                case MetaAttribute.SemanticType: return "Qty";
            }

            return "";
        }
    public static string MatchEventIndicatorMetaAttribute(MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "MultipleCharValue";
        }

        return "";
    }
Ejemplo n.º 19
0
 public InfoSchemaTable()
 {
     Meta = new MetaAttribute();
 }
Ejemplo n.º 20
0
 public abstract void ApplyPropertyMeta(SerializedProperty property, MetaAttribute metaAttribute, bool drawField);
Ejemplo n.º 21
0
    public static string CharacterEncodingMetaAttribute(MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "";
        }

        return "";
    }
        public static string MdUpdateActionMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case MetaAttribute.Epoch: return "unix";
                case MetaAttribute.TimeUnit: return "nanosecond";
                case MetaAttribute.SemanticType: return "";
            }

            return "";
        }
Ejemplo n.º 23
0
        public void ProcessFile(FileInfo file)
        {
            string[] lines = File.ReadAllLines(file.FullName);

            Class  cls  = null;
            string line = "";
            bool   isMetaOrConfigOption = false;

            List <string>        comments   = new List <string>();
            List <MetaAttribute> attributes = new List <MetaAttribute>();

            for (int i = 0; i < lines.Length; i++)
            {
                line = lines[i].Trim();

                if (Utils.IsComment(line))
                {
                    comments.Add(line.RightOf("///").Trim());
                    continue;
                }

                if (Utils.IsAttribute(line))
                {
                    MetaAttribute attr = new MetaAttribute(line);
                    attributes.Add(attr);

                    if (attr.Type == "Meta" || attr.Type == "ConfigOption")
                    {
                        isMetaOrConfigOption = true;
                    }

                    continue;
                }

                if (Utils.IsClass(line))
                {
                    if (cls != null)
                    {
                        this.Root.Classes.Add(cls);
                    }

                    cls = new Class(line);

                    cls.RawComments = comments;
                    cls.Attributes  = attributes;

                    comments   = new List <string>();
                    attributes = new List <MetaAttribute>();

                    continue;
                }

                /* This is only required for Ext.Net.API.Meta.Parser.exe which is currently not in use.
                 * So, commented out for now and review when Ext.Net.API.Meta.Parser will be in use again if ever.
                 *
                 * if (Utils.IsXType(line))
                 * {
                 *  var temp = lines[i + 4].Trim();
                 *
                 *  if (temp.StartsWith("return"))
                 *  {
                 *      cls.XType = temp.RightOf('"').Replace("\"", "").Replace(" ", "").Replace(";", "").Replace(":", ",").Trim();
                 *  }
                 *
                 *  continue;
                 * }
                 *
                 * if (Utils.IsInstanceOf(line))
                 * {
                 *  var temp = lines[i + 4].Trim();
                 *
                 *  if (temp.StartsWith("return"))
                 *  {
                 *      cls.InstanceOf = temp.RightOf('"').Replace("\"", "").Replace(" ", "").Replace(";", "").Replace(":", ",").Trim();
                 *  }
                 *
                 *  continue;
                 * }
                 */

                if (cls != null && isMetaOrConfigOption)
                {
                    isMetaOrConfigOption = false;

                    if (Utils.IsProperty(line))
                    {
                        ConfigOption member = new ConfigOption(line);

                        member.RawComments = comments;
                        member.Attributes  = attributes;

                        cls.ConfigOptions.Add(member);

                        comments   = new List <string>();
                        attributes = new List <MetaAttribute>();

                        continue;
                    }

                    if (Utils.IsMethod(line))
                    {
                        Method member = new Method(line);

                        member.RawComments = comments;
                        member.Attributes  = attributes;

                        cls.Methods.Add(member);

                        comments   = new List <string>();
                        attributes = new List <MetaAttribute>();

                        continue;
                    }
                }

                isMetaOrConfigOption = false;
                comments             = new List <string>();
                attributes           = new List <MetaAttribute>();
            }

            if (cls != null && cls.Name.IsNotEmpty())
            {
                this.Root.Classes.Add(cls);
            }
        }
Ejemplo n.º 24
0
        public Configuration Configure()
        {
            var configuration = new Configuration();

            // Add the configuration to the container
            configuration.BeforeBindMapping += Configuration_BeforeBindMapping;

            // Get all the filter definitions from all the configurators
            var allFilterDetails = _authorizationStrategyConfigurators
                                   .SelectMany(c => c.GetFilters())
                                   .Distinct()
                                   .ToList();

            // Group the filters by name first (there can only be 1 "default" filter, but flexibility
            // to apply same filter name with same parameters to different entities should be supported
            // (and is in fact supported below when filters are applied to individual entity mappings)
            var allFilterDetailsGroupedByName = allFilterDetails
                                                .GroupBy(f => f.FilterDefinition.FilterName)
                                                .Select(g => g);

            // Add all the filter definitions to the NHibernate configuration
            foreach (var filterDetails in allFilterDetailsGroupedByName)
            {
                configuration.AddFilterDefinition(
                    filterDetails.First()
                    .FilterDefinition);
            }

            // Configure the mappings
            var ormMappingFileData = _ormMappingFileDataProvider.OrmMappingFileData();

            configuration.AddResources(ormMappingFileData.MappingFileFullNames, ormMappingFileData.Assembly);

            //Resolve all extension assemblies and add to NHibernate configuration
            _extensionConfigurationProviders.ForEach(
                e => configuration.AddResources(e.OrmMappingFileData.MappingFileFullNames, e.OrmMappingFileData.Assembly));

            // Invoke configuration activities
            foreach (var configurationActivity in _configurationActivities)
            {
                configurationActivity.Execute(configuration);
            }

            // Apply the previously defined filters to the mappings
            foreach (var mapping in configuration.ClassMappings)
            {
                Type entityType = mapping.MappedClass;
                var  properties = entityType.GetProperties();

                var applicableFilters = allFilterDetails
                                        .Where(filterDetails => filterDetails.ShouldApply(entityType, properties))
                                        .ToList();

                foreach (var filter in applicableFilters)
                {
                    var filterDefinition = filter.FilterDefinition;

                    // Save the filter criteria applicators
                    _filterCriteriaApplicatorProvider.AddCriteriaApplicator(
                        filterDefinition.FilterName,
                        entityType,
                        filter.CriteriaApplicator);

                    mapping.AddFilter(
                        filterDefinition.FilterName,
                        filterDefinition.DefaultFilterCondition);

                    var metaAttribute = new MetaAttribute(filterDefinition.FilterName);
                    metaAttribute.AddValue(filter.HqlConditionFormatString);

                    mapping.MetaAttributes.Add(
                        "HqlFilter_" + filterDefinition.FilterName,
                        metaAttribute);
                }
            }

            configuration.AddCreateDateHooks();

            return(configuration);
        }
        public static string ManualOrderIndicatorMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "";
            }

            return "";
        }
        public static string CustomerOrFirmMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "";
            }

            return "";
        }
Ejemplo n.º 27
0
        /// <summary> Write a Meta XML Element from attributes in a member. </summary>
        public virtual void WriteMeta(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, MetaAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass)
        {
            writer.WriteStartElement( "meta" );
            // Attribute: <attribute>
            writer.WriteAttributeString("attribute", attribute.Attribute==null ? DefaultHelper.Get_Meta_Attribute_DefaultValue(member) : GetAttributeValue(attribute.Attribute, mappedClass));
            // Attribute: <inherit>
            if( attribute.InheritSpecified )
            writer.WriteAttributeString("inherit", attribute.Inherit ? "true" : "false");

            WriteUserDefinedContent(writer, member, null, attribute);

            // Write the content of this element (mixed="true")
            writer.WriteString(attribute.Content);

            writer.WriteEndElement();
        }
    public static string MatchAlgorithmMetaAttribute(MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "char";
        }

        return "";
    }
Ejemplo n.º 29
0
 public override void ApplyPropertyMeta(SerializedProperty property, MetaAttribute metaAttribute)
 {
     EditorGUILayout.Space();
 }
        public static string SettlPriceTypeMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case MetaAttribute.Epoch: return "unix";
                case MetaAttribute.TimeUnit: return "nanosecond";
                case MetaAttribute.SemanticType: return "MultipleCharValue";
            }

            return "";
        }
        public static string TradingReferenceDateMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case MetaAttribute.Epoch: return "unix";
                case MetaAttribute.TimeUnit: return "nanosecond";
                case MetaAttribute.SemanticType: return "LocalMktDate";
            }

            return "";
        }
        public static string OpenCloseSettleFlagMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case MetaAttribute.Epoch: return "unix";
                case MetaAttribute.TimeUnit: return "nanosecond";
                case MetaAttribute.SemanticType: return "";
            }

            return "";
        }
        public static string NumberOfOrdersMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case MetaAttribute.Epoch: return "unix";
                case MetaAttribute.TimeUnit: return "nanosecond";
                case MetaAttribute.SemanticType: return "";
            }

            return "";
        }
        public static string TradeIdMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case MetaAttribute.Epoch: return "unix";
                case MetaAttribute.TimeUnit: return "nanosecond";
                case MetaAttribute.SemanticType: return "ExecID";
            }

            return "";
        }
Ejemplo n.º 35
0
        public void NonMutatedInheritance()
        {
            PersistentClass cm            = cfg.GetClassMapping("NHibernate.Test.MappingTest.Wicked");
            MetaAttribute   metaAttribute = cm.GetMetaAttribute("globalmutated");

            Assert.That(metaAttribute, Is.Not.Null);

            /*assertEquals( metaAttribute.getValues().size(), 2 );
             * assertEquals( "top level", metaAttribute.getValues().get(0) );*/
            Assert.That(metaAttribute.Value, Is.EqualTo("wicked level"));

            Property      property          = cm.GetProperty("Component");
            MetaAttribute propertyAttribute = property.GetMetaAttribute("globalmutated");

            Assert.That(propertyAttribute, Is.Not.Null);

            /*assertEquals( propertyAttribute.getValues().size(), 3 );
             * assertEquals( "top level", propertyAttribute.getValues().get(0) );
             * assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/
            Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount level"));

            var component = (NHibernate.Mapping.Component)property.Value;

            property          = component.GetProperty("X");
            propertyAttribute = property.GetMetaAttribute("globalmutated");

            Assert.That(propertyAttribute, Is.Not.Null);

            /*assertEquals( propertyAttribute.getValues().size(), 4 );
             * assertEquals( "top level", propertyAttribute.getValues().get(0) );
             * assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
             * assertEquals( "monetaryamount level", propertyAttribute.getValues().get(2) );*/
            Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount x level"));

            property          = cm.GetProperty("SortedEmployee");
            propertyAttribute = property.GetMetaAttribute("globalmutated");

            Assert.That(propertyAttribute, Is.Not.Null);

            /*assertEquals( propertyAttribute.getValues().size(), 3 );
             * assertEquals( "top level", propertyAttribute.getValues().get(0) );
             * assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/
            Assert.That(propertyAttribute.Value, Is.EqualTo("sortedemployee level"));

            property          = cm.GetProperty("AnotherSet");
            propertyAttribute = property.GetMetaAttribute("globalmutated");

            Assert.That(propertyAttribute, Is.Not.Null);

            /*assertEquals( propertyAttribute.getValues().size(), 2 );
             * assertEquals( "top level", propertyAttribute.getValues().get(0) );*/
            Assert.That(propertyAttribute.Value, Is.EqualTo("wicked level"));

            var bag = (Bag)property.Value;

            component = (NHibernate.Mapping.Component)bag.Element;

            Assert.That(component.MetaAttributes.Count, Is.EqualTo(4));

            metaAttribute = component.GetMetaAttribute("globalmutated");

            /*assertEquals( metaAttribute.getValues().size(), 3 );
             * assertEquals( "top level", metaAttribute.getValues().get(0) );
             * assertEquals( "wicked level", metaAttribute.getValues().get(1) );*/
            Assert.That(metaAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite level"));

            property          = component.GetProperty("Emp");
            propertyAttribute = property.GetMetaAttribute("globalmutated");

            Assert.That(propertyAttribute, Is.Not.Null);

            /*assertEquals( propertyAttribute.getValues().size(), 4 );
             * assertEquals( "top level", propertyAttribute.getValues().get(0) );
             * assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
             * assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/
            Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite property emp level"));

            property          = component.GetProperty("Empinone");
            propertyAttribute = property.GetMetaAttribute("globalmutated");

            Assert.That(propertyAttribute, Is.Not.Null);

            /*assertEquals( propertyAttribute.getValues().size(), 4 );
             * assertEquals( "top level", propertyAttribute.getValues().get(0) );
             * assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
             * assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/
            Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite property empinone level"));
        }
Ejemplo n.º 36
0
                public static string SecurityIDSourceMetaAttribute(MetaAttribute metaAttribute)
                {
                    switch (metaAttribute)
                    {
                    case MetaAttribute.Epoch: return "unix";
                    case MetaAttribute.TimeUnit: return "nanosecond";
                    case MetaAttribute.SemanticType: return "";
                    }

                    return "";
                }
Ejemplo n.º 37
0
 public abstract void ApplyPropertyMeta(SerializedProperty property, MetaAttribute metaAttribute);
Ejemplo n.º 38
0
        public NHibernate.Cfg.Configuration Configure()
        {
            SetAssemblyBinding();

            var configuration = new NHibernate.Cfg.Configuration();

            // NOTE: the NHibernate documentation states that this file would be automatically loaded, however in testings this was not the case.
            // The expectation is that this file will be in the binaries location.
            configuration.Configure(
                Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "hibernate.cfg.xml"));

            // Add the configuration to the container
            configuration.BeforeBindMapping += Configuration_BeforeBindMapping;

            // Get all the filter definitions from all the configurators
            var allFilterDetails = _authorizationStrategyConfigurators
                                   .SelectMany(c => c.GetFilters())
                                   .Distinct()
                                   .ToList();

            // Group the filters by name first (there can only be 1 "default" filter, but flexibility
            // to apply same filter name with same parameters to different entities should be supported
            // (and is in fact supported below when filters are applied to individual entity mappings)
            var allFilterDetailsGroupedByName = allFilterDetails
                                                .GroupBy(f => f.FilterDefinition.FilterName)
                                                .Select(g => g);

            // Add all the filter definitions to the NHibernate configuration
            foreach (var filterDetails in allFilterDetailsGroupedByName)
            {
                configuration.AddFilterDefinition(
                    filterDetails.First()
                    .FilterDefinition);
            }

            // Configure the mappings
            var ormMappingFileData = _ormMappingFileDataProvider.OrmMappingFileData();

            configuration.AddResources(ormMappingFileData.MappingFileFullNames, ormMappingFileData.Assembly);

            //Resolve all extension assemblies and add to NHibernate configuration
            _extensionConfigurationProviders.ForEach(
                e => configuration.AddResources(e.OrmMappingFileData.MappingFileFullNames, e.OrmMappingFileData.Assembly));

            // Invoke configuration activities
            foreach (var configurationActivity in _configurationActivities)
            {
                configurationActivity.Execute(configuration);
            }

            // Apply the previously defined filters to the mappings
            foreach (var mapping in configuration.ClassMappings)
            {
                Type entityType = mapping.MappedClass;
                var  properties = entityType.GetProperties();

                var applicableFilters = allFilterDetails
                                        .Where(filterDetails => filterDetails.ShouldApply(entityType, properties))
                                        .ToList();

                foreach (var filter in applicableFilters)
                {
                    var filterDefinition = filter.FilterDefinition;

                    // Save the filter criteria applicators
                    _filterCriteriaApplicatorProvider.AddCriteriaApplicator(
                        filterDefinition.FilterName,
                        entityType,
                        filter.CriteriaApplicator);

                    mapping.AddFilter(
                        filterDefinition.FilterName,
                        filterDefinition.DefaultFilterCondition);

                    var metaAttribute = new MetaAttribute(filterDefinition.FilterName);
                    metaAttribute.AddValue(filter.HqlConditionFormatString);

                    mapping.MetaAttributes.Add(
                        "HqlFilter_" + filterDefinition.FilterName,
                        metaAttribute);
                }
            }

            configuration.AddCreateDateHooks();

            return(configuration);

            void SetAssemblyBinding()
            {
                // NHibernate does not behave nicely with assemblies that are loaded from another folder.
                // By default NHibernate tries to load the assembly from the execution folder.
                // In our case we have pre loaded the assemblies into the domain, so we just need to tell NHibernate to pull the loaded
                // assembly. Setting the AssemblyResolve event fixes this. c.f. https://nhibernate.jira.com/browse/NH-2063 for further details.
                var assemblies = AppDomain.CurrentDomain.GetAssemblies();

                AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
                {
                    var assemblyName = e.Name.Split(",")[0];

                    return(assemblies.FirstOrDefault(a => a.GetName().Name.EqualsIgnoreCase(assemblyName)));
                };
            }
        }
        public Configuration Configure(IWindsorContainer container)
        {
            //Resolve all extensions to include in core mapping
            var extensionConfigurationProviders = container.ResolveAll <IExtensionNHibernateConfigurationProvider>()
                                                  .ToList();

            _entityExtensionHbmBagsByEntityName = extensionConfigurationProviders
                                                  .SelectMany(x => x.EntityExtensionHbmBagByEntityName)
                                                  .GroupBy(x => x.Key)
                                                  .ToDictionary(
                x => x.Key,
                x => x.Select(y => y.Value)
                .ToArray());

            _aggregateExtensionHbmBagsByEntityName = extensionConfigurationProviders
                                                     .SelectMany(x => x.AggregateExtensionHbmBagsByEntityName)
                                                     .GroupBy(x => x.Key)
                                                     .ToDictionary(
                x => x.Key,
                x => x.SelectMany(y => y.Value)
                .ToArray());

            _extensionDescriptorByEntityName = extensionConfigurationProviders
                                               .SelectMany(x => x.NonDiscriminatorBasedHbmJoinedSubclassesByEntityName)
                                               .GroupBy(x => x.Key)
                                               .ToDictionary(
                x => x.Key,
                x => x.SelectMany(y => y.Value)
                .ToArray());

            _extensionDerivedEntityByEntityName = extensionConfigurationProviders
                                                  .SelectMany(x => x.DiscriminatorBasedHbmSubclassesByEntityName)
                                                  .GroupBy(x => x.Key)
                                                  .ToDictionary(k => k.Key, v => v.SelectMany(y => y.Value).ToArray());

            _beforeBindMappingActivities = container.ResolveAll <INHibernateBeforeBindMappingActivity>();

            // Start the NHibernate configuration
            var configuration = new Configuration();

            // Add the configuration to the container
            container.Register(
                Component.For <Configuration>()
                .Instance(configuration));

            configuration.BeforeBindMapping += Configuration_BeforeBindMapping;

            // Get all the authorization strategy configurators
            var authorizationStrategyConfigurators = container.ResolveAll <INHibernateFilterConfigurator>();

            // Get all the filter definitions from all the configurators
            var allFilterDetails =
                (from c in authorizationStrategyConfigurators
                 from f in c.GetFilters()
                 select f)
                .Distinct()
                .ToList();

            // Group the filters by name first (there can only be 1 "default" filter, but flexibility
            // to apply same filter name with same parameters to different entities should be supported
            // (and is in fact supported below when filters are applied to individual entity mappings)
            var allFilterDetailsGroupedByName =
                from f in allFilterDetails
                group f by f.FilterDefinition.FilterName
                into g
                select g;

            // Add all the filter definitions to the NHibernate configuration
            foreach (var filterDetails in allFilterDetailsGroupedByName)
            {
                configuration.AddFilterDefinition(
                    filterDetails.First()
                    .FilterDefinition);
            }

            // Configure the mappings
            var ormMappingFileData = container.Resolve <IOrmMappingFileDataProvider>().OrmMappingFileData();

            configuration.AddResources(ormMappingFileData.MappingFileFullNames, ormMappingFileData.Assembly);

            //Resolve all extension assemblies and add to NHibernate configuration
            extensionConfigurationProviders
            .ForEach(
                e => configuration.AddResources(e.OrmMappingFileData.MappingFileFullNames, e.OrmMappingFileData.Assembly));

            var filterCriteriaApplicatorProvider = container.Resolve <IFilterCriteriaApplicatorProvider>();

            // Invoke configuration activities
            var configurationActivities = container.ResolveAll <INHibernateConfigurationActivity>();

            foreach (var configurationActivity in configurationActivities)
            {
                configurationActivity.Execute(configuration);
            }

            // Apply the previously defined filters to the mappings
            foreach (var mapping in configuration.ClassMappings)
            {
                Type entityType = mapping.MappedClass;
                var  properties = entityType.GetProperties();

                var applicableFilters = allFilterDetails
                                        .Where(filterDetails => filterDetails.ShouldApply(entityType, properties))
                                        .ToList();

                foreach (var filter in applicableFilters)
                {
                    var filterDefinition = filter.FilterDefinition;

                    // Save the filter criteria applicators
                    filterCriteriaApplicatorProvider.AddCriteriaApplicator(
                        filterDefinition.FilterName,
                        entityType,
                        filter.CriteriaApplicator);

                    mapping.AddFilter(
                        filterDefinition.FilterName,
                        filterDefinition.DefaultFilterCondition);

                    var metaAttribute = new MetaAttribute(filterDefinition.FilterName);
                    metaAttribute.AddValue(filter.HqlConditionFormatString);

                    mapping.MetaAttributes.Add(
                        "HqlFilter_" + filterDefinition.FilterName,
                        metaAttribute);
                }
            }

            // NHibernate Dependency Injection
            Environment.ObjectsFactory = new WindsorObjectsFactory(container);

            configuration.AddCreateDateHooks();

            // Build and register the session factory with the container
            container.Register(
                Component
                .For <ISessionFactory>()
                .UsingFactoryMethod(configuration.BuildSessionFactory)
                .LifeStyle.Singleton);

            container.Register(
                Component
                .For <Func <IStatelessSession> >()
                .UsingFactoryMethod <Func <IStatelessSession> >(
                    kernel => () => kernel.Resolve <ISessionFactory>().OpenStatelessSession())
                .LifestyleSingleton());     // The function is a singleton, not the session

            container.Register(
                Component
                .For <EdFiOdsConnectionProvider>()
                .DependsOn(
                    Dependency
                    .OnComponent(
                        typeof(IDatabaseConnectionStringProvider),
                        typeof(IDatabaseConnectionStringProvider).GetServiceNameWithSuffix(
                            Databases.Ods.ToString()))));

            // Register the SQL Server version of the parameter list setter
            // This is registered with the API by the SqlServerSupportConditionalFeature
            // in the non-legacy code.
            container.Register(
                Component
                .For <IParameterListSetter>()
                .ImplementedBy <SqlServerTableValuedParameterListSetter>());

            return(configuration);
        }
        public static string MdPriceLevelMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case MetaAttribute.Epoch: return "unix";
                case MetaAttribute.TimeUnit: return "nanosecond";
                case MetaAttribute.SemanticType: return "MDPriceLevel";
            }

            return "";
        }
        public static string CustOrderHandlingInstMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "char";
            }

            return "";
        }
        public static string RptSeqMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case MetaAttribute.Epoch: return "unix";
                case MetaAttribute.TimeUnit: return "nanosecond";
                case MetaAttribute.SemanticType: return "SequenceNumber";
            }

            return "";
        }
        public static string StopPxMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
            case MetaAttribute.Epoch: return "unix";
            case MetaAttribute.TimeUnit: return "nanosecond";
            case MetaAttribute.SemanticType: return "Price";
            }

            return "";
        }
        public static string NetChgPrevDayMetaAttribute(MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case MetaAttribute.Epoch: return "unix";
                case MetaAttribute.TimeUnit: return "nanosecond";
                case MetaAttribute.SemanticType: return "";
            }

            return "";
        }