コード例 #1
0
        public void RemovePropertyStringTest()
        {
            PropertyCollection collection = new PropertyCollection(new string[0]);

            AttachEvents(collection);

            Property prop1 = new StringProperty("test", "orange");
            Property prop2 = new StringProperty("two", "number");

            collection.Add(prop1);
            collection.Add(prop2);

            collection.PropertyRemoved += (s, e) =>
            {
                Assert.AreSame(prop1, e.Property);
                Assert.AreEqual(1, collection.Count);
                Assert.IsFalse(collection.Contains("test"));
                Assert.IsTrue(collection.Contains("two"));
                Assert.IsFalse(collection.Contains(prop1));
                Assert.IsTrue(collection.Contains(prop2));
            };

            _eventsFired = EventFlags.None;

            collection.Remove("test");

            Assert.AreEqual(EventFlags.PropertyRemoved | EventFlags.Modified, _eventsFired);
        }
コード例 #2
0
        public void RenamePropertyTest()
        {
            PropertyCollection collection = new PropertyCollection(new string[0]);

            AttachEvents(collection);

            StringProperty prop = new StringProperty("test", "orange");

            collection.PropertyRenamed += (s, e) =>
            {
                Assert.AreEqual("test", e.OldName);
                Assert.AreEqual("two", e.NewName);
                Assert.AreEqual(1, collection.Count);
                Assert.IsFalse(collection.Contains("test"));
                Assert.IsTrue(collection.Contains("two"));
                Assert.IsTrue(collection.Contains(prop));
            };

            collection.Add(prop);

            _eventsFired = EventFlags.None;

            prop.Name = "two";

            Assert.AreEqual(EventFlags.PropertyRenamed | EventFlags.Modified, _eventsFired);
        }
