Exemplo n.º 1
0
        private async void GetNotificationPositionsAsync()
        {
            var localNotificationPositions = new ObservableCollection <NameValue>();

            await Task.Run(() =>
            {
                localNotificationPositions.Add(new NameValue {
                    Name = ResourceUtils.GetStringResource("Language_Bottom_Left"), Value = (int)NotificationPosition.BottomLeft
                });
                localNotificationPositions.Add(new NameValue {
                    Name = ResourceUtils.GetStringResource("Language_Top_Left"), Value = (int)NotificationPosition.TopLeft
                });
                localNotificationPositions.Add(new NameValue {
                    Name = ResourceUtils.GetStringResource("Language_Top_Right"), Value = (int)NotificationPosition.TopRight
                });
                localNotificationPositions.Add(new NameValue {
                    Name = ResourceUtils.GetStringResource("Language_Bottom_Right"), Value = (int)NotificationPosition.BottomRight
                });
            });

            this.NotificationPositions = localNotificationPositions;

            NameValue localSelectedNotificationPosition = null;

            await Task.Run(() => localSelectedNotificationPosition = NotificationPositions.Where((np) => np.Value == XmlSettingsClient.Instance.Get <int>("Behaviour", "NotificationPosition")).Select((np) => np).First());

            this.SelectedNotificationPosition = localSelectedNotificationPosition;
        }
        public void WebServiceHeaderBuilder_GivenEmptyHeaders_SetHeaders()
        {
            //------------Setup for test--------------------------
            var mod     = new WebServiceHeaderBuilder();
            var newMock = new Mock <IHeaderRegion>();

            newMock.SetupProperty(region => region.Headers);
            var jsonHeader = new NameValue();

            newMock.Object.Headers = new ObservableCollection <INameValue> {
                jsonHeader, new NameValue()
            };
            var content = "{\"NormalText\":\"\"}";

            //---------------Assert Precondition----------------
            Assert.IsNotNull(newMock.Object.Headers);
            Assert.AreEqual(2, newMock.Object.Headers.Count);
            //------------Execute Test---------------------------
            mod.BuildHeader(newMock.Object, content);
            //------------Assert Results-------------------------
            Assert.IsNotNull(newMock.Object.Headers);
            Assert.AreEqual(2, newMock.Object.Headers.Count);
            var countContentTypes       = newMock.Object.Headers.Count(value => value.Name.Equals(GlobalConstants.ContentType));
            var countContentTypesValues = newMock.Object.Headers.Count(value => value.Value.Equals(GlobalConstants.ApplicationJsonHeader));

            Assert.AreEqual(1, countContentTypesValues);
            Assert.AreEqual(1, countContentTypes);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更改父节点
 /// </summary>
 /// <param name="parentNode">父节点</param>
 /// <returns>更新记录数</returns>
 public int ChangeParent(Teams parentNode)
 {
     return(ChangeParent(parentNode,
                         () => _owner.Owner.HttpClient.CallAsync <int>(HttpMethod.Patch, ApiConfig.ApiSecurityMyselfRootTeamsNodePath,
                                                                       NameValue.Set <Teams>(p => p.Id, Id),
                                                                       NameValue.Set <Teams>(p => p.ParentId, parentNode.Id)).Result));
 }
Exemplo n.º 4
0
        void Attendance_Loaded(object sender, RoutedEventArgs e)
        {
            txtStartDate.DateTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01"));
            txtStartDate.Text     = "";
            txtEndDate.DateTime   = DateTime.Now;

            //F_ID,F_Name,F_TypeCode,F_Order
            DataTable        dt = SystemManager.Instance.Services.EquipmentService.GetList("F_IsDelete='0' order by F_Order").Tables[0];
            List <NameValue> l1 = new List <NameValue>();

            foreach (DataRow row in dt.Rows)
            {
                NameValue nameValue = new NameValue();
                nameValue.Value      = row["F_ID"].ToString();
                nameValue.Name       = row["F_Name"].ToString();
                nameValue.IsSelected = true;
                l1.Add(nameValue);
            }
            NameValue nameValue1 = new NameValue();

            nameValue1.Value      = "0";
            nameValue1.Name       = "外租设备出场天数";
            nameValue1.IsSelected = true;
            l1.Add(nameValue1);
            listEquipment.ItemsSource = l1;


            List <NameValue> l = SystemManager.Instance.Services.ProjectService.GetNameViewList("");

            listProject.ItemsSource = l;
            BindDataList();
        }
Exemplo n.º 5
0
 /// <summary>
 /// 添加子团体
 /// </summary>
 /// <param name="name">名称</param>
 public Teams AddChild(string name)
 {
     return(AddChild(() => new Teams(_owner, name),
                     node => _owner.Owner.HttpClient.CallAsync <long>(HttpMethod.Put, ApiConfig.ApiSecurityMyselfRootTeamsNodePath,
                                                                      NameValue.Set <Teams>(p => p.Name, node.Name),
                                                                      NameValue.Set <Teams>(p => p.ParentId, node.ParentId)).Result));
 }
        private string GetProxySite(HttpApplication app)
        {
            if (s_rules == null)
            {
                return(null);
            }

            string path = app.Request.Path;

            for (int i = 0; i < s_rules.Length; i++)
            {
                NameValue nv = s_rules[i];

                // 转发所有请求
                if (nv.Name == "**")   // 2 个星号
                {
                    return(nv.Value);
                }

                // 只要包含指定的部分就转发
                // 说明:这里不用【正则表达式】,因为几乎遇到的所有场景中都不会有复杂到必须使用正则表达式才能搞定的
                //     反而应该在设计URL时保留一些特定的名称就可以识别不同的应用
                if (path.IndexOfIgnoreCase(nv.Name) >= 0)
                {
                    return(nv.Value);
                }
            }

            return(null);
        }
Exemplo n.º 7
0
        public void BuildHeader(IHeaderRegion region, string content)
        {
            var hasEmptyHeaders = region.Headers?.Any(value => !string.IsNullOrEmpty(value.Name)) ?? false;

            if (hasEmptyHeaders)
            {
                return;
            }

            var isValidJson = content?.IsValidJson() ?? false;

            if (isValidJson && !(content == "{}"))
            {
                var jsonHeader = new NameValue(GlobalConstants.ContentType, GlobalConstants.ApplicationJsonHeader);

                region.Headers = new ObservableCollection <INameValue> {
                    jsonHeader, new NameValue()
                };
            }
            else
            {
                var isValidXml = content.IsValidXml();
                if (isValidXml)
                {
                    var jsonHeader = new NameValue(GlobalConstants.ContentType, GlobalConstants.ApplicationXmlHeader);

                    region.Headers = new ObservableCollection <INameValue> {
                        jsonHeader, new NameValue()
                    };
                }
            }
        }
Exemplo n.º 8
0
 private GRRow <NameValue <string> > ToGRRow(NameValue <string> x)
 {
     return(new GRRow <NameValue <string> >(ConvTable)
     {
         Source = x
     });
 }
Exemplo n.º 9
0
 public void AddExtensionItem(string key, string value)
 {
     //if(_stringNameValueExtension==null)
     //    _stringNameValueExtension = new MessageExtension<string, string>();
     var nv = new NameValue<string, string>(key, value);
     _stringNameValueExtension.AddNameValue(nv);
 }
Exemplo n.º 10
0
        public void BuildHeader_GivenHasExistingJsonHeaderAndContentIsJson_PassAddNoHeaders()
        {
            //------------Setup for test--------------------------
            var mod     = new WebServiceHeaderBuilder();
            var newMock = new Mock <IHeaderRegion>();

            newMock.SetupProperty(region => region.Headers);
            var jsonHeader = new NameValue("Content-Type", "application/json");

            newMock.Object.Headers = new ObservableCollection <INameValue> {
                jsonHeader, new NameValue()
            };
            var content = "{\"NormalText\":\"\"}";

            //---------------Assert Precondition----------------
            Assert.IsNotNull(newMock.Object.Headers);
            Assert.AreEqual(2, newMock.Object.Headers.Count);
            //------------Execute Test---------------------------
            mod.BuildHeader(newMock.Object, content);
            //------------Assert Results-------------------------
            Assert.IsNotNull(newMock.Object.Headers);
            Assert.AreEqual(2, newMock.Object.Headers.Count);
            var countContentTypes       = newMock.Object.Headers.Count(value => value.Name.Equals("Content-Type"));
            var countContentTypesValues = newMock.Object.Headers.Count(value => value.Value.Equals("application/json"));

            Assert.AreEqual(1, countContentTypesValues);
            Assert.AreEqual(1, countContentTypes);
        }
Exemplo n.º 11
0
 private void SaveNewCookie(HttpWebResponse webResponse)
 {
     //string[] cc = webResponse.Headers.GetValues("Set-Cookie");		// 这行代码有BUG
     string[] cc = GetHeaderValues(webResponse.Headers, "Set-Cookie");
     if (cc != null && cc.Length > 0)
     {
         foreach (string cookie in cc)
         {
             NameValue nv = ReadCookie(cookie);
             if (nv != null)
             {
                 if (nv.Value == null)                           // 删除COOKIE
                 {
                     _setCookies = (from x in _setCookies
                                    where x.Name.EqualsIgnoreCase(nv.Name) == false
                                    select x
                                    ).ToList();
                 }
                 else
                 {
                     // 保存服务端创建的COOKIE,这里不分析 domain,expires,path,path,HttpOnly 这些参数
                     NameValue c = _setCookies.FirstOrDefault(x => x.Name.EqualsIgnoreCase(nv.Name));
                     if (c == null)
                     {
                         _setCookies.Add(nv);
                     }
                     else
                     {
                         c.Value = nv.Value;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
        void SetupHeaders(ModelItem modelItem)
        {
            var existing = modelItem.GetProperty <IList <INameValue> >("Headers");
            var headers  = new ObservableCollection <INameValue>();

            if (existing != null)
            {
                foreach (var header in existing)
                {
                    var nameValue = new NameValue(header.Name, header.Value);
                    nameValue.PropertyChanged += ValueOnPropertyChanged;
                    headers.Add(nameValue);
                }
            }
            else
            {
                var nameValue = new NameValue();
                nameValue.PropertyChanged += ValueOnPropertyChanged;
                headers.Add(nameValue);
            }
            headers.CollectionChanged += HeaderCollectionOnCollectionChanged;
            Headers = headers;

            AddHeaders();
        }
Exemplo n.º 13
0
        async Task IProjectGrain.PostProjectProceeds(ProjectProceeds source)
        {
            if (Kernel == null)
            {
                throw new ProjectNotFoundException();
            }

            if (!await IsMyProject())
            {
                throw new SecurityException("非请毋加!");
            }

            if (source.InvoiceAmount > Kernel.ContAmount - Kernel.TotalInvoiceAmount)
            {
                throw new ValidationException(String.Format("本开票金额({0})已超过{1}可开数额({2})!",
                                                            source.InvoiceAmount, Kernel.ProjectName, Kernel.ContAmount - Kernel.TotalInvoiceAmount));
            }

            Database.Execute((DbTransaction dbTransaction) =>
            {
                source.InsertSelf(dbTransaction);
                Kernel.UpdateSelf(dbTransaction,
                                  NameValue.Set <ProjectInfo>(p => p.TotalInvoiceAmount, p => p.TotalInvoiceAmount + source.InvoiceAmount));
            });
            ProjectProceedsList.Add(source);
        }
Exemplo n.º 14
0
 /// <summary>
 /// 下载文件
 /// </summary>
 /// <param name="message">上传消息</param>
 /// <param name="fileName">下载文件名</param>
 /// <param name="chunkNumber">下载文件块号</param>
 /// <returns>下载的文件块信息</returns>
 public async Task <FileChunkInfo> DownloadFileChunkAsync(string message, string fileName, int chunkNumber)
 {
     return(await CallAsync <FileChunkInfo>(HttpMethod.Get, ApiConfig.ApiInoutFilePath,
                                            NameValue.Set("message", message),
                                            NameValue.Set("fileName", fileName),
                                            NameValue.Set("chunkNumber", chunkNumber)));
 }
Exemplo n.º 15
0
        private async void SetSelectedSpectrumStyle()
        {
            NameValue localSelectedSpectrumStyle = null;
            await Task.Run(() => localSelectedSpectrumStyle = this.SpectrumStyles.Where((s) => s.Value == SettingsClient.Get <int>("Playback", "SpectrumStyle")).Select((s) => s).First());

            this.SelectedSpectrumStyle = localSelectedSpectrumStyle;
        }
        internal void AddFormUrlEncodedContentType()
        {
            var addItem = new NameValue(CONTENTTYPE, GenerateFormUrlEncodedContentType());

            _evaluatedHeaders.Add(addItem);
            _notEvaluated.Add(addItem);
        }
        private void ProcessValues(IEventPattern e, PatternTestResultEventPattern re)
        {
            #region Value
            if (e.Options.Value)
            {
                var prop = PropertyService.GetProperty(new LineArgs
                {
                    Path  = _path,
                    iLine = e.iLine,
                    Line  = e.Line
                });

                foreach (var valueName in e.Options.ValueParameters)
                {
                    var value = prop.FindPropertyValue(valueName);
                    if (value != null)
                    {
                        var v = new NameValue()
                        {
                            Name  = valueName,
                            Value = value,
                            Type  = Model.IDE.ValueType.Value
                        };
                        re.Values.Add(v);
                    }
                }
            }
            #endregion
        }
Exemplo n.º 18
0
        public void SetValueByCreatingItIfnotExists()
        {
            NameValue nvv = new NameValue(DatabaseServer.SqlServer, LocalizationTests.CONNECTION_STRING, "EntityValue");

            nvv.CreateIfNotExists = true;
            nvv.SetValue("fssd", "adbahdasdasd");
        }
        /// <summary>
        /// Delete my existing record and create a new one.
        /// </summary>
        /// <param name="relatedRecords">CRM module names/ids of records to which I should be related.</param>
        /// <param name="fails">Any previous failures in attempting to save me.</param>
        /// <returns>An archive result object describing the outcome of this attempt.</returns>
        private ArchiveResult TryUpdate(IEnumerable <CrmEntity> relatedRecords, Exception[] fails)
        {
            ArchiveResult result;

            try
            {
                // delete
                NameValue[] deletePacket = new NameValue[2];
                deletePacket[0] = RestAPIWrapper.SetNameValuePair("id", this.CrmEntryId);
                deletePacket[1] = RestAPIWrapper.SetNameValuePair("deleted", "1");
                RestAPIWrapper.SetEntry(deletePacket, "Emails");
                // recreate
                result = this.TrySave(relatedRecords, fails);
            }
            catch (Exception any)
            {
                List <Exception> newFails = new List <Exception>();
                newFails.Add(any);
                if (fails != null && fails.Any())
                {
                    newFails.AddRange(fails);
                }
                result = ArchiveResult.Failure(newFails.ToArray());
            }

            return(result);
        }
Exemplo n.º 20
0
 /// <summary>
 /// 更新自己
 /// </summary>
 public int UpdateSelf()
 {
     return(_owner.HttpClient.CallAsync <int>(HttpMethod.Patch, ApiConfig.ApiSecurityMyselfPath,
                                              NameValue.ToArray(
                                                  NameValue.Set <User>(p => p.Phone, Phone),
                                                  NameValue.Set <User>(p => p.EMail, EMail)), true).Result);
 }
Exemplo n.º 21
0
        public override LuaValue Evaluate(LuaTable enviroment)
        {
            LuaTable table = new LuaTable();

            foreach (Field field in this.FieldList)
            {
                NameValue nameValue = field as NameValue;
                if (nameValue != null)
                {
                    table.SetNameValue(nameValue.Name, nameValue.Value.Evaluate(enviroment));
                    continue;
                }

                KeyValue keyValue = field as KeyValue;
                if (keyValue != null)
                {
                    table.SetKeyValue(
                        keyValue.Key.Evaluate(enviroment),
                        keyValue.Value.Evaluate(enviroment));
                    continue;
                }

                ItemValue itemValue = field as ItemValue;
                if (itemValue != null)
                {
                    table.AddValue(itemValue.Value.Evaluate(enviroment));
                    continue;
                }
            }

            return(table);
        }
Exemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        public FormDriveMapping()
        {
            InitializeComponent();

            List <NameValue> drives = new List <NameValue>();

            for (int index = 65; index < 91; index++)
            {
                NameValue nameValue = new NameValue();
                nameValue.Name  = Convert.ToChar(index) + @":\";
                nameValue.Value = Convert.ToChar(index) + @":\";

                drives.Add(nameValue);
            }

            cboOriginalDrive.DisplayMember = "Name";
            cboOriginalDrive.ValueMember   = "Value";
            cboOriginalDrive.Items.AddRange(drives.ToArray());

            if (drives.Count > 0)
            {
                cboOriginalDrive.SelectedIndex = 0;
            }

            RefreshDrives();
        }
        private async void GetSpectrumStylesAsync()
        {
            var localSpectrumStyles = new ObservableCollection <NameValue>();

            await Task.Run(() =>
            {
                localSpectrumStyles.Add(new NameValue {
                    Name = "Flames", Value = 1
                });
                localSpectrumStyles.Add(new NameValue {
                    Name = "Lines", Value = 2
                });
                localSpectrumStyles.Add(new NameValue {
                    Name = "Bars", Value = 3
                });
                localSpectrumStyles.Add(new NameValue {
                    Name = "Stripes", Value = 4
                });
            });

            this.SpectrumStyles = localSpectrumStyles;

            NameValue localSelectedSpectrumStyle = null;
            await Task.Run(() => localSelectedSpectrumStyle = this.SpectrumStyles.Where((s) => s.Value == SettingsClient.Get <int>("Playback", "SpectrumStyle")).Select((s) => s).First());

            this.SelectedSpectrumStyle = localSelectedSpectrumStyle;
        }
Exemplo n.º 24
0
        /// <summary>
        ///
        /// </summary>
        private void RefreshDrives()
        {
            using (new HourGlass(this))
            {
                var drives = System.IO.DriveInfo.GetDrives().Where(d => d.DriveType == System.IO.DriveType.Fixed);

                List <NameValue> temp = new List <NameValue>();
                foreach (DriveInfo driveInfo in drives)
                {
                    if (driveInfo.IsReady == false)
                    {
                        continue;
                    }

                    try
                    {
                        NameValue nameValue = new NameValue();
                        nameValue.Name  = driveInfo.Name + " (" + driveInfo.DriveFormat + ")";
                        nameValue.Value = driveInfo.Name;

                        temp.Add(nameValue);
                    }
                    catch (Exception) { }
                }

                cboMappedDrive.DisplayMember = "Name";
                cboMappedDrive.ValueMember   = "Value";
                cboMappedDrive.Items.AddRange(temp.ToArray());

                if (temp.Count > 0)
                {
                    cboMappedDrive.SelectedIndex = 0;
                }
            }
        }
Exemplo n.º 25
0
        private async void ImportToken(object sender, RoutedEventArgs e)
        {
            NameValue <string> NV = new NameValue <string>("", "");

            StringResources stx = StringResources.Load("AppResources", "ContextMenu");

            Dialogs.NameValueInput NVInput = new Dialogs.NameValueInput(
                NV, stx.Text("New") + stx.Text("AccessTokens", "ContextMenu")
                , stx.Text("Name"), stx.Text("AccessTokens", "ContextMenu")
                );

            await Popups.ShowDialog(NVInput);

            if (NVInput.Canceled)
            {
                return;
            }

            try
            {
                TokMgr.ImportAuth(NV.Name, NV.Value);
                ReloadAuths(TokenList, SHTarget.TOKEN, TokMgr);
            }
            catch (Exception)
            { }
        }
Exemplo n.º 26
0
        public void WriteNameValue(NameValue nameValue)
        {
            this.WriteText(nameValue.Name);
            this.WriteInt32((int)nameValue.Kind);
            switch (nameValue.Kind)
            {
            case NameValue.ValueKind.Text:
                this.WriteText(nameValue.GetValue <string>());
                break;

            case NameValue.ValueKind.Int32:
                this.WriteInt32(nameValue.GetValue <int>());
                break;

            case NameValue.ValueKind.Double:
                this.WriteDouble(nameValue.GetValue <double>());
                break;

            case NameValue.ValueKind.Guid:
                this.WriteGuid(nameValue.GetValue <Guid>());
                break;

            default:
                throw new ArgumentOutOfRangeException("NameValueKind is not supported".Formatted(nameValue.Kind));
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Deserializes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Deserialize(System.Xml.XmlElement element)
        {
            this._projectFile    = string.Empty;
            this.Variables       = new CloneableList <NameValue> ();
            this.ShowBanner      = null;
            this.Timeout         = null;
            this.DoNotWriteToLog = null;
            this.Version         = null;

            if (string.Compare(element.Name, this.TypeName, false) != 0)
            {
                throw new InvalidCastException(string.Format("Unable to convert {0} to a {1}", element.Name, this.TypeName));
            }

            this.ProjectFile = Util.GetElementOrAttributeValue("ProjectFile", element);
            string s = Util.GetElementOrAttributeValue("FBVersion", element);

            if (!string.IsNullOrEmpty(s))
            {
                int i = 0;
                if (int.TryParse(s, out i))
                {
                    this.Version = i;
                }
            }

            s = Util.GetElementOrAttributeValue("DontWriteToLog", element);
            if (!string.IsNullOrEmpty(s))
            {
                this.DoNotWriteToLog = string.Compare(s, bool.TrueString, true) == 0;
            }

            s = Util.GetElementOrAttributeValue("ShowBanner", element);
            if (!string.IsNullOrEmpty(s))
            {
                this.ShowBanner = string.Compare(s, bool.TrueString, true) == 0;
            }

            s = Util.GetElementOrAttributeValue("Timeout", element);
            if (!string.IsNullOrEmpty(s))
            {
                int i = 0;
                if (int.TryParse(s, out i))
                {
                    this.Timeout = i;
                }
            }

            XmlElement subElement = element.SelectSingleNode("FBVariables") as XmlElement;

            if (subElement != null)
            {
                foreach (XmlElement vEle in subElement.SelectNodes("./*"))
                {
                    NameValue nv = new NameValue(vEle.GetAttribute("name"));
                    nv.Value = vEle.GetAttribute("value");
                    this.Variables.Add(nv);
                }
            }
        }
        public void WebServiceHeaderBuilder_GivenHasExistingXmlHeaderAndCOntentIsXml_PassAddNoHeaders()
        {
            //------------Setup for test--------------------------
            var mod     = new WebServiceHeaderBuilder();
            var newMock = new Mock <IHeaderRegion>();

            newMock.SetupProperty(region => region.Headers);
            var jsonHeader = new NameValue(GlobalConstants.ContentType, GlobalConstants.ApplicationXmlHeader);

            newMock.Object.Headers = new ObservableCollection <INameValue> {
                jsonHeader, new NameValue()
            };
            var content = "<DataList><a>2</a></DataList>";

            //---------------Assert Precondition----------------
            Assert.IsNotNull(newMock.Object.Headers);
            Assert.AreEqual(2, newMock.Object.Headers.Count);
            //------------Execute Test---------------------------
            mod.BuildHeader(newMock.Object, content);
            //------------Assert Results-------------------------
            Assert.IsNotNull(newMock.Object.Headers);
            Assert.AreEqual(2, newMock.Object.Headers.Count);
            var countContentTypes       = newMock.Object.Headers.Count(value => value.Name.Equals(GlobalConstants.ContentType));
            var countContentTypesValues = newMock.Object.Headers.Count(value => value.Value.Equals(GlobalConstants.ApplicationXmlHeader));

            Assert.AreEqual(1, countContentTypesValues);
            Assert.AreEqual(1, countContentTypes);
        }
Exemplo n.º 29
0
        private async void GetScrollVolumePercentagesAsync()
        {
            var localScrollVolumePercentages = new ObservableCollection <NameValue>();

            await Task.Run(() =>
            {
                localScrollVolumePercentages.Add(new NameValue {
                    Name = "1 %", Value = 1
                });
                localScrollVolumePercentages.Add(new NameValue {
                    Name = "2 %", Value = 2
                });
                localScrollVolumePercentages.Add(new NameValue {
                    Name = "5 %", Value = 5
                });
                localScrollVolumePercentages.Add(new NameValue {
                    Name = "10 %", Value = 10
                });
                localScrollVolumePercentages.Add(new NameValue {
                    Name = "15 %", Value = 15
                });
                localScrollVolumePercentages.Add(new NameValue {
                    Name = "20 %", Value = 20
                });
            });

            this.ScrollVolumePercentages = localScrollVolumePercentages;

            NameValue localSelectedScrollVolumePercentage = null;
            await Task.Run(() => localSelectedScrollVolumePercentage = this.ScrollVolumePercentages.Where((svp) => svp.Value == SettingsClient.Get <int>("Behaviour", "ScrollVolumePercentage")).Select((svp) => svp).First());

            this.SelectedScrollVolumePercentage = localSelectedScrollVolumePercentage;
        }
Exemplo n.º 30
0
        /// <summary>
        /// Load values stored in cookies
        /// </summary>
        protected virtual void LoadCookieValues()
        {
            HttpCookie user    = this.Context.Request.Cookies[_userIdKey];
            HttpCookie offset  = this.Context.Request.Cookies[_offsetKey];
            HttpCookie sorting = this.Context.Request.Cookies[_sortKey];

            if (user != null)
            {
                _userID = new Guid(user.Value);
            }
            _timeOffset = (offset == null) ? TimeSpan.Zero : TimeSpan.Parse(offset.Value);

            if (sorting != null)
            {
                // id=col=direction|id2=col2=direction2
                NameValue <string, Entity.SortDirections> columnSort;
                string[] parts;
                string   id;
                string[] grids = sorting.Value.Split(new char[] { '|' });

                foreach (string g in grids)
                {
                    parts = g.Split(new char[] { '=' });
                    id    = parts[0];

                    columnSort       = new NameValue <string, Entity.SortDirections>();
                    columnSort.Name  = parts[1];
                    columnSort.Value = parts[2].ToEnum <Entity.SortDirections>();

                    this.GridSort.Add(id, columnSort);
                }
            }
        }
Exemplo n.º 31
0
        public void BuildHeader(IHeaderRegion region, string content)
        {
            var hasEmptyHeaders = region.Headers?.Any(value => !string.IsNullOrEmpty(value.Name)) ?? false;

            if (hasEmptyHeaders)
            {
                return;
            }

            var isValidJson = content?.IsValidJson() ?? false;

            if (isValidJson)
            {
                var jsonHeader = new NameValue(GlobalConstants.ContentType, GlobalConstants.ApplicationJsonHeader);

                SetupHeader(region, jsonHeader);
            }
            else
            {
                var isValidXml = content.IsValidXml();
                if (isValidXml)
                {
                    var jsonHeader = new NameValue(GlobalConstants.ContentType, GlobalConstants.ApplicationXmlHeader);

                    SetupHeader(region, jsonHeader);
                }
            }
        }
Exemplo n.º 32
0
        public void ValueTextTest()
        {
            string s = new NameValue("name", 1.23).ValueText;
            (s == "1.23" || s == "1,23").Should().Be.True(); // comma will be either . or ,

            new NameValue("name", "bugs bunny").ValueText.Should().Be("bugs bunny");
            new NameValue("name", Guid.Empty).ValueText.Should().Be(Guid.Empty.ToString());
        }
Exemplo n.º 33
0
        public static NameValue Create(string name, string value)
        {
            var stringTC = OrbServices.GetSingleton().create_string_tc(0);

            var item = new NameValue();
            item.name = name;
            item.value = new Any(value, stringTC);

            return item;
        }
Exemplo n.º 34
0
			public ShortcutsListBox(ShortcutsCollection editingInstance):base()
			{
				// Load all shortcuts
				Array a=eShortcut.GetValues(typeof(eShortcut));
				for(int i=1;i<a.Length;i++)
				{
					NameValue nv=new NameValue(eShortcut.GetName(typeof(eShortcut),a.GetValue(i)),(eShortcut)a.GetValue(i));
					if(editingInstance.Contains((eShortcut)a.GetValue(i)))
					{
						this.Items.Add(nv,System.Windows.Forms.CheckState.Checked);
					}
					else
						this.Items.Add(nv,System.Windows.Forms.CheckState.Unchecked);
				}
			}
Exemplo n.º 35
0
        public NameValueInput( NameValue<string> Item
            , string Title
            , string NameLabel, string ValueLabel
            , string BtnLeft = "OK", string BtnRight = "Cancel" )
        {
            this.InitializeComponent();

            Canceled = true;
            Target = Item;

            StringResources stx = new StringResources( "Message" );
            PrimaryButtonText = stx.Str( BtnLeft );
            SecondaryButtonText = stx.Str( BtnRight );

            TitleText.Text = Title;
            NameLbl.Text = NameLabel;
            ValueLbl.Text = ValueLabel;
        }
Exemplo n.º 36
0
 public void WriteNameValue(NameValue nameValue)
 {
     this.WriteText(nameValue.Name);
     this.WriteInt32((int)nameValue.Kind);
     switch (nameValue.Kind)
     {
     case NameValue.ValueKind.Text:
         this.WriteText(nameValue.GetValue<string>());
         break;
     case NameValue.ValueKind.Int32:
         this.WriteInt32(nameValue.GetValue<int>());
         break;
     case NameValue.ValueKind.Double:
         this.WriteDouble(nameValue.GetValue<double>());
         break;
     case NameValue.ValueKind.Guid:
         this.WriteGuid(nameValue.GetValue<Guid>());
         break;
     default:
         throw new ArgumentOutOfRangeException("NameValueKind is not supported".Formatted(nameValue.Kind));
     }
 }
Exemplo n.º 37
0
        /// <summary>
        /// 
        /// </summary>
        public void LoadPriorities()
        {
            if (LicenseManager.UsageMode == LicenseUsageMode.Runtime)
            {
                string[] priorities = System.IO.File.ReadAllLines(System.IO.Path.Combine(Misc.GetApplicationDirectory(), Global.PRIORITIES_FILE));

                List<NameValue> temp = new List<NameValue>();

                NameValue nameValue = new NameValue();
                nameValue.Name = "All";
                nameValue.Value = "All";
                temp.Add(nameValue);

                foreach (string priority in priorities)
                {
                    nameValue = new NameValue();
                    nameValue.Name = priority;
                    nameValue.Value = priority;
                    temp.Add(nameValue);
                }

                cboPriority.Items.Clear();
                cboPriority.DisplayMember = "Name";
                cboPriority.ValueMember = "Value";
                cboPriority.Items.AddRange(temp.ToArray());
                UserInterface.SetDropDownWidth(cboPriority);

                cboPriority.SelectedIndex = 0;
            }
        }
Exemplo n.º 38
0
        /// <summary>
        /// Creates a new <see cref="NameValueDto"/>.
        /// </summary>
        /// <param name="nameValue">A <see cref="NameValue"/> object to get it's name and value</param>
        public NameValueDto(NameValue nameValue)
            : this(nameValue.Name, nameValue.Value)
        {

        }
Exemplo n.º 39
0
 ///<exclude/>
 public bool Equals(NameValue other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other._Name == (_Name) && other._Value == (_Value);
 }
Exemplo n.º 40
0
 /// <remarks/>
 public System.IAsyncResult BeginaddAsset(string in0, string in1, string in2, string in3, string in4, string in5, bool in6, NameValue[] in7, MovieMetadata in8, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("addAsset", new object[] {
                 in0,
                 in1,
                 in2,
                 in3,
                 in4,
                 in5,
                 in6,
                 in7,
                 in8}, callback, asyncState);
 }
Exemplo n.º 41
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="db"></param>
        public void LoadAcknowledgementClasses(NPoco.Database db)
        {
            using (new HourGlass(this))
            {
                List<AcknowledgmentClass> data = db.Fetch<AcknowledgmentClass>(_sql.GetQuery(Sql.Query.SQL_ACKNOWLEDGEMENT_CLASSES));

                _acknowledgementClasses = new List<NameValue>();
                foreach (var result in data)
                {
                    NameValue nameValue = new NameValue();
                    nameValue.Name = result.Desc;
                    nameValue.Value = result.Id.ToString();
                    _acknowledgementClasses.Add(nameValue);
                }
            }
        }
Exemplo n.º 42
0
        private void btnImport_Click(object sender, System.EventArgs e)
        {
            if (txtPathToFile.Text.Length == 0)
            {
                System.Windows.Forms.MessageBox.Show("Enter the path to an existing MPEG Asset.");
                txtPathToFile.Focus();
                return;
            }
            if (txtName.Text.Length == 0)
            {
                //System.Windows.Forms.MessageBox.Show("Enter a valid Name for the MPEG Asset.");
                //return;
                string[] spl = txtPathToFile.Text.Split(new char[] {'/'});
                string ss = spl[spl.Length - 1];
                txtName.Text = ss.Substring(0,ss.LastIndexOf(".mpg"));
            }
            if (cboAssetGroups.SelectedIndex == -1)
            {
                System.Windows.Forms.MessageBox.Show("Select an Asset Group.");
                cboAssetGroups.Focus();
                return;
            }
            if (cboEncodingType.SelectedIndex == -1)
            {
                System.Windows.Forms.MessageBox.Show("Select an Encoding Type.");
                cboEncodingType.Focus();
                return;
            }

            NameValue[] nv = new NameValue[0];
            MovieMetadata mmd = new MovieMetadata();
            string sId = m_jglue.addAsset(m_sSession,txtName.Text,cboAssetGroups.SelectedItem.ToString(),
                cboEncodingType.SelectedItem.ToString(),txtPathToFile.Text,"",false,nv,mmd);

            m_Parent.statusBar1.Panels[0].Text = "Import complete...";
            m_Parent.RefreshAssetList();
        }
Exemplo n.º 43
0
        private static string DecodeObjectCompressedData(string fieldName, object fieldData)
        {
            StringBuilder result = new StringBuilder();
            byte[] block = (byte[])fieldData;
            int i = 0;

            // UUID
            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                                        "ID",
                                        new UUID(block, 0),
                                        "UUID");
            i += 16;

            // Local ID
            uint LocalID = (uint)(block[i++] + (block[i++] << 8) +
                                   (block[i++] << 16) + (block[i++] << 24));

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                                        "LocalID",
                                        LocalID,
                                        "Uint32");
            // PCode
            PCode pcode = (PCode)block[i++];

            result.AppendFormat("{0,30}: {1,-3} {2,-36} [{3}]" + Environment.NewLine,
                "PCode",
                (int)pcode,
                "(" + pcode + ")",
                "PCode");

            // State
            AttachmentPoint point = (AttachmentPoint)block[i++];
            result.AppendFormat("{0,30}: {1,-3} {2,-36} [{3}]" + Environment.NewLine,
                                        "State",
                                        (byte)point,
                                        "(" + point + ")",
                                        "AttachmentPoint");

            // TODO: CRC

            i += 4;
            // Material
            result.AppendFormat("{0,30}: {1,-3} {2,-36} [{3}]" + Environment.NewLine,
                "Material",
                block[i],
                "(" + (Material)block[i++] + ")",
                "Material");

            // Click action
            result.AppendFormat("{0,30}: {1,-3} {2,-36} [{3}]" + Environment.NewLine,
                "ClickAction",
                block[i],
                "(" + (ClickAction)block[i++] + ")",
                "ClickAction");

            // Scale
            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                                        "Scale",
                                        new Vector3(block, i),
                                        "Vector3");
            i += 12;

            // Position
            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                                        "Position",
                                        new Vector3(block, i),
                                        "Vector3");
            i += 12;

            // Rotation
            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                            "Rotation",
                            new Vector3(block, i),
                            "Vector3");

            i += 12;
            // Compressed flags
            CompressedFlags flags = (CompressedFlags)Utils.BytesToUInt(block, i);
            result.AppendFormat("{0,30}: {1,-10} {2,-29} [{3}]" + Environment.NewLine,
                            "CompressedFlags",
                            Utils.BytesToUInt(block, i),
                            "(" + (CompressedFlags)Utils.BytesToUInt(block, i) + ")",
                            "UInt");
            i += 4;

            // Owners ID
            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                                        "OwnerID",
                                        new UUID(block, i),
                                        "UUID");
            i += 16;

            // Angular velocity
            if ((flags & CompressedFlags.HasAngularVelocity) != 0)
            {
                result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "AngularVelocity",
                new Vector3(block, i),
                "Vector3");
                i += 12;
            }

            // Parent ID
            if ((flags & CompressedFlags.HasParent) != 0)
            {
                result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "ParentID",
                (uint)(block[i++] + (block[i++] << 8) +
                                        (block[i++] << 16) + (block[i++] << 24)),
                "UInt");
            }

            // Tree data
            if ((flags & CompressedFlags.Tree) != 0)
            {
                result.AppendFormat("{0,30}: {1,-2} {2,-37} [{3}]" + Environment.NewLine,
                "TreeSpecies",
                block[i++],
                "(" + (Tree)block[i] + ")",
                "Tree");
            }

            // Scratch pad
            else if ((flags & CompressedFlags.ScratchPad) != 0)
            {
                int size = block[i++];
                byte[] scratch = new byte[size];
                Buffer.BlockCopy(block, i, scratch, 0, size);
                result.AppendFormat("{0,30}: {1,-40} [ScratchPad[]]" + Environment.NewLine,
                "ScratchPad",
                Utils.BytesToHexString(scratch, String.Format("{0,30}", "Data")));
                i += size;
            }

            // Floating text
            if ((flags & CompressedFlags.HasText) != 0)
            {
                string text = String.Empty;
                while (block[i] != 0)
                {
                    text += (char)block[i];
                    i++;
                }
                i++;

                // Floating text
                result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "Text",
                text,
                "string");

                // Text color
                result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "TextColor",
                new Color4(block, i, false),
                "Color4");
                i += 4;
            }

            // Media URL
            if ((flags & CompressedFlags.MediaURL) != 0)
            {
                string text = String.Empty;
                while (block[i] != 0)
                {
                    text += (char)block[i];
                    i++;
                }
                i++;

                result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                    "MediaURL",
                    text,
                    "string");
            }

            // Particle system
            if ((flags & CompressedFlags.HasParticles) != 0)
            {
                Primitive.ParticleSystem p = new Primitive.ParticleSystem(block, i);
                result.AppendLine(DecodeObjectParticleSystem("ParticleSystem", p));
                i += 86;
            }

            // Extra parameters TODO:
            Primitive prim = new Primitive();
            i += prim.SetExtraParamsFromBytes(block, i);

            //Sound data
            if ((flags & CompressedFlags.HasSound) != 0)
            {
                result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                    "SoundID",
                    new UUID(block, i),
                    "UUID");
                i += 16;

                result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                    "SoundGain",
                    Utils.BytesToFloat(block, i),
                    "Float");
                i += 4;

                result.AppendFormat("{0,30}: {1,-2} {2,-37} [{3}]" + Environment.NewLine,
                "SoundFlags",
                block[i++],
                "(" + (SoundFlags)block[i] + ")",
                "SoundFlags");

                result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "SoundRadius",
                Utils.BytesToFloat(block, i),
                "Float");
                i += 4;
            }

            // Name values
            if ((flags & CompressedFlags.HasNameValues) != 0)
            {
                string text = String.Empty;
                while (block[i] != 0)
                {
                    text += (char)block[i];
                    i++;
                }
                i++;

                // Parse the name values
                if (text.Length > 0)
                {
                    string[] lines = text.Split('\n');
                    NameValue[] nameValues = new NameValue[lines.Length];

                    for (int j = 0; j < lines.Length; j++)
                    {
                        if (!String.IsNullOrEmpty(lines[j]))
                        {
                            NameValue nv = new NameValue(lines[j]);
                            nameValues[j] = nv;
                        }
                    }
                    DecodeNameValue("NameValues", nameValues);
                }
            }

            result.AppendFormat("{0,30}: {1,-2} {2,-37} [{3}]" + Environment.NewLine,
                "PathCurve",
                block[i],
                "(" + (PathCurve)block[i++] + ")",
                "PathCurve");

            ushort pathBegin = Utils.BytesToUInt16(block, i);
            i += 2;
            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathBegin",
                Primitive.UnpackBeginCut(pathBegin),
                "float");

            ushort pathEnd = Utils.BytesToUInt16(block, i);
            i += 2;
            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathEnd",
                Primitive.UnpackEndCut(pathEnd),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathScaleX",
                Primitive.UnpackPathScale(block[i++]),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathScaleY",
                Primitive.UnpackPathScale(block[i++]),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                            "PathShearX",
                            Primitive.UnpackPathShear((sbyte)block[i++]),
                            "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathShearY",
                Primitive.UnpackPathShear((sbyte)block[i++]),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathTwist",
                Primitive.UnpackPathTwist((sbyte)block[i++]),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathTwistBegin",
                Primitive.UnpackPathTwist((sbyte)block[i++]),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathRadiusOffset",
                Primitive.UnpackPathTwist((sbyte)block[i++]),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathTaperX",
                Primitive.UnpackPathTaper((sbyte)block[i++]),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathTaperY",
                Primitive.UnpackPathTaper((sbyte)block[i++]),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathRevolutions",
                Primitive.UnpackPathRevolutions(block[i++]),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "PathSkew",
                Primitive.UnpackPathTwist((sbyte)block[i++]),
                "float");

            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "ProfileCurve",
                block[i++],
                "float");

            ushort profileBegin = Utils.BytesToUInt16(block, i);
            i += 2;
            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "ProfileBegin",
                Primitive.UnpackBeginCut(profileBegin),
                "float");

            ushort profileEnd = Utils.BytesToUInt16(block, i);
            i += 2;
            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "ProfileEnd",
                Primitive.UnpackEndCut(profileEnd),
                "float");

            ushort profileHollow = Utils.BytesToUInt16(block, i);
            i += 2;
            result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
                "ProfileHollow",
                Primitive.UnpackProfileHollow(profileHollow),
                "float");

            int textureEntryLength = (int)Utils.BytesToUInt(block, i);
            i += 4;
            //prim.Textures = new Primitive.TextureEntry(block, i, textureEntryLength);
            String s = DecodeTextureEntry("TextureEntry", new Primitive.TextureEntry(block, i, textureEntryLength));
            result.AppendLine(s);
            i += textureEntryLength;

            // Texture animation
            if ((flags & CompressedFlags.TextureAnimation) != 0)
            {
                i += 4;
                string a = DecodeObjectTextureAnim("TextureAnimation", new Primitive.TextureAnimation(block, i));
                result.AppendLine(a);
            }

            return result.ToString();
        }
