public static Dictionary<String, Property> getProperties(XmlNode xnXmlDataToProcess)
 {
     var dProperties = new Dictionary<String, Property>();
     //XmlElement xeXmlElement = (XmlElement)xnXmlDataToProcess;
     foreach (XmlNode xnChildNode in xnXmlDataToProcess.ChildNodes)
     {
         if (xnChildNode.Name == "property" && xnChildNode.Attributes["name"] != null)
         {
             var pProperty = new Property(xnChildNode.Attributes["name"].Value);
             if (xnChildNode.Attributes["value"] != null)
                 pProperty.sValue = xnChildNode.Attributes["value"].Value;
             if (xnChildNode.Attributes["ref"] != null)
                 pProperty.sRef = xnChildNode.Attributes["ref"].Value;
             if (xnChildNode.ChildNodes != null)
             {
                 pProperty.xnlChildNodes = xnChildNode.ChildNodes;
                 if (pProperty.sValue == null)
                     pProperty.sValue =
                         xnChildNode.InnerText.Replace(Environment.NewLine, "").Replace("\t", "").Trim();
             }
             dProperties.Add(pProperty.sName, pProperty);
         }
     }
     return dProperties;
 }
        public static void WriteXml(XmlWriter writer, string key, Property value)
        {
            writer.WriteStartElement("PropertyEntry");

            writer.WriteAttributeString("Key", key);

            var type = value.GetType();
            try
            {
                var ser = GetSerializer(type);
                writer.WriteAttributeString("Type", type.AssemblyQualifiedName);
                ser.Serialize(writer, value);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Serialization failed: " + ex.Message);
                Console.WriteLine("Property Key: " + key);
                Console.WriteLine("Property Value: " + value);
                Console.WriteLine("Property Type Name: " + type.Name);
                Console.WriteLine("Property Type Qualified Name: " + type.AssemblyQualifiedName);
                Console.WriteLine("Stacktrace: " + ex.StackTrace);
            }

            writer.WriteEndElement();
        }
Example #3
0
        public override Property Make(PropertyList propertyList) {
            if (m_defaultProp == null) {
                m_defaultProp = Make(propertyList, "0", propertyList.getParentFObj());
            }
            return m_defaultProp;

        }
        public void GetData(ref DBQueryUC dBQueryUC)
        {
            //Input Parameter
            List<Property> listProPerty_Input = new List<Property>();

            for (int i = 0; i < dataGridView2.Rows.Count - 1; i++)
            {
                Property property = new Property();
                property.PropertyName = dataGridView2.Rows[i].Cells[0].Value.ToString();
                listProPerty_Input.Add(property);
            }
            dBQueryUC.InputParameter = new InputParameter();
            dBQueryUC.InputParameter.Properties = listProPerty_Input;

            //Output Parameter
            List<Property> listProPerty_Output = new List<Property>();
            for (int i = 0; i < dataGridView3.Rows.Count - 1; i++)
            {
                Property property = new Property();
                property.PropertyName = dataGridView3.Rows[i].Cells[0].Value.ToString();
                listProPerty_Output.Add(property);
            }
            dBQueryUC.OutputParameter = new OutputParameter();
            dBQueryUC.OutputParameter.Properties = listProPerty_Output;

            dBQueryUC.SqlQuery = richTextBox1.Text;
        }
        protected override void Arrange()
        {
            base.Arrange();

            authenticationMode = EmailTraceListener.Property("AuthenticationMode");
            authenticationMode.Value = EmailAuthenticationMode.UserNameAndPassword;
        }
        public void PropertyShouldHaveProperties()
        {
            var property = new Property()
                {
                    LastTransferOn = new DateTime(),
                    SoldOn = new DateTime(),
                    PurchasedOn = new DateTime(),
                    Buyer = new Person(),
                    Seller = new Person(),
                    PlotNumber = "",
                    PlotSizeInKanals = 456,
                    Address = new Address(),
                    PropertyType = new PropertyType(),
                    PropertyZone = new PropertyZone(),
                    ConstructionStatus = new ConstructionStatus(),
                    OccupationStatus = new OccupationStatus(),
                };

            Assert.AreEqual(typeof(DateTime), property.LastTransferOn.GetType());
            Assert.AreEqual(typeof(DateTime), property.SoldOn.GetType());
            Assert.AreEqual(typeof(DateTime), property.PurchasedOn.GetType());
            Assert.AreEqual(typeof(Person), property.Buyer.GetType());
            Assert.AreEqual(typeof(Person), property.Seller.GetType());
            Assert.AreEqual(typeof(string), property.PlotNumber.GetType());
            Assert.AreEqual(typeof(decimal), property.PlotSizeInKanals.GetType());
            Assert.AreEqual(typeof(Address), property.Address.GetType());
            Assert.AreEqual(typeof(PropertyType), property.PropertyType.GetType());
            Assert.AreEqual(typeof(PropertyZone), property.PropertyZone.GetType());
            Assert.AreEqual(typeof(ConstructionStatus), property.ConstructionStatus.GetType());
            Assert.AreEqual(typeof(OccupationStatus), property.OccupationStatus.GetType());
        }
Example #7
0
        public Board()
        {
            propertysquares[0] = new Property { name = "go",
                price = 0,
                hotelprice = 0,
                colour = "nonproperty",
                canbesold = false,
                canhavehouses = false,
                houseprice = 0,
                ischance = false,
                iscommunityChest = false,
                hashotel = false,
                issold = false,
                numberofhouses = 0,
                rentprice = -200 };

            propertysquares[2] = new Property
            {
                name = "mayfair",
                price = 400,
                hotelprice = 250,
                colour = "Dark Blue",
                canbesold = true,
                canhavehouses = true,
                houseprice = 0,
                ischance = false,
                iscommunityChest = false,
                hashotel = false,
                issold = false,
                numberofhouses = 0,
                rentprice = 50
            };
        }
        public IHttpActionResult PutProperty(int id, Property property)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != property.PropertyId)
            {
                return BadRequest();
            }

            db.Entry(property).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PropertyExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Example #9
0
    public int getUser(Property objUser)
    {
        SqlConnection sqlCon = new SqlConnection(conStr);
        SqlCommand sqlCmd = new SqlCommand("sp_verfiyEmail", sqlCon);
        sqlCmd.CommandType = CommandType.StoredProcedure;

        SqlParameter eMailID = sqlCmd.Parameters.Add("@EmailID", SqlDbType.VarChar, 50);
        eMailID.Value = objUser.EmailID;

        SqlParameter passWordRem = sqlCmd.Parameters.Add("@PwdRem", SqlDbType.VarChar, 50);
        passWordRem.Value = objUser.PwdRem;

        SqlParameter flag = sqlCmd.Parameters.Add("@Flag", SqlDbType.Int);
        flag.Direction = ParameterDirection.Output;
        flag.Value = 0;

        try
        {
            sqlCon.Open();
            sqlCmd.ExecuteNonQuery();
            if ((int)flag.Value == 1)
                eMailFlag = 1;
            else
                eMailFlag = 0;
        }
        catch (Exception ex)
        { }
        finally
        {
            sqlCon.Close();
        }

        return eMailFlag;
    }
