示例#1
0
        protected override void Initialize(EvaluationContext context)
        {
            _canBuildFast = true;
            var expression = (ObjectExpression)_expression;

            if (expression.Properties.Count == 0)
            {
                // empty object initializer
                return;
            }

            var engine = context.Engine;

            _valueExpressions = new JintExpression[expression.Properties.Count];
            _properties       = new ObjectProperty[expression.Properties.Count];

            for (var i = 0; i < _properties.Length; i++)
            {
                string?propName = null;
                var    property = expression.Properties[i];
                if (property is Property p)
                {
                    if (p.Key is Literal literal)
                    {
                        propName = EsprimaExtensions.LiteralKeyToString(literal);
                    }

                    if (!p.Computed && p.Key is Identifier identifier)
                    {
                        propName       = identifier.Name;
                        _canBuildFast &= propName != "__proto__";
                    }

                    _properties[i] = new ObjectProperty(propName, p);

                    if (p.Kind == PropertyKind.Init || p.Kind == PropertyKind.Data)
                    {
                        var propertyValue = p.Value;
                        _valueExpressions[i] = Build(engine, propertyValue);
                        _canBuildFast       &= !propertyValue.IsFunctionDefinition();
                    }
                    else
                    {
                        _canBuildFast = false;
                    }
                }
                else if (property is SpreadElement spreadElement)
                {
                    _canBuildFast        = false;
                    _properties[i]       = null;
                    _valueExpressions[i] = Build(engine, spreadElement.Argument);
                }
                else
                {
                    ExceptionHelper.ThrowArgumentOutOfRangeException("property", "cannot handle property " + property);
                }

                _canBuildFast &= propName != null;
            }
        }
        public static MessageBuildResult Build(
            string token,
            IEnumerable <ObjectProperty> superProperties,
            object distinctId,
            object alias)
        {
            MessageCandidate messageCandidate = TrackMessageBuilderBase.CreateValidMessageCandidate(
                token,
                superProperties,
                null,
                distinctId,
                null,
                out string messageCandidateErrorMessage);

            if (messageCandidate == null)
            {
                return(MessageBuildResult.CreateFail(messageCandidateErrorMessage));
            }

            var message = new Dictionary <string, object>(2);

            message["event"] = "$create_alias";

            var properties = new Dictionary <string, object>(3);

            message["properties"] = properties;

            // token
            properties["token"] = messageCandidate.GetSpecialProperty(TrackSpecialProperty.Token).Value;

            // distinct_id
            ObjectProperty rawDistinctId = messageCandidate.GetSpecialProperty(TrackSpecialProperty.DistinctId);

            if (rawDistinctId == null)
            {
                return(MessageBuildResult.CreateFail($"'{TrackSpecialProperty.DistinctId}' is not set."));
            }

            ValueParseResult distinctIdParseResult = DistinctIdParser.Parse(rawDistinctId.Value);

            if (!distinctIdParseResult.Success)
            {
                return(MessageBuildResult.CreateFail(
                           $"Error parsing '{TrackSpecialProperty.DistinctId}'.", distinctIdParseResult.ErrorDetails));
            }

            properties["distinct_id"] = distinctIdParseResult.Value;

            // alias
            ValueParseResult aliasParseResult = DistinctIdParser.Parse(alias);

            if (!aliasParseResult.Success)
            {
                return(MessageBuildResult.CreateFail("Error parsing 'alias'. " + aliasParseResult.ErrorDetails));
            }
            properties["alias"] = aliasParseResult.Value;


            return(MessageBuildResult.CreateSuccess(message));
        }
 NewObjectDefaults(List <ObjectProperty> list)
 {
     InitializeComponent();
     _propertyList = list;
     for (int i = 0; i < list.Count; i++)
     {
         ObjectProperty p   = list[i];
         Label          lbl = new Label();
         lbl.Text = ValueProperty.SplitOnCaps(p.PropertyName);
         TextBox tBox = new TextBox();
         tBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
         tBox.AutoCompleteCustomSource.AddRange(p.ValueList);
         tBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
         tBox.Tag      = p.PropertyName;
         tBox.Width    = 300;
         tBox.TabIndex = i;
         tBox.DataBindings.Add("Text", p, "PropertyValue", false, DataSourceUpdateMode.OnPropertyChanged);
         tableLayoutPanel1.Controls.Add(lbl, 0, i);
         tableLayoutPanel1.Controls.Add(tBox, 1, i);
         if (i == 0)
         {
             ActiveControl = tBox;
         }
     }
 }