Exemplo n.º 44
0
        private void btnConnect_Click(object sender, System.EventArgs e)
        {
            if (m_bConnected)
            {
                // disconnect
                listView1.Clear();
                m_jglue = null;
                btnConnect.Text = "Connect";
                btnUpload.Enabled = false;
                btnImportFile.Enabled = false;
                statusBar1.Panels[0].Text = "Ready...";
            }
            else
            {
                if (m_jglue != null)
                    m_jglue = null;
                if (txtServerName.Text != "")
                {
                    btnConnect.Text = "Disconnect";
                    m_jglue = new JglueService(txtServerName.Text);
                    NameValue[] credentials = new NameValue[0];
                    m_sSessionId = m_jglue.login(credentials);
                    if (m_sSessionId == "")
                    {
                        System.Windows.Forms.MessageBox.Show(this,"Could not get session id from server. Login command failed.");
                        statusBar1.Panels[0].Text = "Error connecting...";
                    }
                    else
                    {
                        m_bConnected = true;
                        statusBar1.Panels[0].Text = "Connected, listing assets...";
                        Application.DoEvents();
                        RefreshAssetList();
                        statusBar1.Panels[0].Text = "List assets complete.";

                        statusBar1.Panels[0].Text = "Making ftp connection...";

                        FtpSession = null;
                        FtpSession = new KCommon.Net.FTP.Session();
                        FtpSession.Port = 2121;
                        FtpSession.Server = txtServerName.Text;
                        FtpSession.Connect("oyster","oyster");

                        FtpSession.CommandSent += new KCommon.Net.FTP.FtpCommandEventHandler(FtpSession_CommandSent);
                        FtpSession.BeginPutFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_BeginPutFile);
                        FtpSession.EndPutFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_EndPutFile);
                        FtpSession.FileTransferProgress += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_FileTransferProgress);
                        FtpSession.ResponseReceived += new KCommon.Net.FTP.FtpResponseEventHandler(FtpSession_ResponseReceived);
                        FtpSession.BeginGetFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_BeginGetFile);
                        FtpSession.EndGetFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_EndGetFile);

            //						foreach (KCommon.Net.FTP.FtpDirectory dir in FtpSession.CurrentDirectory.SubDirectories)
            //						{
            //							if (dir.Name == "Oyster")
            //							{
            //								goto Oyster_Found;
            //							}
            //						}
            //					Oyster_Found:

                        statusBar1.Panels[0].Text = "Online. Ready.";
                        btnUpload.Enabled = true;
                        btnImportFile.Enabled = true;
                    }
                }
            }
        }