Example #10
0
        /// <summary>
        /// Initializes a new instance of the ModelTemplateModel class.
        /// </summary>
        /// <param name="source">The object to create model from.</param>
        /// <param name="allTypes">The list of all model types; Used to implement polymorphism.</param>
        public ModelTemplateModel(CompositeType source, ISet<CompositeType> allTypes)
        {
            this.LoadFrom(source);
            PropertyTemplateModels = new List<PropertyTemplateModel>();
            source.Properties.ForEach(p => PropertyTemplateModels.Add(new PropertyTemplateModel(p)));

            if (!string.IsNullOrEmpty(source.PolymorphicDiscriminator))
            {
                if (!source.Properties.Any(p => p.Name == source.PolymorphicDiscriminator))
                {
                    var polymorphicProperty = new Property
                    {
                        IsRequired = true,
                        Name = source.PolymorphicDiscriminator,
                        SerializedName = source.PolymorphicDiscriminator,
                        Documentation = "Polymorhpic Discriminator",
                        Type = new PrimaryType(KnownPrimaryType.String)
                    };
                    source.Properties.Add(polymorphicProperty);
                }
            }

            if (source.BaseModelType != null)
            {
                this.parent = new ModelTemplateModel(source.BaseModelType, allTypes);
            }

            this.allTypes = allTypes;
        }
        public RecordsSource_EnumEntityFilters()
        {
            DB.EntityChanges.Insert(new
            {
                EntityName = "Entity",
                EntityKey = "1",
                ChangedOn = DateTime.Now,
                ChangeType = EntityChangeType.Insert
            });
            DB.EntityChanges.Insert(new
            {
                EntityName = "Entity",
                EntityKey = "1",
                ChangedOn = DateTime.Now,
                ChangeType = EntityChangeType.Update
            });
            DB.EntityChanges.Insert(new
            {
                EntityName = "Entity",
                EntityKey = "1",
                ChangedOn = DateTime.Now,
                ChangeType = EntityChangeType.Delete
            });

            _source = new RecordsSource(new Notificator());
            Admin.AddEntity<EntityChange>();
            Admin.SetForeignKeysReferences();
            Admin.ConnectionStringName = ConnectionStringName;
            _entity = Admin.ChangeEntity;
            _property = _entity["ChangeType"];
        }
		public void Test()
		{
			var property = new Property { Name = "Property 1" };
			using (var session = OpenSession())
			{
				using (var tx = session.BeginTransaction())
				{
					session.Save(property);

					tx.Commit();
				}

				var item = new Item();
				using (var tx = session.BeginTransaction())
				{
					item.Name = "Item 1";
					item.PropertyValues = new Dictionary<Guid, PropertyValue>
											  {
												  {property.Id, new PropertyValue {Value = "Value 1"}}
											  };

					session.Save(item);

					tx.Commit();
				}
				session.Clear();

				var savedItem = session.Get<Item>(item.Id);
				Assert.AreEqual(1, savedItem.PropertyValues.Count);
				Assert.AreEqual("Value 1", savedItem.PropertyValues[property.Id].Value);
			}
		}
Example #13
0
 public ClearanceException(Property property, AccessLevel playerAccess, AccessLevel neededAccess, string accessType)
     : base(property, string.Format(
     "You must be at least {0} to {1} this property.",
     Mobile.GetAccessLevelName(neededAccess),
     accessType))
 {
 }
Example #14
0
    protected void btnSaveNewPwd_Click(object sender, ImageClickEventArgs e)
    {
        RegisterUserBLL objUser = new RegisterUserBLL();
        Property objProp = new Property();

        objProp.UserID = txtUserID.Text;
        objProp.OldPassword = txtOldPwd.Text;
        objProp.Password = txtNewPassword.Text;

        string user = (string)Session["User"];

        try
        {
            if (objUser.ChangePassword(objProp, user))
            {
                string str = "alert('Password Changed Successfully...');";
                ScriptManager.RegisterStartupScript(btnSaveNewPwd, typeof(Page), "alert", str, true);
            }
            else
            {
                string str = "alert('Failed to Change Password, Please try again...');";
                ScriptManager.RegisterStartupScript(btnSaveNewPwd, typeof(Page), "alert", str, true);
            }
            ClearControls();
        }
        catch(Exception ex)
        {
            objNLog.Error("Error: " + ex.Message);
        }
    }
        public void Export(Property property, XElement propertyTag, Dictionary<int, ObjectTypes> dependantNodes)
        {
            if (property.Value != null && !string.IsNullOrWhiteSpace(property.Value.ToString()))
            {
                var items = new DampModel(property.Value.ToString());
                var guidList = new List<Guid>();

                if (items.Any)
                {
                    foreach (var item in items)
                    {
                        var media = Services.MediaService.GetById(item.Id);
                        if (media != null)
                        {
                            guidList.Add(Services.MediaService.GetById(item.Id).Key);

                            if (!dependantNodes.ContainsKey(item.Id))
                            {
                                dependantNodes.Add(item.Id, ObjectTypes.Media);
                            }
                        }
                    }
                }

                propertyTag.Value = string.Join(",", guidList);
            }
        }
Example #16
0
        public override void Parse(System.Xml.XmlNode dom)
        {
            this.Name = dom.Attributes["Name"].Value;

            foreach (XmlNode n in dom.ChildNodes)
            {
                if (n.Name == "Key")
                {
                    var key = new Key();
                    key.Parse(n);
                    key.Parent = this;
                    this.Key = key;
                }

                if (n.Name == "Property")
                {
                    var property = new Property();
                    property.Parse(n);
                    property.Parent = this;
                    this.Propertys.Add(property.Name, property);
                }

                if (n.Name == "NavigationProperty")
                {
                    var property = new NavigationProperty();
                    property.Parse(n);
                    property.Parent = this;
                    this.NavigationPropertys.Add(property.Name, property);
                }

            }
        }
Example #17
0
    public void Biggylist_Updates_Single_Item_In_Json_Store() {
      var propertyList = new BiggyList<Property>(_propertyStore);
      int initialCount = propertyList.Count;

      var newProperty = new Property { Id = 1, Name = "John's Luxury Apartments", Address = "2639 I St NW, Washington, D.C. 20037" };
      propertyList.Add(newProperty);

      int addedItemId = newProperty.Id;

      // Just to be sure, reload from backing store and check what was added:
      propertyList = new BiggyList<Property>(_propertyStore);
      var addedProperty = propertyList.FirstOrDefault(p => p.Id == addedItemId);
      bool isAddedProperly = addedProperty.Name.Contains("John's Luxury");

      // Now Update:
      string newName = "John's Low-Rent Apartments";
      addedProperty.Name = newName;
      propertyList.Update(addedProperty);

      // Go fetch again:
      propertyList = new BiggyList<Property>(_propertyStore);
      addedProperty = propertyList.FirstOrDefault(p => p.Id == addedItemId);
      bool isUpdatedProperly = addedProperty.Name == newName;

      Assert.IsTrue(isAddedProperly && isUpdatedProperly);
    }
        public void CreateReport(string reportName, string parentPath, byte[] definition, string dataSourcePath)
        {
            Property[] reportProperties = new Property[1];
            Property hidden = new Property();
            hidden.Name = "Hidden";
            hidden.Value = reportName.StartsWith("_") ? "true" : "false";
            reportProperties[0] = hidden;
            _reportService.CreateReport(reportName, parentPath, true, definition, reportProperties);

            DataSourceReference dsRef = new DataSourceReference();
            dsRef.Reference = dataSourcePath;
            DataSource[] Sources = _reportService.GetItemDataSources(parentPath + "/" + reportName);
            if (Sources != null && Sources.Length > 0)
            {
                Sources[0].Item = dsRef;
                try
                {
                    _reportService.SetItemDataSources(parentPath + "/" + reportName, Sources);
                }
                catch (Exception )
                {

                }
            }
        }
        public void SetUp()
        {
            _property = PropertyBuilder.AProperty().Build();
            _transactionRepository = new Mock<ITransactionRepository>();

            _balancePerAccountReport = new BalancePerAccount(_transactionRepository.Object);
        }