示例#4
0
        public override bool CanAddItem(Item item)
        {
            string profession = PlayerPrefs.GetString("Profession");

            if (item == null || !(item is EquipmentItem equipmentItem))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(profession))
            {
                return(true);
            }

            ObjectProperty property = item.FindProperty("Profession");

            if (property == null)
            {
                return(true);
            }

            string[] professions = property.stringValue.Split(';');
            for (int i = 0; i < professions.Length; i++)
            {
                if (PlayerPrefs.GetString("Profession") == professions[i])
                {
                    return(true);
                }
            }
            return(false);
        }
示例#5
0
        /// <summary>
        /// Lookup ObjectProperty for the given (base, property) pair.
        /// </summary>
        /// <param name="base">
        ///            The Object to analyze. </param>
        /// <param name="property">
        ///            The name of the property to analyze. Will be coerced to a String. </param>
        /// <returns> The ObjectProperty representing (base, property). </returns>
        /// <exception cref="PropertyNotFoundException">
        ///             if no ObjectProperty can be found. </exception>
        private ObjectProperty ToObjectProperty(object @base, object property)
        {
            ObjectProperties ObjectProperties = null;

            if (cache.Keys.Contains(@base.GetType()))
            {
                ObjectProperties = cache[@base.GetType()];
            }
            if (ObjectProperties == null)
            {
                ObjectProperties newObjectProperties = new ObjectProperties(@base.GetType());
                ObjectProperties = cache.GetOrAdd(@base.GetType(), newObjectProperties);
                if (ObjectProperties == null)
                { // put succeeded, use new value
                    ObjectProperties = newObjectProperties;
                }
            }
            ObjectProperty ObjectProperty = property == null ? null : ObjectProperties.GetObjectProperty(property.ToString());

            if (ObjectProperty == null)
            {
                throw new PropertyNotFoundException("Could not find property " + property + " in " + @base.GetType());
            }
            return(ObjectProperty);
        }
示例#6
0
        public SMAC_ActorNode(int idx, float x, float y, IMEPackage p, PathingGraphEditor grapheditor, float z)
            : base(idx, x, y, p, grapheditor)
        {
            Z = z;
            ObjectProperty sm = export.GetProperty <ObjectProperty>("StaticMesh");

            if (sm != null)
            {
                IEntry meshexp = pcc.GetEntry(sm.Value);
                string text    = comment.Text;
                if (text != "")
                {
                    text += "\n";
                }
                comment.Text = text + meshexp.ObjectName.Instanced;
            }
            else
            {
                string text = comment.Text;
                if (text != "")
                {
                    text += "\n";
                }
                comment.Text = text + export.ObjectName.Instanced;
            }
        }
示例#7
0
    //
    void FixedUpdate()
    {
        Vector2    bulletOffset = Random.insideUnitCircle * UIDynamicCrosshair.spread;
        Ray        ray          = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2 + bulletOffset.x, Screen.height / 2 + bulletOffset.y, 0));
        RaycastHit hit;

        if (attack == true)
        {
            attack = false;
            source.PlayOneShot(attackSound);
            StartCoroutine("Attack");
            if (Physics.Raycast(ray, out hit, range, -5, QueryTriggerInteraction.Ignore))
            {
                Debug.Log("Попали в коллайдер " + hit.collider.gameObject.name);
                //hit.collider.gameObject.SendMessage("pistolHit", pistolDamage, SendMessageOptions.DontRequireReceiver);
                EnemyHealthAndArmor enemy = hit.collider.GetComponent <EnemyHealthAndArmor>();
                if (enemy != null)
                {
                    enemy.Damage((int)damage, hit);
                }

                ObjectProperty envir = hit.collider.GetComponent <ObjectProperty>();
                if (envir != null)
                {
                    envir.Hit((int)damage, hit);
                }
            }
        }
    }
示例#8
0
        public void When_NameFormattingConfigured_Then_FormattingAppliedToPropertyNames()
        {
            var config = new MixpanelConfig {
                MixpanelPropertyNameFormat = MixpanelPropertyNameFormat.TitleCase
            };

            var superProperties = CreateSuperProperties(
                // Must be overwritten by message property
                ObjectProperty.Default("PropertyA", PropertyOrigin.SuperProperty, 10),
                ObjectProperty.Default("PropertyC", PropertyOrigin.SuperProperty, 3));

            var rawProperties = new
            {
                PropertyA = 1,
                PropertyB = 2
            };

            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, superProperties, rawProperties, DistinctId, config);

            AssertMessageSuccess(
                messageBuildResult,
                Token,
                Event,
                DistinctId,
                new KeyValuePair <string, object>("Property A", 1),
                new KeyValuePair <string, object>("Property B", 2),
                new KeyValuePair <string, object>("Property C", 3));
        }