Exemplo n.º 45
0
        public void NameValueRoundTripTest()
        {
            var stream = new MemoryStream();
            var fio = new FileIO(stream);
            var w = new FormattedWriter(fio);

            Guid g = new Guid("1116C195-8975-4E73-B777-23E1C548BC71");
            const string testText = "some text with special characters €,@, ʤǤDŽƪҗ∰";
            {
                var nv1 = new NameValue("name1", 1.23);
                var nv2 = new NameValue("name2", 722);
                var nv3 = new NameValue("name3", g);
                var nv4 = new NameValue("name4", testText);

                w.WriteNameValue(nv1);
                w.WriteNameValue(nv2);
                w.WriteNameValue(nv3);
                w.WriteNameValue(nv4);
            }

            stream.Position = 0;

            var r = new FormattedReader(fio);
            {
                var nv1 = r.ReadNameValue();
                nv1.Name.Should().Be("name1");
                nv1.GetValue<double>().Should().Be(1.23);
                nv1.Kind.Should().Be(NameValue.ValueKind.Double);

                var nv2 = r.ReadNameValue();
                nv2.Name.Should().Be("name2");
                nv2.GetValue<int>().Should().Be(722);
                nv2.Kind.Should().Be(NameValue.ValueKind.Int32);

                var nv3 = r.ReadNameValue();
                nv3.Name.Should().Be("name3");
                nv3.GetValue<Guid>().Should().Be(g);
                nv3.Kind.Should().Be(NameValue.ValueKind.Guid);

                var nv4 = r.ReadNameValue();
                nv4.Name.Should().Be("name4");
                nv4.GetValue<string>().Should().Be(testText);
                nv4.Kind.Should().Be(NameValue.ValueKind.Text);
            }
        }