Example #20
0
        public static Boolean CreateProperty(Property prop )
        {
            String propertyID = String.Empty;
               Boolean flag = false;
               if (!(IsExistingProperty(prop)))
               {
               using (TransactionScope scope = new TransactionScope())
               {
                   using (var context = new SycousCon())
                   {
                       try
                       {
                           context.Properties.AddObject(prop);
                           context.SaveChanges();
                           scope.Complete();
                           context.AcceptAllChanges();
                           propertyID = prop.ID.ToString();
                           flag = true;
                       }
                       catch (Exception ex)
                       {
                           context.Dispose();
                           throw;
                       }
                   }//
               }// using
               }//if

               return flag;
        }
Example #21
0
        public override Property Eval(Property[] args, PropertyInfo pInfo)
        {
            Length distance =
                pInfo.getPropertyList().GetProperty("provisional-distance-between-starts").GetLength();
            Length separation =
                pInfo.getPropertyList().GetNearestSpecifiedProperty("provisional-label-separation").GetLength();

            FObj item = pInfo.getFO();
            while (item != null && !(item is ListItem))
            {
                item = item.getParent();
            }
            if (item == null)
            {
                throw new PropertyException("label-end() called from outside an fo:list-item");
            }
            Length startIndent = item.properties.GetProperty("start-indent").GetLength();

            LinearCombinationLength labelEnd = new LinearCombinationLength();

            LengthBase bse = new LengthBase(item, pInfo.getPropertyList(),
                                            LengthBase.CONTAINING_BOX);
            PercentLength refWidth = new PercentLength(1.0, bse);

            labelEnd.AddTerm(1.0, refWidth);
            labelEnd.AddTerm(-1.0, distance);
            labelEnd.AddTerm(-1.0, startIndent);
            labelEnd.AddTerm(1.0, separation);

            labelEnd.ComputeValue();

            return new LengthProperty(labelEnd);
        }
        public ContentDocument(IDataTypeService service, IContent content)
            : this()
        {
            Id = content.Id;
            ContentTypeId = content.ContentTypeId;
            ContentType = content.ContentType.Name;
            Name = content.Name;
            ParentId = content.ParentId;
            Level = content.Level;
            Path = content.Path;

            foreach (var propInfo in content.PropertyTypes.OrderBy(n => n.SortOrder))
            {

                var p = new Property
                {
                    Name = propInfo.Name,
                    Alias = propInfo.Alias,
                    Description = propInfo.Description,
                    Required = propInfo.Mandatory,
                    Validation = propInfo.ValidationRegExp,
                    DataType = service.GetDataTypeDefinitionById(propInfo.DataTypeDefinitionId).Name,
                    Value = (content.Properties.SingleOrDefault(n => n.Alias == propInfo.Alias).Value ?? string.Empty).ToString()
                };
                Properties.Add(p);
            }
        }
Example #23
0
 public void AddProperty(Property property)
 {
     if (Properties.ContainsKey(property.Name))
         Properties[property.Name] = property;
     else
         Properties.Add(property.Name, property);
 }
 public void AddPropertyToGameObject()
 {
     GameObject newGameObject = new GameObject("new game object");
     Property newProperty = new Property(PropertyType.String, "new property", "a new value");
     Assert.IsTrue(newGameObject.AddProperty(newProperty));
     Assert.IsTrue(newGameObject.DoesPropertyExist(newProperty.Name));
 }
 public void GetPropertyFromGameObject()
 {
     GameObject newGameObject = new GameObject("new game object");
     Property newProperty = new Property(PropertyType.String, "new property", "a new value");
     newGameObject.AddProperty(newProperty);
     Assert.IsTrue(newProperty.Value == newGameObject.GetProperty(newProperty.Name).Value);
 }
Example #26
0
 public async static Task<EntityResponse<Property>> Delete(Property propertyType)
 {
     using (var db = Database.Connect())
     {
         return await db.Entities.DeleteAsync<Property>(propertyType);
     }
 }
Example #27
0
        /// <summary>Generates a feature.</summary>
        /// <exception cref="InvalidOperationException">Thrown when the requested operation is invalid.</exception>
        /// <param name="type">The type.</param>
        /// <param name="name">The name.</param>
        /// <returns>The feature.</returns>
        public static Property GenerateFeature(Type type, string name)
        {
            Property p;
            if (type == typeof(string))
                p = new StringProperty();
            else if (type == typeof(DateTime))
                p = new DateTimeProperty();
            else if (type.GetInterfaces().Contains(typeof(IEnumerable)))
                throw new InvalidOperationException(
                    string.Format("Property {0} needs to be labeled as an EnumerableFeature", name));
            else
                p = new Property();


            p.Discrete = type.BaseType == typeof(Enum) ||
                         type == typeof(bool) ||
                         type == typeof(string) ||
                         type == typeof(char) ||
                         type == typeof(DateTime);

            p.Type = type;
            p.Name = name;

            return p;
        }
        public PostfixOptionsViewModel([NotNull] Lifetime lifetime,
                                   [NotNull] OptionsSettingsSmartContext settings,
                                   [NotNull] PostfixTemplatesManager templatesManager)
        {
            mySettingsStore = settings;
              myTemplatesManager = templatesManager;
              Templates = new ObservableCollection<PostfixTemplateViewModel>();

              ShowPostfixTemplates = new Property<bool>(lifetime, "ShowPostfixTemplates");
              ShowStaticMembers = new Property<bool>(lifetime, "ShowStaticMembers");
              ShowEnumHelpers = new Property<bool>(lifetime, "ShowEnumHelpers");
              ShowLengthCountItems = new Property<bool>(lifetime, "ShowLengthCountItems");
              UseBracesForStatements = new Property<bool>(lifetime, "UseBracesForStatements");
              InvokeParameterInfo = new Property<bool>(lifetime, "InvokeParameterInfo");
              SearchVarOccurrences = new Property<bool>(lifetime, "SearchVarOccurrences");

              Reset = new DelegateCommand(ResetExecute);

              settings.SetBinding(lifetime, PostfixSettingsAccessor.ShowPostfixItems, ShowPostfixTemplates);
              settings.SetBinding(lifetime, PostfixSettingsAccessor.ShowStaticMethods, ShowStaticMembers);
              settings.SetBinding(lifetime, PostfixSettingsAccessor.ShowEnumHelpers, ShowEnumHelpers);
              settings.SetBinding(lifetime, PostfixSettingsAccessor.BracesForStatements, UseBracesForStatements);
              settings.SetBinding(lifetime, PostfixSettingsAccessor.InvokeParameterInfo, InvokeParameterInfo);
              settings.SetBinding(lifetime, PostfixSettingsAccessor.ShowLengthCountItems, ShowLengthCountItems);
              settings.SetBinding(lifetime, PostfixSettingsAccessor.SearchVarOccurrences, SearchVarOccurrences);

              FillTemplates();
        }
        public void ImplementProperty_GenerateLineBreaks()
        {
            WithSourceFiles(Files.ChildClass, Files.Mixin);

            var typeSymbol = Substitute.For<ITypeSymbol>();
            var mixin = Substitute.For<MixinReference>();
            mixin.Name.Returns("_mixin");

            var property = new Property("Name", typeSymbol, true, true);

            var implementPropertyStrategy = new ImplementPropertyForwarding(
                mixin, Semantic, new Settings(avoidLineBreaksInProperties:false));

            var memberDeclaration = implementPropertyStrategy.ImplementMember(property, 0);

            // Assert:
            // let the formatting engine format the output source and ensure
            // that the text has only 6 lines:
            // <empty line>
            // public Name
            // { 
            //    get
            //    {
            //        ...
            //    }
            //    <empty line>
            //    ...
            // }

            var workspace = new AdhocWorkspace();
            memberDeclaration = (MemberDeclarationSyntax)Formatter.Format(memberDeclaration, workspace);
            var sourceText = SourceText.From(memberDeclaration.ToFullString());
            Assert.AreEqual(13, sourceText.Lines.Count);
        }