示例#9
0
        private void SaveSettings()
        {
            XDocument doc = new XDocument(new XElement("serversettings"));

            ObjectProperty.SaveProperties(this, doc.Root, true);

            doc.Root.SetAttributeValue("SubSelection", subSelectionMode.ToString());
            doc.Root.SetAttributeValue("ModeSelection", modeSelectionMode.ToString());

            doc.Root.SetAttributeValue("TraitorsEnabled", TraitorsEnabled.ToString());

            if (GameMain.NetLobbyScreen != null && GameMain.NetLobbyScreen.ServerMessage != null)
            {
                doc.Root.SetAttributeValue("ServerMessage", GameMain.NetLobbyScreen.ServerMessage.Text);
            }

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;
            settings.NewLineOnAttributes = true;

            using (var writer = XmlWriter.Create(SettingsFile, settings))
            {
                doc.Save(writer);
            }
        }
示例#10
0
    public void Interact()
    {
        // 이미 연결중인 상호작용 물체가 있는경우
        if (curObj)
        {
            // ObjectProperty가 넣어주기
            if (curObjAct == null)
            {
                curObjAct = curObj.GetComponent <ObjectProperty>();
            }

            isInteracting = false;
            curObjAct.StopInteracting();
            curObj    = null;
            curObjAct = null;

            isInteracting = false;
        }
        // 연결중인 상호작용 물체가 없던경우
        else
        {
            // 인접한 오브젝트가 있는경우에만 플레이어와 링크해준다.
            if (adjacentObj)
            {
                curObj        = adjacentObj;
                curObjAct     = curObj.GetComponent <ObjectProperty>();
                isInteracting = true;

                curObjAct.DoInteracting();
            }
        }
    }
示例#11
0
        private int GetMissingPropertyTarget(ObjectProperty property)
        {
            var category = (ObjectPropertyCategory)PrtgAPIHelpers.GetPropertyCategory(property);

            switch (category)
            {
            case ObjectPropertyCategory.Devices:
            case ObjectPropertyCategory.CredentialsForLinux:
            case ObjectPropertyCategory.CredentialsForVMware:
            case ObjectPropertyCategory.CredentialsForSNMP:
            case ObjectPropertyCategory.CredentialsForDatabases:
            case ObjectPropertyCategory.CredentialsForAmazon:
                return(Settings.Device);

            case ObjectPropertyCategory.HttpSpecific:
            case ObjectPropertyCategory.ProxySettingsForHttp:
                return(Settings.UpSensor);

            case ObjectPropertyCategory.SensorSettingsExeXml:
                return(Settings.ExeXml);

            case ObjectPropertyCategory.SensorFactorySpecific:
                return(Settings.SensorFactory);

            case ObjectPropertyCategory.DatabaseSpecific:
            case ObjectPropertyCategory.Data:
                return(Settings.SqlServerDB);

            default:
                throw new NotImplementedException($"Handler for object category '{category}' is not implemented");
            }
        }
示例#12
0
        public void EditText_NewObject_ReturnsStringArrToEdit(object value,
                                                              string[] expected)
        {
            var objectProperty = new ObjectProperty("Name", value);

            Assert.AreEqual(expected, objectProperty.EditText);
        }
示例#13
0
        private T GetObjectProperties <T>(int objectId, ObjectType objectType, ObjectProperty mandatoryProperty)
        {
            var response = GetObjectPropertiesRawInternal(objectId, objectType);

            var data = ResponseParser.GetObjectProperties <T>(response, ObjectEngine.XmlEngine, mandatoryProperty);

            if (data is TableSettings)
            {
                var table = (TableSettings)(object)data;

                if (table.scheduleStr == null || PrtgObject.GetId(table.scheduleStr) == -1)
                {
                    table.schedule = new LazyValue <Schedule>(table.scheduleStr, () => new Schedule(table.scheduleStr));
                }
                else
                {
                    table.schedule = new LazyValue <Schedule>(
                        table.scheduleStr,
                        () => GetSchedule(PrtgObject.GetId(table.scheduleStr)),
                        LazyThreadSafetyMode.PublicationOnly
                        );
                }
            }

            ValidateTypedProperties(objectId, objectType, data);

            return(data);
        }
示例#14
0
        /// <summary>
        ///     Generates any class to ObjectProperty data type
        /// </summary>
        /// <param name="Class">Give any class object to retrieve it's property and values.</param>
        /// <returns></returns>
        public static List <ObjectProperty> Get(object Class)
        {
            if (Class != null)
            {
                var propertise =
                    Class.GetType()
                    .GetProperties(TypeOfPropertise)
                    .Where(p => /* p.Name != "EntityKey" &&*/ p.Name != "EntityState")
                    .ToList();

                var list = new List <ObjectProperty>(propertise.Count);
                foreach (var prop in propertise)
                {
                    var val          = prop.GetValue(Class, null);
                    var propertyName = prop.Name;
                    var obj          = new ObjectProperty {
                        Name  = propertyName,
                        Value = val
                    };
                    list.Add(obj);
                }
                return(list);
            }
            return(null);
        }