Exemplo n.º 46
0
 public bool ContainsExtensionItem(NameValue<string, string> nv)
 {
     return StringNameValueExtension.NameValueList.Exists(
         delegate(NameValue<string, string> nvItem) { return nvItem.Equals(nv); });
 }
Exemplo n.º 47
0
        /// <summary>
        /// Do a macro substitiution for a string. Allow depth macro replacement, but do protect from doing it
        /// forever! :-)
        /// </summary>
        /// <param name="src"></param>
        /// <param name="macroList"></param>
        /// <returns></returns>
        private static string MacroReplacement(string src, NameValue[] macroList)
        {
            Regex macroFinder = new Regex(@"\$(\w+)");
            int count = 0;
            bool nomatches = false;
            while (count < 100 && !nomatches)
            {
                nomatches = true;
                foreach (Match m in macroFinder.Matches(src))
                {
                    nomatches = false;
                    var macro = (from mac in macroList where mac.Name == m.Groups[1].Value select mac).FirstOrDefault();
                    if (macro == null)
                        throw new InvalidDataException(string.Format("Macro '{0}' is not defined in this dataset", m.Groups[1].Value));
                    src = src.Replace(m.Value, macro.Value);
                }
                count++;
            }

            return src;
        }
Exemplo n.º 48
0
 public static void AddStringValue(ref NameValue[] target, string name, string value)
 {
     var list = target == null ? new List<NameValue>() : target.ToList();
     list.Add(Create(name, value));
     target = list.ToArray();
 }