Example #30
0
        public static String AddProperty(Property prop)
        {
            String ReturnpropertyID = String.Empty;

               //if (!(IsExistingProperty(prop)))
               //{
               using (TransactionScope scope = new TransactionScope())
               {
                   using (var context = new SycousCon())
                   {
                       try
                       {
                           context.Properties.AddObject(prop);
                           context.SaveChanges();
                           scope.Complete();
                           context.AcceptAllChanges();
                           ReturnpropertyID = prop.ID.ToString();
                       }
                       catch (Exception ex)
                       {
                           context.Dispose();
                           throw;
                       }
                   }//
               }// using
               //}//if

               return ReturnpropertyID;
        }
Example #31
0
 /// <summary>
 /// SMO property is a DestinationLibrary  (for copy/move methods)
 /// </summary>
 public static bool IsDestinationLibrary(this Property property)
 {
     return(string.Compare(property.Name, Constants.SOProperties.DestinationLibrary) == 0);
 }
Example #32
0
 /// <summary>
 /// SMO property is for UseCheckedInVersion
 /// </summary>
 public static bool IsUseCheckedInVersion(this Property property)
 {
     return(string.Compare(property.Name, Constants.SOProperties.UseCheckedInVersion) == 0);
 }
Example #33
0
 /// <summary>
 /// SMO property is for RetainCheckout
 /// </summary>
 public static bool IsRetainCheckout(this Property property)
 {
     return(string.Compare(property.Name, Constants.SOProperties.RetainCheckOut) == 0);
 }
Example #34
0
 /// <summary>
 /// SMO property is for CheckInComments
 /// </summary>
 public static bool IsCheckInComments(this Property property)
 {
     return(string.Compare(property.Name, Constants.SOProperties.CheckInComment) == 0);
 }
Example #35
0
 /// <summary>
 /// SMO property is a GroupLogins (for permission methods)
 /// </summary>
 public static bool IsGroupLogins(this Property property)
 {
     return(string.Compare(property.Name, Constants.SOProperties.GroupLogins) == 0);
 }
Example #36
0
 /// <summary>
 /// SMO property is a UserOrGroup (for permission methods)
 /// </summary>
 public static bool IsUserOrGroup(this Property property)
 {
     return(string.Compare(property.Name, Constants.SOProperties.UserOrGroup) == 0);
 }
Example #37
0
 /// <summary>
 /// SMO property is a Permission (for permission methods)
 /// </summary>
 public static bool IsPermissionColumn(this Property property)
 {
     return(string.Compare(property.Name, Constants.SOProperties.Permission) == 0);
 }
Example #38
0
 /// <summary>
 /// SMO property is an indicator for overwrite exesting document (for upload document)
 /// </summary>
 public static bool IsOverwriteExistingDocument(this Property property)
 {
     return(string.Compare(property.Name, Constants.SOProperties.OverwriteExistingDocument) == 0);
 }