示例#15
0
        public static void RunForValidUserProperties(
            MessageCandidate messageCandidate,
            Func <object, ValueParseResult> parseFn,
            Action <string, object> fn)
        {
            foreach (KeyValuePair <string, ObjectProperty> pair in messageCandidate.UserProperties)
            {
                string         formattedPropertyName = pair.Key;
                ObjectProperty objectProperty        = pair.Value;

                if (objectProperty.Origin == PropertyOrigin.SuperProperty)
                {
                    // Skip all non special super properties as they are not valid for people message
                    continue;
                }

                ValueParseResult result = parseFn(objectProperty.Value);
                if (!result.Success)
                {
                    continue;
                }

                fn(formattedPropertyName, result.Value);
            }
        }
        private float GetSoundVolume(ItemSound sound)
        {
            if (sound == null)
            {
                return(0.0f);
            }
            if (sound.VolumeProperty == "")
            {
                return(1.0f);
            }

            ObjectProperty op = null;

            if (properties.TryGetValue(sound.VolumeProperty.ToLowerInvariant(), out op))
            {
                float newVolume = 0.0f;
                try
                {
                    newVolume = (float)op.GetValue();
                }
                catch
                {
                    return(0.0f);
                }
                newVolume *= sound.VolumeMultiplier;

                return(MathHelper.Clamp(newVolume, 0.0f, 1.0f));
            }

            return(0.0f);
        }
示例#17
0
        public void DisplayText_NewObject_ReturnsDisplayTextInStringArr(
            string name, object value, object defaultValue, string[] expected)
        {
            var objectProperty = new ObjectProperty(name, value, defaultValue);

            Assert.AreEqual(expected, objectProperty.DisplayText);
        }
示例#18
0
        public DocTopic ParseProperty(ObjectProperty property, DocTopic parentClassTopic)
        {
            var topic = new DocTopic(_project)
            {
                Title = parentClassTopic.ClassInfo.Classname + "." + property.Name,
                //ListTitle = property.Name,
                DisplayType = "classproperty",

                ClassInfo = new ClassInfo
                {
                    MemberName = property.Name,
                    Signature  = property.Signature,
                    Scope      = property.Scope,
                    IsStatic   = property.Static,
                    Syntax     = property.Syntax
                },

                Remarks = property.Remarks,
                Example = property.Example,
                SeeAlso = property.SeeAlso,

                Parent   = parentClassTopic,
                ParentId = parentClassTopic?.Id
            };

            topic.Parent = parentClassTopic;
            topic.CreateRelativeSlugAndLink(topic);
            topic.Body = property.HelpText;

            return(topic);
        }
        private void TestIllegalCharacter(int objectId, ObjectProperty property, Func <Sensor, string> getValue)
        {
            var originalProperty = client.GetObjectProperty <string>(objectId, property);
            var originalValue    = getValue(client.GetSensor(objectId));

            AssertEx.AreEqual(originalValue, originalProperty, "Original value did not match original property value");

            var str = "first & second";

            try
            {
                client.SetObjectProperty(objectId, property, str);

                var newProperty = client.GetObjectProperty <string>(objectId, property);
                var newValue    = getValue(client.GetSensor(objectId));

                Assert.AreNotEqual(originalProperty, newProperty);
                Assert.AreNotEqual(newValue, originalValue);

                Assert.AreEqual(newProperty, newValue);
            }
            finally
            {
                client.SetObjectProperty(objectId, property, originalValue);
            }
        }
示例#20
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Type == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Type");
     }
     if (ContainerResource != null)
     {
         ContainerResource.Validate();
     }
     if (External != null)
     {
         External.Validate();
     }
     if (ObjectProperty != null)
     {
         ObjectProperty.Validate();
     }
     if (Pods != null)
     {
         Pods.Validate();
     }
     if (Resource != null)
     {
         Resource.Validate();
     }
 }
示例#21
0
        public void When_SuperPropertiesAndRawProperties_Then_RawPropertiesOverwriteSuperProperties()
        {
            var superProperties = CreateSuperProperties(
                // Must be overwritten by message property
                ObjectProperty.Default(StringPropertyName2, PropertyOrigin.SuperProperty, StringPropertyValue2 + "-Super"),
                ObjectProperty.Default(IntPropertyName, PropertyOrigin.SuperProperty, IntPropertyValue));

            var rawProperties = new Dictionary <string, object>
            {
                { StringPropertyName, StringPropertyValue },
                { StringPropertyName2, StringPropertyValue2 },
                { DecimalPropertyName, DecimalPropertyValue }
            };


            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, superProperties, rawProperties, DistinctId, null);

            AssertMessageSuccess(
                messageBuildResult,
                Token,
                Event,
                DistinctId,
                new KeyValuePair <string, object>(StringPropertyName, StringPropertyValue),
                new KeyValuePair <string, object>(StringPropertyName2, StringPropertyValue2),
                new KeyValuePair <string, object>(DecimalPropertyName, DecimalPropertyValue),
                new KeyValuePair <string, object>(IntPropertyName, IntPropertyValue));
        }
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (obj.GetType() != GetType())
            {
                return(false);
            }

            var value = obj as ComplexBuiltins;

            if (value == null)
            {
                return(false);
            }

            return
                (ObjectProperty != null && value.ObjectProperty != null &&
                 ObjectProperty.Equals(value.ObjectProperty) &&
                 StringProperty != null && value.StringProperty != null &&
                 StringProperty.Equals(value.StringProperty));
        }