コード例 #3
0
ファイル: STABLE.cs プロジェクト: paulorades/externals
        /// <summary>
        /// Sets the properties specified in the configuration string
        /// </summary>
        /// <param name="props">Properties to set</param>
        /// <returns>False if properties were specified that are not know, otherwise true</returns>
        public override bool setProperties(PropertyCollection props)
        {
            if (props.Contains("digest_timeout"))
            {
                digest_timeout = Convert.ToInt64(props["digest_timeout"]);
                props.Remove("digest_timeout");
            }
            if (props.Contains("desired_avg_gossip"))
            {
                desired_avg_gossip = Convert.ToInt64(props["desired_avg_gossip"]);
                props.Remove("desired_avg_gossip");
            }
            if (props.Contains("stability_delay"))
            {
                stability_delay = Convert.ToInt64(props["stability_delay"]);
                props.Remove("stability_delay");
            }
            if (props.Contains("max_gossip_runs"))
            {
                max_gossip_runs = Convert.ToInt32(props["max_gossip_runs"]);
                num_gossip_runs = max_gossip_runs;
                props.Remove("max_gossip_runs");
            }

            if (props.Count > 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #4
0
ファイル: NAKACK.cs プロジェクト: paulorades/externals
 /// <summary>
 /// Sets the properties specified in the configuration string
 /// </summary>
 /// <param name="props">Properties to set</param>
 /// <returns>False if properties were specified that are not know, otherwise true</returns>
 public override bool setProperties(PropertyCollection props)
 {
     if (props.Contains("retransmit_timeout"))
     {
         String[] strArray = Convert.ToString(props["retransmit_timeout"]).Split(new Char[] { ',' });
         for (int i = 0; i < strArray.Length; i++)
         {
             retransmit_timeout[i] = Convert.ToInt64(strArray[i]);
         }
         props.Remove("retransmit_timeout");
     }
     if (props.Contains("gc_lag"))
     {
         gc_lag = Convert.ToInt32(props["gc_lag"]);
         if (gc_lag < 1)
         {
             if (Trace.trace)
             {
                 Trace.error("NAKACK.setProperties()", "gc_lag has to be at least 1 (set to 10)");
             }
             gc_lag = 10;
         }
         props.Remove("gc_lag");
     }
     if (props.Contains("max_xmit_size"))
     {
         max_xmit_size = Convert.ToInt64(props["max_xmit_size"]);
         props.Remove("max_xmit_size");
     }
     if (props.Count > 0)
     {
         return(false);
     }
     return(true);
 }
コード例 #5
0
        /// <summary>
        /// Sets the properties specified in the configuration string
        /// </summary>
        /// <param name="props">Properties to set</param>
        /// <returns>False if properties were specified that are not know, otherwise true</returns>
        public override bool setProperties(PropertyCollection props)
        {
            if (props.Contains("timeout"))
            {
                timeout = Convert.ToInt64(props["timeout"]);
                props.Remove("timeout");
            }

            if (props.Contains("num_msgs"))
            {
                num_msgs = Convert.ToInt32(props["num_msgs"]);
                if (num_msgs <= 0)
                {
                    if (Trace.trace)
                    {
                        Trace.warn("VERIFY_SUSPECT.setProperties()", "num_msgs is invalid (" +
                                   num_msgs + "): setting it to 1");
                    }
                    num_msgs = 1;
                }
                props.Remove("num_msgs");
            }

            if (props.Count > 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #6
0
        public void ModifyPropertyTest()
        {
            PropertyCollection collection = new PropertyCollection(new string[0]);

            AttachEvents(collection);

            StringProperty prop = new StringProperty("test", "orange");

            collection.PropertyModified += (s, e) =>
            {
                Assert.AreSame(prop, e.Property);
                Assert.AreEqual(1, collection.Count);
                Assert.IsTrue(collection.Contains("test"));
                Assert.IsTrue(collection.Contains(prop));
                Assert.AreEqual("blue", e.Property.ToString());
            };

            collection.Add(prop);

            _eventsFired = EventFlags.None;

            prop.Value = "blue";

            Assert.AreEqual(EventFlags.PropertyModified | EventFlags.Modified, _eventsFired);
        }
コード例 #7
0
ファイル: UDP.cs プロジェクト: paulorades/externals
        /// <summary>
        /// Sets the properties specified in the configuration string
        /// </summary>
        /// <param name="props">Properties to set</param>
        /// <returns>False if properties were specified that are not know, otherwise true</returns>
        public override bool setProperties(PropertyCollection props)
        {
            if (props.Contains("mcast_addr"))
            {
                mcast_addr.IP = IPAddress.Parse(Convert.ToString(props["mcast_addr"]));
                props.Remove("mcast_addr");
            }
            if (props.Contains("mcast_port"))
            {
                mcast_addr.Port = Convert.ToInt32(props["mcast_port"]);
                props.Remove("mcast_port");
            }
            if (props.Contains("bind_addr"))
            {
                bind_addr.IP = IPAddress.Parse(Convert.ToString(props["bind_addr"]));
                props.Remove("bind_addr");
            }
            if (props.Contains("bind_port"))
            {
                bind_addr.Port = Convert.ToInt32(props["mcast_port"]);
                props.Remove("mcast_port");
            }
            if (props.Contains("ip_ttl"))
            {
                ip_ttl = Convert.ToInt32(props["ip_ttl"]);
                props.Remove("ip_ttl");
            }
            if (props.Contains("bind_port"))
            {
                bind_addr.Port = Convert.ToInt32(props["bind_port"]);
                props.Remove("bind_port");
            }
            if (props.Contains("mcast_send_buf_size"))
            {
                mcast_send_buf_size = Convert.ToInt32(props["mcast_send_buf_size"]);
                props.Remove("mcast_send_buf_size");
            }
            if (props.Contains("mcast_recv_buf_size"))
            {
                mcast_recv_buf_size = Convert.ToInt32(props["mcast_recv_buf_size"]);
                props.Remove("mcast_recv_buf_size");
            }
            if (props.Contains("ucast_send_buf_size"))
            {
                ucast_send_buf_size = Convert.ToInt32(props["ucast_send_buf_size"]);
                props.Remove("ucast_send_buf_size");
            }
            if (props.Contains("ucast_recv_buf_size"))
            {
                ucast_recv_buf_size = Convert.ToInt32(props["ucast_recv_buf_size"]);
                props.Remove("ucast_recv_buf_size");
            }

            if (props.Count > 0)
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
        /// <summary>
        /// Sets the properties specified in the configuration string
        /// </summary>
        /// <param name="props">Properties to set</param>
        /// <returns>False if properties were specified that are not know, otherwise true</returns>
        public override bool setProperties(PropertyCollection props)
        {
            if (props.Contains("timeout"))
            {
                String[] strArray = Convert.ToString(props["timeout"]).Split(new Char[] { ',' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    timeout[i] = Convert.ToInt64(strArray[i]);
                }
                props.Remove("timeout");
            }
            if (props.Contains("window_size"))
            {
                window_size = Convert.ToInt32(props["window_size"]);
                props.Remove("window_size");
            }
            if (props.Contains("min_threshold"))
            {
                min_threshold = Convert.ToInt32(props["min_threshold"]);
                props.Remove("min_threshold");
            }

            if (props.Count > 0)
            {
                return(false);
            }

            // Some sanity checks
            if ((window_size > 0 && min_threshold <= 0) || (window_size <= 0 && min_threshold > 0))
            {
                if (Trace.trace)
                {
                    Trace.error("UNICAST.setProperties()",
                                "window_size and min_threshold have to be both set if one of them is set");
                }
                return(false);
            }
            if (window_size > 0 && min_threshold > 0 && window_size < min_threshold)
            {
                if (Trace.trace)
                {
                    Trace.error("UNICAST.setProperties()", "min_threshold (" + min_threshold +
                                ") has to be less than window_size (" + window_size + ")");
                }
                return(false);
            }
            return(true);
        }
コード例 #9
0
        /// <summary>
        /// Get a value typed property for the specified attribute name.
        /// </summary>
        /// <typeparam name="T">The return value type that should be returned.</typeparam>
        /// <param name="properties">The properties to extract the value from.</param>
        /// <param name="attributeName">The name of the attribute to get the property value for.</param>
        /// <param name="index">The array index of the proeprty we want to return (all properties are multi-valued).</param>
        /// <returns>The typed value of the property at the specified index if it can be found and cast, otherwise null/default.</returns>
        public static T?GetValue <T>(this PropertyCollection properties, string attributeName, int index = 0) where T : struct
        {
            var result = new T?();

            if (properties.Contains(attributeName) && properties[attributeName].Count >= index)
            {
                try
                {
                    if (typeof(T) == typeof(Guid))
                    {
                        var guid = properties.GetReference <string>(attributeName, index);
                        result = (T)(object)new Guid(guid);
                    }
                    else
                    {
                        result = (T)properties[attributeName][index];
                    }
                }
                catch
                {
                    // NOTE: Ignore the error in casting, we will return the default of T?.
                }
            }

            return(result);
        }
コード例 #10
0
        public void Contains_KnownProperty()
        {
            var properties         = new PropertyBase[] { CreateProperty() };
            var propertyCollection = new PropertyCollection(properties);

            Assert.That(propertyCollection.Contains("Scalar"), Is.True);
        }
コード例 #11
0
        public Enemy Spawn(EnemyType type, Vector3 pos, PropertyCollection props)
        {
            Enemy e = null;

            switch (type)
            {
            case EnemyType.Asteroid:
                e = new Asteroid(pos, spriteSheets["Asteroid"]);
                break;

            case EnemyType.Omega:
                e = new Omega(pos, spriteSheets["Omega"]);
                break;

            case EnemyType.Turret:
                e = new Turret(pos, spriteSheets["Turret"], props.Contains("Inverted"));
                break;

            case EnemyType.Squid:
                e = new Squid(pos, spriteSheets["Squid"]);
                break;
            }

            Enemies.Add(e);
            return(e);
        }
コード例 #12
0
        public void Contains_UnkownProperty()
        {
            var properties         = new PropertyBase[] { CreateProperty() };
            var propertyCollection = new PropertyCollection(properties);

            Assert.That(propertyCollection.Contains("Invalid"), Is.False);
        }
コード例 #13
0
        private Dictionary <string, object> GetGroupsMember(PropertyCollection subgroupProps, Dictionary <string, object> subgroup)
        {
            if (subgroupProps.Contains("member"))
            {
                var subgroupMember = new List <Dictionary <string, object> >();
                foreach (Object subgroupProp in subgroupProps["member"])
                {
                    DirectoryEntry sub_gpMemberEntry = new DirectoryEntry("LDAP://" + subgroupProp);
                    var            new_subgroupProps = sub_gpMemberEntry.Properties;
                    subgroupMember.Add(GetGroupsMember(new_subgroupProps, subgroup));
                }
                foreach (Object subgroupProp in subgroupProps["cn"])
                {
                    subgroup.Add(subgroupProp.ToString(), subgroupMember);
                }

                return(subgroup);
            }
            else
            {
                var    userDetail     = new Dictionary <string, object>();
                var    userProps      = subgroupProps;
                string USERNAME_FIELD = !string.IsNullOrEmpty(AMSCore.WebConfigReadKey("AD_USERNAME_FIELD")) ? AMSCore.WebConfigReadKey("AD_USERNAME_FIELD") : "SAMAccountName";
                object obVal          = userProps[USERNAME_FIELD].Value;
                if (null != obVal)
                {
                    userDetail.Add(USERNAME_FIELD, obVal.ToString());
                }
                return(userDetail);
            }
        }
コード例 #14
0
 public static object getpropertyvalue(PropertyCollection Properties, string PropertyName)
 {
     if (Properties.Contains(PropertyName))
     {
         if (Properties[PropertyName].Value != null)
         {
             try
             {
                 //PropertyValueCollection ValueCollection = Properties[PropertyName];
                 //for (int i = 0; i < ValueCollection.Count; i++)
                 //{
                 //    if (i == 0)
                 //    {
                 //        result[count] = ValueCollection[i].ToString();
                 //    }
                 //    else
                 //    {
                 //        result[count] += "|" + ValueCollection[i].ToString();
                 //    }
                 //}
                 return(Properties[PropertyName].Value);
             }
             catch (Exception ex)
             {
             }
         }
     }
     return(null);
 }
コード例 #15
0
        public void Property_Contains_Case_Insensitive_Compare()
        {
            var collection = new PropertyCollection();

            collection.Add(new Property(new PropertyType("propEditor", DataTypeDatabaseType.Nvarchar, "test")));

            Assert.IsTrue(collection.Contains("Test"));
        }
コード例 #16
0
        public PropertyCategory LookupCategory(string propertyName)
        {
            if (_classManager.ContainsDefinition(propertyName))
            {
                return(PropertyCategory.Predefined);
            }
            if (_custom.Contains(propertyName))
            {
                return(PropertyCategory.Custom);
            }
            if (_customParent != null && _customParent.PropertyManager.CustomProperties.Contains(propertyName))
            {
                return(PropertyCategory.Inherited);
            }

            return(PropertyCategory.None);
        }
コード例 #17
0
 /// <summary>
 /// Get properties
 /// </summary>
 /// <param name="directoryEntryProperties"></param>
 /// <param name="property"></param>
 /// <returns></returns>
 internal static XElement getProperty(PropertyCollection directoryEntryProperties, string property)
 {
     if (directoryEntryProperties.Contains(property))
     {
         return(new XElement((XName)property, (object)directoryEntryProperties[property].Value.ToString()));
     }
     return(new XElement((XName)property, (object)""));
 }
コード例 #18
0
        /// <summary>
        /// Gets a collection of reference typed properties for the specified attribute name.
        /// </summary>
        /// <typeparam name="T">The type we expect to be contained in the collection.</typeparam>
        /// <param name="properties">The properties to extract our values from.</param>
        /// <param name="attributeName">The name of the attribute to get the property values for.</param>
        /// <returns>
        /// A collection of properties, or null/empty if they cannot be found.
        /// </returns>
        /// <remarks>The collection may still contain null values, as we are using the friendly 'as' casting method.</remarks>
        public static IEnumerable <T> GetCollectionReference <T>(this PropertyCollection properties, string attributeName) where T : class
        {
            if (properties.Contains(attributeName) && properties[attributeName].Count > 0)
            {
                return((from object attribute in properties[attributeName] select attribute as T).ToList());
            }

            return(Enumerable.Empty <T>());
        }
コード例 #19
0
    public void Property_Contains_Case_Insensitive_Compare()
    {
        var collection = new PropertyCollection
        {
            new Property(new PropertyType(TestHelper.ShortStringHelper, "propEditor", ValueStorageType.Nvarchar, "test")),
        };

        Assert.IsTrue(collection.Contains("Test"));
    }
コード例 #20
0
        /// <summary>
        /// Removes and sets all generic properties of a Protocol, then passes remainder of properties on to implementation
        /// </summary>
        /// <param name="properties">Collection of properties</param>
        /// <returns>False if properties were specified that are not know, otherwise true</returns>
        public bool setPropertiesInternal(PropertyCollection properties)
        {
            this.props = properties;

            if (props.Contains("down_thread"))
            {
                down_thread = Convert.ToBoolean(props["down_thread"]);
                props.Remove("down_thread");
            }

            if (props.Contains("up_thread"))
            {
                up_thread = Convert.ToBoolean(props["up_thread"]);
                props.Remove("up_thread");
            }

            return(setProperties(props));
        }
コード例 #21
0
        public void AddPropertyTest()
        {
            PropertyCollection collection = new PropertyCollection(new string[0]);
            AttachEvents(collection);

            Property prop = new StringProperty("test", "orange");

            collection.PropertyAdded += (s, e) =>
            {
                Assert.AreSame(prop, e.Property);
                Assert.AreEqual(1, collection.Count);
                Assert.IsTrue(collection.Contains("test"));
                Assert.IsTrue(collection.Contains(prop));
            };

            collection.Add(prop);

            Assert.AreEqual(EventFlags.PropertyAdded | EventFlags.Modified, _eventsFired);
        }
コード例 #22
0
ファイル: AdUser.cs プロジェクト: DatasourceDev/IDM
 private static string getpropertyvalue(PropertyCollection Properties, string PropertyName)
 {
     if (Properties.Contains(PropertyName))
     {
         if (Properties[PropertyName].Value != null)
         {
             return(Properties[PropertyName].Value.ToString());
         }
     }
     return("");
 }
コード例 #23
0
        public void AddPropertyTest()
        {
            PropertyCollection collection = new PropertyCollection(new string[0]);

            AttachEvents(collection);

            Property prop = new StringProperty("test", "orange");

            collection.PropertyAdded += (s, e) =>
            {
                Assert.AreSame(prop, e.Property);
                Assert.AreEqual(1, collection.Count);
                Assert.IsTrue(collection.Contains("test"));
                Assert.IsTrue(collection.Contains(prop));
            };

            collection.Add(prop);

            Assert.AreEqual(EventFlags.PropertyAdded | EventFlags.Modified, _eventsFired);
        }
コード例 #24
0
ファイル: PING.cs プロジェクト: paulorades/externals
        /// <summary>
        /// Sets the properties specified in the configuration string
        /// </summary>
        /// <param name="props">Properties to set</param>
        /// <returns>False if properties were specified that are not know, otherwise true</returns>
        public override bool setProperties(PropertyCollection props)
        {
            if (props.Contains("num_initial_members"))
            {
                num_initial_members = Convert.ToInt32(props["num_initial_members"]);
                props.Remove("num_initial_members");
            }
            if (props.Contains("timeout"))
            {
                timeout = Convert.ToInt64(props["timeout"]);
                props.Remove("timeout");
            }

            if (props.Count > 0)
            {
                return(false);
            }

            return(true);
        }
コード例 #25
0
        private static string GetPropertyValue(string name, PropertyCollection propertyCollection)
        {
            if (propertyCollection.Contains(name))
            {
                PropertyValueCollection propertyValueCollection = propertyCollection[name];

                if (propertyValueCollection.Count > 0)
                {
                    return(propertyValueCollection[0].ToString());
                }
            }

            return(string.Empty);
        }
コード例 #26
0
ファイル: FD.cs プロジェクト: paulorades/externals
        /// <summary>
        /// Sets the properties specified in the configuration string
        /// </summary>
        /// <param name="props">Properties to set</param>
        /// <returns>False if properties were specified that are not know, otherwise true</returns>
        public override bool setProperties(PropertyCollection props)
        {
            if (props.Contains("timeout"))
            {
                timeout = Convert.ToInt64(props["timeout"]);
                props.Remove("timeout");
            }
            if (props.Contains("max_tries"))
            {
                max_tries = Convert.ToInt32(props["max_tries"]);
                props.Remove("max_tries");
            }
            if (props.Contains("shun"))
            {
                shun = Convert.ToBoolean(props["shun"]);
                props.Remove("shun");
            }

            if (props.Count > 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #27
0
ファイル: DISCARD.cs プロジェクト: paulorades/externals
        /// <summary>
        /// Sets the properties specified in the configuration string
        /// </summary>
        /// <param name="props">Properties to set</param>
        /// <returns>False if properties were specified that are not know, otherwise true</returns>
        public override bool setProperties(PropertyCollection props)
        {
            if (props.Contains("up"))
            {
                probUp = Convert.ToDouble(props["up"]);
                props.Remove("up");
            }
            if (props.Contains("down"))
            {
                probDown = Convert.ToDouble(props["down"]);
                props.Remove("down");
            }
            if (props.Contains("excludeItself"))
            {
                excludeItself = Convert.ToBoolean(props["excludeItself"]);
                props.Remove("excludeItself");
            }

            if (props.Count > 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #28
0
        /// <summary>
        /// Gets the value for the specified attribute name.
        /// </summary>
        /// <typeparam name="T">The return type the value should be cast to.</typeparam>
        /// <param name="properties">The properties to extract the value from.</param>
        /// <param name="attributeName">The name of the attribute to get the property value for.</param>
        /// <param name="index">The array index of the property we want to return (all properties are multi-valued).</param>
        /// <returns>The typed value of the property at the specified index if it can be found, otherwise null/empty.</returns>
        public static T GetReference <T>(this PropertyCollection properties, string attributeName, int index = 0) where T : class
        {
            if (properties.Contains(attributeName) && properties[attributeName].Count >= index)
            {
                return(properties[attributeName][index] as T);
            }

            if (typeof(T) == typeof(string))
            {
                // TODO: Is this really needed if the requestor is aware we return null and is using the null-conditional operator '?.'
                // We couldn't find what the requestor asked for, but they wanted a string.
                return((T)(object)string.Empty);
            }

            return(null);
        }
コード例 #29
0
ファイル: AuthUtility.cs プロジェクト: weijx-xa/test
 private static string GetFirstValue(PropertyCollection res, string key)
 {
     if (res.Contains(key))
     {
         var values = res[key];
         if (values.Count > 0 && values[0] != null)
         {
             return(values[0].ToString());
         }
         else
         {
             Log.Warn("域中此字段无值:" + key);
         }
     }
     else
     {
         Log.Warn("域中不包含此字段:" + key);
     }
     return(String.Empty);
 }
コード例 #30
0
        /// <summary>
        ///     Adds a key to a concrete <see cref="PropertyCollection"/> instance, checking
        ///     if duplicate keys are allowed in the configuration
        /// </summary>
        /// <param name="key">
        ///     Key name
        /// </param>
        /// <param name="value">
        ///     Key's value
        /// </param>
        /// <param name="keyDataCollection">
        ///     <see cref="Property"/> collection where the key should be inserted
        /// </param>
        /// <param name="sectionName">
        ///     Name of the section where the <see cref="PropertyCollection"/> is contained.
        ///     Used only for logging purposes.
        /// </param>
        private void AddKeyToKeyValueCollection(string key, string value, PropertyCollection keyDataCollection, string sectionName)
        {
            // Check for duplicated keys
            if (keyDataCollection.Contains(key))
            {
                // We already have a key with the same name defined in the current section
                HandleDuplicatedKeyInCollection(key, value, keyDataCollection, sectionName);
            }
            else
            {
                // Save the keys
                keyDataCollection.Add(key, value);
            }

            if (Configuration.ParseComments)
            {
                keyDataCollection.FindByKey(key).Comments = CurrentCommentListTemp;
                CurrentCommentListTemp.Clear();
            }
        }
コード例 #31
0
ファイル: GMS.cs プロジェクト: paulorades/externals
        /// <summary>
        /// Sets the properties specified in the configuration string
        /// </summary>
        /// <param name="props">Properties to set</param>
        /// <returns>False if properties were specified that are not know, otherwise true</returns>
        public override bool setProperties(PropertyCollection props)
        {
            if (props.Contains("shun"))
            {
                shun = Convert.ToBoolean(props["shun"]);
                props.Remove("shun");
            }
            if (props.Contains("print_local_addr"))
            {
                print_local_addr = Convert.ToBoolean(props["print_local_addr"]);
                props.Remove("print_local_addr");
            }
            if (props.Contains("join_timeout"))
            {
                join_timeout = Convert.ToInt64(props["join_timeout"]);
                props.Remove("join_timeout");
            }
            if (props.Contains("join_retry_timeout"))
            {
                join_retry_timeout = Convert.ToInt64(props["join_retry_timeout"]);
                props.Remove("join_retry_timeout");
            }
            if (props.Contains("leave_timeout"))            // time to wait until coord responds to LEAVE req.
            {
                leave_timeout = Convert.ToInt64(props["leave_timeout"]);
                props.Remove("leave_timeout");
            }
            if (props.Contains("digest_timeout"))            // time to wait for GET_DIGEST_OK from PBCAST
            {
                digest_timeout = Convert.ToInt64(props["digest_timeout"]);
                props.Remove("digest_timeout");
            }
            if (props.Contains("disable_initial_coord"))            // time to wait for GET_DIGEST_OK from PBCAST
            {
                disable_initial_coord = Convert.ToBoolean(props["disable_initial_coord"]);
                props.Remove("disable_initial_coord");
            }

            if (props.Count > 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #32
0
        public void RemovePropertyTest()
        {
            PropertyCollection collection = new PropertyCollection(new string[0]);
            AttachEvents(collection);

            Property prop1 = new StringProperty("test", "orange");
            Property prop2 = new StringProperty("two", "number");

            collection.Add(prop1);
            collection.Add(prop2);

            collection.PropertyRemoved += (s, e) =>
            {
                Assert.AreSame(prop1, e.Property);
                Assert.AreEqual(1, collection.Count);
                Assert.IsFalse(collection.Contains("test"));
                Assert.IsTrue(collection.Contains("two"));
                Assert.IsFalse(collection.Contains(prop1));
                Assert.IsTrue(collection.Contains(prop2));
            };

            _eventsFired = EventFlags.None;

            collection.Remove(prop1);

            Assert.AreEqual(EventFlags.PropertyRemoved | EventFlags.Modified, _eventsFired);
        }
コード例 #33
0
ファイル: Audit.cs プロジェクト: ccellar/crmaudit
 /// <summary>
 /// Gets an Object from a Dynamic Entity's Property collection
 /// </summary>
 /// <param name="col"></param>
 /// <param name="propertyName"></param>
 /// <returns></returns>
 private object GetObjectFromProperty(PropertyCollection col, string propertyName)
 {
     return col.Contains(propertyName) ? col[propertyName] : null;
 }
コード例 #34
0
ファイル: BuildContext.cs プロジェクト: jlyonsmith/Playroom
        public BuildContext(String properties, ParsedPath contentFilePath)
        {
            ContentFilePath = contentFilePath;

            ContentFile = new ContentFileV4();
            ContentFile.Load(ContentFilePath);

            WriteMessage("Read content file '{0}'", ContentFilePath);

            Properties = new PropertyCollection();

            // Start with the environment
            Properties.AddFromEnvironment();

            // Set defaults for important locations
            Properties.Set("BuildContentDir", new ParsedPath(Assembly.GetExecutingAssembly().Location, PathType.File).VolumeAndDirectory.ToString());
            Properties.Set("ContentFileDir", contentFilePath.VolumeAndDirectory);
            Properties.Set("InputDir", contentFilePath.VolumeAndDirectory);
            Properties.Set("OutputDir", contentFilePath.VolumeAndDirectory);

            // Now override with from content file
            Properties.AddFromList(ContentFile.Properties.Select(nv => new KeyValuePair<string, string>(nv.Name.Value, nv.Value.Value)));

            // Now override with command line
            Properties.AddFromString(properties);

            // Add content file hash location if not set already
            if (!Properties.Contains("ContentFileHashes"))
            {
                ParsedPath path = new ParsedPath(Properties.GetRequiredValue("OutputDir"), PathType.Directory);

                Properties.Set("ContentHashesFile", path.Append(ContentFilePath.FileAndExtension + ".hashes", PathType.File));
            }

            ContentFileHashesPath = new ParsedPath(Properties.GetRequiredValue("ContentHashesFile"), PathType.File).MakeFullPath();
            ContentFileWriteTime = File.GetLastWriteTime(this.ContentFilePath);

            // Create a hash of all the things than can affect the build

            SHA1 sha1 = SHA1.Create();
            StringBuilder sb = new StringBuilder();

            foreach (var rawAssembly in ContentFile.CompilerAssemblies)
            {
                sb.Append(rawAssembly.Value);
            }

            foreach (var rawProperty in ContentFile.Properties)
            {
                sb.Append(rawProperty.Name.Value);
                sb.Append(rawProperty.Value.Value);
            }
            foreach (var rawCompilerSettings in this.ContentFile.CompilerSettings)
            {
                sb.Append(rawCompilerSettings.Name);

                foreach (var extension in rawCompilerSettings.CompilerExtensions)
                {
                    foreach (var input in extension.Inputs)
                        sb.Append(input.Value);

                    foreach (var output in extension.Outputs)
                        sb.Append(output.Value);
                }

                foreach (var parameter in rawCompilerSettings.Parameters.KeyValues)
                {
                    sb.Append(parameter.Key.Value);
                    sb.Append(parameter.Value.ToString());
                }
            }

            GlobalHash = BitConverter.ToString(sha1.ComputeHash(Encoding.UTF8.GetBytes(sb.ToString()))).Replace("-", "");

            LoadCompilerClasses();
        }
コード例 #35
0
        public Enemy Spawn(EnemyType type, Vector3 pos, PropertyCollection props)
        {
            Enemy e = null;
            switch (type)
            {
                case EnemyType.Asteroid:
                    e = new Asteroid(pos, spriteSheets["Asteroid"]);
                    break;
                case EnemyType.Omega:
                    e = new Omega(pos, spriteSheets["Omega"]);
                    break;
                case EnemyType.Turret:
                    e = new Turret(pos, spriteSheets["Turret"], props.Contains("Inverted"));
                    break;
                case EnemyType.Squid:
                    e = new Squid(pos, spriteSheets["Squid"]);
                    break;
            }

            Enemies.Add(e);
            return e;
        }
コード例 #36
0
        public void ModifyPropertyTest()
        {
            PropertyCollection collection = new PropertyCollection(new string[0]);
            AttachEvents(collection);

            StringProperty prop = new StringProperty("test", "orange");

            collection.PropertyModified += (s, e) =>
            {
                Assert.AreSame(prop, e.Property);
                Assert.AreEqual(1, collection.Count);
                Assert.IsTrue(collection.Contains("test"));
                Assert.IsTrue(collection.Contains(prop));
                Assert.AreEqual("blue", e.Property.ToString());
            };

            collection.Add(prop);

            _eventsFired = EventFlags.None;

            prop.Value = "blue";

            Assert.AreEqual(EventFlags.PropertyModified | EventFlags.Modified, _eventsFired);
        }
コード例 #37
0
        public void RenamePropertyTest()
        {
            PropertyCollection collection = new PropertyCollection(new string[0]);
            AttachEvents(collection);

            StringProperty prop = new StringProperty("test", "orange");

            collection.PropertyRenamed += (s, e) =>
            {
                Assert.AreEqual("test", e.OldName);
                Assert.AreEqual("two", e.NewName);
                Assert.AreEqual(1, collection.Count);
                Assert.IsFalse(collection.Contains("test"));
                Assert.IsTrue(collection.Contains("two"));
                Assert.IsTrue(collection.Contains(prop));
            };

            collection.Add(prop);

            _eventsFired = EventFlags.None;

            prop.Name = "two";

            Assert.AreEqual(EventFlags.PropertyRenamed | EventFlags.Modified, _eventsFired);
        }