Example #39
0
        private void Initialize()
        {
            // populating model type and property descriptions
            this.resourceDescs = new Dictionary <long, ResourcePropertiesDesc>();

            ResourcePropertiesDesc desc = null;

            InitializeTypeIdsInInsertOrder();

            //// Initialize metadata for core entities
            InitializeNotSettablePropertyIds();

            foreach (ModelCode code in Enum.GetValues(typeof(ModelCode)))
            {
                allModelCodes.Add(code);
            }

            foreach (DMSType type in Enum.GetValues(typeof(DMSType)))
            {
                allDMSTypes.Add(type);
            }


            #region get all class model codes from core

            //// Get all class model codes for all services and for all classes, abstract or not. Extensibility included
            List <ModelCode> classIds = new List <ModelCode>();
            foreach (ModelCode code in allModelCodes)
            {
                // don't insert attribute codes
                if (((long)code & (long)ModelCodeMask.MASK_ATTRIBUTE_TYPE) == 0)
                {
                    classIds.Add(code);
                }
            }

            #endregion get all class model codes from core

            #region Initialize non abstract class and resourceDescription map from core

            foreach (ModelCode classId in classIds)
            {
                //// Initialize leafs
                if (((long)classId & (long)ModelCodeMask.MASK_TYPE) != 0)
                {
                    nonAbstractClassIds.Add(classId);
                }

                //// Initialize resourceDescription map
                desc = this.AddResourceDesc(classId);
                long classIdMask = unchecked ((long)0xffffffff00000000);

                foreach (ModelCode propertyId in allModelCodes)
                {
                    PropertyType propertyType = Property.GetPropertyType(propertyId);

                    if (propertyType == 0)
                    {
                        continue;
                    }

                    if (((long)propertyId & classIdMask) == ((long)classId & classIdMask))
                    {
                        if (!desc.PropertyExists(propertyId))
                        {
                            desc.AddPropertyId(propertyId);
                        }
                    }
                }
            }

            #endregion Initialize non abstract class and resourceDescription map  from core

            #region Initialize type 2 model code map

            //// Model codes names from enum, these are only names for core model codes
            string[] modelCodeNamesFromCore = Enum.GetNames(typeof(ModelCode));

            classIds = new List <ModelCode>();
            foreach (ModelCode code in allModelCodes)
            {
                // don't insert attribute codes
                if (((long)code & (long)ModelCodeMask.MASK_ATTRIBUTE_TYPE) == 0)
                {
                    classIds.Add(code);
                }
            }

            //// Initialize DMSType 2 ModelCode map
            foreach (DMSType t in allDMSTypes)
            {
                DMSType type = t & DMSType.MASK_TYPE;

                ////  if DMSType is not addad and it is not mask
                if (!this.type2modelCode.ContainsKey(type) && type != DMSType.MASK_TYPE)
                {
                    //// DMSTypes that have same name as appropriete model code
                    if (modelCodeNamesFromCore.Contains(type.ToString()))
                    {
                        this.type2modelCode[type] = GetModelCodeFromTypeForCore(type);
                    }
                    else                     // for DMSTypes which don't have it's ModelCode with same name or are not in core
                    {
                        try                  // for DMSTypes which have it's ModelCode but with different name
                        {
                            foreach (ModelCode classId in classIds)
                            {
                                if (GetTypeFromModelCode(classId) == type)
                                {
                                    this.type2modelCode[type] = classId;
                                    break;
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            string message = $"Initialize => Exception: {e.Message}";
                            Logger.LogDebug(message, e);
                        }
                    }
                }
            }

            #endregion Initialize type 2 model code map
        }
Example #40
0
 /// <summary>
 /// SMO property is a NewFileName (for rename document)
 /// </summary>
 public static bool IsNewFileName(this Property property)
 {
     return(string.Compare(property.Name, Constants.SOProperties.NewFileName) == 0);
 }
Example #41
0
        public void TestProperties()
        {
            resetDbContext();

            using (var bc = new GameContext())
            {
                var player1 = new User();
                player1.UserName = "******";
                bc.Users.Add(player1);

                // Test 1 - A player should be able to create a new Board.
                var new_board = bc.CreateNewGameBoard(player1, 2, 20);
                new_board.minSkillRange = Board.LowestSkillPoints;
                new_board.maxSkillRange = Board.LowestSkillPoints + 500;

                var AddedPlayer = new_board.GetPlayerByUsername(player1.UserName);

                // Test 2 - A player should be able to join an existing Board.

                var player2 = new User();
                player2.UserName = "******";
                bc.Users.Add(player2);

                bc.AddPlayerToBoard(player2, new_board);

                bool isDoubles;
                //int rollVal;// = player1.Roll(out isDoubles);

                //new_board.AssignPlayerTurn(player1.UserName, 2);
                //new_board.AssignPlayerTurn(player2.UserName, 1);

                // The Player with the current Turn should be player 2 as the Turn Index = 1
                bc.SaveChanges();

                // Initialize all the Properties on the Board.
                new_board.GenerateBoardProperties();
                bc.SaveChanges();

                // Create a move on the board.
                int rollValue = 10;
                isDoubles = false;

                Move firstMove = new_board.MakeCurrentPlayerMove(isDoubles, rollValue);


                var endMove = new_board.EndCurrentPlayerTurn(); // This method should end player 1's turn

                Assert.AreEqual(new_board.ActiveBoardPlayer, player2);

                var nextPlayer = new_board.GetPlayerWithCurrentTurn();
                Assert.AreEqual(nextPlayer, player2);

                rollValue = 12;
                Move p2FirstMove = new_board.MakeCurrentPlayerMove(isDoubles, rollValue);

                endMove = new_board.EndCurrentPlayerTurn(); // This method should end player 2's turn

                Assert.AreEqual(new_board.ActiveBoardPlayer, player2);

                // player2 rolled higher value, so next turn is p2's
                nextPlayer = new_board.GetPlayerWithCurrentTurn();

                Assert.AreEqual(nextPlayer, player2);

                rollValue = 6;
                var p2NextTurn = new_board.MakeCurrentPlayerMove(isDoubles, rollValue);
                Assert.AreEqual(p2NextTurn.CurrentPos, rollValue + 1);

                endMove = new_board.EndCurrentPlayerTurn();
                Assert.AreEqual(new_board.ActiveBoardPlayer, player1);

                // Next player is p1
                nextPlayer = new_board.GetPlayerWithCurrentTurn();
                Assert.AreEqual(nextPlayer, player1);

                rollValue = 10;
                isDoubles = true;

                var p1NextTurn = new_board.MakeCurrentPlayerMove(isDoubles, rollValue);
                Assert.AreEqual(p1NextTurn.CurrentPos, rollValue + 1);

                nextPlayer = new_board.GetPlayerWithCurrentTurn();
                Assert.AreEqual(nextPlayer, player1);
                // Do not end player turn if doubles
                bc.SaveChanges();

                // For this test, it is assumed that player buys property.
                // Check if money is deducted for property.

                firstMove.CurrentPos = 2;
                BoardUser bu = new_board.GetBoardUser(player1.UserName);
                bu.Money = 1000;

                Property p             = new_board.GetPropertyFromPosition(firstMove.CurrentPos);
                int      expectedMoney = bu.Money - p.Price;

                player1.LandedOn(new_board, firstMove);
                bc.SaveChanges();
                Assert.AreEqual(expectedMoney, bu.Money);

                // Player owns property p now.
                // Test mortgage property.

                expectedMoney = bu.Money + (int)(p.Price * Property.MortgagePercentage);
                player1.MortgageProperty(new_board, p);
                bc.SaveChanges();

                Assert.AreEqual(expectedMoney, bu.Money);

                // Now that property is mortgaged, it shouldn't
                // deduct money from player2 for landing on it.
                bu       = new_board.GetBoardUser(player2.UserName);
                bu.Money = 500;

                expectedMoney = bu.Money;
                player2.LandedOn(new_board, firstMove);
                bc.SaveChanges();

                Assert.AreEqual(expectedMoney, bu.Money);

                // Check if player owns a group of properties.
                Assert.AreEqual(false, player1.OwnsGroup(new_board, "Purple"));

                //Check if player can build a house before owning group.
                Assert.AreEqual(false, bu.CanBuildHouse(p));

                var props = (from prop in new_board.Properties
                             where prop.Group == "Purple"
                             select prop);

                foreach (Property property in props)
                {
                    property.User = player1;
                }
                bc.SaveChanges();

                // Player should now own all purple
                Assert.AreEqual(true, player1.OwnsGroup(new_board, "Purple"));

                Property purpleProp = props.FirstOrDefault();

                //Check if player can build a house after owning group.
                Assert.AreEqual(true, bu.CanBuildHouse(purpleProp));

                //Check if player can build hotel after owning group with no houses.
                Assert.AreEqual(false, bu.CanBuildHotel(purpleProp));

                purpleProp.NumHouses = 3;
                bu.BuildHouse(purpleProp);
                bc.SaveChanges();

                //Check that player has built a house with BuildHouse()
                Assert.AreEqual(true, purpleProp.NumHouses == 4);

                // Check that player can build hotel after owning 4 houses on property.
                Assert.AreEqual(true, bu.CanBuildHotel(purpleProp));

                //Build a hotel now that we have 4 houses.
                bu.BuildHotel(purpleProp);

                Assert.AreEqual(true, purpleProp.NumHouses == 0);
                Assert.AreEqual(true, purpleProp.NumHotels == 1);

                bu       = new_board.GetBoardUser(player1.UserName);
                bu.Money = 10;

                purpleProp.NumHouses = 0;
                purpleProp.NumHotels = 0;
                bc.SaveChanges();

                Assert.AreEqual(false, bu.CanBuildHotel(purpleProp));
                Assert.AreEqual(false, bu.CanBuildHouse(purpleProp));
            }
        }
Example #42
0
        public static async IAsyncEnumerable <Schema> GetRefreshSchemas(IConnectionFactory connFactory,
                                                                        RepeatedField <Schema> refreshSchemas, int sampleSize = 5)
        {
            var conn = connFactory.GetConnection();
            await conn.OpenAsync();

            foreach (var schema in refreshSchemas)
            {
                if (string.IsNullOrWhiteSpace(schema.Query))
                {
                    yield return(await GetRefreshSchemaForTable(connFactory, schema, sampleSize));

                    continue;
                }

                var cmd = connFactory.GetCommand(schema.Query, conn);

                var reader = await cmd.ExecuteReaderAsync();

                var schemaTable = reader.GetSchemaTable();

                var properties = new List <Property>();
                if (schemaTable != null)
                {
                    var unnamedColIndex = 0;

                    // get each column and create a property for the column
                    foreach (DataRow row in schemaTable.Rows)
                    {
                        // get the column name
                        var colName = row["ColumnName"].ToString();
                        if (string.IsNullOrWhiteSpace(colName))
                        {
                            colName = $"UNKNOWN_{unnamedColIndex}";
                            unnamedColIndex++;
                        }

                        // create property
                        var property = new Property
                        {
                            Id          = Utility.Utility.GetSafeName(colName),
                            Name        = colName,
                            Description = "",
                            Type        = GetPropertyType(row),
                            // TypeAtSource = row["DataType"].ToString(),
                            IsKey             = !string.IsNullOrWhiteSpace(row["IsKey"].ToString()) && Boolean.Parse(row["IsKey"].ToString()),
                            IsNullable        = string.IsNullOrWhiteSpace(row["AllowDBNull"].ToString()) || Boolean.Parse(row["AllowDBNull"].ToString()),
                            IsCreateCounter   = false,
                            IsUpdateCounter   = false,
                            PublisherMetaJson = ""
                        };

                        // add property to properties
                        properties.Add(property);
                    }
                }

                // add only discovered properties to schema
                schema.Properties.Clear();
                schema.Properties.AddRange(properties);

                // get sample and count
                yield return(await AddSampleAndCount(connFactory, schema, sampleSize));
            }

            await conn.CloseAsync();
        }
Example #43
0
        private Dictionary <DMSType, ResourceDescription> CreateResourcesForUpdate(List <long> gids)
        {
            Dictionary <DMSType, ResourceDescription> updates = new Dictionary <DMSType, ResourceDescription>(new DMSTypeComparer());
            Delta delta = new Delta();

            ResourceDescription rd          = null;
            List <ModelCode>    propertyIDs = null;
            DMSType             type;

            #region Creating resources

            foreach (long gid in gids)
            {
                type        = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(gid);
                propertyIDs = modelResourcesDesc.GetAllPropertyIds(modelResourcesDesc.GetModelCodeFromType(type));
                rd          = new ResourceDescription(gid);

                foreach (ModelCode propertyId in propertyIDs)
                {
                    if (!modelResourcesDesc.NotSettablePropertyIds.Contains(propertyId))
                    {
                        switch (Property.GetPropertyType(propertyId))
                        {
                        case PropertyType.Bool:
                            rd.AddProperty(new Property(propertyId, true));
                            break;

                        case PropertyType.Byte:
                            rd.AddProperty(new Property(propertyId, (byte)7));
                            break;

                        case PropertyType.Int32:
                            rd.AddProperty(new Property(propertyId, (int)500));
                            break;

                        case PropertyType.Int64:
                        case PropertyType.TimeSpan:
                        case PropertyType.DateTime:
                            rd.AddProperty(new Property(propertyId, (long)3112));
                            break;

                        case PropertyType.Enum:
                            rd.AddProperty(new Property(propertyId, (short)2));
                            break;

                        case PropertyType.Reference:
                            rd.AddProperty(new Property(propertyId, (long)0));
                            break;

                        case PropertyType.Float:
                            rd.AddProperty(new Property(propertyId, (float)1.05));
                            break;

                        case PropertyType.String:
                            rd.AddProperty(new Property(propertyId, "UpdateString"));
                            break;

                        case PropertyType.Int64Vector:
                            List <long> longVector = new List <long>();
                            longVector.Add((long)20);
                            longVector.Add((long)21);
                            longVector.Add((long)22);
                            longVector.Add((long)23);
                            longVector.Add((long)24);
                            longVector.Add((long)25);
                            rd.AddProperty(new Property(propertyId, longVector));
                            break;

                        case PropertyType.FloatVector:
                            List <float> floatVector = new List <float>();
                            floatVector.Add((float)21.1);
                            floatVector.Add((float)22.2);
                            floatVector.Add((float)23.3);
                            floatVector.Add((float)24.4);
                            floatVector.Add((float)25.5);
                            rd.AddProperty(new Property(propertyId, floatVector));
                            break;

                        case PropertyType.EnumVector:
                            List <short> enumVector = new List <short>();
                            enumVector.Add((short)44);
                            enumVector.Add((short)45);
                            enumVector.Add((short)46);
                            rd.AddProperty(new Property(propertyId, enumVector));
                            break;

                        default:
                            break;
                        }
                    }
                }

                if (!updates.ContainsKey(type))
                {
                    updates.Add(type, rd);
                    delta.AddDeltaOperation(DeltaOpType.Update, rd, true);
                }
            }
            #endregion Creating resources

            #region Set references

            SetPowerTransformerReferences(updates);
            SetTransformerWindingReferences(updates);
            SetWindingTestRefernces(updates);

            #endregion Set references

            return(updates);
        }
        private static void SetWIAProperty(IProperties properties, object propName, object propValue)
        {
            Property prop = properties.get_Item(ref propName);

            prop.set_Value(ref propValue);
        }
Example #45
0
        public async Task <IActionResult> Create(PropertyViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //  Check that Start Date and End Date are within Policy Cover Start and Cover End Date
                    Guid policyId = viewModel.PolicyID;
                    viewModel.ErrMsg = string.Empty;

                    var startDate = viewModel.Property.StartDate;
                    var endDate   = viewModel.Property.EndDate;

                    CompareDates compareDates = new CompareDates(_context);

                    if (compareDates.CompareStartDate(policyId, startDate) < 0)
                    {
                        viewModel.ErrMsg = $"Start Date cannot be earlier than Policy Cover Start Date";
                        ModelState.AddModelError(string.Empty, viewModel.ErrMsg);
                    }

                    if (compareDates.CompareEndDate(policyId, endDate) > 0)
                    {
                        viewModel.ErrMsg = $"End Date cannot be later than Policy Cover End Date";
                        ModelState.AddModelError(string.Empty, viewModel.ErrMsg);
                    }

                    if (string.IsNullOrEmpty(viewModel.ErrMsg))
                    {
                        Property property = viewModel.Property;
                        property.ID       = Guid.NewGuid();
                        property.PolicyID = policyId;
                        _context.Add(property);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction("PolicyRisks", "Policies",
                                                new { productId = viewModel.ProductID, clientId = viewModel.ClientID, policyid = viewModel.PolicyID }));
                    }
                }
            }
            catch (DbUpdateException ex)
            {
                var errorMsg = ex.InnerException.Message.ToString();

                viewModel.ErrMsg = errorMsg;
                ModelState.AddModelError(string.Empty, viewModel.ErrMsg);
            }

            viewModel.CoverageList = new SelectList(await _context.Coverages
                                                    .AsNoTracking()
                                                    .ToListAsync(), "ID", "Name", viewModel.Property.CoverageID);
            viewModel.ResidenceTypeList = new SelectList(await _context.ResidenceTypes
                                                         .AsNoTracking()
                                                         .ToListAsync(), "ID", "Name", viewModel.Property.ResidenceTypeID);
            viewModel.RoofTypeList = new SelectList(await _context.RoofTypes
                                                    .AsNoTracking()
                                                    .ToListAsync(), "ID", "Name", viewModel.Property.RoofTypeID);
            viewModel.WallTypeList = new SelectList(await _context.WallTypes
                                                    .AsNoTracking()
                                                    .ToListAsync(), "ID", "Name", viewModel.Property.WallTypeID);
            return(View(viewModel));
        }