示例#23
0
 public AdvancedVendor(string title, Type cashType, TextDefinition cashName, bool showCashName = true)
     : this(title)
 {
     CashProperty = new ObjectProperty();
     CashType     = cashType ?? typeof(Gold);
     CashName     = cashName ?? "Gold";
     ShowCashName = showCashName;
 }
        public object DeserializeObjectProperty(ObjectProperty property, string rawValue)
        {
#if DEBUG && DEBUG_SERIALIZATION
            return(((Func <XmlExpressionSerializerImpl, ObjectProperty, string, TypeBuilder, object>)lambda)(this, property, rawValue, typeBuilder));
#else
            return(((Func <XmlExpressionSerializerImpl, ObjectProperty, string, object>)lambda)(this, property, rawValue));
#endif
        }
    private void Awake()
    {
        direction = (int)Mathf.Pow(-1, Random.Range(0, 99) % 2);
        speed     = Random.Range(speedMin, speedMax) * ScreenInfo.screenCoefficient.x;

        spriteRenderer = GetComponent <SpriteRenderer>();
        objectProperty = GetComponent <ObjectProperty>();
    }
示例#26
0
        public void DefaultValue_NewProperty_ReturnsDefaultValueOrEmptyAsString(
            object defaultValue, string expectedValue)
        {
            var property = new ObjectProperty(string.Empty, string.Empty,
                                              defaultValue);

            Assert.AreEqual(expectedValue, property.DefaultValue);
        }
示例#27
0
 public AdvancedVendor(string title, string cashProp, TextDefinition cashName, bool showCashName = true)
     : this(title)
 {
     CashProperty = new ObjectProperty(cashProp);
     CashType     = typeof(ObjectProperty);
     CashName     = cashName ?? "Credits";
     ShowCashName = showCashName;
 }
示例#28
0
        public void AddProperty(string name, object value)
        {
            ObjectProperty property = new ObjectProperty();

            property.Name = name;
            property.SetValue(value);
            properties.Add(property);
        }
示例#29
0
        private string GetObjectPropertyName(ObjectProperty property)
        {
            var info = BaseSetObjectPropertyParameters <ObjectProperty> .GetPropertyInfoViaTypeLookup(property);

            var name = BaseSetObjectPropertyParameters <ObjectProperty> .GetParameterNameStatic(property, info);

            return(name);
        }
示例#30
0
        private static void ToDateTime(object model, ObjectProperty property, string val)
        {
            DateTime setter;

            if (DateTime.TryParse(val, out setter))
            {
                property.TrySetValue(model, setter);
            }
        }
示例#31
0
		private static ObjectProperty CreatePropertyFromValue(string propertyName, Value value)
		{
			ObjectProperty property = new ObjectProperty();
			property.Name = propertyName;
			// property.Expression = ?.Age
			// - cannot use expression,
			// if the value is returned from an enumerator, it has no meaningful expression
			property.IsAtomic = value.Type.IsPrimitive;
			property.IsNull = value.IsNull;
			property.Value = value.IsNull ? "" : value.InvokeToString();
			return property;
		}
示例#32
0
        /// <summary>
        /// Action method for adding child templates to this object
        /// </summary>
        /// <param name="token"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected virtual ConFileEntry Method_AddTemplate(Token token, string name)
        {
            // Get the internal property, and check if templates is null
            var info = GetProperty("__addTemplate").Value;
            if (Templates == null)
                Templates = new ObjectPropertyList<ChildTemplate>("addTemplate", token, info, this);

            // Create the object template value, and the object property
            ChildTemplate ct = new ChildTemplate(token.TokenArgs.Arguments.Last(), token);
            var prop = new ObjectProperty<ChildTemplate>("addTemplate", token, info, this);

            // We must also manually define the ValueInfo, because ChildTemplate
            // is NOT a RefernceType object
            prop.Argument = new ValueInfo<ChildTemplate>(ct);
            Templates.Items.Add(prop);

            return prop;
        }