Exemplo n.º 49
0
 protected bool Equals(NameValue other)
 {
     return string.Equals(Name, other.Name);
 }
Exemplo n.º 50
0
        /// <summary>
        /// 
        /// </summary>
        public void UpdateSensors()
        {
            using (NPoco.Database db = new NPoco.Database(Db.GetOpenMySqlConnection()))
            {
                List<Sensor> data = db.Fetch<Sensor>(_sql.GetQuery(Sql.Query.SQL_SENSORS_HOSTNAME));

                List<NameValue> sensors = new List<NameValue>();

                // Add a default
                NameValue nameValue = new NameValue();
                nameValue.Name = "All";
                nameValue.Value = string.Empty;
                sensors.Add(nameValue);

                foreach (var result in data)
                {
                    nameValue = new NameValue();
                    nameValue.Name = result.HostName;
                    nameValue.Value = result.HostName;
                    sensors.Add(nameValue);
                }

                cboSensor.Items.Clear();
                cboSensor.DisplayMember = "Name";
                cboSensor.ValueMember = "Value";
                cboSensor.Items.AddRange(sensors.ToArray());
                UserInterface.SetDropDownWidth(cboSensor);

                if (sensors.Count > 0)
                {
                    cboSensor.SelectedIndex = 0;
                }
            }
        }