Example #46
0
 public bool VisitProperty(Property property)
 {
     return(false);
 }
 public void AddProperty(Property property)
 {
     _properties.Add(property);
 }
Example #48
0
        private Dictionary <DMSType, ResourceDescription> CreateResourcesToInsert()
        {
            long globalId                   = 0;
            ResourceDescription rd          = null;
            List <ModelCode>    propertyIDs = null;
            Dictionary <DMSType, ResourceDescription> updates = new Dictionary <DMSType, ResourceDescription>(new DMSTypeComparer());

            #region Create resources

            foreach (DMSType type in modelResourcesDesc.AllDMSTypes)
            {
                if (type != DMSType.MASK_TYPE)
                {
                    globalId    = ModelCodeHelper.CreateGlobalId(0, (short)type, -1);
                    propertyIDs = modelResourcesDesc.GetAllPropertyIds(modelResourcesDesc.GetModelCodeFromType(type));
                    rd          = new ResourceDescription(globalId);

                    foreach (ModelCode propertyId in propertyIDs)
                    {
                        if (!modelResourcesDesc.NotSettablePropertyIds.Contains(propertyId))
                        {
                            switch (Property.GetPropertyType(propertyId))
                            {
                            case PropertyType.Bool:
                                rd.AddProperty(new Property(propertyId, true));
                                break;

                            case PropertyType.Byte:
                                rd.AddProperty(new Property(propertyId, (byte)100));
                                break;

                            case PropertyType.Int32:
                                rd.AddProperty(new Property(propertyId, (int)4));
                                break;

                            case PropertyType.Int64:
                            case PropertyType.TimeSpan:
                            case PropertyType.DateTime:
                                rd.AddProperty(new Property(propertyId, (long)101));
                                break;

                            case PropertyType.Enum:
                                rd.AddProperty(new Property(propertyId, (short)1));
                                break;

                            case PropertyType.Reference:
                                rd.AddProperty(new Property(propertyId));
                                break;

                            case PropertyType.Float:
                                rd.AddProperty(new Property(propertyId, (float)10.5));
                                break;

                            case PropertyType.String:
                                rd.AddProperty(new Property(propertyId, "TestString"));
                                break;

                            case PropertyType.Int64Vector:
                                List <long> longVector = new List <long>();
                                longVector.Add((long)10);
                                longVector.Add((long)11);
                                longVector.Add((long)12);
                                longVector.Add((long)13);
                                longVector.Add((long)14);
                                longVector.Add((long)15);
                                rd.AddProperty(new Property(propertyId, longVector));
                                break;

                            case PropertyType.FloatVector:
                                List <float> floatVector = new List <float>();
                                floatVector.Add((float)11.1);
                                floatVector.Add((float)12.2);
                                floatVector.Add((float)13.3);
                                floatVector.Add((float)14.4);
                                floatVector.Add((float)15.5);
                                rd.AddProperty(new Property(propertyId, floatVector));
                                break;

                            case PropertyType.EnumVector:
                                List <short> enumVector = new List <short>();
                                enumVector.Add((short)1);
                                enumVector.Add((short)2);
                                enumVector.Add((short)3);
                                rd.AddProperty(new Property(propertyId, enumVector));
                                break;

                            case PropertyType.StringVector:
                                List <string> stringVector = new List <string>();
                                stringVector.Add("TestString1");
                                stringVector.Add("TestString2");
                                stringVector.Add("TestString3");
                                stringVector.Add("TestString4");
                                rd.AddProperty(new Property(propertyId, stringVector));
                                break;

                            case PropertyType.Int32Vector:
                                List <int> intVector = new List <int>();
                                intVector.Add(11);
                                intVector.Add(12);
                                intVector.Add(13);
                                intVector.Add(14);
                                rd.AddProperty(new Property(propertyId, intVector));
                                break;

                            default:
                                break;
                            }
                        }
                    }

                    updates[type] = rd;
                }
            }

            #endregion Create resources

            #region Set references

            SetPowerTransformerReferences(updates);
            SetTransformerWindingReferences(updates);
            SetWindingTestRefernces(updates);

            #endregion Set references

            return(updates);
        }