示例#33
0
 /// <summary>
 /// Returns value indicating whether the given property is valid for being assigned to a search field.
 /// </summary>
 /// <param name="property">Object property to examine.</param>
 /// <returns>Value indicating whether the given property is valid for being assigned to a search field.</returns>
 private bool IsValidSearchFieldProperty(ObjectProperty property)
 {
     return property != null && property.Type != null && property.HasFlag(ObjectPropertyFlags.Searchable);
 }
示例#34
0
 /// <summary>
 /// Registers new search field that corresponds to a given object shape property.
 /// </summary>
 /// <param name="property">Object shape property.</param>
 /// <param name="updateIndexes">Value indicating whether to update indexes.</param>
 private void RegisterFieldInternal(ObjectProperty property, bool updateIndexes)
 {
     RegisterFieldInternal(property, string.Empty, updateIndexes);
 }
示例#35
0
        /// <summary>
        /// Registers new search field that corresponds to a given object shape property.
        /// </summary>
        /// <param name="property">Object shape property.</param>
        /// <param name="name">Field name.</param>
        /// <param name="updateIndexes">Value indicating whether to update indexes.</param>
        private void RegisterFieldInternal(ObjectProperty property, string name, bool updateIndexes)
        {
            SearchField field = null;
            string[] freeTextSearchableProperties = { "Name", "Description", "Tags" };

            System.Action tryAddField = () =>
                {
                    string fullName = GetFullName(field);

                    if (!_fullNameToField.ContainsKey(fullName))
                    {
                        _fields.Add(field);
                        _fullNameToField.Add(fullName, _fields.Count - 1);

                        if (updateIndexes)
                            UpdateIndexes();
                    }
                };

            if (property != null && IsValidSearchFieldProperty(property))
            {
                field = new SearchField();

                field.Name = name;

                if (string.IsNullOrEmpty(name))
                    field.Name = property.Name;

                field.Property = property;

                tryAddField();

                if (string.IsNullOrEmpty(name) && freeTextSearchableProperties.Any(p => string.Compare(p, property.Name, StringComparison.InvariantCultureIgnoreCase) == 0))
                {
                    field = new SearchField();

                    field.Name = string.Empty;
                    field.Property = property;

                    tryAddField();
                }
            }
        }
示例#36
0
 /// <summary>
 /// Registers new search field that corresponds to a given object shape property.
 /// </summary>
 /// <param name="property">Object shape property.</param>
 /// <exception cref="System.ArgumentNullException"><paramref name="property">property</paramref> is null.</exception>
 public void RegisterField(ObjectProperty property)
 {
     if (property == null)
         throw new ArgumentNullException("property");
     else
         RegisterFieldInternal(property, true);
 }
示例#37
0
        internal void AddPropertyAfter(ObjectProperty property, ConFileEntry afterItem)
        {
            // Make sure this entry doesnt already exist
            if (Entries.IndexOf(property) > 0)
                throw new Exception("The specified ObjectProperty already exists in this confile.");

            // Find the owner object
            int index = Entries.IndexOf(afterItem) + 1;
            if (index == 0)
                throw new Exception("The specified \"afterObject\" does not exist in this ConFile");

            // Insert item
            if (index == Entries.Count)
                Entries.Add(property);
            else
                Entries.Insert(index, property);
        }
