/// <summary> /// Vraca putanju za property /// </summary> /// <param name="input">objekat za koji se vraca putanja ka propertiju</param> /// <param name="iPI"></param> /// <param name="returnPropertyPath"></param> /// <returns></returns> public static string getPathForProperty(this IObjectWithParent input, PropertyInfo iPI, bool returnPropertyPath = false) { string output = input.getPathForObjectWithParent(); string key = imbProjectResourceBase.prefix_PROPERTY_PATH; string needle = iPI.Name; if (returnPropertyPath) { key = imbProjectResourceBase.prefix_PROPERTYINFO; } else { key = imbProjectResourceBase.prefix_PROPERTY_PATH; object relObj = input.imbGetPropertySafe(iPI, null); if (relObj is IObjectWithName) { IObjectWithName relObj_IObjectWithName = (IObjectWithName)relObj; needle = relObj_IObjectWithName.name; } } output = output.add(needle, key); return(output); }
/// <summary> /// Gets the filename. /// </summary> /// <param name="instance">The instance.</param> /// <param name="sufix">The sufix.</param> /// <returns></returns> protected String getFilename(IObjectWithName instance, String sufix = "") { if (sufix.isNullOrEmpty()) { sufix = instance.GetType().Name; } return(getFilename(instance.name, sufix)); }
public void Add(graphWrapNode <htmlWrapper> input) { IObjectWithName rni = input.root as IObjectWithName; string xp = input.path.removeStartsWith(rni.name).Replace("/", "\\"); xPathRoots.AddUnique(xp); foreach (var lf in input.getAllLeafs()) { graphWrapNode <htmlWrapper> ch = lf as graphWrapNode <htmlWrapper>; Add(ch.item); } }
private static string _getPathKey(object input, object parent, out string prefix) { string key = ""; prefix = imbProjectResourceBase.prefix_PROPERTY_PATH; if (parent is ICollection) { //if (parent is ICollectionWithKeyProperty) //{ // ICollectionWithKeyProperty input_parent_ICollectionWithKeyProperty = // (ICollectionWithKeyProperty) parent; // key = input_parent_ICollectionWithKeyProperty.getKeyForInstance(input); //} if (string.IsNullOrEmpty(key)) { if (parent is IList) { IList il = parent as IList; key = il.IndexOf(input).ToString(); } } if (string.IsNullOrEmpty(key)) { if (input is IObjectWithName) { IObjectWithName input_IObjectWithName = (IObjectWithName)input; key = input_IObjectWithName.name; } } prefix = imbProjectResourceBase.prefix_COLLECTION_INDEX_ACCESS; } else { //oneOrMore<imbPropertyInfoWithValue> relations = parent.getAllPropertyInfoWithValue(input); //if (relations.isSomething) //{ // imbPropertyInfoWithValue iPIV = relations.First(); // prefix = iPIV.property.relationType.toPrefixString(imbProjectResourceBase.prefix_PROPERTY_PATH); // key = iPIV.property.name; //} //else //{ //} } return(key); }
/// <summary> /// Gets the path from object - just casting trick /// </summary> /// <param name="head">The head.</param> /// <returns></returns> public static String getPathFromObject(this IObjectWithPath head) { IObjectWithPath p_head = head as IObjectWithPath; if (p_head != null) { return(p_head.path); } if (head is IObjectWithName) { IObjectWithName n_head = head as IObjectWithName; return(PATHGO_PARENT + n_head.name); } return(PATHSPLITER); }
/// <summary> /// Gets the universal ID name for specified element /// </summary> /// <param name="element">The element.</param> /// <param name="autoSet">if set to <c>true</c> [automatic set].</param> /// <param name="useRelatedObject">if set to <c>true</c> [use related object].</param> /// <returns></returns> internal string getUID(diagramElementBase element, bool autoSet = true, bool useRelatedObject = false) { string output = ""; if (element is diagramNode) { if (useRelatedObject) { if (element.relatedObject is IObjectWithPath) { IObjectWithPath element_relatedObject_IObjectWithPath = (IObjectWithPath)element.relatedObject; string ptname = element_relatedObject_IObjectWithPath.path.getCleanPropertyName(); output = nodes.makeUniqueDictionaryName(ptname, ref _lastNamingIteration, 10); } else if (element.relatedObject is IObjectWithName) { IObjectWithName withName = (IObjectWithName)element.relatedObject; output = nodes.makeUniqueDictionaryName(withName.name.getCleanPropertyName(), ref _lastNamingIteration, 100); } } if (output.isNullOrEmpty()) { output = ((long)nodeCount).DecimalToOrdinalLetterSystem(); } } else if (element is diagramLink) { if (useRelatedObject) { diagramLink link = element as diagramLink; if (link.isConnected) { output = link.from.name + "to" + link.to.name; } } if (output.isNullOrEmpty()) { output = ((long)linkCount).DecimalToOrdinalLetterSystem() + "_link"; } } if (autoSet) { element.name = output; } return(output); }
private object GetFormatter(XElement element) { string formatterType = GetAttribute(element, "Type"); string formatterName = GetAttribute(element, "Name"); IObjectWithName returnFormatter = null; if (formatterType == "ByteArrayFormatter") { ByteArrayFormatter formatter = null; if (element.Attribute("TypeId") != null && !string.IsNullOrEmpty(element.Attribute("TypeId").Value)) { formatter = new ByteArrayFormatter(formatterName, byte.Parse(element.Attribute("TypeId").Value)); } else { formatter = new ByteArrayFormatter(formatterName); } foreach (var itemElement in element.Elements("Item")) { formatter.AddItem(GetItem(itemElement)); } returnFormatter = formatter; } else if (formatterType == "StringFormatter") { StringFormatter formatter = new StringFormatter(formatterName); foreach (var itemElement in element.Elements("Item")) { formatter.AddItem(GetItem(itemElement)); } returnFormatter = formatter; } else { throw new UnknownElementException("Unkown formatter type:" + formatterType); } _adapterObjects[_currentAdapterName].Add(returnFormatter.Name, returnFormatter); return(returnFormatter); }
/// <summary> /// Adds the data table row. /// </summary> /// <param name="table">The table.</param> /// <param name="item">The item.</param> /// <param name="options">The options.</param> public static void AddDataTableRow(this DataTable table, object item, buildDataTableOptions options) { DataRow dr = table.NewRow(); foreach (DataColumn dc in table.Columns) { object val = dc.DataType.GetDefaultValue(); if (!dc.AutoIncrement) { if (dc.ColumnName == nameof(globalMeasureUnitDictionary.globalMeasureEnum.itemTitle)) { if (item is IObjectWithName) { IObjectWithName item_IObjectWithName = (IObjectWithName)item; val = item_IObjectWithName; } else if (item is string) { val = item; } else if (item is KeyValuePair <string, int> ) { var pair = (KeyValuePair <string, int>)item; val = pair.Key; } else { val = item.GetType().Name; } } var pi = item.GetType().GetProperty(dc.ColumnName); val = pi.GetValue(dc.ColumnName, null); // item.GetPropertyValue(dc.ColumnName); PropertyEntry pe = dc.ExtendedProperties.getProperObject <PropertyEntry>(templateFieldDataTable.col_pe); if (pe != null) { val = PropertyDataStructureTools.getColumnValue(pe, item, table.Rows.Count, "D3"); } //String format = dc.ExtendedProperties.get(templateFieldDataTable.col_format, "").toStringSafe(); //if (format != "") val = val. dr[dc] = val; } } table.Rows.Add(dr); }
private static string _getPathForParent(object parent) { string line = ""; if (parent == null) { return(""); } #region PARENT PATH ------ //if (parent is imbApplicationProject) //{ // line.Append(imbProjectResourceBase.prefix_PROJECT_PATH); //} //else if (parent is IObjectWithPath) { IObjectWithPath input_parent_IObjectWithPath = (IObjectWithPath)parent; line = line.add(input_parent_IObjectWithPath.path); } else { if (parent is IObjectWithName) { IObjectWithName input_parent_IObjectWithName = (IObjectWithName)parent; line = line.add(input_parent_IObjectWithName.name); } //else if (parent.GetType() == typeof(imbTypeInfo)) //{ // imbTypeInfo parent_imbTypeInfo = (imbTypeInfo) parent; // if (parent_imbTypeInfo.isStatic) // { // line.Append("~" + parent_imbTypeInfo.type.Name); // } //} } #endregion PARENT PATH ------ return(line); }
/// <summary> /// 2014c: Univerzalni konstruktor putanje /// </summary> /// <param name="input"></param> /// <returns></returns> public static string getPathForObject(this object input) { //if (input is imbProjectResourceBase) //{ // imbProjectResourceBase input_imbProjectResourceBase = (imbProjectResourceBase) input; // return input_imbProjectResourceBase.path; //} if (input is IObjectWithParent) { IObjectWithParent input_IObjectWithParent = (IObjectWithParent)input; return(getPathForObjectWithParent(input_IObjectWithParent)); } if (input is IObjectWithName) { IObjectWithName input_IObjectWithName = (IObjectWithName)input; return(input_IObjectWithName.name); } return(""); }
private object GetInterpreter(XElement element) { string interpreterType = GetAttribute(element, "Type"); string interpreterName = GetAttribute(element, "Name"); var headerElement = element.Element("Header"); var trailerElement = element.Element("Tailer"); IObjectWithName returnInterpreter = null; if (interpreterType == "MultipleFormatterByteArrayInterpreter") { MultipleFormatterByteArrayInterpreter interpreter = new MultipleFormatterByteArrayInterpreter(interpreterName); if (headerElement != null && !string.IsNullOrEmpty(headerElement.Value.Trim())) { string headerString = headerElement.Value; interpreter.SetHeaders(HexStringToByteArray(headerString)); } if (trailerElement != null && !string.IsNullOrEmpty(trailerElement.Value.Trim())) { string tailerString = trailerElement.Value; interpreter.SetTailers(HexStringToByteArray(tailerString)); } foreach (var formatterElement in element.Elements("Formatter")) { interpreter.AddFormatter((IFormatter <byte[]>)GetFormatter(formatterElement)); } if (element.Element("FormatterFilter") != null) { foreach (var filterElement in element.Elements("FormatterFilter")) { IFormatterFilter <byte[]> filter = (IFormatterFilter <byte[]>)GetFormatterFilter(filterElement); interpreter.AddFormatterFilter(filter); } } returnInterpreter = interpreter; } else if (interpreterType == "SingleFormatterByteArrayInterpreter") { SingleFormatterByteArrayInterpreter interpreter = new SingleFormatterByteArrayInterpreter(interpreterName); if (headerElement != null && !string.IsNullOrEmpty(headerElement.Value.Trim())) { string headerString = headerElement.Value; interpreter.SetHeaders(HexStringToByteArray(headerString)); } if (trailerElement != null && !string.IsNullOrEmpty(trailerElement.Value.Trim())) { string tailerString = trailerElement.Value; interpreter.SetTailers(HexStringToByteArray(tailerString)); } var formatterElement = element.Element("Formatter"); interpreter.AddFormatter((IFormatter <byte[]>)GetFormatter(formatterElement)); returnInterpreter = interpreter; } else if (interpreterType == "StringInterpreter") { StringInterpreter interpreter = new StringInterpreter(interpreterName); var formatterElement = element.Element("Formatter"); interpreter.AddFormatter((IFormatter <string>)GetFormatter(formatterElement)); returnInterpreter = interpreter; } else { throw new UnknownElementException("Unknown interpreter type:" + interpreterType); } _adapterObjects[_currentAdapterName].Add(returnInterpreter.Name, returnInterpreter); return(returnInterpreter); }
private object GetChannel(XElement element) { string channelType = GetAttribute(element, "Type"); string name = GetAttribute(element, "Name"); IObjectWithName channel = null; if (channelType == "TcpServerChannel") { int port = int.Parse(GetAttribute(element, "LocalPort")); TcpServerChannel tcpServerChannel = new TcpServerChannel(name, port); channel = tcpServerChannel; } else if (channelType == "TcpClientChannel") { TcpClientChannel tcpClientChannel = null; string ip = GetAttribute(element, "RemoteIP"); int port = int.Parse(GetAttribute(element, "RemotePort")); IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(ip), port); if (element.Attribute("RetryInterval") != null && !string.IsNullOrEmpty(element.Attribute("RetryInterval").Value)) { int retryInterval = int.Parse(GetAttribute(element, "RetryInterval")); tcpClientChannel = new TcpClientChannel(name, ipEndPoint, retryInterval); } else { tcpClientChannel = new TcpClientChannel(name, ipEndPoint); } channel = tcpClientChannel; } else if (channelType == "UdpChannel") { UdpChannel udpChannel = null; int remotePort = int.Parse(GetAttribute(element, "RemotePort")); int localPort = int.Parse(GetAttribute(element, "LocalPort")); if (element.Attribute("LocalIP") != null && !string.IsNullOrEmpty(element.Attribute("LocalIP").Value)) { string localIP = GetAttribute(element, "LocalIP"); udpChannel = new UdpChannel(name, remotePort, localPort, IPAddress.Parse(localIP)); } else { udpChannel = new UdpChannel(name, remotePort, localPort); } channel = udpChannel; } else if (channelType == "HttpReaderChannel") { HttpReaderChannel httpReaderChannel = null; int remotePort = int.Parse(GetAttribute(element, "RemotePort")); string remoteIP = GetAttribute(element, "RemoteIP"); string requestUrl = GetAttribute(element, "RequestUrl"); string userName = string.Empty; string password = string.Empty; if (element.Attribute("UserName") != null && !string.IsNullOrEmpty(element.Attribute("UserName").Value)) { userName = GetAttribute(element, "UserName"); } if (element.Attribute("Password") != null && !string.IsNullOrEmpty(element.Attribute("Password").Value)) { password = GetAttribute(element, "Password"); } httpReaderChannel = new HttpReaderChannel(name, remoteIP, remotePort, requestUrl, userName, password); channel = httpReaderChannel; } else { throw new UnknownElementException("Unknown channel type:" + channelType); } _adapterObjects[_currentAdapterName].Add(channel.Name, channel); return(channel); }
/// <summary> /// Saves the meta. /// </summary> /// <param name="instance">The instance.</param> public void saveMeta(IObjectWithName instance) { instance.saveObjectToXML(getFilename(instance)); }
public imbTreeNodeLeaf(IObjectWithName __value) { _nameBase = __value.name; value = __value; // UID = imbStringGenerators.getRandomString(32); }
/// <summary> /// Builds the custom data table. /// </summary> /// <param name="instance_items">The instance items.</param> /// <param name="presenter">The presenter.</param> /// <param name="isPreviewTable">if set to <c>true</c> [is preview table].</param> /// <returns></returns> public DataTable buildCustomDataTable(IEnumerable instance_items, dataUnitPresenter presenter, bool isPreviewTable) { if (presenter == complete_Table) { if (tableShema.Columns.Count == 0) { tableShema = buildDataTableShema(presenter); } } DataTable selectedShema = selectDataTableShema(tableShema, presenter); DataTable output = selectedShema; switch (presenter.presentationType) { case dataDeliveryPresenterTypeEnum.tableVertical: output = new DataTable(presenter.name); output.ExtendedProperties.copyInto(selectedShema.ExtendedProperties); List <DataColumn> value_columns = new List <DataColumn>(); List <PropertyEntryColumn> extra_columns = new List <PropertyEntryColumn>(); //addStandardColumnShema(output, presenter, PropertyEntryColumn.entry_name); PropertyCollectionExtended pce = null; int i = 0; foreach (object instance in instance_items) { pce = new PropertyCollectionExtended(); pce.setFromObject(instance); var dc = addStandardColumnShema(output, presenter, PropertyEntryColumn.entry_value); if (instance is IObjectWithName) { IObjectWithName input_IObjectWithName = (IObjectWithName)instance; dc.Caption = input_IObjectWithName.name; } if (instance is IObjectWithDescription) { IObjectWithDescription instanceIObjectWithDescription = (IObjectWithDescription)instance; dc.ExtendedProperties[templateFieldDataTable.col_desc] = instanceIObjectWithDescription.description; } dc.ExtendedProperties[imbAttributeName.menuRelevance] = dataPointImportance.important; dc.ExtendedProperties[imbAttributeName.metaData] = pce; dc.ColumnName = "value_" + i.ToString(); value_columns.Add(dc); i++; } addStandardColumnShema(output, presenter, PropertyEntryColumn.entry_description); foreach (PropertyEntryColumn epec in presenter.extraColumns.getEnumListFromFlags <PropertyEntryColumn>()) { if ((epec != PropertyEntryColumn.entry_name) && (epec != PropertyEntryColumn.entry_description)) { extra_columns.Add(epec); addStandardColumnShema(output, presenter, epec); } } // <----------------------------------- izgradnja redova foreach (string cns in map.fieldsByNeedle[presenter.key]) { DataColumn dcShema = null; if (selectedShema.Columns.Contains(cns)) { dcShema = selectedShema.Columns[cns]; } DataRow dr = output.NewRow(); // dr[output.Columns[PropertyEntryColumn.entry_name.ToString()]] = dcShema.Caption; int vi = 0; object val = null; foreach (object instance in instance_items) { var dc = value_columns[vi]; dr[dc] = instance.imbGetPropertySafe(cns, "--"); if (dr[dc] != null) { val = dr[dc]; } vi++; } //dr[output.Columns[PropertyEntryColumn.entry_description.ToString()]] = dcShema.ExtendedProperties[templateFieldDataTable.col_desc]; if (extra_columns.Any()) { foreach (PropertyEntryColumn epec in extra_columns) { dr[output.Columns[epec.ToString()]] = pce[output.Columns[epec.ToString()]]; } } } break; case dataDeliveryPresenterTypeEnum.tableTwoColumnParam: object ins = instance_items.imbGetItemAt(0); PropertyCollectionExtended pc2 = new PropertyCollectionExtended(); // instance.buildPropertyCollection(true, true, ""); //pc2.setFromObject(ins); // pc2 = ins.buildPropertyCollection<PropertyCollectionExtended>(doOnlyWithDisplayName:false, doInherited:true, filedName_prefix:"", output:null, fieldsOrCategoriesToShow:map.fieldsByNeedle[presenter.key]); foreach (var pairs in pc2.entries) { } break; case dataDeliveryPresenterTypeEnum.lineGraph: case dataDeliveryPresenterTypeEnum.pieGraph: case dataDeliveryPresenterTypeEnum.barGraph: case dataDeliveryPresenterTypeEnum.tableHorizontal: output = getDataTable(instance_items, presenter, isPreviewTable, false); break; } return(output); }