Example #49
0
 protected override void VisitProperty <TContainer, TValue>(Property <TContainer, TValue> property, ref TContainer container, ref TValue value)
 {
     throw new InvalidBindingException($"SearchElement has invalid data bindings. FilterDataPath=[{FilterDataPath}] FilterDataType=[{typeof(TValue)}] is not a collection type");
 }
Example #50
0
        public override void Awake()
        {
            base.Awake();
            this.EnabledWhenPaused = true;

            this.Add(new NotifyBinding(main.AlphaDrawablesModified, this.DrawOrder));

            this.Add(new SetBinding <bool>(this.CannotSuspendByDistance, delegate(bool value)
            {
                this.Entity.CannotSuspendByDistance = value;
            }));

            this.Add(new NotifyBinding(delegate() { this.needResize = true; }, this.main.ScreenSize));

            Action removeFluid = delegate()
            {
                if (this.Fluid.Space != null)
                {
                    this.main.Space.Remove(this.Fluid);
                }
                AkSoundEngine.PostEvent(AK.EVENTS.STOP_WATER_LOOP, this.Entity);
            };

            Action addFluid = delegate()
            {
                if (this.Fluid.Space == null && this.Enabled && !this.Suspended)
                {
                    this.main.Space.Add(this.Fluid);
                    if (!this.main.EditorEnabled)
                    {
                        AkSoundEngine.PostEvent(AK.EVENTS.PLAY_WATER_LOOP, this.Entity);
                    }
                }
            };

            this.Add(new CommandBinding(this.OnSuspended, removeFluid));
            this.Add(new CommandBinding(this.Disable, removeFluid));
            this.Add(new CommandBinding(this.OnResumed, addFluid));
            this.Add(new CommandBinding(this.Enable, addFluid));

            this.camera = new Camera();
            this.main.AddComponent(this.camera);
            this.parameters = new RenderParameters
            {
                Camera           = this.camera,
                Technique        = Technique.Clip,
                ReverseCullOrder = true,
            };

            this.Add(new SetBinding <Vector3>(this.Color, delegate(Vector3 value)
            {
                this.effect.Parameters["Color"].SetValue(value);
            }));

            this.Add(new SetBinding <Vector2>(this.Scale, delegate(Vector2 value)
            {
                this.effect.Parameters["Scale"].SetValue(value);
                this.updatePhysics();
            }));

            this.Add(new SetBinding <Vector3>(this.UnderwaterColor, delegate(Vector3 value)
            {
                this.effect.Parameters["UnderwaterColor"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.Fresnel, delegate(float value)
            {
                this.effect.Parameters["Fresnel"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.Speed, delegate(float value)
            {
                this.effect.Parameters["Speed"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.RippleDensity, delegate(float value)
            {
                this.effect.Parameters["RippleDensity"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.Distortion, delegate(float value)
            {
                this.effect.Parameters["Distortion"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.Brightness, delegate(float value)
            {
                this.effect.Parameters["Brightness"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.Refraction, delegate(float value)
            {
                this.effect.Parameters["Refraction"].SetValue(value);
            }));

            this.Add(new SetBinding <Vector3>(this.Position, delegate(Vector3 value)
            {
                this.effect.Parameters["Position"].SetValue(this.Position);
                if (this.CannotSuspendByDistance)
                {
                    Water.BigWaterHeight.Value = value.Y;
                }
                this.updatePhysics();
            }));

            this.Add(new SetBinding <float>(this.Depth, delegate(float value)
            {
                this.updatePhysics();
            }));

            instances.Add(this);

            this.Add(new Binding <Vector3>(this.soundPosition,
                                           delegate(Vector3 pos)
            {
                BoundingBox box = this.Fluid.BoundingBox;
                pos.X           = Math.Max(box.Min.X, Math.Min(pos.X, box.Max.X));
                pos.Y           = this.Position.Value.Y;
                pos.Z           = Math.Max(box.Min.Z, Math.Min(pos.Z, box.Max.Z));
                return(pos);
            }, this.main.Camera.Position));
            Sound.AttachTracker(this.Entity, this.soundPosition);

            if (!this.main.EditorEnabled && this.Enabled && !this.Suspended)
            {
                AkSoundEngine.PostEvent(AK.EVENTS.PLAY_WATER_LOOP, this.Entity);
            }
        }
Example #51
0
 public static bool IsBoolean(this Property property)
 {
     return(property.Type.EqualsOrdinalIgnoreCase("bool"));
 }
Example #52
0
            protected override void VisitCollection <TContainer, TCollection, TElement>(Property <TContainer, TCollection> property, ref TContainer container, ref TCollection value)
            {
                UnityEngine.Assertions.Assert.IsNotNull(SearchHandler, $"{nameof(SourceDataBindingVisitor)} failed to construct the {nameof(SearchHandler<TElement>)}");

                if (RuntimeTypeInfoCache <TCollection> .CanBeNull && null == value)
                {
                    throw new InvalidBindingException($"SearchElement has invalid data bindings. FilterDataPath=[{FilterDataPath}] is null.");
                }

                if (!(SearchHandler is SearchHandler <TElement> typed))
                {
                    throw new InvalidBindingException($"SearchElement has invalid data bindings. SourceDataPath=[{SourceDataPath}] SourceDataType=[{SearchHandler.SearchDataType}] and FilterDataPath=[{FilterDataPath}] FilterDataType=[{typeof(TElement)}] types do not match.");
                }

                // @NOTE We can possibly add some magic here to handle `readonly` collection types (i.e. Array) by re-creating an instance and assigning each search.
                //       but for now we will just error out.
                if (value.IsReadOnly)
                {
                    throw new InvalidBindingException($"SearchElement has invalid data bindings. FilterDataPath=[{FilterDataPath}] is ReadOnly.");
                }

                var root = PropertyElement;
                var path = FilterDataPath;

                typed.OnBeginSearch += _ =>
                {
                    var filtered = root.GetValue <TCollection>(path);

                    if (RuntimeTypeInfoCache <TCollection> .CanBeNull && null == filtered)
                    {
                        throw new InvalidBindingException($"SearchElement has invalid data bindings. FilterDataPath=[{path}] is null.");
                    }

                    filtered.Clear();
                };

                typed.OnFilter += (_, elements) =>
                {
                    var filtered = root.GetValue <TCollection>(path);

                    if (RuntimeTypeInfoCache <TCollection> .CanBeNull && null == filtered)
                    {
                        throw new InvalidBindingException($"SearchElement has invalid data bindings. FilterDataPath=[{path}] is null.");
                    }

                    foreach (var element in elements)
                    {
                        filtered.Add(element);
                    }
                };
            }
Example #53
0
 public static bool IsDictionary(this Property property)
 {
     return(property.Type.StartsWith("Dictionary<"));
 }
Example #54
0
            protected override void VisitCollection <TContainer, TCollection, TElement>(Property <TContainer, TCollection> property, ref TContainer container, ref TCollection value)
            {
                if (RuntimeTypeInfoCache <TCollection> .CanBeNull && null == value)
                {
                    throw new InvalidBindingException($"SearchElement has invalid data bindings. SourceDataPath=[{SourceDataPath}] is null.");
                }

                var handler = new SearchHandler <TElement>(SearchElement);

                var root = PropertyElement;
                var path = SourceDataPath;

                handler.SetSearchDataProvider(() =>
                {
                    var filtered = root.GetValue <TCollection>(path);

                    if (RuntimeTypeInfoCache <TCollection> .CanBeNull && null == filtered)
                    {
                        throw new InvalidBindingException($"SearchElement has invalid data bindings. SourceDataPath=[{path}] is null.");
                    }

                    return(filtered);
                });

                SearchHandler = handler;
            }
Example #55
0
        private static string[] GetGenerics(Property property)
        {
            var match = Regex.Match(property.Type, ".*<(?<generics>.*)>");

            return(match.Groups["generics"].Value.Split(',').Select(x => x.Trim()).ToArray());
        }
Example #56
0
 public static bool IsLookupTable(this Property property)
 {
     return(property.Type.StartsWith("LookupTable<"));
 }
Example #57
0
 public static string GetCrefTag(this Property property)
 {
     return($"<see cref={$"{property.DataClass.Name}.{property.Name}".DoubleQuote()}/>");
 }
Example #58
0
 public static bool IsList(this Property property)
 {
     return(property.Type.StartsWith("List<"));
 }
Example #59
0
 public static string GetNullableType(this Property property)
 {
     return(property.IsValueType() ? property.Type + "?" : property.Type.Trim('!'));
 }
Example #60
0
 public static string GetListValueType(this Property property)
 {
     Assert.True(property.IsList());
     return(GetGenerics(property).Single());
 }