示例#38
0
        private void WriteListKindOfObjectProperty(FieldInfo f, object v, Type ft, ObjectProperty p, System.Collections.IList list)
        {
            Console.Out.WriteLine("WriteListKindOfObjectProperty()");
            if (p.setorlist.Equals("LIST"))
            {
                ft = ft.GetGenericArguments()[0];
                //inst:IfcLengthMeasure_List_42.
                List<String> valuelist = new List<String>();
                m_writer.Write(";" + "\r\n");
                this.WriteIndent();
                m_writer.Write("ifcowl:" + p.name + " ");
                string xsdt = "";

                for (int i = 0; i < list.Count; i++)
                {
                    object e = list[i];
                    if (e is SEntity)
                    {
                        Type vt = e.GetType();
                        xsdt = vt.Name;
                        valuelist.Add(vt.Name + "_" + ((SEntity)e).OID);
                    }
                    else
                    {
                        Type vt = e.GetType();
                        xsdt = ft.Name;

                        object x = vt.GetField("Value").GetValue(e);

                        if (x is System.Collections.IList)
                        {
                            //IfcLineIndex, IfcArcIndex
                            //IfcSegmentIndexSelect
                            System.Collections.IList l = (System.Collections.IList)x;
                            List<string> sl = new List<string>();
                            for (int j = 0; j < l.Count; j++)
                            {
                                object elem = l[j];
                                if (elem != null) // should never be null, but be safe
                                {
                                    string encodedvalue = System.Security.SecurityElement.Escape(elem.GetType().GetField("Value").GetValue(elem).ToString());
                                    sl.Add(encodedvalue);
                                }
                            }

                            Console.Out.WriteLine("Message: Creating WriteListKindOfObjectProperty list with XSDType : " + l[0].GetType().GetField("Value").FieldType.Name);
                            ListObject newTypeListObject = GetListObject(vt.Name+"_", l[0].GetType().Name.ToString(), sl, l[0].GetType().GetField("Value").FieldType.Name);

                            Console.Out.WriteLine("Handling list of types - newListObject.URI : " + newTypeListObject.URI + " with type " + l[0].GetType().GetField("Value").FieldType.Name);
                            valuelist.Add(newTypeListObject.URI);
                        }
                        else
                        {
                            Console.Out.WriteLine("WriteInnerListKindOfObjectProperty.GetURIObject()");
                            URIObject newUriObject = GetURIObject(vt.Name, vt.GetField("Value").GetValue(e).ToString(), vt.GetField("Value").FieldType.Name);
                            Console.Out.WriteLine("Handling list of types - newUriObject.URI : " + newUriObject.URI + " with type " + vt.GetField("Value").FieldType.Name);
                            valuelist.Add(newUriObject.URI);
                        }

                    }
                }

                Console.Out.WriteLine("Message: Creating WriteListKindOfObjectProperty list with XSDType : " + "###ENTITY###");
                ListObject newListObject = GetListObject(xsdt + "_List_", xsdt, valuelist, "###ENTITY###");
                m_writer.Write("inst:" + newListObject.URI);
                //IfcRepresentation_List_#121_#145_#137
            }

            else if (p.setorlist.Equals("LISTOFLIST"))
            {
                //example:
                //owl: allValuesFrom expr:INTEGER_List_List;
                //owl: onProperty ifc:coordIndex_IfcTriangulatedFaceSet
                ft = ft.GetGenericArguments()[0].GetGenericArguments()[0];

                m_writer.Write(";" + "\r\n");
                this.WriteIndent();
                m_writer.Write("ifcowl:" + p.name + " ");

                List<string> listoflists = new List<string>();
                ListObject newListObject;

                for (int i = 0; i < list.Count; i++)
                {
                    //new List of List
                    List<string> valuelist = new List<string>();
                    System.Collections.IList listInner = (System.Collections.IList)list[i];
                    for (int j = 0; j < listInner.Count; j++)
                    {
                        object e = listInner[j];
                        if (e != null) // should never be null, but be safe
                        {
                            if (e is SEntity)
                            {
                                Type vt = e.GetType();
                                valuelist.Add(vt.Name + "_" + ((SEntity)e).OID);
                            }
                            else
                            {
                                Console.Out.WriteLine("WARNING - unhandled list of list: " + e.ToString());
                            }
                        }
                    }

                    //create listObject
                    Console.Out.WriteLine("Message: Creating WriteListKindOfObjectProperty list with XSDType : " + "###ENTITY###");
                    newListObject = GetListObject(ft.Name+"_List_", ft.Name, valuelist, "###ENTITY###");

                    //add to listOfList
                    listoflists.Add(newListObject.URI);
                }

                ListObject newListOfListObject = GetListOfListObject(ft.Name, listoflists, "###LISTOFLIST###");
                m_writer.Write("inst:" + newListOfListObject.URI);
                //Console.Out.WriteLine("written list of list prop (as obj. prop): attr = " + "inst:" + newListOfListObject.URI);
            }

            else {
                for (int i = 0; i < list.Count; i++)
                {
                    object e = list[i];
                    if (e is SEntity)
                    {
                        if (p.setorlist.Equals("SET"))
                        {
                            m_writer.Write(";" + "\r\n");
                            WriteIndent();
                            m_writer.Write("ifcowl:" + p.name + " ");

                            Type vt = e.GetType();
                            this.m_writer.Write("inst:" + vt.Name + "_" + ((SEntity)e).OID);
                            Console.Out.WriteLine("written object prop to SET:" + p.name + " - " + vt.Name + "_" + ((SEntity)e).OID);
                        }
                        else if (p.setorlist.Equals("LIST") || p.setorlist.Equals("LISTOFLIST"))
                        {
                            //Already handled in the code above
                        }
                        else
                        {
                            Console.Out.WriteLine("Warning: Found something that should not be possible : " + p.name + " - " + ((SEntity)e).OID + " - not handled");
                        }
                    }
                    else if (e is System.Collections.IList)
                    {
                        Console.Out.WriteLine("Skipping: because already handled above (LIST OF LIST)");
                    }
                    else
                    {
                        //#77= IFCTRIMMEDCURVE(#83,(IFCPARAMETERVALUE(0.0),#78),(IFCPARAMETERVALUE(1.52202550844946),#79),.T.,.PARAMETER.);
                        //#78= IFCCARTESIANPOINT((0.0,0.0,0.0));

                        // if flat-list (e.g. structural load Locations) or list of strings (e.g. IfcPostalAddress.AddressLines), must wrap
                        //this.WriteValueWrapper(e);
                        m_writer.Write(";" + "\r\n");
                        WriteIndent();
                        m_writer.Write("ifcowl:" + p.name + " ");
                        Type vt = e.GetType();
                        Console.Out.WriteLine("WriteListKindOfObjectProperty.GetURIObject() - A");
                        URIObject newUriObject = GetURIObject(vt.Name, vt.GetField("Value").GetValue(e).ToString(), vt.GetField("Value").FieldType.Name);
                        if (newUriObject.XSDType == "Value")
                            Console.Out.WriteLine("warning: found Value XSDType");
                        m_writer.Write("inst:" + newUriObject.URI);
                        Console.Out.WriteLine("WARNING-TOCHECK: found list of data values - handled : " + "ifcowl:" + p.name + " inst: " + newUriObject.URI);
                    }
                }
            }
        }