Exemplo n.º 51
0
 public string login(NameValue[] in0) {
     object[] results = this.Invoke("login", new object[] {
                 in0});
     return ((string)(results[0]));
 }
        public static ListView CreateListView(object obj, string propertyName)
        {
            ListView listView = new ListView();

            object propValue =
                    FALibrary.Utility.FAReflection.GetPropertyValue(obj, propertyName);

            if (propValue is System.Collections.IDictionary)
            {
                GridView gridview = new GridView();
                listView.View = gridview;
                GridViewColumn col = new GridViewColumn();
                col.Header = "Name";
                col.Width = double.NaN;
                col.DisplayMemberBinding = new System.Windows.Data.Binding("Name");
                gridview.Columns.Add(col);

                col = new GridViewColumn();
                col.Header = "Value";
                col.Width = double.NaN;
                col.DisplayMemberBinding = new System.Windows.Data.Binding("Value");

                System.Windows.DataTemplate template = new System.Windows.DataTemplate();
                System.Windows.FrameworkElementFactory textBox =
                    new System.Windows.FrameworkElementFactory(typeof(TextBox));
                textBox.SetValue(TextBox.VerticalAlignmentProperty, System.Windows.VerticalAlignment.Center);
                textBox.SetBinding(TextBox.TextProperty, new Binding("Value"));
                template.VisualTree = textBox;
                col.CellTemplate = template;

                gridview.Columns.Add(col);

                foreach (System.Collections.DictionaryEntry item in (System.Collections.IDictionary)propValue)
                {
                    NameValue nv = new NameValue();
                    nv.Name = item.Key.ToString();
                    nv.Value = item.Value;

                    listView.Items.Add(nv);
                }
            }
            else if (propValue is System.Collections.IList)
            {
                GridView gridview = new GridView();
                listView.View = gridview;

                List<string> colNameList = new List<string>();
                foreach (object item in (System.Collections.IList)propValue)
                {
                    TreeViewItem tvItem = MakeTreeItemFromObject(item.GetType(), "");
                    if (tvItem == null)
                    {
                        foreach (PropertyInfo info in item.GetType().GetProperties())
                        {
                            Attribute[] attribs = Attribute.GetCustomAttributes(info);
                            foreach (Attribute attr in attribs)
                            {
                                if (attr is FAAttribute)
                                {
                                    if (colNameList.IndexOf(info.Name) >= 0)
                                        continue;

                                    GridViewColumn column = new GridViewColumn();
                                    column.Header = info.Name;
                                    column.Width = double.NaN;
                                    if (info.PropertyType == typeof(bool))
                                    {
                                        System.Windows.DataTemplate template = new System.Windows.DataTemplate();
                                        System.Windows.FrameworkElementFactory checkBox =
                                            new System.Windows.FrameworkElementFactory(typeof(CheckBox));
                                        checkBox.SetValue(CheckBox.VerticalAlignmentProperty, System.Windows.VerticalAlignment.Center);
                                        checkBox.SetValue(CheckBox.LayoutTransformProperty, new ScaleTransform(CHECKBOX_SIZE, CHECKBOX_SIZE));
                                        Binding bd = new Binding(info.Name);
                                        if (info.GetSetMethod(false) != null)
                                        {
                                            bd.Mode = BindingMode.TwoWay;
                                            checkBox.SetValue(CheckBox.IsEnabledProperty, true);
                                        }
                                        else
                                        {
                                            bd.Mode = BindingMode.OneWay;
                                            //checkBox.SetValue(CheckBox.IsEnabledProperty, false);
                                        }

                                        checkBox.SetBinding(CheckBox.IsCheckedProperty, bd);
                                        template.VisualTree = checkBox;
                                        column.CellTemplate = template;
                                    }
                                    else if (info.PropertyType == typeof(short) ||
                                        info.PropertyType == typeof(ushort) ||
                                        info.PropertyType == typeof(int) ||
                                        info.PropertyType == typeof(uint) ||
                                        info.PropertyType == typeof(long) ||
                                        info.PropertyType == typeof(ulong) ||
                                        info.PropertyType == typeof(float) ||
                                        info.PropertyType == typeof(double))
                                    {
                                        System.Windows.DataTemplate template = new System.Windows.DataTemplate();
                                        System.Windows.FrameworkElementFactory textBox =
                                            new System.Windows.FrameworkElementFactory(typeof(TextBox));
                                        Binding bd = new Binding(info.Name);
                                        if (info.GetSetMethod(false) != null)
                                        {
                                            bd.Mode = BindingMode.TwoWay;
                                            textBox.SetValue(TextBox.IsEnabledProperty, true);
                                        }
                                        else
                                        {
                                            bd.Mode = BindingMode.OneWay;
                                            textBox.SetValue(TextBox.IsEnabledProperty, false);
                                        }

                                        textBox.SetValue(TextBox.MarginProperty, new Thickness(0));
                                        textBox.SetValue(TextBox.WidthProperty, double.NaN);
                                        textBox.SetValue(TextBox.HeightProperty, double.NaN);
                                        textBox.SetValue(TextBox.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
                                        textBox.SetValue(TextBox.VerticalAlignmentProperty, VerticalAlignment.Stretch);
                                        textBox.SetValue(TextBox.HorizontalContentAlignmentProperty, HorizontalAlignment.Right);
                                        textBox.SetValue(TextBox.VerticalContentAlignmentProperty, VerticalAlignment.Center);
                                        textBox.SetBinding(TextBox.TextProperty, bd);
                                        template.VisualTree = textBox;
                                        column.CellTemplate = template;
                                        column.Width = double.NaN;
                                    }
                                    else
                                        column.DisplayMemberBinding = new System.Windows.Data.Binding(info.Name);

                                    gridview.Columns.Add(column);
                                    colNameList.Add(info.Name);
                                }
                            }
                        }

                        listView.Items.Add(item);
                        Style style = new Style();
                        style.TargetType = typeof(ListViewItem);
                        Setter setter = new Setter();
                        setter.Property = ListViewItem.HorizontalContentAlignmentProperty;
                        setter.Value = HorizontalAlignment.Stretch;
                        style.Setters.Add(setter);
                        listView.ItemContainerStyle = style;
                    }
                    else
                    {
                        NameValue nv = new NameValue();
                        nv.Name = item.ToString();

                        TreeView treeview = new TreeView();
                        treeview.Items.Add(tvItem);

                        nv.Value = treeview;
                        listView.Items.Add(treeview);
                    }
                }

                if (gridview.Columns.Count == 0)
                {
                    listView.View = null;
                }
            }

            return listView;
        }
Exemplo n.º 53
0
 /// <remarks/>
 public System.IAsyncResult Beginlogin(NameValue[] in0, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("login", new object[] {
                 in0}, callback, asyncState);
 }
Exemplo n.º 54
0
        private static string DecodeNameValue(string fieldName, object fieldData)
        {
            string nameValue = Utils.BytesToString((byte[])fieldData);
            NameValue[] nameValues = null;
            if (nameValue.Length > 0)
            {
                string[] lines = nameValue.Split('\n');
                nameValues = new NameValue[lines.Length];

                for (int i = 0; i < lines.Length; i++)
                {
                    if (!String.IsNullOrEmpty(lines[i]))
                    {
                        NameValue nv = new NameValue(lines[i]);
                        nameValues[i] = nv;
                    }
                }
            }

            StringBuilder result = new StringBuilder();
            result.AppendFormat("{0,30}", " <NameValues>" + Environment.NewLine);
            if (nameValues != null)
            {
                for (int i = 0; i < nameValues.Length; i++)
                {
                    result.AppendFormat(
                        "{0,30}: Name={1} Value={2} Class={3} Type={4} Sendto={5}" + Environment.NewLine, "NameValue",
                        nameValues[i].Name, nameValues[i].Value, nameValues[i].Class, nameValues[i].Type, nameValues[i].Sendto);
                }
            }
            result.AppendFormat("{0,30}", "</NameValues>");
            return result.ToString();
        }
Exemplo n.º 55
0
 public string addAsset(string in0, string in1, string in2, string in3, string in4, string in5, bool in6, NameValue[] in7, MovieMetadata in8) {
     object[] results = this.Invoke("addAsset", new object[] {
                 in0,
                 in1,
                 in2,
                 in3,
                 in4,
                 in5,
                 in6,
                 in7,
                 in8});
     return ((string)(results[0]));
 }
Exemplo n.º 56
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="db"></param>
        public void LoadClassifications(NPoco.Database db)
        {
            using (new HourGlass(this))
            {
                List<SigClass> data = db.Fetch<SigClass>(_sql.GetQuery(Sql.Query.SQL_SIG_CLASS));

                _classifications = new List<NameValue>();
                foreach (var result in data)
                {
                    NameValue nameValue = new NameValue();
                    nameValue.Name = result.Name;
                    nameValue.Value = result.Id.ToString();
                    _classifications.Add(nameValue);
                }
            }
        }
Exemplo n.º 57
0
        /// <summary>
        /// 
        /// </summary>
        private void LoadProtocols()
        {
            using (new HourGlass(this))
            {
                _protocols = new List<NameValue>();

                NameValue nameValue = new NameValue();
                nameValue.Name = Global.Protocols.Tcp.GetEnumDescription();
                nameValue.Value = ((int)Global.Protocols.Tcp).ToString();
                _protocols.Add(nameValue);

                nameValue = new NameValue();
                nameValue.Name = Global.Protocols.Udp.GetEnumDescription();
                nameValue.Value = ((int)Global.Protocols.Udp).ToString();
                _protocols.Add(nameValue);

                nameValue = new NameValue();
                nameValue.Name = Global.Protocols.Icmp.GetEnumDescription();
                nameValue.Value = ((int)Global.Protocols.Icmp).ToString();
                _protocols.Add(nameValue);
            }
        }
Exemplo n.º 58
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="db"></param>
        public void LoadSensors(NPoco.Database db)
        {
            using (new HourGlass(this))
            {
                List<Sensor> data = db.Fetch<Sensor>(_sql.GetQuery(Sql.Query.SQL_SENSORS));

                _sensors = new List<NameValue>();
                foreach (var result in data)
                {
                    NameValue nameValue = new NameValue();
                    nameValue.Name = result.HostName;
                    nameValue.Value = result.Sid.ToString();
                    _sensors.Add(nameValue);
                }
            }
        }
Exemplo n.º 59
0
        private void SetTemplate()
        {
            AESMgr = new AESManager();
            AESMgr.PropertyChanged += KeyMgr_PropertyChanged;
            TokMgr = new TokenManager();
            TokMgr.PropertyChanged += TokMgr_PropertyChanged;

            Keys.DataContext = AESMgr;
            AccessTokens.DataContext = TokMgr;

            StringResources stx = new StringResources();
            FileName.Text = stx.Text( "PickAFile" );

            Scopes = new NameValue<SpiderScope>[]
            {
                new NameValue<SpiderScope>( stx.Text( "HS_Book" ), SpiderScope.BOOK )
                , new NameValue<SpiderScope>( stx.Text( "HS_Zone" ), SpiderScope.ZONE )
            };

            ScopeLevel.ItemsSource = Scopes;
        }