public override ValidaterInfo Validating(object value, object source, PropertyHandler hander) { ValidaterInfo vi = new ValidaterInfo(); vi.Message = Message; if (value != null && !string.IsNullOrEmpty(value.ToString())) { string data = Convert.ToString(value); if (MinLength != null && MinLength>data.Length) { vi.State = ValidaterState.Error; return vi; } if (MaxLength != null&& data.Length> MaxLength) { vi.State = ValidaterState.Error; return vi; } } return vi; }
public void AddHandler(BindableProperty property, PropertyHandler handler) { if (handler == null) throw new ArgumentNullException(); List<BindableProperty> propStore; if (!PropertiesByName.TryGetValue(property.PropertyName, out propStore)) { propStore = new List<BindableProperty> { property }; PropertiesByName.Add(property.PropertyName, propStore); } else { if (!propStore.Contains(property)) propStore.Add(property); } List<PropertyHandler> handlStore; if(!PropertyHandlers.TryGetValue(property, out handlStore)) { handlStore = new List<PropertyHandler>(); PropertyHandlers.Add(property, handlStore); } handlStore.Add(handler); if (_target != null) handler(property); }
public ObjectBinding() { ParameterStrategies.Add(new ComposeParameterStrategy(ComposeParametersExactPredicate, ComposeParametersExactConverter)); ParameterStrategies.Add(new ComposeParameterStrategy(ComposeParametersStrictPredicate, ComposeParametersStrictConverter)); ParameterStrategies.Add(new ComposeParameterStrategy(ComposeParametersWeekPredicate, ComposeParametersWeekConverter)); IHandler property = new PropertyHandler(this); IHandler field = new FieldHandler(this); IHandler @event = new EventHandler(this); //IHandler mutant = new MutantHandler(); IHandler sriptable = new ScriptableHandler(this); Getters.Add(property); Getters.Add(field); Getters.Add(@event); Getters.Add(new MethodGetter(this)); Getters.Add(sriptable); Getters.Add(new NestedTypeGetter(this)); //Getters.Add(new NameSpaceGetter()); Setters.Add(property); Setters.Add(field); Setters.Add(@event); Setters.Add(sriptable); }
public PropertyBinder(System.Reflection.PropertyInfo pi) { Handler = new PropertyHandler(pi); BindAttribute[] bas = Functions.GetPropertyAttributes<BindAttribute>(pi, false); if (bas.Length > 0) Binder = bas[0]; ViewStateAttribute[] vsa = Functions.GetPropertyAttributes<ViewStateAttribute>(pi, false); if (vsa.Length > 0) ViewState = vsa[0]; }
public override ValidaterInfo Validating(object value, object source, PropertyHandler hander) { ValidaterInfo vi = new ValidaterInfo(); vi.Message = Message; if (value == null || string.IsNullOrEmpty(value.ToString())) { vi.State = ValidaterState.Error; } return vi; }
public override ValidaterInfo Validating(object value, object source, PropertyHandler hander) { ValidaterInfo vi = new ValidaterInfo(); vi.Message = Message; if (value != null && !string.IsNullOrEmpty(value.ToString())) { string data = Convert.ToString(value); if (MinLength != null && MinLength > data.Length) { vi.State = ValidaterState.Error; return(vi); } if (MaxLength != null && data.Length > MaxLength) { vi.State = ValidaterState.Error; return(vi); } } return(vi); }
public RelatedDocumentsMapping(PropertyInfo property, string tableName, string schemaName) { TableName = tableName; SchemaName = schemaName; Handler = new PropertyHandler(property); }
private static ReflectionPropertyResult DeterminePropertyHandler(object source) { PropertyHandler result; if (source.GetType().IsMarshalByRef) { result = new PropertyHandler(GetSimple, SetSimple); } else if (source is IReflectionModel) { result = new PropertyHandler(GetReflection, SetReflection); } else if (source is IHaveIndexer) { result = new PropertyHandler(GetIndexer, SetIndexer); } else if (source is IDictionary) { result = new PropertyHandler(GetDictionary, SetDictionary); } else if (source is IDictionary<string, object>) { result = new PropertyHandler(GetLookUpDictionary, SetLookUpDictionary); } else if (source is NameValueCollection) { result = new PropertyHandler(GetNameValueCollection, SetNameValueCollection); } else if (source is Array) { result = new PropertyHandler(GetArray, SetArray); } else if (source is IList) { result = new PropertyHandler(GetList, SetList); } else if (source is IEnumerable) { result = new PropertyHandler(GetEnumerable, SetEnumerable); } else { result = new PropertyHandler(GetSimple, SetSimple); } return new ReflectionPropertyResult { PropertyHandler = result }; }
protected void btnContinue_Click(object sender, EventArgs e) { int quoteID = Convert.ToInt32(Session["QuoteID"]); string strQuoteMode = Convert.ToString(Session["QuoteMode"]); string strQuoteNo = Convert.ToString(Session["QuoteNo"]); if (strQuoteMode == "EDIT") { vwPropertyHandler objPropertyhandler = new vwPropertyHandler(); vwProperty objvwProperty = objPropertyhandler.GetDetailsByQuoteNo(strQuoteNo); //int propertyID = Convert.ToInt32(ViewState["PropertyID"]); Property objProperty = new Property(); objProperty.ID = objvwProperty.ID; objProperty.QuoteID = Convert.ToInt32(Session["QuoteID"]); objProperty.Address1 = Convert.ToString(txtAddress1.Text); objProperty.Address2 = Convert.ToString(txtAddress2.Text); objProperty.Zip = Convert.ToInt32(txtZip.Text); objProperty.City = Convert.ToString(txtCity.Text); objProperty.StateID = Convert.ToInt32(ddlState.SelectedValue); objProperty.ClassID = Convert.ToInt32(ddlSelectClass.SelectedValue); objProperty.StructureDescription = objvwProperty.StructureDescription; objProperty.ConstructionType = objvwProperty.ConstructionType; objProperty.HigherWindHall = objvwProperty.HigherWindHall; objProperty.ConstType_ApplySpriniderSafeguardP1 = objvwProperty.ConstType_ApplySpriniderSafeguardP1; objProperty.ConstType_ExcludeWindHall = objvwProperty.ConstType_ExcludeWindHall; objProperty.YearBuilt = objvwProperty.YearBuilt; objProperty.LastCompleteUpdateYear = objvwProperty.LastCompleteUpdateYear; objProperty.Plumbing = objvwProperty.Plumbing; objProperty.Rooting = objvwProperty.Rooting; objProperty.Wiring = objvwProperty.Wiring; objProperty.Coverage_Building = objvwProperty.Coverage_Building; objProperty.Coverage_BusinessIncome = objvwProperty.Coverage_BusinessIncome; objProperty.Coverage_PersonalPropertyofOthers = objvwProperty.Coverage_PersonalPropertyofOthers; objProperty.Coverage_PropertyInOpen = objvwProperty.Coverage_PropertyInOpen; objProperty.Coverage_Signs = objvwProperty.Coverage_Signs; PropertyHandler propertyHandler = new PropertyHandler(); propertyHandler.Update(objProperty); } else { Property objProperty = new Property(); objProperty.QuoteID = Convert.ToInt32(Session["QuoteID"]); objProperty.Address1 = Convert.ToString(txtAddress1.Text); objProperty.Address2 = Convert.ToString(txtAddress2.Text); objProperty.Zip = Convert.ToInt32(txtZip.Text); objProperty.City = Convert.ToString(txtCity.Text); objProperty.StateID = Convert.ToInt32(ddlState.SelectedValue); objProperty.ClassID = Convert.ToInt32(ddlSelectClass.SelectedValue); PropertyHandler propertyHandler = new PropertyHandler(); propertyHandler.AddNew(objProperty); } //string strQuoteNo = Convert.ToString(Session["QuoteNo"]); LoadPropertyDetails(strQuoteNo); mvProperty.SetActiveView(vwBuilding); }
private SelectDataReader CreateSelectReader(Type type) { SelectDataReader sr = new SelectDataReader(); if (type != ObjectType) { sr.Proxy = true; } bool isgroup = false;; StringBuilder select = new StringBuilder(); StringBuilder group = new StringBuilder(); PropertyHandler handler = null; if (ID != null) { handler = MatchProperty(ID.Handler.Property, type); if (handler != null) { select.Append("(" + ID.ColumnName + ") as p_" + ID.Handler.Property.Name); group.Append(ID.ColumnName); sr.AddProperty(ID); sr.ProxyProperties.Add(handler); } } foreach (PropertyMapper pm in Properties) { handler = MatchProperty(pm.Handler.Property, type); if (handler == null) { continue; } sr.ProxyProperties.Add(handler); sr.AddProperty(pm); if (select.Length > 0) { select.Append(","); } if (pm.Aggregation != null) { if (pm.Aggregation.DISTINCT) { select.Append("(" + pm.Aggregation.Type + "(DISTINCT " + pm.ColumnName + ")) as p_" + pm.Handler.Property.Name); } else { select.Append("(" + pm.Aggregation.Type + "(" + pm.ColumnName + ")) as p_" + pm.Handler.Property.Name); } isgroup = true; } else { select.Append("(" + pm.ColumnName + ") as p_" + pm.Handler.Property.Name); if (group.Length > 0) { group.Append(","); } group.Append(pm.ColumnName); } } sr.Select = "Select " + DISTINCT + select.ToString() + " from {0}"; if (isgroup) { sr.Group = group.ToString(); } if (sr.Properties.Count == 0) { throw new PeanutException(string.Format(DataMsg.BOBJ_NOTMATCH_DOBJ, type, ObjectType)); } return(sr); }
public InvokeParameter(PropertyInfo info) { Info = info; Handler = new PropertyHandler(info); }
//New Skin Constructor //Constructor that creates info for storage public NewSkin(int id, String fullname, int cspslot, String libraryname, LibraryHandler global_library, PropertyHandler global_properties, Filebank golabl_filebank) { #region Handlers this.library = global_library; this.config = global_properties; this.filebank = golabl_filebank; #endregion #region SkinInfo #region Basic info this.fullname = fullname; this.libraryname = libraryname; this.csp_foldername = library.get_cspfolder_fullname(this.fullname); this.model_foldername = library.get_modelfolder_fullname(this.fullname); this.dlc = library.get_dlc_status(this.fullname); #endregion #region localisation settings if (config.property_get("unlocalised") == "1") { this.dlc_datafolder = "data"; } else { this.dlc_datafolder = config.property_get("datafolder"); } #endregion #region ID if (id == -1) { this.id = generate_id(); } else { this.id = id; } #endregion #region Slots //Setting slots this.cspslot = cspslot; this.modelslot = cspslot - 1; //Setting slot texts this.modelslot_text = (this.modelslot < 10 ? "0" + this.modelslot.ToString() : this.modelslot.ToString()); this.cspslot_text = (this.cspslot < 10 ? "0" + this.cspslot.ToString() : this.cspslot.ToString()); #endregion #endregion #region Library Folders //Filebank folders this.filebank_folder = Application.StartupPath + "/mmsl_filebank/Skins/" + this.fullname + "/meteor_" + this.id + "_" + this.libraryname; //Extract folders this.extract_model_folder = Application.StartupPath + "/mmsl_workspace/data/fighter/" + this.model_foldername + "/model"; this.extract_csp_folder = Application.StartupPath + "/mmsl_workspace/data/ui/replace/chr/"; this.extract_dlc_csp_folder = Application.StartupPath + "/mmsl_workspace/" + this.dlc_datafolder + "/ui/replace/append/chr/"; this.extract_meta_folder = Application.StartupPath + "/mmsl_config/meta/" + model_foldername + "/slot_" + cspslot; #endregion }
public ObjectTransformation(PropertyHandler propertyHandler) { _propertyHandler = propertyHandler; }
private void ReaderToProperty(System.Data.IDataReader reader, object obj, ReadProperty rp, PropertyMapper pm, PropertyHandler handler) { try { object dbvalue = reader[rp.Index]; if (dbvalue != DBNull.Value) { if (pm.Cast != null) { dbvalue = pm.Cast.ToProperty(dbvalue, pm.Handler.Property.PropertyType, obj); } handler.Set(obj, Convert.ChangeType(dbvalue, pm.Handler.Property.PropertyType)); } } catch (Exception e_) { throw new PeanutException(string.Format(DataMsg.READER_TO_PROPERTY_ERROR, pm.ColumnName, pm.Handler.Property.Name), e_); } }
public void GetProperties_PassDefaultPropertyCollection_ReturnsSameCollection() { var defaultProperties = A.Fake<IPropertyCollection>(); var propertyHandler = new PropertyHandler("username", defaultProperties, null); Assert.AreEqual(defaultProperties, propertyHandler.GetProperties()); }
public abstract ValidaterInfo Validating(object value, object source, PropertyHandler hander);
public override ValidaterInfo Validating(object value, object source, PropertyHandler hander) { ValidaterInfo vi = new ValidaterInfo(); vi.Message = Message; if (value != null && !string.IsNullOrEmpty(value.ToString())) { string data = Convert.ToString(value); if (System.Text.RegularExpressions.Regex.Match( data, Regex, RegexOptions.IgnoreCase).Length==0) { vi.State = ValidaterState.Error; } } return vi; }
public static List <IItem> GetJsupItemsByStore(DesktopSession dSession, string pStoreNumber, string pTransferType, out string errorMessage) { // Declare OUT parameters. DataTable table = new DataTable(); DataTable tableDesc = new DataTable(); string errorCode; string errorText; errorMessage = string.Empty; List <IItem> items = new List <IItem>(); bool retVal = TransfersDBProcedures.ExecuteGetJsupMerchandise( pStoreNumber, pTransferType, out table, out tableDesc, out errorCode, out errorText); if (retVal == false || table == null || string.IsNullOrEmpty(errorText) == false) { errorMessage = errorCode + ": " + errorText; FileLogger.Instance.logMessage(LogLevel.ERROR, null, errorMessage); return(items); } IItem item = new Item(); //re-instantiated and re-used in each loop iteration foreach (DataRow r in table.Rows) { if (pTransferType.Equals("SCRAP", StringComparison.CurrentCultureIgnoreCase)) { item = new ScrapItem(); } else if (pTransferType.Equals("REFURB", StringComparison.CurrentCultureIgnoreCase)) { //item = new Item(); item = new ScrapItem(); } else if (pTransferType.Equals("EXCESS", StringComparison.CurrentCultureIgnoreCase)) { // item = new Item(); item = new ScrapItem(); } //else handled by TransfersDBProcedures's call above returning false with errorCode and errorText having been set int icndocFromRow = Utilities.GetIntegerValue(r["ICN_DOC"], -1); string storeNumberFromRow = Utilities.GetStringValue(r["STORENUMBER"], ""); item.RefurbNumber = Utilities.GetIntegerValue(r["RFB_NO"]); item.Icn = Utilities.GetStringValue(r["ICN"]); item.TicketDescription = Utilities.GetStringValue(r["MD_DESC"]); item.ItemAmount = Utilities.GetDecimalValue(r["PFI_AMOUNT"]); item.ItemStatus = (ProductStatus)Enum.Parse(typeof(ProductStatus), Utilities.GetStringValue(r["STATUS_CD"], "")); item.mDocType = Utilities.GetStringValue(r["ICN_DOC_TYPE"]); item.mStore = Utilities.GetIntegerValue(r["ICN_STORE"]); item.CategoryCode = Utilities.GetIntegerValue(r["CAT_CODE"], 0); item.CategoryDescription = Utilities.GetStringValue(r["CAT_DESC"], ""); item.mItemOrder = Utilities.GetIntegerValue(r["ICN_ITEM"]); item.CaccLevel = Utilities.GetIntegerValue(r["CACC_LEV"], -1); item.Attributes = new List <ItemAttribute>(); //Used to get the attributes of the item. //This will be helpful later, such as determining the type of metal for scraps. for (int iMask = 1; iMask <= 15; iMask++) { ItemAttribute itemAttribute = new ItemAttribute(); if (Utilities.GetIntegerValue(r["MASK" + iMask.ToString()], 0) > 0) { itemAttribute.MaskOrder = iMask; Answer answer = new Answer(); answer.AnswerCode = Utilities.GetIntegerValue(r["MASK" + iMask.ToString()], 0); answer.AnswerText = Utilities.GetStringValue(r["MASK_DESC" + iMask.ToString()], ""); // Pull from Other Description List Table if (tableDesc != null && answer.AnswerCode == 999) { string sOtherDscFilter = "STORENUMBER = '" + storeNumberFromRow + "'"; sOtherDscFilter += " and ICN_STORE = " + item.mStore.ToString(); sOtherDscFilter += " and ICN_YEAR = " + item.mYear.ToString(); sOtherDscFilter += " and ICN_DOC = '" + icndocFromRow + "' "; sOtherDscFilter += " and ICN_DOC_TYPE = " + item.mDocType; sOtherDscFilter += " and ICN_ITEM = " + item.mItemOrder; sOtherDscFilter += " and ICN_SUB_ITEM = 0"; sOtherDscFilter += " and MASK_SEQ = " + iMask.ToString(); DataRow[] dataOtherDScRows = tableDesc.Select(sOtherDscFilter); if (dataOtherDScRows.Length > 0) { answer.AnswerCode = 999; answer.AnswerText = Utilities.GetStringValue(dataOtherDScRows[0]["OD_DESC"], ""); } else { answer.AnswerCode = 0; answer.AnswerText = ""; } } itemAttribute.Answer = answer; } if (itemAttribute.Answer.AnswerCode == 999 || itemAttribute.Answer.AnswerCode > 0) { item.Attributes.Add(itemAttribute); } } //Set item attributes int iCategoryMask = dSession.CategoryXML.GetCategoryMask(item.CategoryCode); DescribedMerchandise dmPawnItem = new DescribedMerchandise(iCategoryMask); Item pawnItem = (Item)item; Item.PawnItemMerge(ref pawnItem, dmPawnItem.SelectedPawnItem, true); //Should copy the description, etc. over to the item. PropertyInfo[] fromFields = typeof(Item).GetProperties(); PropertyInfo[] toFields = //typeof(ScrapItem).GetProperties(); item.GetType().GetProperties(); PropertyHandler.SetProperties(fromFields, toFields, pawnItem, item); //Does not merge well. item.Quantity = Utilities.GetIntegerValue(r["QUANTITY"]); if (item is ScrapItem) { //Wait to add scrap items until after merge. ((ScrapItem)item).StoreNumber = storeNumberFromRow; ((ScrapItem)item).TicketNumber = icndocFromRow; } items.Add(item); } return(items); }
//acts as a constructor to setup the propertycell public void CellInitialize(PropertyHandler handlerParam) { txtProperty.text = handlerParam.sName + ": " + CleanUpNumber(handlerParam.fValue); }
public override ValidaterInfo Validating(object value, object source, PropertyHandler hander) { ValidaterInfo vi = new ValidaterInfo(); vi.Message = Message; if (value != null && !string.IsNullOrEmpty(value.ToString())) { DateTime data = Convert.ToDateTime(value); if (MinValue != null) { if (MinValue > data) { vi.State = ValidaterState.Error; return vi; } } if (MaxValue != null) { if (data > MaxValue) { vi.State = ValidaterState.Error; return vi; } } } return vi; }
public static void UnRegister(System.Type t) { PropertyHandler.UnRegisterExtension(typeof(P4EXPColumnExtension)); }
/// <summary> /// Adds a handler to the collection /// </summary> /// <param name="property">The property the handler handles</param> /// <param name="handler">The handler</param> public void Add(string property, PropertyHandler handler) { InnerHashtable.Add(property.ToLower(), handler); }
// Only EditorGUI.DefaultPropertyField is replaced with EditorGUIHelper.DefaultPropertyFieldDelayed private static bool OnGUIDelayed(this PropertyHandler handler, Rect position, SerializedProperty property, GUIContent label, bool includeChildren) { Rect visibleArea = new Rect(0f, 0f, float.MaxValue, float.MaxValue); handler.TestInvalidateCache(); float oldLabelWidth, oldFieldWidth; float propHeight = position.height; position.height = 0; if (handler.m_DecoratorDrawers != null && !handler.isCurrentlyNested) { foreach (DecoratorDrawer decorator in handler.m_DecoratorDrawers) { position.height = decorator.GetHeight(); oldLabelWidth = EditorGUIUtility.labelWidth; oldFieldWidth = EditorGUIUtility.fieldWidth; decorator.OnGUI(position); EditorGUIUtility.labelWidth = oldLabelWidth; EditorGUIUtility.fieldWidth = oldFieldWidth; position.y += position.height; propHeight -= position.height; } } position.height = propHeight; if (handler.propertyDrawer != null) { // Remember widths oldLabelWidth = EditorGUIUtility.labelWidth; oldFieldWidth = EditorGUIUtility.fieldWidth; // Draw with custom drawer handler.propertyDrawer.OnGUISafe(position, property.Copy(), label ?? EditorGUIUtility.TempContent(property.localizedDisplayName)); // Restore widths EditorGUIUtility.labelWidth = oldLabelWidth; EditorGUIUtility.fieldWidth = oldFieldWidth; return(false); } if (PropertyHandler.IsNonStringArray(property)) { string key = ReorderableListWrapper.GetPropertyIdentifier(property); if (!PropertyHandler.s_reorderableLists.TryGetValue(key, out ReorderableListWrapper reorderableList)) { throw new IndexOutOfRangeException( $"collection with name \"{property.name}\" doesn't have ReorderableList assigned to it."); } reorderableList.Property = property; reorderableList.Draw(position, visibleArea); return(false); } if (!includeChildren) { return(EditorGUIHelper.DefaultPropertyFieldDelayed(position, property, label)); } // Remember state Vector2 oldIconSize = EditorGUIUtility.GetIconSize(); bool wasEnabled = GUI.enabled; int origIndent = EditorGUI.indentLevel; int relIndent = origIndent - property.depth; SerializedProperty prop = property.Copy(); position.height = EditorGUI.GetSinglePropertyHeight(prop, label); // First property with custom label EditorGUI.indentLevel = prop.depth + relIndent; bool childrenAreExpanded = EditorGUIHelper.DefaultPropertyFieldDelayed(position, prop, label) && EditorGUI.HasVisibleChildFields(prop); position.y += position.height + EditorGUI.kControlVerticalSpacing; // Loop through all child properties if (childrenAreExpanded) { SerializedProperty endProperty = prop.GetEndProperty(); while (prop.NextVisible(childrenAreExpanded) && !SerializedProperty.EqualContents(prop, endProperty)) { var childHandler = ScriptAttributeUtility.GetHandler(prop); EditorGUI.indentLevel = prop.depth + relIndent; position.height = childHandler.GetHeight(prop, null, false); if (position.Overlaps(visibleArea)) { EditorGUI.BeginChangeCheck(); childrenAreExpanded = childHandler.OnGUIDelayed(position, prop, null, false) && EditorGUI.HasVisibleChildFields(prop); // Changing child properties (like array size) may invalidate the iterator, // so stop now, or we may get errors. if (EditorGUI.EndChangeCheck()) { break; } } position.y += position.height + EditorGUI.kControlVerticalSpacing; } } // Restore state GUI.enabled = wasEnabled; EditorGUIUtility.SetIconSize(oldIconSize); EditorGUI.indentLevel = origIndent; return(false); }
public void RegisterPropertyHandler(string propertyId, PropertyHandler handler) { throw new NotImplementedException(); }
public abstract ValidaterInfo Validating(object value,object source,PropertyHandler hander);
public CustomerGroupBuilder(Vector startLocation, Vector destination) { PropertyHandler.ResetProperties(); CustomerGroup = new CustomerGroup(random.Next(1, (int)Math.Round(3 / 2.0 * 3.0)), new Building(startLocation, 10), new Building(destination, 10)); }
/// <summary> /// Adds a <see cref="PropertyHandler{TProperty}"/> to convert a property to an <see cref="XElement"/>. /// If the handler does not set the <c>itemprop</c> attribute on the returned element, it will be /// set automatically. /// </summary> public void Property <TProperty>(Expression <Func <T, TProperty> > expression, PropertyHandler <TProperty> propertyHandler) { var info = GetMemberInfo(expression.Body); propertyHandlers.Add(info.Name, propertyHandler); }
public CityBuilder() { PropertyHandler.ResetProperties(); City = new City("Test City"); }
/// <summary> /// Adds a <see cref="EntityHandler{TEntity}"/> to create an <see cref="XElement"/>. This overload /// can be used to generate a computed property when such a property is not present on the entity. /// If the handler does not set the <c>itemprop</c> attribute on the returned element, it will be /// set automatically. /// </summary> public void Property <TProperty>(string propertyName, PropertyHandler <TProperty> propertyHandler) { propertyHandlers.Add(propertyName, propertyHandler); }
public PropertyBinder(System.Reflection.PropertyInfo pi) { Handler = new PropertyHandler(pi); BindAttribute[] bas = Functions.GetPropertyAttributes<BindAttribute>(pi, false); if (bas.Length > 0) Binder = bas[0]; ViewStateAttribute[] vsa = Functions.GetPropertyAttributes<ViewStateAttribute>(pi, false); if (vsa.Length > 0) ViewState = vsa[0]; foreach (ValidaterAttribute va in Functions.GetPropertyAttributes<ValidaterAttribute>(pi, false)) { Validaters.Add(va); } }
public static City MakeCity(XmlDocument city, string name) { var properties = PropertyHandler.GetProperties(); if (properties.ContainsKey("availableCars")) { PropertyHandler.ResetProperties(); } var cityObject = new City(name); var root = city.DocumentElement; if (root == null) { throw new XmlException("Missing root node"); } //selecting and adding roads to List var roads = city.SelectSingleNode("//City/Roads"); if (roads == null) { throw new XmlException("Missing roads in city."); } foreach (var road in roads.ChildNodes) { cityObject.Roads.Add(ParseRoad((XmlNode)road)); } //selecting and adding buildings to List var buildings = city.SelectSingleNode("//City/Buildings"); if (buildings == null) { throw new XmlException("Missing buildings in city."); } foreach (var building in buildings.ChildNodes) { cityObject.Buildings.Add(ParseBuilding((XmlNode)building)); } //selecting and adding intersections to list var intersections = city.SelectSingleNode("//City/Intersections"); if (intersections == null) { throw new XmlException("Missing intersections in city."); } foreach (var intersection in intersections.ChildNodes) { cityObject.Intersections.Add(ParseIntersection((XmlNode)intersection)); } try { NodeNetwork.GenerateNetwork(cityObject.Roads, cityObject.Intersections); } catch (Exception) { App.Console?.Print("Unable to load road network!", Colors.Red); } return(cityObject); }
public void RegisterPropertyHandler(string propertyId, PropertyHandler handler) { submodelServiceProvider.RegisterPropertyHandler(propertyId, handler); }
public String createSession(String sessionType, String inss, String password, Boolean isMock) { be.ehealth.technicalconnector.session.SessionItem sessionItem; String resultSession; try { if (isMock) { resultSession = "Create session not supported for mock";; } else { sessionItem = SessionUtil.createSession(SessionType.valueOf(sessionType), PropertyHandler.getInstance().getPropertiesCopy(), inss, password); resultSession = SAML10Converter.toXMLString(sessionItem.getSAMLToken().getAssertion()); } return(resultSession); } catch (IntegrationModuleException e) { errorMessage = e.getMessage(); throw e; } }
public CityController(City city) { City = city; PropertyHandler.RegisterProperty("customerSpawnRate", ref customerSpawnRate); }
/// <summary> /// Generate Viewpoint /// </summary> private VisualizationInfo generateViewpoint() { try { // save selected elements to BCF compoments first List <Component> bcfComponents = new List <Component>(); var selectedElements = MSApp.ActiveModelReference.GetSelectedElements().BuildArrayFromContents(); if (selectedElements.Length > 0) { string originatingSystem = getBentleyProductName(); bcfComponents = new List <Component>(); foreach (Element e in selectedElements) { string ifcGuid = string.Empty; PropertyHandler handler = MSApp.CreatePropertyHandler(e); if (handler.SelectByAccessString("GUID")) { Guid guid = parseGuid(handler.GetDisplayString()); ifcGuid = IfcGuid.ToIfcGuid(guid).ToString(); } bcfComponents.Add(new Component(originatingSystem, e.ID.ToString(), ifcGuid)); } } // get current view int activeViewNum = getActiveViewNumber(); View currentView = MSApp.ActiveDesignFile.Views[activeViewNum]; double unitFactor = 1 / GetGunits(); // enable perspective camera back and forth to get correct view attributes, see the post below // https://communities.bentley.com/products/programming/microstation_programming/f/343173/t/80064 MSApp.CadInputQueue.SendKeyin("MDL KEYIN BENTLEY.VIEWATTRIBUTESDIALOG,VAD VIEWATTRIBUTESDIALOG SETATTRIBUTE 0 Camera True"); MSApp.CadInputQueue.SendKeyin("MDL KEYIN BENTLEY.VIEWATTRIBUTESDIALOG,VAD VIEWATTRIBUTESDIALOG SETATTRIBUTE 0 Camera False"); // camera direction Point3d direction = MSApp.Point3dNormalize(MSApp.Point3dSubtract(currentView.get_CameraTarget(), currentView.get_CameraPosition())); // force view center to be identical as camera target if camera direction is not along Z axis (i.e., not top view or bottom view) if (direction.X > distancePrecision || direction.Y > distancePrecision) // arbitrary precision { Point3d center = new Point3d(); center = currentView.get_Center(); Point3d extents = new Point3d(); extents = currentView.get_Extents(); Point3d translation = new Point3d(); translation = MSApp.Point3dSubtract(center, currentView.get_CameraTarget()); ViewCameraParameters vcp = new ViewCameraParametersClass(); vcp.set_CameraPosition(MSApp.Point3dAdd(currentView.get_CameraPosition(), translation)); vcp.set_CameraTarget(MSApp.Point3dAdd(currentView.get_CameraTarget(), translation)); currentView.SetCameraProperties(vcp); currentView.set_Extents(extents); currentView.set_Center(center); currentView.Redraw(); } // camera scale double h = currentView.get_Extents().Y *unitFactor; double w = currentView.get_Extents().X *unitFactor; double fov = 180 * currentView.CameraAngle / Math.PI; // camera location Point3d cameraLocation = MSApp.Point3dScale(currentView.get_CameraPosition(), unitFactor); // grab current view center point and force to top view if camera direction is along Z axis (i.e., top view or bottom view) if (direction.X < distancePrecision && direction.Y < distancePrecision) // arbitrary precision { cameraLocation = MSApp.Point3dScale(currentView.get_Center(), unitFactor); direction.Z = -1.0; } // camera up vector Point3d upVector = currentView.get_CameraUpVector(); // set up BCF viewpoint VisualizationInfo v = new VisualizationInfo(); v.Components = bcfComponents; // FIXME: ignore perspective view for now /*if (currentView.isPerspective) * { * v.PerspectiveCamera = new PerspectiveCamera(); * v.PerspectiveCamera.CameraViewPoint.X = cameraLocation.X; * v.PerspectiveCamera.CameraViewPoint.Y = cameraLocation.Y; * v.PerspectiveCamera.CameraViewPoint.Z = cameraLocation.Z; * v.PerspectiveCamera.CameraUpVector.X = upVector.X; * v.PerspectiveCamera.CameraUpVector.Y = upVector.Y; * v.PerspectiveCamera.CameraUpVector.Z = upVector.Z; * v.PerspectiveCamera.CameraDirection.X = direction.X; * v.PerspectiveCamera.CameraDirection.Y = direction.Y; * v.PerspectiveCamera.CameraDirection.Z = direction.Z; * v.PerspectiveCamera.FieldOfView = fov; * } * else * {*/ v.OrthogonalCamera = new OrthogonalCamera(); v.OrthogonalCamera.CameraViewPoint.X = cameraLocation.X; v.OrthogonalCamera.CameraViewPoint.Y = cameraLocation.Y; v.OrthogonalCamera.CameraViewPoint.Z = cameraLocation.Z; v.OrthogonalCamera.CameraUpVector.X = upVector.X; v.OrthogonalCamera.CameraUpVector.Y = upVector.Y; v.OrthogonalCamera.CameraUpVector.Z = upVector.Z; v.OrthogonalCamera.CameraDirection.X = direction.X; v.OrthogonalCamera.CameraDirection.Y = direction.Y; v.OrthogonalCamera.CameraDirection.Z = direction.Z; v.OrthogonalCamera.ViewToWorldScale = h; //} // get current clip volume and compute clipping planes ulong previousClipVolumeId = 0; try { int status = mdlView_getClipBoundaryElement(ref previousClipVolumeId, activeViewNum - 1).ToInt32(); if (status == 0) { Element previousClipVolume = MSApp.ActiveModelReference.GetElementByID((long)previousClipVolumeId); var smartSolids = MSApp.SmartSolid.ConvertToSmartSolidElement(previousClipVolume).BuildArrayFromContents(); if (smartSolids.Length > 0) { // just consider one solid for now SmartSolidElement clipVolumeSolid = smartSolids[0].AsSmartSolidElement; var surfaces = clipVolumeSolid.ExtractAllSurfaceFromSolid().BuildArrayFromContents(); List <ClippingPlane> clippingPlanes = new List <ClippingPlane>(); foreach (Element surface in surfaces) { ComplexShapeElement surfaceShape = surface.AsComplexShapeElement(); var vertices = surfaceShape.ConstructVertexList(0.1); // arbitrary tolerance for now if (vertices.Length > 0) { // produce BCF clipping planes Point3d location = MSApp.Point3dScale(MSApp.Point3dAdd(clipVolumeSolid.Origin, vertices[0]), unitFactor); ClippingPlane clippingPlane = new ClippingPlane() { Direction = new Direction() { X = surfaceShape.Normal.X, Y = surfaceShape.Normal.Y, Z = surfaceShape.Normal.Z }, Location = new Classes.BCF2.Point() { X = location.X, Y = location.Y, Z = location.Z } }; clippingPlanes.Add(clippingPlane); } } // add to BCF clipping planes v.ClippingPlanes = clippingPlanes.ToArray(); } } } catch (Exception ex) { // do nothing just for catching the exception when clip volume not found, element not found, or not being converted to smart solid } return(v); } catch (System.Exception ex1) { MessageBox.Show("exception: " + ex1, "Error!"); } return(null); }