示例#39
0
		public virtual void Visit(ObjectProperty mapping)
		{
		}
示例#40
0
		public virtual void Visit(ObjectProperty property) { }
示例#41
0
        internal void AddProperty(ObjectProperty property)
        {
            // To speed up the initial parsing, we only insert
            // to position if we are finalized
            if (Finished)
            {
                // Make sure this entry doesnt already exist
                if (Entries.IndexOf(property) > 0)
                    throw new Exception("The specified ObjectProperty already exists in this confile.");

                // Find the owner object
                int index = Entries.IndexOf(property.Owner) + 1;
                if (index == 0)
                    throw new Exception("The property owner does not exist in this ConFile");

                // Search for next object
                for (int i = index + 1; i < Entries.Count; i++)
                {
                    TokenType kind = Entries[i].Token.Kind;
                    if (kind == TokenType.ActiveSwitch || kind == TokenType.ObjectStart)
                    {
                        Entries.Insert(i, property);
                        return;
                    }
                }
            }

            // If we are here, just append to the end
            Entries.Add(property);
        }
示例#42
0
		public ObjectInspectorData (object target)
		{
			this.target = target;
			this.targetType = target != null ? target.GetType () : typeof(object);

			IsList = (target is IList) || (target is IDictionary);

			if (IsList) {
				Properties = new ObjectProperty[0];
				Hierarchy = new Type[0];
			} else {

				var props = targetType.GetProperties ().
					Where (x =>
						x.GetIndexParameters ().Length == 0 &&
						x.GetMethod != null &&
						!x.GetMethod.IsStatic).
					Select (GetObjectPropertyFromProperty);
				var fields = targetType.GetFields ().
					Where (x =>
						!x.IsStatic).
					Select (GetObjectPropertyFromField);

				Properties = fields.Concat (props).OrderBy (x => x.Name).ToArray ();

				var h = new List<Type> ();
				h.Add (this.targetType);
				while (h [h.Count - 1] != typeof(object)) {
					var bt = h [h.Count - 1].BaseType;
					if (bt != null) {
						h.Add (bt);
					} else {
						break;
					}
				}
				h.Remove (this.targetType);
				h.Remove (typeof(object));
				h.Remove (typeof(ValueType));
				Hierarchy = h.ToArray ();
			}

			var elementMax = 1000;

			if (this.target is IDictionary) {
				var res = new List<ObjectElement> ();
				IDictionaryEnumerator de = ((IDictionary)this.target).GetEnumerator ();
				while (res.Count < elementMax && de.MoveNext ()) {
					res.Add (new ObjectElement {
						Title = string.Format ("{0}: {1}", de.Key, de.Value),
						Value = de.Value,
					});
				}
				Elements = res.ToArray ();
			} else {

				var ie = this.target as IEnumerable;
				if (ie != null && !(this.target is string)) {
					try {
						Elements = ie.Cast<object> ().Take (elementMax).Select ((x, i) => new ObjectElement {
							Title = string.Format ("{0}: {1}", i, x),
							Value = x,
						}).ToArray ();					
					} catch (Exception ex) {
						Log (ex);
					}
				}
			}
			if (Elements == null) {
				Elements = new ObjectElement[0];
			}

			Title = this.targetType.Name;

			if (target == null) {
				ToStringValue = "null";
				HashDisplayString = "#0";
			}
			else {
				try {
					ToStringValue = target.ToString ();
				} catch (Exception ex) {
					ToStringValue = ex.ToString ();
					Log (ex);
				}
				try {
					HashDisplayString = "#" + target.GetHashCode ();
				} catch (Exception ex) {
					HashDisplayString = ex.ToString ();
					Log (ex);
				}
			}
		}